<?php
class MyQuery{
public function query() {
die('callable called');
}
}
class QueryHandler {
public $query;
public function setQuery(callable $query) {
echo "checkpoint 1 reached"."\n";
$this->query = $query;
}
public function runQuery(){
$this->$query();
echo "end (should not show)"."\n";
}
}
echo "start"."\n";
$myQuery = new MyQuery;
$queryHandler = new QueryHandler;
$queryHandler->setQuery($myQuery->query);
$queryHandler->runQuery();
start
Warning: Undefined property: MyQuery::$query in /in/9TgDG on line 37
Fatal error: Uncaught TypeError: QueryHandler::setQuery(): Argument #1 ($query) must be of type callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG:19
Stack trace:
#0 /in/9TgDG(37): QueryHandler->setQuery(NULL)
#1 {main}
thrown in /in/9TgDG on line 19
Process exited with code 255.
start
Notice: Undefined property: MyQuery::$query in /in/9TgDG on line 37
Fatal error: Uncaught TypeError: Argument 1 passed to QueryHandler::setQuery() must be callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG:19
Stack trace:
#0 /in/9TgDG(37): QueryHandler->setQuery(NULL)
#1 {main}
thrown in /in/9TgDG on line 19
Process exited with code 255.
Output for 7.3.32 - 7.3.33
start
Fatal error: Uncaught TypeError: Argument 1 passed to QueryHandler::setQuery() must be callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG:19
Stack trace:
#0 /in/9TgDG(37): QueryHandler->setQuery(NULL)
#1 {main}
thrown in /in/9TgDG on line 19
Process exited with code 255.
start
Notice: Undefined property: MyQuery::$query in /in/9TgDG on line 37
Catchable fatal error: Argument 1 passed to QueryHandler::setQuery() must be callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG on line 19
Process exited with code 255.