|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-08-28 05:37 UTC] me at kelunik dot com
Description: ------------ The namespace shouldn't be repeated after :: and -> for anonymous functions. https://3v4l.org/F7R3l#v700alpha2 Test script: --------------- <?php namespace A { class Foo { public $foo; public function __construct() { $this->foo = function (int $a) { var_dump("foo"); }; } } } namespace { ((new A\Foo)->foo)(null); } Expected result: ---------------- Fatal error: Uncaught TypeError: Argument 1 passed to A\Foo::{closure}() must be of the type integer, null given, called in /in/F7R3l on line 16 and defined in /in/F7R3l:8 Stack trace: #0 /in/F7R3l(16): A\Foo->{closure}(NULL) #1 {main} thrown in /in/F7R3l on line 8 Actual result: -------------- Fatal error: Uncaught TypeError: Argument 1 passed to A\Foo::A\{closure}() must be of the type integer, null given, called in /in/F7R3l on line 16 and defined in /in/F7R3l:8 Stack trace: #0 /in/F7R3l(16): A\Foo->A\{closure}(NULL) #1 {main} thrown in /in/F7R3l on line 8 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 00:00:02 2025 UTC |
Actually, thinking about it, it's not quite a bug. The function name is A\{closure} … bound to the Class A\Foo. Hence we end up with A\Foo::A\{closure}. In case you bindTo() another class, like the class Baz in namespace B, we'll have B\Baz::A\{closure}, still indicating that the Closure is in namespace A. Hence closing as not a bug.