<?php
class foo
{
protected $bar = 'A bar';
public function getBarDumper()
{
$that = $this;
return function() { var_dump($this->bar); };
}
public static function getFactory()
{
// la fonction anonyme suivante est statique
// car elle est déclarée dans une méthode statique.
return function() { var_dump($this); return new static(); };
}
}
class bar {}
$factory = foo::getFactory();
$bar = new bar();
$factory = $factory->bindTo($bar, $bar);
Warning: Cannot bind an instance to a static closure in /in/VkojJ on line 24
Output for 5.3.0 - 5.3.29
Fatal error: Call to undefined method Closure::bindTo() in /in/VkojJ on line 24
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/VkojJ on line 9
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br />
<b>Parse error</b>: syntax error, unexpected T_FUNCTION in <b>/in/VkojJ</b> on line <b>9</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br />
<b>Parse error</b>: parse error, unexpected T_FUNCTION in <b>/in/VkojJ</b> on line <b>9</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/VkojJ</b> on line <b>4</b><br />
Process exited with code 255.
<br />
<b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/VkojJ</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br />
<b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/VkojJ</b> on line <b>4</b><br />
Process exited with code 255.