Menu

← Back to varTag.*

Error Identifier: varTag.internalEnum

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

use Internal\CacheStrategy;

/** @var CacheStrategy $strategy */
$strategy = getStrategy();

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.

 <?php declare(strict_types = 1);
 
 namespace App;

-use Internal\CacheStrategy;
+use Public\CacheStrategy;

-/** @var CacheStrategy $strategy */
+/** @var CacheStrategy $strategy */
 $strategy = getStrategy();

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]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.