website/errors/property.deprecatedInterface.md
<?php declare(strict_types = 1);
/** @deprecated Use NewInterface instead */
interface OldInterface
{
public function doSomething(): void;
}
class Foo
{
public OldInterface $service;
}
A property's type declaration references an interface that has been marked as @deprecated. Using deprecated interfaces in property types ties the code to APIs that are scheduled for removal. The deprecation notice indicates that a replacement exists and should be used instead.
This rule is provided by the phpstan-deprecation-rules package.
Replace the deprecated interface with its recommended replacement in the property type:
<?php declare(strict_types = 1);
class Foo
{
- public OldInterface $service;
+ public NewInterface $service;
}
If the replacement interface does not exist yet or the migration is ongoing, the error can be ignored on a per-line basis using a PHPStan ignore comment while the migration is being planned.