Menu

← Back to typeAlias.*

Error Identifier: typeAlias.internalClass

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;

// Defined in a third-party package:
// /** @internal */
// class InternalHelper {}

use ThirdParty\InternalHelper;

/**
 * @phpstan-type HelperType InternalHelper
 */
class MyClass
{
}

Why is it reported? #

The type alias defined with @phpstan-type references a class that is marked as @internal. Internal symbols are not meant to be used outside the package or namespace that defines them. Referencing an internal class in a type alias creates a dependency on an implementation detail that may change without notice in future versions of the package.

How to fix it #

Replace the internal class with a public type in the type alias:

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

-use ThirdParty\InternalHelper;
+use ThirdParty\PublicHelperInterface;

 /**
- * @phpstan-type HelperType InternalHelper
+ * @phpstan-type HelperType PublicHelperInterface
  */
 class MyClass
 {
 }

If the class is internal to the same package, the error will not be reported. The @internal restriction only applies to cross-package usage.

How to ignore this error #

You can use the identifier typeAlias.internalClass to ignore this error using a comment:

// @phpstan-ignore typeAlias.internalClass
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: typeAlias.internalClass

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.