Commit 2b1f6ad52bf for php.net
commit 2b1f6ad52bfc50afd36ef9e10e3fee93c042c23d
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Wed Sep 2 12:04:47 2026 -0700
Reflection: add regression tests for printing boolean constant values
Add regression tests for the output of `ReflectionClassConstant::__toString()`
and `ReflectionConstant::__toString()` when the value of the constant is
boolean `true` or `false`. The `true` cases are already covered by some
existing tests, but it seems that the `false` cases are currently untested.
diff --git a/ext/reflection/tests/ReflectionClassConstant_toString.phpt b/ext/reflection/tests/ReflectionClassConstant_toString.phpt
new file mode 100644
index 00000000000..e3baca55597
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClassConstant_toString.phpt
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionClassConstant::__toString() and class constant display
+--FILE--
+<?php
+
+class Demo {
+ public const IS_TRUE = true;
+ public const IS_FALSE = false;
+}
+
+echo new ReflectionClassConstant(Demo::class, 'IS_TRUE');
+echo new ReflectionClassConstant(Demo::class, 'IS_FALSE');
+
+echo new ReflectionClass(Demo::class);
+
+?>
+--EXPECTF--
+Constant [ public bool IS_TRUE ] { 1 }
+Constant [ public bool IS_FALSE ] { }
+Class [ <user> class Demo ] {
+ @@ %s %d-%d
+
+ - Constants [2] {
+ Constant [ public bool IS_TRUE ] { 1 }
+ Constant [ public bool IS_FALSE ] { }
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
diff --git a/ext/reflection/tests/ReflectionConstant_toString.phpt b/ext/reflection/tests/ReflectionConstant_toString.phpt
new file mode 100644
index 00000000000..74221cc1f13
--- /dev/null
+++ b/ext/reflection/tests/ReflectionConstant_toString.phpt
@@ -0,0 +1,15 @@
+--TEST--
+ReflectionConstant::__toString()
+--FILE--
+<?php
+
+const IS_TRUE = true;
+const IS_FALSE = false;
+
+echo new ReflectionConstant('IS_TRUE');
+echo new ReflectionConstant('IS_FALSE');
+
+?>
+--EXPECT--
+Constant [ bool IS_TRUE ] { 1 }
+Constant [ bool IS_FALSE ] { }