Bug #79652 [Opn->Ver]: Wrong ReflectionType for sprintf/printf args parameter

From: Date: Fri, 29 May 2020 20:23:52 +0000
Subject: Bug #79652 [Opn->Ver]: Wrong ReflectionType for sprintf/printf args parameter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227235@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: Open +Status: Verified Type: Bug Package: Reflection related PHP Version: master-Git-2020-05-29 (Git) -Assigned To: +Assigned To: kocsismate Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#227235) next »