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 Node\Stmt\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:----o/uCdJ7tErT8kndw8jTJHuTh2o3rzHMq+UOb8s9ICbPw+HJeT9dEzsb8Fv4EOdEMlzc1aBP2lISzZhEuXD7i4tr4ESBzxzRQMw0KekD8C/DXaGU40IhBDx+OylEtUYSm4iPxtvrkSOfpMyW0q9NJ9R66GWDh2IElFHoGvOf0Ciym0gEsa2LrmKpDFUoZHVYF1fu0lN1tGwkzWtgy31Wg0EvO/tRl5q/pMlKu//99hYlARDw4rOboXwEsWLEW3hz5x2aJ1ahrREml1Gy8XbKuY6xHSl1KLz1uwmK2Y1n9EfVTtjnOkAF+Exy2Xdn7mGBvOxldCgUbJBVH1PVFQqcSj4+psr4JW0dBY1xI+u/UpLdhWWrubtG5msxW97aZH+qHSqEHyaAeI8T7eAUtKaE6ndufa0RR+0wvEhZyNb+8YKCirr/LeCgfie7uwU2KXaf97YmCfH7LDrSn6cz3gbEIk0F4sPB8olae7Z8xYIqYFVRXdUXpqhTEdHv6UwolIi7U5ldtxjEQ9GyuIdRlAw0YAFQRWA0flDqcjj/R7pKGTACvUJKzwDhuavSAlg1TIBWfcaBmM8dFD0w/5eYLOZdHIvdapdNcAuKjXEt3axipTTH6qkcOyo/LAgyilWSRST4MGSibGevkK+KDuH0Uts8cE4QHEftmdrUx2e43wpEBEcY=----ATTACHMENT:----MTAzNTM3NjA0MjczMDMzNyA0MzQ3MjM0MzY3NzY2NzkyIDkwODY3NDUwMzUwMzY4OTU=