1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00
Files
archived-php-src/ext/reflection/tests/request38992.phpt
Christoph M. Becker f706897f33 Implement #38992: invoke() and invokeArgs() static method calls should match
We don't want ReflectionMethod::invoke() to simply ignore its first argument,
if the method to invoke is a static method. Instead we match its ZPP with
that of ReflectionMethod::invokeArgs(). Furthermore, we apply the DRY
principle by factoring out the code to a common helper function to prevent
inadvertent future divergence of the implementations of both methods.

As can be seen from the necessity to adapt some test cases, this causes a
BC break for some pathological cases. Therefore we apply this patch to PHP
7.1 only, which is still in beta phase.
2016-08-08 01:43:03 +02:00

23 lines
582 B
PHP

--TEST--
Request #38992 (invoke() and invokeArgs() static method calls should match)
--FILE--
<?php
class MyClass
{
public static function doSomething()
{
echo "Did it!\n";
}
}
$r = new ReflectionMethod('MyClass', 'doSomething');
$r->invoke('WTF?');
$r->invokeArgs('WTF?', array());
?>
===DONE===
--EXPECTF--
Warning: ReflectionMethod::invoke() expects parameter 1 to be object, string given in %s%erequest38992.php on line %d
Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, string given in %s%erequest38992.php on line %d
===DONE===