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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 - 18 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 22:01:27 2024 UTC