php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81626 Error on use static:: in __сallStatic() wrapped to Closure::fromCallable()
Submitted: 2021-11-16 11:36 UTC Modified: 2021-11-16 11:42 UTC
From: sergey dot predvoditelev at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 8.0.12 OS:
Private report: No CVE-ID: None
 [2021-11-16 11:36 UTC] sergey dot predvoditelev at gmail dot com
Description:
------------
Throws error on use static:: in __сallStatic() wrapped to Closure::fromCallable().

Note, if use static:: in static method wrapped to Closure::fromCallable(), then no errors.

Test script:
---------------
class TestClass {
    public static bool $wasCalled = false;
    public static function __callStatic(string $name, array $args): string
    {
        static::$wasCalled = true;
        return 'ok';
    }
}
$closure = Closure::fromCallable([TestClass::class, 'foo']);
$closure();

Expected result:
----------------
No errors.

Actual result:
--------------
Error: Cannot access "static" when no class scope is active

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-16 11:42 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-11-16 11:42 UTC] nikic@php.net
Confirming on 7.4/8.0, fixed in 8.1.
 [2021-11-16 11:47 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/d26965b2474229efd9b4a997570b3fb924405be9
Log: Fixed bug #81626
 [2021-11-16 11:47 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC