php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79652 Wrong ReflectionType for sprintf/printf args parameter
Submitted: 2020-05-29 17:56 UTC Modified: 2020-05-29 20:23 UTC
From: kukulich at kukulich dot cz Assigned: kocsismate (profile)
Status: Closed Package: Reflection related
PHP Version: master-Git-2020-05-29 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kukulich at kukulich dot cz
New email:
PHP Version: OS:

 

 [2020-05-29 17:56 UTC] 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) "--------"

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-29 20:23 UTC] kocsismate@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: kocsismate
 [2020-05-29 20:23 UTC] 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 20:57 UTC] 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-30 06:59 UTC] kocsismate@php.net
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
 [2020-05-30 06:59 UTC] kocsismate@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC