fileName = \hash('sha256', $file); return parent::shouldRunFile($file); } /** * Leave new. * * @param New_ $node New stmt * @param Context $ctx Context * * @return void */ public function leaveNew(New_ $node, Context $ctx): void { $classNode = $node->class; if (!$classNode instanceof Node\Stmt\Class_) { return; } $classNode->name = new Identifier('PhabelAnonymousClass'.$this->fileName.($this->count++)); $node->class = new Node\Name($classNode->name->name); foreach ($ctx->parents as $node) { if ($node instanceof Namespace_ || $node instanceof RootNode) { $ctx->insertBefore($ctx->getCurrentChild($node), $classNode); return; } } throw new \RuntimeException('Could not find hook for inserting anonymous class!'); } }