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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gregorv at web dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 00:01:35 2025 UTC