|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-05-08 13:07 UTC] thomas dot wleight at googlemail dot com
Description:
------------
There is a difference in results.
ReflectionParameter getType() function returns "int".
But builtin function "gettype" returns "integer".
Just check the test script below.
Test script:
---------------
class A {
function f(int $a) {}
}
$r = new ReflectionClass("A");
$m = $r->getMethods();
$p = $m[0]->getParameters();
$t = $p[0]->getType();
echo $t; // "int"
echo PHP_EOL;
echo gettype(42); // "integer"
Expected result:
----------------
In both cases should return "integer"
Actual result:
--------------
ReflectionParameter returns "int" and gettype() returns "integer"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
oh, i see function/method typehint can be literally anything. Something like this would be hard to check and compare - "getType()" (ReflectionParameter) results with "gettype()" builtin function: function foo(int $i, string $s, Foo $foo, Bar\Baz $barbaz) { ... } int string Foo Bar\Baz