<?php
class A {
private $callback;
public function __construct(Closure $callback){
$callback = $this->callback;
$callback();
}
public function aaa(){
$this->callback();
}
}
$a = new A(function () { echo 'a'; });
$a->aaa();
Fatal error: Uncaught Error: Value of type null is not callable in /in/FB5sO:7
Stack trace:
#0 /in/FB5sO(14): A->__construct(NULL)
#1 {main}
thrown in /in/FB5sO on line 7
Process exited with code 255.
Fatal error: Uncaught Error: Function name must be a string in /in/FB5sO:7
Stack trace:
#0 /in/FB5sO(14): A->__construct(NULL)
#1 {main}
thrown in /in/FB5sO on line 7
Process exited with code 255.
Fatal error: Function name must be a string in /in/FB5sO on line 7
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/FB5sO on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/FB5sO on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/FB5sO on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/FB5sO on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/FB5sO on line 4
Process exited with code 255.