[php-src] Issue #22905: Reflection exception messages truncate on null bytes

From: Date: Mon, 27 Jul 2026 23:55:47 +0000
Subject: [php-src] Issue #22905: Reflection exception messages truncate on null bytes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252495@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22905 Author: DanielEScherzer After #22681 I looked into exception messages: <details> <summary>Reflection*::getAttributes() with ReflectionAttribute::IS_INSTANCEOF</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->getAttributes("foo\0bar", ReflectionAttribute::IS_INSTANCEOF); ``` </details> <details> <summary>ReflectionFunction::__construct()</summary> ```php <?php new ReflectionFunction("foo\0bar"); ``` </details> <details> <summary>ReflectionParameter::__construct() with string function</summary> ```php <?php new ReflectionParameter("foo\0bar", 0); ``` </details> <details> <summary>ReflectionParameter::__construct() with array with class name</summary> ```php <?php new ReflectionParameter(["foo\0bar", ""], 0); ``` </details> <details> <summary>ReflectionParameter::__construct() with array with method name</summary> ```php <?php class Demo {} new ReflectionParameter([Demo::class, "foo\0bar"], 0); ``` </details> <details> <summary>ReflectionMethod::__construct() with class name</summary> ```php <?php new ReflectionMethod("foo\0bar", ""); ``` </details> <details> <summary>ReflectionMethod::__construct() with method name</summary> ```php <?php class Demo {} new ReflectionMethod(Demo::class, "foo\0bar"); ``` </details> the above two should also apply to ReflectionMethod::createFromMethodName() - they share the same lookup code <details> <summary>ReflectionClassConstant::__construct() with class name</summary> ```php <?php new ReflectionClassConstant("foo\0bar", ""); ``` </details> <details> <summary>ReflectionClassConstant::__construct() with constant name</summary> ```php <?php class Demo {} new ReflectionClassConstant(Demo::class, "foo\0bar"); ``` </details> <details> <summary>ReflectionClass::__construct()</summary> ```php <?php new ReflectionClass("foo\0bar"); ``` </details> <details> <summary>ReflectionClass::getStaticPropertyValue()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->getStaticPropertyValue("foo\0bar"); ``` </details> <details> <summary>ReflectionClass::setStaticPropertyValue()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->setStaticPropertyValue("foo\0bar", 123); ``` </details> <details> <summary>ReflectionClass::getMethod()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->getMethod("foo\0bar"); ``` </details> <details> <summary>ReflectionClass::getProperty()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->getProperty("foo\0bar"); ``` </details> <details> <summary>ReflectionClass::isSubclassOf()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->isSubclassOf("foo\0bar"); ``` </details> <details> <summary>ReflectionClass::implementsInterface()</summary> ```php <?php class Demo {} $r = new ReflectionClass(Demo::class); $r->implementsInterface("foo\0bar"); ``` </details> <details> <summary>ReflectionProperty::__construct() with class name</summary> ```php <?php new ReflectionProperty("foo\0bar", ""); ``` </details> <details> <summary>ReflectionProperty::__construct() with property name</summary> ```php <?php class Demo {} new ReflectionProperty(Demo::class, "foo\0bar"); ``` </details> <details> <summary>ReflectionProperty::skipLazyInitialization() with property name</summary> ```php <?php $o = (object)["foo\0bar" => "baz"]; $r = new ReflectionProperty($o, "foo\0bar"); $r->skipLazyInitialization($o); ``` </details> also affects anything else using reflection_property_check_lazy_compatible() <details> <summary>ReflectionEnum::getCase() with missing case</summary> ```php <?php enum Demo {} $r = new ReflectionEnum(Demo::class); $r->getCase("foo\0bar"); ``` </details> <details> <summary>ReflectionConstant::__construct()</summary> ```php <?php new ReflectionConstant("foo\0bar"); ``` </details>

« previous php.bugs (#252495) next »