Menu

← Back to generics.*

Error Identifier: generics.internalInterfaceBound

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

// In package vendor/some-library:
// /** @internal */
// interface InternalInterface {}

/**
 * @template T of \SomeLibrary\InternalInterface
 */
class Foo
{
}

Why is it reported? #

A template type bound references an interface that is marked as @internal by its declaring package. The @template T of SomeInterface syntax constrains the template type to subtypes of the given interface. When that interface is internal, using it as a bound creates a dependency on an implementation detail that may change without notice.

How to fix it #

Use a public interface as the template type bound instead:

 /**
- * @template T of \SomeLibrary\InternalInterface
+ * @template T of \SomeLibrary\PublicInterface
  */
 class Foo
 {
 }

If no suitable public interface exists, consider removing the bound or contacting the library maintainers:

 /**
- * @template T of \SomeLibrary\InternalInterface
+ * @template T
  */
 class Foo
 {
 }

How to ignore this error #

You can use the identifier generics.internalInterfaceBound to ignore this error using a comment:

// @phpstan-ignore generics.internalInterfaceBound
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: generics.internalInterfaceBound

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.