Menu

Error Identifier: varTag.internalEnum

← Back to varTag.*

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);

namespace Vendor {
	/** @internal */
	enum InternalEnum {
		case A;
	}
}

namespace App {
	function getStatus(): object {
		return new \stdClass();
	}

	/** @var \Vendor\InternalEnum $status */
	$status = getStatus();
}

Why is it reported? #

The @var PHPDoc tag references an enum that is marked as @internal in another package. Internal symbols are not meant to be used outside of their own package. Referencing them in @var tags creates a dependency on implementation details that can change without notice.

How to fix it #

Use the public API type instead of the internal enum in the @var tag:

 namespace App {
-	/** @var \Vendor\InternalEnum $status */
+	/** @var \Vendor\PublicEnum $status */
 	$status = getStatus();
 }

How to ignore this error #

You can use the identifier varTag.internalEnum to ignore this error using a comment:

// @phpstan-ignore varTag.internalEnum
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: varTag.internalEnum

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]
Theme
A
© 2026 PHPStan s.r.o.