php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71158 Calling methods with reserved keywords is inconsistent.
Submitted: 2015-12-18 12:37 UTC Modified: 2015-12-18 12:58 UTC
From: gregorv at web dot de Assigned:
Status: Duplicate Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2015-12-18 12:37 UTC] gregorv at web dot de
Description:
------------
Inconsistent parsing errors for using language constructs as functions in combination with magic methods. 

Calling methods with names of reserved keywords produce a fatal error when 
called statically like Something::list(), but work perfectly well when doing $something->list();

See code in Test Script. 

Test script:
---------------
class Testing {
    public function scopeList() {
        echo "scopeList";
    }
    public function __call($method, $parameters) {

        if($method == "list") {
            $this->scopeList();
        }
    }
    public static function __callStatic($method, $parameters) {

        $instance = new static;
        call_user_func_array([$instance, $method], $parameters);
    }
}
// Testingg::list() failes;
//Testing::list();
$testing = new Testing();
$testing->list(); // this does not



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-18 12:57 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2015-12-18 12:58 UTC] requinix@php.net
StackOverflow? Might explain why #71157 came in too.
 [2015-12-18 13:06 UTC] gregorv at web dot de
Yeah... obviously this was just copied by reading the question...
 [2015-12-18 13:08 UTC] gregorv at web dot de
He even copied my script one to one... that's sad...
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 26 09:01:25 2019 UTC