Req->Bug #50029 [Ana]: Weird invoke issue on class as property

From: Date: Sun, 03 Nov 2013 04:41:36 +0000
Subject: Req->Bug #50029 [Ana]: Weird invoke issue on class as property
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182566@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50029&edit=1

 ID:                 50029
 Updated by:         yohgaki@php.net
 Reported by:        marc dot gray at gmail dot com
 Summary:            Weird invoke issue on class as property
 Status:             Analyzed
-Type:               Feature/Change Request
+Type:               Bug
 Package:            Class/Object related
-Operating System:   Ubuntu 9.04
+Operating System:   *
-PHP Version:        5.3.0
+PHP Version:        master
 Block user comment: N
 Private report:     N

 New Comment:

I think this is bug, not FR.


Previous Comments:
------------------------------------------------------------------------
[2013-11-02 23:29:42] worldoffame at hotmail dot com

Has this bug been fixed yet? Its one of the most annoying glitches in PHP, and funny it has existed
for more than 4 years.

------------------------------------------------------------------------
[2013-08-29 10:50:17] worldoffame at hotmail dot com

Also the argument that invoking class property could override class methods itself is just nonsense.
Guess what? Its a poor design if your method shares the same name as your property anyway. If
collision occurs it looks more like an improper OOP practice to me.

------------------------------------------------------------------------
[2013-08-29 10:44:14] worldoffame at hotmail dot com

Any updates on this? I hope it gets fixed asap, cant believe this bug has been around for 3+ years
and still left untouched. *sigh*

------------------------------------------------------------------------
[2012-06-08 12:24:34] programmierung at pfink dot de

The worst thing on this bug is that is_callable() returns true in this case even though it's
not callable:

The lines

if(is_callable($this->objectWithInvokeMethod))
return $this->objectWithInvokeMethod(0);

produce the fatal error

Fatal error: Call to undefined method MyClass::objectWithInvokeMethod()

------------------------------------------------------------------------
[2011-12-06 16:34:31] karsten at typo3 dot org

I would go for simple rules to solve this. When having a class and calling

$this->prop() PHP should

* use __invoke on $this->prop if there is no method prop() in the class
* if there is an actual method, the method takes precedence

In the latter one can still use $this->prop->__invoke(), but should probably 
rather clean up the code. :)

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=50029


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


Thread (20 messages)

« previous php.bugs (#182566) next »