coreClassReflection = new CoreReflectionClass($anonymousClassObject); } /** * {@inheritDoc} * * @throws ParseToAstFailure */ public function locateIdentifier(Reflector $reflector, Identifier $identifier): Reflection|null { return $this->getReflectionClass($reflector, $identifier->getType()); } /** * {@inheritDoc} * * @throws ParseToAstFailure */ public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType): array { return array_filter([$this->getReflectionClass($reflector, $identifierType)]); } private function getReflectionClass(Reflector $reflector, IdentifierType $identifierType): ReflectionClass|null { if (! $identifierType->isClass()) { return null; } if (! $this->coreClassReflection->isAnonymous()) { return null; } /** @phpstan-var non-empty-string $fileName */ $fileName = $this->coreClassReflection->getFileName(); if (strpos($fileName, 'eval()\'d code') !== false) { throw EvaledAnonymousClassCannotBeLocated::create(); } FileChecker::assertReadableFile($fileName); $fileName = FileHelper::normalizeWindowsPath($fileName); $nodeVisitor = new class ($fileName, $this->coreClassReflection->getStartLine()) extends NodeVisitorAbstract { /** @var list */ private array $anonymousClassNodes = []; public function __construct(private string $fileName, private int $startLine) { } /** * {@inheritDoc} */ public function enterNode(Node $node) { if (! ($node instanceof Class_) || $node->name !== null || $node->getLine() !== $this->startLine) { return null; } $this->anonymousClassNodes[] = $node; return null; } public function getAnonymousClassNode(): Class_ { if ($this->anonymousClassNodes === []) { throw NoAnonymousClassOnLine::create($this->fileName, $this->startLine); } if (isset($this->anonymousClassNodes[1])) { throw TwoAnonymousClassesOnSameLine::create($this->fileName, $this->startLine); } return $this->anonymousClassNodes[0]; } }; $fileContents = file_get_contents($fileName); /** @var list $ast */ $ast = $this->parser->parse($fileContents); $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor(new NameResolver()); $nodeTraverser->addVisitor($nodeVisitor); $nodeTraverser->traverse($ast); $reflectionClass = (new NodeToReflection())->__invoke( $reflector, $nodeVisitor->getAnonymousClassNode(), new AnonymousLocatedSource($fileContents, $fileName), null, ); assert($reflectionClass instanceof ReflectionClass); return $reflectionClass; } } __halt_compiler();----SIGNATURE:----LLu3bRwe7TH0Xn02Di0L2WrJ1aIRGcWsXSD0+QbNzLZvYiY2Oh4RHbAhRRIcAuMXs/MvRjD/8h7QBfO5M3r2J7fQiBxm7XuhdgEP3Xbxeq1S53/PzwXkUiL72zSIUDGVZZoT25uf6n7KSaw70G4V+TNyUBqkbmNfOWsmLm7e8kwAw5apl39CinOqcRp/FwUOOUwwrFoHWpdbgoxHsNjhka0kT3HKNGt5vFHPXCrlHUotnx2EKv/XFcgQAQKKCb9PelTjNazhEXpXFpZyxT7yCDWmqqoPdQovdrLELpJwlvABxx3RdiltUCOvJOhl2I/cxjhQAf5w2NXHrSQtw+ENL4ziy9WY1bQSNHa5+jVERcajXPg2cbU2wbjYyxXIln7/tf1KAWQCiEz7tB/ehq8JFkBJlzFfFQ0JRrshX5jpPLxhSzdiUo8EOUssYFp4qbjcjG16J8dRbN1PWNPwOn4ZisC8diE+4YCsmFaLgs+7O74U0Ic7b06gm6jZc6jBH0ufcEDFzhihi73rlYQljmreZ1uO8WVFxCwl470voAoX7gel1OtDyzfPg44Ip0x+uQFIx+JE630s+wORHhfqTtY22dKtRn+t1NFEAIV6jVU3TCqTF1mTynJJ8OJGfa7ecGVKFH0WRgMUnjRVVGew08uLCn8xXfJGKdx67ehaNhSoTGw=----ATTACHMENT:----OTEwNDQzNjU1MDEwNTUzMSAyMzg2ODA1NDIxMzI4NTA1IDY5MDE3NDU1NzM5MzgzODg=