Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeTraverser.php

function NodeTraverser::ensureReplacementReasonable

Same name in this branch
  1. 11.1.x vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php \PhpParser\NodeTraverser::ensureReplacementReasonable()
2 calls to NodeTraverser::ensureReplacementReasonable()
NodeTraverser::traverseArray in vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php
* Recursively traverse array (usually of nodes). * *
NodeTraverser::traverseNode in vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php
* Recursively traverse a node. * *

File

vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php, line 293

Class

NodeTraverser
Inspired by https://github.com/nikic/PHP-Parser/tree/36a6dcd04e7b0285e8f0868f44bd49…

Namespace

PHPStan\PhpDocParser\Ast

Code

private function ensureReplacementReasonable(Node $old, Node $new) : void {
    if ($old instanceof TypeNode && !$new instanceof TypeNode) {
        throw new LogicException(sprintf('Trying to replace TypeNode with %s', get_class($new)));
    }
    if ($old instanceof ConstExprNode && !$new instanceof ConstExprNode) {
        throw new LogicException(sprintf('Trying to replace ConstExprNode with %s', get_class($new)));
    }
    if ($old instanceof PhpDocChildNode && !$new instanceof PhpDocChildNode) {
        throw new LogicException(sprintf('Trying to replace PhpDocChildNode with %s', get_class($new)));
    }
    if ($old instanceof PhpDocTagValueNode && !$new instanceof PhpDocTagValueNode) {
        throw new LogicException(sprintf('Trying to replace PhpDocTagValueNode with %s', get_class($new)));
    }
}
RSS feed
Powered by Drupal