Menu

← Back to generics.*

Error Identifier: generics.wrongParent

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

/**
 * @implements \ArrayAccess<string, int>
 */
class MyCollection implements Collection
{
}

Why is it reported? #

A @extends or @implements PHPDoc tag references a class or interface that the current class does not actually extend or implement. The generic type annotation must match one of the actual parent classes or interfaces in the class declaration.

How to fix it #

Make sure the PHPDoc tag matches the actual parent class or interface:

 <?php declare(strict_types = 1);
 
 /** @template T */
 interface Collection
 {
 }

 /**
- * @implements \ArrayAccess<string, int>
+ * @implements Collection<int>
  */
 class MyCollection implements Collection
 {
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Generics\ClassAncestorsRule [1]
  • PHPStan\Rules\Generics\EnumAncestorsRule [1]
  • PHPStan\Rules\Generics\InterfaceAncestorsRule [1]
  • PHPStan\Rules\Generics\UsedTraitsRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.