Menu

← Back to generics.*

Error Identifier: generics.internalClassBound

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 */
class InternalHandler
{
}

// In your code:

/**
 * @template T of InternalHandler
 */
class Pipeline
{
}

Why is it reported? #

A @template tag uses an internal class as its bound type. The class referenced in the of clause has been marked with the @internal PHPDoc tag. Internal classes are not part of the public API and are intended to be used only within the package or root namespace where they are defined. Referencing an internal class as a template bound from outside its root namespace creates a dependency on an implementation detail that may change or be removed without notice.

How to fix it #

Replace the internal class with a public (non-internal) class in the template bound:

 <?php declare(strict_types = 1);
 
 /**
- * @template T of InternalHandler
+ * @template T of PublicHandler
  */
 class Pipeline
 {
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.