Bug #79290 [Opn->Nab]: getType doesn't return a type
| From: | nikic@php.net | Date: | Thu, 20 Feb 2020 12:53:01 +0000 |
| Subject: | Bug #79290 [Opn->Nab]: getType doesn't return a type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225650@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79290&edit=1
ID: 79290
Updated by: nikic@php.net
Reported by: dalius dot ulevicius at gmail dot com
Summary: getType doesn't return a type
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reflection related
PHP Version: 7.4.2
Block user comment: N
Private report: N
New Comment:
See https://www.php.net/reflectionnamedtype
for information on the object that is being returned. You can get the name of the type using
$type->getName().
You really could have figured this out yourself.
Previous Comments:
------------------------------------------------------------------------
[2020-02-20 11:34:18] dalius dot ulevicius at gmail dot com
Description:
------------
Reflection getType function doesn't return a type
Test script:
---------------
function someFunction(string $param, int $param2 = null) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams = $reflectionFunc->getParameters();
var_dump($reflectionParams[0]->hasType());
echo '<br>';
var_dump($reflectionParams[1]->hasType());
echo '<br>';
var_dump($reflectionParams[0]->getType());
echo '<br>';
var_dump($reflectionParams[1]->getType());
Expected result:
----------------
bool(true)
bool(true)
string
int
Actual result:
--------------
bool(true)
bool(true)
class ReflectionNamedType#4 (0) { }
class ReflectionNamedType#4 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79290&edit=1