Bug #71157 [NEW]: Using reserved words in magic methods

From: Date: Fri, 18 Dec 2015 11:21:56 +0000
Subject: Bug #71157 [NEW]: Using reserved words in magic methods
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197991@lists.php.net to get a copy of this message
From:             sergey dot karavay at gmail dot com
Operating system: Windows 7 x64
PHP version:      5.5.30
Package:          *General Issues
Bug Type:         Bug
Bug description:Using reserved words in magic methods

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 bug report at https://bugs.php.net/bug.php?id=71157&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71157&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71157&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71157&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71157&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71157&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71157&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71157&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71157&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71157&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71157&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71157&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71157&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71157&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71157&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71157&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71157&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71157&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71157&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71157&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71157&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#197991) next »