Bug #65598 [ReO->Csd]: Closure executed via static autoload incorrectly marked as static
| From: | nikic@php.net | Date: | Fri, 08 May 2015 13:21:31 +0000 |
| Subject: | Bug #65598 [ReO->Csd]: Closure executed via static autoload incorrectly marked as static | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192583@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65598&edit=1
ID: 65598
Updated by: nikic@php.net
Reported by: php at davidstockton dot com
Summary: Closure executed via static autoload incorrectly
marked as static
-Status: Re-Opened
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Centos 6
PHP Version: 5.5.3
Assigned To: nikic
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2015-05-08 13:21:18] nikic@php.net
@arjen: Should be fixed by https://github.com/php/php-src/commit/8f9f21e8d24c1b48dc271330e38f2931086c0c94.
------------------------------------------------------------------------
[2015-05-08 09:14:29] nikic@php.net
@arjen: Nope, there should be no difference with call_user_func(). I'll look into it.
------------------------------------------------------------------------
[2015-05-08 09:11:51] arjen at react dot com
I'm not sure about the following behaviour:
<?php
class A {
public static function exec(callable $c)
{
// this works
$c();
// this won't
return call_user_func($c);
}
public static function doSomething()
{
// implicit static in 5.x, non-static in 7
return self::exec(function(){
return "okay";
});
}
}
echo A::doSomething();
After this commit, the closure created by doSomething and passed to exec() cannot be called by
call_user_func anymore: "Fatal error: Non-static method A::{closure}() cannot be called
statically in staticClosures.php on line 10"
However, calling $c(); still works.
Is this expected or an unwanted effect of this patch?
------------------------------------------------------------------------
[2015-05-06 16:19:21] nikic@php.net
Fixed in PHP 7 by https://github.com/php/php-src/commit/bc2ff4a299a182c4ab9681fa6ba52cf747f53ace.
This won't be backported, as it depends on some other changes, which are ABI incompatible.
------------------------------------------------------------------------
[2013-09-20 16:10:24] php at davidstockton dot com
Your examples make sense. However in this particular case, it seems to make sense
that the autoloader's "staticness" would or should not affect the things that are
loaded via the autoloader-i.e, make a special case for autoloaders.
The behavior of the code should not be changed based on whether the code was
loaded via a static or non-static autoloader.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=65598
--
Edit this bug report at https://bugs.php.net/bug.php?id=65598&edit=1