Menu

← Back to typeAlias.*

Error Identifier: typeAlias.internalTrait

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 Vendor\Internal\SomeTrait;

/**
 * @phpstan-type MyType SomeTrait
 */
class Foo
{
}

Where SomeTrait is marked as @internal in the Vendor package.

Why is it reported? #

A PHPStan type alias (@phpstan-type) references a trait that is marked as @internal. Internal traits are not part of a package’s public API and may change or be removed without notice. Using them in a type alias creates a hidden dependency on unstable implementation details.

How to fix it #

Replace the internal trait with a public type from the package.

 /**
- * @phpstan-type MyType SomeTrait
+ * @phpstan-type MyType PublicType
  */
 class Foo
 {
 }

If no public alternative exists, consider whether the type alias is necessary, or contact the package maintainer to request a public API.

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.