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
22 lines
384 B
PHP
22 lines
384 B
PHP
--TEST--
|
|
ReflectionClass::getProperty() with a qualified anonymous class name
|
|
--FILE--
|
|
<?php
|
|
|
|
$obj = new class {
|
|
public $p = 42;
|
|
};
|
|
|
|
$reflector = new ReflectionClass($obj);
|
|
$name = $reflector->getName();
|
|
var_dump(str_contains($name, "\0"));
|
|
|
|
$p = $reflector->getProperty($name . '::p');
|
|
var_dump($p->getName(), $p->getValue($obj));
|
|
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
string(1) "p"
|
|
int(42)
|