Req #79574 [Com]: ReflectionType and gettype return different values
| From: | thomas dot wleight at googlemail dot com | Date: | Fri, 08 May 2020 13:09:47 +0000 |
| Subject: | Req #79574 [Com]: ReflectionType and gettype return different values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226958@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79574&edit=1
ID: 79574
Comment by: thomas dot wleight at googlemail dot com
Reported by: thomas dot wleight at googlemail dot com
Summary: ReflectionType and gettype return different values
Status: Open
Type: Feature/Change Request
Package: *General Issues
PHP Version: 7.3.17
Block user comment: N
Private report: N
New Comment:
This as an inconsistency issue. Please stick to one only variant: "int" XOR
"integer". Using both variants is ambiguous.
Previous Comments:
------------------------------------------------------------------------
[2020-05-08 13:07:48] 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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79574&edit=1