[php-src] PHP-8.6: Reflection: add regression tests for printing boolean constant values
| From: | Daniel Scherzer | Date: | Tue, 22 Sep 2026 21:09:59 +0000 |
| Subject: | [php-src] PHP-8.6: Reflection: add regression tests for printing boolean constant values | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141449@lists.php.net to get a copy of this message | ||
Author: Daniel Scherzer (DanielEScherzer)
Date: 2026-09-22T13:23:52-07:00
Commit: https://github.com/php/php-src/commit/2b1f6ad52bfc50afd36ef9e10e3fee93c042c23d
Raw diff: https://github.com/php/php-src/commit/2b1f6ad52bfc50afd36ef9e10e3fee93c042c23d.diff
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.
Changed paths:
A ext/reflection/tests/ReflectionClassConstant_toString.phpt
A ext/reflection/tests/ReflectionConstant_toString.phpt
Diff:
diff --git a/ext/reflection/tests/ReflectionClassConstant_toString.phpt
b/ext/reflection/tests/ReflectionClassConstant_toString.phpt
new file mode 100644
index 000000000000..e3baca55597c
--- /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 000000000000..74221cc1f13d
--- /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 ] { }