Bug #71157 [Csd->Opn]: Using reserved words in magic methods

From: Date: Fri, 18 Dec 2015 13:58:25 +0000
Subject: Bug #71157 [Csd->Opn]: Using reserved words in magic methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198002@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71157&edit=1

 ID:                 71157
 User updated by:    sergey dot karavay at gmail dot com
 Reported by:        sergey dot karavay at gmail dot com
 Summary:            Using reserved words in magic methods
-Status:             Closed
+Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows 7 x64
 PHP Version:        5.5.30
 Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

To gregorv at web dot de

Yep, sorry, was too initiative. 
The issue was originally posted on: http://stackoverflow.com/questions/34353400/php-using-language-constructs-in-combination-with-magic-methods


Previous Comments:
------------------------------------------------------------------------
[2015-12-18 13:57:36] nikic@php.net

Supported in PHP 7.

------------------------------------------------------------------------
[2015-12-18 13:45:54] gregorv at web dot de

You shouldn't just copy some stuff, but give reference to the original poster...

------------------------------------------------------------------------
[2015-12-18 11:21:55] sergey dot karavay at gmail dot com

Description:
------------
Define __call and __callStatic methods for a class. Then try to call both static and non-static
methods as a reserved keyword (for example, list).

Test script:
---------------
<?php
class Testing {

    public function scopeList() {
        echo "scopeList";
    }

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

    public static function __callStatic($method, $parameters) {
	echo 1; die();
        $instance = new static;
        call_user_func_array([$instance, $method], $parameters);
    }
}

Testing::list(); // fails
Testing::{'list'}(); // works

$testing = new Testing();
$testing->list(); //works

Expected result:
----------------
The same behavior for both (both fails or both works).

Actual result:
--------------
Fails for static call, works for non-static.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71157&edit=1


Thread (5 messages)

« previous php.bugs (#198002) next »