Menu

Error Identifier: generics.internalInterfaceBound

← Back to generics.*

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 */
	interface InternalInterface {}
}

namespace App {
	/**
	 * @template T of \Vendor\InternalInterface
	 */
	class Container {}
}

Why is it reported? #

A template type bound references an interface that is marked as @internal. 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 \Vendor\InternalInterface
+ * @template T of \Vendor\PublicInterface
  */
 class Container {}

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

 /**
- * @template T of \Vendor\InternalInterface
+ * @template T
  */
 class Container {}

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]
Theme
A
© 2026 PHPStan s.r.o.