Menu

← Back to method.*

Error Identifier: method.notFound

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 doFoo(): void
	{
	}
}

$foo = new Foo();
$foo->doBar();

Why is it reported? #

A method is called on an object, but the method does not exist on that object’s type. In the example above, doBar() is called on a Foo object, but only doFoo() is defined.

How to fix it #

Call a method that exists on the class:

 <?php declare(strict_types = 1);
 
 $foo = new Foo();
-$foo->doBar();
+$foo->doFoo();

Or add the missing method to the class.

How to ignore this error #

You can use the identifier method.notFound to ignore this error using a comment:

// @phpstan-ignore method.notFound
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: method.notFound

Rules that report this error #

  • PHPStan\Rules\Methods\CallMethodsRule [1]
  • PHPStan\Rules\Methods\MethodCallableRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.