Menu

← Back to new.*

Error Identifier: new.deprecatedInterface

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.

This error is reported by phpstan/phpstan-deprecation-rules.

Code example #

<?php declare(strict_types = 1);

/** @deprecated Use NewCacheInterface instead */
interface OldCacheInterface
{
}

class FileCache implements OldCacheInterface
{
}

$cache = new FileCache();

Why is it reported? #

An object is being instantiated from a class that implements a deprecated interface, or the class itself is a deprecated interface-like structure being referenced in a new expression context. The @deprecated tag on the interface signals that it should no longer be used, and all code depending on it should migrate to the recommended replacement.

How to fix it #

Update the code to use the replacement class or interface as indicated in the deprecation message.

 <?php declare(strict_types = 1);
 
-class FileCache implements OldCacheInterface
+class FileCache implements NewCacheInterface
 {
 }

 $cache = new FileCache();

How to ignore this error #

You can use the identifier new.deprecatedInterface to ignore this error using a comment:

// @phpstan-ignore new.deprecatedInterface
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: new.deprecatedInterface

Rules that report this error #

  • PHPStan\Rules\Deprecations\RestrictedDeprecatedClassNameUsageExtension [1] phpstan/phpstan-deprecation-rules

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.