Bug #70376 [Asn->Nab]: Wrong signature for errors in namespaced anonymous functions
Edit report at https://bugs.php.net/bug.php?id=70376&edit=1
ID: 70376
Updated by: bwoebi@php.net
Reported by: me at kelunik dot com
Summary: Wrong signature for errors in namespaced anonymous
functions
-Status: Assigned
+Status: Not a bug
Type: Bug
Package: *General Issues
PHP Version: 7.0.0RC1
Assigned To: jpauli
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-08-28 07:29:10] bwoebi@php.net
This is a regression introduced by the bug fix for #70159 ... https://github.com/php/php-src/commit/a28115ccdb11301a418cc748ef7716a1687cc585#diff-3a8139128d4026ce0cb0c86beba4e6b9
Thus assigning to Julien.
------------------------------------------------------------------------
[2015-08-28 05:37:06] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70376&edit=1
Thread (3 messages)