Created
November 26, 2016 17:50
-
-
Save bitkorn/6b20541c5ea5287aea7ea562e9155f36 to your computer and use it in GitHub Desktop.
call __invoke() of a class member
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A | |
{ | |
/** | |
* | |
* @var \SomeNamespace\SomeMember | |
*/ | |
private $someMember; | |
/** | |
* PHP Fatal error: Call to undefined method | |
* @return type | |
*/ | |
public function doesNotWork() | |
{ | |
return $this->someMember(); | |
} | |
public function foo() | |
{ | |
$tmp = $this->someMember; | |
return $tmp(); | |
} | |
public function bar() | |
{ | |
return call_user_func($this->someMember); | |
} | |
public function shit() | |
{ | |
return $this->someMember->__invoke(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment