/** * Analyzer a given closure. * * @param Closure $closure * * @return array */ public function analyze(Closure $closure) { $reflection = new ReflectionClosure($closure); $scope = $reflection->getClosureScopeClass(); $data = ['reflection' => $reflection, 'code' => $reflection->getCode(), 'hasThis' => $reflection->isBindingRequired(), 'context' => $reflection->getUseVariables(), 'hasRefs' => false, 'binding' => $reflection->getClosureThis(), 'scope' => $scope ? $scope->getName() : null, 'isStatic' => $reflection->isStatic()]; return $data; }
public function testClosureStaticFail() { $f = static function () { }; $rc = new ReflectionClosure($f); $this->assertFalse($rc->isStatic()); }