Menu

← Back to phpParser.*

Error Identifier: phpParser.nodeConnectingAttribute

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;

/** @implements Rule<Node\Stmt\Echo_> */
class MyRule implements Rule
{
	public function getNodeType(): string
	{
		return Node\Stmt\Echo_::class;
	}

	public function processNode(Node $node, Scope $scope): array
	{
		$parent = $node->getAttribute('parent');
		return [];
	}
}

Why is it reported? #

The code accesses a PHP-Parser node attribute (parent, previous, or next) that was previously provided by the NodeConnectingVisitor but is no longer available. PHPStan no longer uses this visitor, so these attributes are not set on AST nodes.

Learn more: Preprocessing AST for Custom Rules

How to fix it #

Use PHPStan’s built-in node types that provide parent/sibling information instead of relying on node attributes:

-$parent = $node->getAttribute('parent');
+// Use PHPStan's custom node types that provide structural context

See the blog post Preprocessing AST for Custom Rules for the recommended approach to accessing parent and sibling nodes in PHPStan rules.

How to ignore this error #

You can use the identifier phpParser.nodeConnectingAttribute to ignore this error using a comment:

// @phpstan-ignore phpParser.nodeConnectingAttribute
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: phpParser.nodeConnectingAttribute

Rules that report this error #

  • PHPStan\Rules\Api\NodeConnectingVisitorAttributesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.