Menu

← Back to requireExtends.*

Error Identifier: requireExtends.nonObject

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

/**
 * @phpstan-require-extends int
 */
trait MyTrait
{
}

Why is it reported? #

The @phpstan-require-extends PHPDoc tag contains a non-object type. This tag is meant to restrict which classes can use the trait by requiring that they extend a specific class. It only makes sense with object (class) types, not scalar types like int, string, etc.

How to fix it #

Use an object (class) type in the @phpstan-require-extends tag:

 <?php declare(strict_types = 1);
 
 /**
- * @phpstan-require-extends int
+ * @phpstan-require-extends SomeBaseClass
  */
 trait MyTrait
 {
 }

How to ignore this error #

You can use the identifier requireExtends.nonObject to ignore this error using a comment:

// @phpstan-ignore requireExtends.nonObject
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: requireExtends.nonObject

Rules that report this error #

  • PHPStan\Rules\PhpDoc\RequireExtendsDefinitionClassRule [1]
  • PHPStan\Rules\PhpDoc\RequireExtendsDefinitionTraitRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.