betterNodeFinder = $betterNodeFinder; $this->reflectionResolver = $reflectionResolver; } /** * @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $node */ public function isLegal($node) : bool { if ($node->static) { return \false; } $nodes = $node instanceof Closure ? $node->stmts : [$node->expr]; return !(bool) $this->betterNodeFinder->findFirst($nodes, function (Node $subNode) : bool { if (!$subNode instanceof StaticCall) { return $subNode instanceof Variable && $subNode->name === 'this'; } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromStaticCall($subNode); if (!$methodReflection instanceof MethodReflection) { return \false; } return !$methodReflection->isStatic(); }); } }