<?php
class myClass {
public function toCall() {
echo 'called';
}
public function fromCall(callable $call) {
echo 'from';
}
public function __construct()
{
$this->fromCall($this, 'toCall');
}
}
$myClass = new myClass();
Fatal error: Uncaught TypeError: myClass::fromCall(): Argument #1 ($call) must be of type callable, myClass given, called in /in/XD04K on line 14 and defined in /in/XD04K:8
Stack trace:
#0 /in/XD04K(14): myClass->fromCall(Object(myClass), 'toCall')
#1 /in/XD04K(19): myClass->__construct()
#2 {main}
thrown in /in/XD04K on line 8
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to myClass::fromCall() must be callable, object given, called in /in/XD04K on line 14 and defined in /in/XD04K:8
Stack trace:
#0 /in/XD04K(14): myClass->fromCall(Object(myClass), 'toCall')
#1 /in/XD04K(19): myClass->__construct()
#2 {main}
thrown in /in/XD04K on line 8
Process exited with code 255.
Catchable fatal error: Argument 1 passed to myClass::fromCall() must be callable, object given, called in /in/XD04K on line 14 and defined in /in/XD04K on line 8
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Catchable fatal error: Argument 1 passed to myClass::fromCall() must be an instance of callable, instance of myClass given, called in /in/XD04K on line 14 and defined in /in/XD04K on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'callable' not found in /in/XD04K on line 8
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/XD04K 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/XD04K 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/XD04K on line 4
Process exited with code 255.