Passing an object property into a closure in PHP
问题 I am trying to pass an object property into a closure (that's within a method of that object), like so: class Entity extends ControllerBase { private $view; private $events; public function print($tid) { self::loadView($tid); self::loopView(); return (new StreamedResponse(function() use ($this->events){ ... } } } The $events property gets instantiated in the loopView() method. This seems like it should work to me, but I get this error: ParseError: syntax error, unexpected '->' (T_OBJECT