Bug #79652 [Ver->Csd]: Wrong ReflectionType for sprintf/printf args parameter
| From: | kocsismate@php.net | Date: | Sat, 30 May 2020 06:59:11 +0000 |
| Subject: | Bug #79652 [Ver->Csd]: Wrong ReflectionType for sprintf/printf args parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227239@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79652&edit=1
ID: 79652
Updated by: kocsismate@php.net
Reported by: kukulich at kukulich dot cz
Summary: Wrong ReflectionType for sprintf/printf args
parameter
-Status: Verified
+Status: Closed
Type: Bug
Package: Reflection related
PHP Version: master-Git-2020-05-29 (Git)
Assigned To: kocsismate
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of kocsismate@woohoolabs.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=dd6e54b7461d24598d1e125953e330e3924147ed
Log: Fix #79652 Ensure that the mixed type is displayed instead of the union of all types
Previous Comments:
------------------------------------------------------------------------
[2020-05-29 20:57:51] carusogabriel@php.net
The following pull request has been associated:
Patch Name: Fix #79652 Ensure that the mixed type is displayed instead of the union of all types
On GitHub: https://github.com/php/php-src/pull/5643
Patch: https://github.com/php/php-src/pull/5643.patch
------------------------------------------------------------------------
[2020-05-29 20:23:52] kocsismate@php.net
Thank you for the report, I managed to verify the problem. PR is on the way.
The issue is related to the recently introduced mixed type what made it possible to annotate these
parameters with the mixed type.
------------------------------------------------------------------------
[2020-05-29 17:56:14] kukulich at kukulich dot cz
Description:
------------
Wrong ReflectionType for sprintf/printf args parameter.
It should return ReflectionUnionType.
Test script:
---------------
<?php
foreach (['sprintf', 'printf'] as $functionName) {
$rf = new ReflectionFunction($functionName);
$rp = $rf->getParameters()[1];
$rt = $rp->getType();
var_dump($functionName);
var_dump($rp->getName());
var_dump($rt::class);
if ($rt instanceof ReflectionNamedType) {
var_dump($rt->getName());
}
var_dump('--------');
}
Expected result:
----------------
string(7) "sprintf"
string(4) "args"
string(19) "ReflectionUnionType"
string(8) "--------"
string(6) "printf"
string(4) "args"
string(19) "ReflectionUnionType"
string(8) "--------"
Actual result:
--------------
string(7) "sprintf"
string(4) "args"
string(19) "ReflectionNamedType"
string(39) "object|array|string|int|float|bool|null"
string(8) "--------"
string(6) "printf"
string(4) "args"
string(19) "ReflectionNamedType"
string(39) "object|array|string|int|float|bool|null"
string(8) "--------"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79652&edit=1