Req #79961 [NEW]: Reflection Type method "GetName" returns different values then old gettype()
| From: | petr dot vejchoda at seznam dot cz | Date: | Wed, 12 Aug 2020 10:01:02 +0000 |
| Subject: | Req #79961 [NEW]: Reflection Type method "GetName" returns different values then old gettype() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228537@lists.php.net to get a copy of this message | ||
From: petr dot vejchoda at seznam dot cz
Operating system: Win10
PHP version: 7.4.9
Package: Reflection related
Bug Type: Feature/Change Request
Bug description:Reflection Type method "GetName" returns different values then old
gettype()
Description:
------------
---
From manual page: https://php.net/class.reflectionnamedtype
---
Legacy php method gettype() returns different type names for variables
then Reflection class methods making it unnecessarily complex to check
whether method parameter is the same type of reflected typed property.
Test script:
---------------
class testClass
public int $int;
public float $float;
public bool $bool;
public string $string;
public final function __construct()
{
$intType = (new \ReflectionClass($this))->getProperty("int");
$floatType = (new
\ReflectionClass($this))->getProperty("float");
$boolType = (new \ReflectionClass($this))->getProperty("bool");
$stringType = (new
\ReflectionClass($this))->getProperty("string");
$int = 0;
$float = 0.0;
$bool = true;
$string = 'string';
var_dump(($intType->getName()));
var_dump(($floatType->getName()));
var_dump(($boolType->getName()));
var_dump(($stringType->getName()));
var_dump(gettype($int));
var_dump(gettype($float));
var_dump(gettype($bool));
var_dump(gettype($string));
die();
}
}
Expected result:
----------------
Expect all booleans to be named the same, all integers, all floating
numbers to be named the same. So that I can check it by string
comparison even though I hate to check types by string comparison ...
Actual result:
--------------
Mess. Total unholy mess.
--
Edit bug report at https://bugs.php.net/bug.php?id=79961&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79961&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79961&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79961&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79961&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79961&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79961&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79961&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79961&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79961&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79961&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79961&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79961&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79961&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79961&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79961&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79961&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79961&r=mysqlcfg