Skip to content

Instantly share code, notes, and snippets.

@bitkorn
Created November 26, 2016 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitkorn/6b20541c5ea5287aea7ea562e9155f36 to your computer and use it in GitHub Desktop.
Save bitkorn/6b20541c5ea5287aea7ea562e9155f36 to your computer and use it in GitHub Desktop.
call __invoke() of a class member
<?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