Skip to content

Instantly share code, notes, and snippets.

@tobiasgies
Last active August 29, 2015 14:07
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 tobiasgies/df5ef2ef658401cc634d to your computer and use it in GitHub Desktop.
Save tobiasgies/df5ef2ef658401cc634d to your computer and use it in GitHub Desktop.
Invoke class property test
<?php
class Invokeable {
public function __invoke() {
echo "Hello World!\r\n";
}
}
class Container {
private $_invokeable;
public function __construct(Invokeable $invokeable) {
$this->_invokeable = $invokeable;
}
public function callIt() {
$this->_invokeable();
}
}
$invokeable = new Invokeable();
$invokeable();
$container = new Container($invokeable);
$container->callIt();
@tobiasgies
Copy link
Author

Result of running this file:

Hello World!
PHP Fatal error:  Call to undefined method Container::_invokeable() in /home/tobias/sources/playground/invoke.php on line 17

Fatal error: Call to undefined method Container::_invokeable() in /home/tobias/sources/playground/invoke.php on line 17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment