Menu

← Back to generics.*

Error Identifier: generics.notSupportedBound

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

/**
 * @template T of resource
 */
class ResourceWrapper
{
}

Why is it reported? #

The @template tag specifies a bound type that is not supported as a generic type constraint. PHPStan supports the following types as template bounds: mixed, object, class/interface types (including generic classes), array, string, int, float, bool, null, union types, intersection types, iterable, key-of, object-shape, and other template types.

Types like resource, callable, void, and never are not supported as template bounds.

How to fix it #

Use a supported type as the bound. If the template type does not need a specific bound, omit the of clause entirely:

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

Or use a more appropriate supported bound type:

 <?php declare(strict_types = 1);
 
 /**
- * @template T of resource
+ * @template T of object
  */
 class ResourceWrapper
 {
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Generics\ClassTemplateTypeRule [1]
  • PHPStan\Rules\Generics\FunctionTemplateTypeRule [1]
  • PHPStan\Rules\Generics\InterfaceTemplateTypeRule [1]
  • PHPStan\Rules\Generics\MethodTagTemplateTypeRule [1]
  • PHPStan\Rules\Generics\MethodTagTemplateTypeTraitRule [1]
  • PHPStan\Rules\Generics\MethodTemplateTypeRule [1]
  • PHPStan\Rules\Generics\TraitTemplateTypeRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyHookPhpDocTypeRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyPhpDocTypeRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.