Bug #79652 [PATCH]: Wrong ReflectionType for sprintf/printf args parameter
| From: | carusogabriel@php.net | Date: | Fri, 29 May 2020 20:57:51 +0000 |
| Subject: | Bug #79652 [PATCH]: Wrong ReflectionType for sprintf/printf args parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227236@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
Patch added by: carusogabriel@php.net
Reported by: kukulich at kukulich dot cz
Summary: Wrong ReflectionType for sprintf/printf args
parameter
Status: Verified
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:
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
Previous Comments:
------------------------------------------------------------------------
[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