Menu

← Back to class.*

Error Identifier: class.missingImplements

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

interface Loggable
{
	public function log(): void;
}

/** @phpstan-require-implements Loggable */
trait LoggableTrait
{
	public function log(): void
	{
		// ...
	}
}

class UserService
{
	use LoggableTrait;
}

Why is it reported? #

The trait declares a @phpstan-require-implements tag that requires any class using the trait to implement a specific interface. The class using the trait does not implement the required interface.

In the example above, LoggableTrait requires the using class to implement Loggable, but UserService does not declare implements Loggable.

How to fix it #

Add the required interface to the class declaration:

 <?php declare(strict_types = 1);
 
-class UserService
+class UserService implements Loggable
 {
 	use LoggableTrait;
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Classes\RequireImplementsRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.