Req #79574 [Opn->Sus]: ReflectionType and gettype return different values

From: Date: Fri, 08 May 2020 13:39:28 +0000
Subject: Req #79574 [Opn->Sus]: ReflectionType and gettype return different values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226960@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 Updated by: cmb@php.net Reported by: thomas dot wleight at googlemail dot com Summary: ReflectionType and gettype return different values -Status: Open +Status: Suspended Type: Feature/Change Request -Package: *General Issues +Package: Variables related PHP Version: 7.3.17 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: The values returned by gettype() ar#e unlikely to be ever changed for backward compatibility reasons. In PHP 8 the new function get_debug_type()[1] will be available, which returns "int". If you strongly feel that the return values of gettype() should be changed, feel free to pursue the RFC process[2]. For the time being, I'm suspending this ticket. [1] <https://wiki.php.net/rfc/get_debug_type> [2] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2020-05-08 13:09:47] thomas dot wleight at googlemail dot com This as an inconsistency issue. Please stick to one only variant: "int" XOR "integer". Using both variants is ambiguous. ------------------------------------------------------------------------ [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

« previous php.bugs (#226960) next »