eZ\Publish\Core\MVC\Symfony\Translation\TranslatableExceptionsFileVisitor::enterNode PHP Метод

enterNode() публичный Метод

public enterNode ( PhpParser\Node $node )
$node PhpParser\Node
    public function enterNode(Node $node)
    {
        if (!$node instanceof Node\Stmt\Throw_ || !$node->expr instanceof Node\Expr\New_) {
            $this->previousNode = $node;
            return;
        }
        $exceptionClass = $node->expr->class->parts[0];
        if (!in_array(strtolower($exceptionClass), array_map('strtolower', $this->exceptionsToExtractFrom))) {
            $this->previousNode = $node;
            return;
        }
        $node = $node->expr;
        $ignore = false;
        $desc = $meaning = null;
        if (null !== ($docComment = $this->getDocCommentForNode($node))) {
            if ($docComment instanceof Doc) {
                $docComment = $docComment->getText();
            }
            foreach ($this->docParser->parse($docComment, 'file ' . $this->file . ' near line ' . $node->getLine()) as $annot) {
                if ($annot instanceof Ignore) {
                    $ignore = true;
                } elseif ($annot instanceof Desc) {
                    $desc = $annot->text;
                } elseif ($annot instanceof Meaning) {
                    $meaning = $annot->text;
                }
            }
        }
        if (!$node->args[0]->value instanceof String_) {
            if ($ignore) {
                return;
            }
            $message = sprintf('Can only extract the translation id from a scalar string, but got "%s". Please refactor your code to make it extractable, or add the doc comment /** @Ignore */ to this code element (in %s on line %d).', get_class($node->args[0]->value), $this->file, $node->args[0]->value->getLine());
            if ($this->logger) {
                $this->logger->error($message);
                return;
            }
            throw new RuntimeException($message);
        }
        $id = $node->args[0]->value->value;
        $message = new Message($id, $this->defaultDomain);
        $message->setDesc($desc);
        $message->setMeaning($meaning);
        $message->addSource($this->fileSourceFactory->create($this->file, $node->getLine()));
        $this->catalogue->add($message);
    }