Files
php-src/ext/reflection/tests/ReflectionMethod_createFromMethodName_abstract.phpt
Ilia Alshanetsky b80ef095ea Check object_init_ex() in ReflectionMethod::createFromMethodName()
The result was ignored, so calling the factory on an uninstantiable
subclass ran on a NULL zend_object: object_init_ex() throws, sets the
return value to NULL and reports FAILURE, and Z_REFLECTION_P() then
offsets backwards from that NULL. Other object_init_ex() calls in this
file already test the result.

Closes GH-22978
2026-07-31 13:28:44 -04:00

24 lines
443 B
PHP

--TEST--
ReflectionMethod::createFromMethodName() called on an abstract subclass
--FILE--
<?php
class C {
public function a() {}
}
abstract class R extends ReflectionMethod {}
try {
R::createFromMethodName('C::a');
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
var_dump(ReflectionMethod::createFromMethodName('C::a')->name);
?>
--EXPECT--
Error: Cannot instantiate abstract class R
string(1) "a"