1--TEST-- 2The closure name includes the source location (2) 3--FILE-- 4<?php 5 6namespace NameSpaceName { 7 class ClassName { 8 public function methodName() { 9 $c = function () {}; 10 $r = new \ReflectionFunction($c); 11 var_dump($r->name); 12 } 13 14 public function nestedClosure() { 15 $c = function () { 16 $c = function () { 17 $c = function () {}; 18 $r = new \ReflectionFunction($c); 19 var_dump($r->name); 20 }; 21 22 $c(); 23 }; 24 25 $c(); 26 } 27 } 28 29 function function_name() { 30 $c = function () { }; 31 $r = new \ReflectionFunction($c); 32 var_dump($r->name); 33 } 34} 35 36namespace { 37 class ClassName { 38 public function methodName() { 39 $c = function () {}; 40 $r = new \ReflectionFunction($c); 41 var_dump($r->name); 42 } 43 44 public function nestedClosure() { 45 $c = function () { 46 $c = function () { 47 $c = function () {}; 48 $r = new \ReflectionFunction($c); 49 var_dump($r->name); 50 }; 51 52 $c(); 53 }; 54 55 $c(); 56 } 57 } 58 59 function function_name() { 60 $c = function () { }; 61 $r = new \ReflectionFunction($c); 62 var_dump($r->name); 63 } 64 65 $class = new \NameSpaceName\ClassName(); 66 $class->methodName(); 67 $class->nestedClosure(); 68 \NameSpaceName\function_name(); 69 70 $class = new \ClassName(); 71 $class->methodName(); 72 $class->nestedClosure(); 73 \function_name(); 74 75 $c = function () { }; 76 $r = new \ReflectionFunction($c); 77 var_dump($r->name); 78} 79 80?> 81--EXPECTF-- 82string(49) "{closure:NameSpaceName\ClassName::methodName():6}" 83string(79) "{closure:{closure:{closure:NameSpaceName\ClassName::nestedClosure():12}:13}:14}" 84string(42) "{closure:NameSpaceName\function_name():27}" 85string(36) "{closure:ClassName::methodName():36}" 86string(65) "{closure:{closure:{closure:ClassName::nestedClosure():42}:43}:44}" 87string(28) "{closure:function_name():57}" 88string(%d) "{closure:%sclosure_%d.php:72}" 89