|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-08-16 04:38 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2018-08-16 04:38 UTC] requinix@php.net
[2018-08-16 08:56 UTC] j dot vanbeele at gmail dot com
[2018-08-16 09:27 UTC] requinix@php.net
-Status: Feedback
+Status: Duplicate
[2018-08-16 09:27 UTC] requinix@php.net
[2018-08-16 09:28 UTC] requinix@php.net
[2018-08-16 10:59 UTC] j dot vanbeele at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 18:00:01 2025 UTC |
Description: ------------ See below. Test script: --------------- <?php declare(strict_types=1); namespace poop; // Commenting this fixes strict typing // A.php class A { public function MyFunction(string $str) { return $str; } } // B.php class B { public function __call($func, $args) { // Uncommenting this breaks strict typing given namespace // return call_user_func_array(array(new A, $func), $args); // Uncommenting this breaks strict typing given namespace // $ref = new \ReflectionMethod('poop\A', 'MyFunction'); // return $ref->invokeArgs(new A, $args); // Doesn't break strict typing return (new A)->$func($args); } } // Script.php var_dump((new B)->MyFunction(1)); Expected result: ---------------- The expected result is that none of the cases above should break strict typing. As a side note, if theres classes were stored in the following way: A.php B.php Script.php then the declare(strict_types=1) should be done in B.php over Script.php since due to __call, B is technically the caller, and not Script.php. This is already the case with (new A)->$func($args) and hopefully that behaviour will be reproduced given this bug will be fixed. P.S - Is there any way I could pass multiple arguments to (new A)->$func() for the timebeing? Actual result: -------------- Using invoke or call_user_func will make the code resort back to weak typing unless the namespace is commented out.