Doc #71158 [Com]: Calling methods with reserved keywords is inconsistent.
| From: | gregorv at web dot de | Date: | Fri, 18 Dec 2015 13:08:32 +0000 |
| Subject: | Doc #71158 [Com]: Calling methods with reserved keywords is inconsistent. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12961@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71158&edit=1
ID: 71158
Comment by: gregorv at web dot de
Reported by: gregorv at web dot de
Summary: Calling methods with reserved keywords is
inconsistent.
Status: Duplicate
Type: Documentation Problem
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
He even copied my script one to one... that's sad...
Previous Comments:
------------------------------------------------------------------------
[2015-12-18 13:06:43] gregorv at web dot de
Yeah... obviously this was just copied by reading the question...
------------------------------------------------------------------------
[2015-12-18 12:58:37] requinix@php.net
StackOverflow? Might explain why #71157 came in too.
------------------------------------------------------------------------
[2015-12-18 12:56:33] gregorv at web dot de
Bug report originally inspired by http://stackoverflow.com/questions/34353400/php-using-language-constructs-in-combination-with-magic-methods/34355096?noredirect=1#comment56453476_34355096
User: hek2mgl
------------------------------------------------------------------------
[2015-12-18 12:37:12] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71158&edit=1