Commit e025f2a1484 for php.net
commit e025f2a14846ed5f9a83df7ed811aaf3043a4dd4
Author: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date: Sun Nov 30 01:39:04 2025 -0800
reflection: Test ReflectionFunction::__toString() with bound variables (#20608)
diff --git a/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt b/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt
new file mode 100644
index 00000000000..142e6613614
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ReflectionFunction::__toString() with bound variables
+--FILE--
+<?php
+
+$closure_without_bounds = fn () => 0;
+
+$rf = new ReflectionFunction($closure_without_bounds);
+echo (string) $rf;
+
+$global = "";
+$closure_with_bounds = function() use($global) {
+ static $counter = 0;
+ return $counter++;
+};
+
+$rf = new ReflectionFunction($closure_with_bounds);
+echo (string) $rf;
+
+?>
+--EXPECTF--
+Closure [ <user> function {closure:%s:%d} ] {
+ @@ %sReflectionFunction__toString_bound_variables.php 3 - 3
+}
+Closure [ <user> function {closure:%s:%d} ] {
+ @@ %sReflectionFunction__toString_bound_variables.php 9 - 12
+
+ - Bound Variables [2] {
+ Variable #0 [ $global ]
+ Variable #1 [ $counter ]
+ }
+}