Menu

← Back to class.*

Error Identifier: class.noParent

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

class Foo
{
    public function bar(): void
    {
        parent::bar(); // reported: Foo::bar() calls parent::bar() but Foo does not extend any class.
    }
}

Why is it reported? #

The parent keyword is used inside a class that does not extend any other class. The parent keyword refers to the parent class, so using it in a class without a parent has no valid target and results in a fatal error at runtime.

How to fix it #

Either extend a parent class that provides the referenced member, or remove the parent:: call.

Adding a parent class:

-class Foo
+class Foo extends BaseClass
 {
     public function bar(): void
     {
         parent::bar();
     }
 }

Or removing the call:

 class Foo
 {
     public function bar(): void
     {
-        parent::bar();
     }
 }

How to ignore this error #

You can use the identifier class.noParent to ignore this error using a comment:

// @phpstan-ignore class.noParent
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: class.noParent

Rules that report this error #

  • PHPStan\Rules\Classes\ClassConstantRule [1]
  • PHPStan\Rules\Classes\InstantiationRule [1]
  • PHPStan\Rules\Methods\CallStaticMethodsRule [1]
  • PHPStan\Rules\Methods\StaticMethodCallableRule [1]
  • PHPStan\Rules\Properties\AccessStaticPropertiesInAssignRule [1]
  • PHPStan\Rules\Properties\AccessStaticPropertiesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.