|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-01-08 15:14 UTC] pablick at gmail dot com
[2011-07-22 08:36 UTC] jille at hexon dot cx
[2016-01-16 02:41 UTC] danack@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: danack
[2016-01-16 02:41 UTC] danack@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 07:00:01 2025 UTC |
Description: ------------ When one defines a class with __callStatic() which under some circumstances accepts method name of "new", it may not be called. However, with __call(), it may be called. May be solved using call_user_func(), but that loses the nice syntax. Personally, I don't get it why "new" is parsed as T_NEW after "Base::" and not after $base->. Test script: --------------- <?php class Base { public static function __callStatic($method, $args) { if ($method == 'new') echo 'Base::new() called successfully'; } public function __call($method, $args) { if ($method == 'new') echo '$base->new() called successfully'; } } $base = Base::new(); call_user_func(array('Base', 'new'); $base = new Base; $base->new(); ?> Expected result: ---------------- Base::new() called successfully Base::new() called successfully $base->new() called successfully Actual result: -------------- Parse error: syntax error, unexpected T_NEW, expecting T_STRING or T_VARIABLE or '$' in C:\inetpub\wwwroot\test.php on line 14