mirror of
https://github.com/php/php-src.git
synced 2026-10-28 17:56:50 +08:00
ReflectionMethod::__construct(), ReflectionMethod::createFromMethodName() and ReflectionClass::getProperty() split "Class::member" with strstr(), which stops at the first NUL. Anonymous class names embed one, so a name obtained from ReflectionClass::getName() was rejected. Use zend_memnstr() over the whole string instead. Closes GH-22970
21 lines
394 B
PHP
21 lines
394 B
PHP
--TEST--
|
|
ReflectionMethod::createFromMethodName() with an anonymous class name
|
|
--FILE--
|
|
<?php
|
|
|
|
$obj = new class {
|
|
public function m() { return 42; }
|
|
};
|
|
|
|
$name = (new ReflectionClass($obj))->getName();
|
|
var_dump(str_contains($name, "\0"));
|
|
|
|
$m = ReflectionMethod::createFromMethodName($name . '::m');
|
|
var_dump($m->getName(), $m->invoke($obj));
|
|
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
string(1) "m"
|
|
int(42)
|