website/errors/traitUse.deprecatedTrait.md
<?php declare(strict_types = 1);
namespace App;
/** @deprecated Use NewTrait instead */
trait OldTrait
{
public function doSomething(): void
{
}
}
class Foo
{
use OldTrait;
}
This error is reported by the phpstan/phpstan-deprecation-rules package.
The class uses a trait that is marked as @deprecated via the use statement in the class body. Deprecated traits are scheduled for removal or replacement and should no longer be used in new code.
Replace the deprecated trait with its recommended replacement:
<?php declare(strict_types = 1);
namespace App;
class Foo
{
- use OldTrait;
+ use NewTrait;
}
If the class is itself deprecated, the error will not be reported:
<?php declare(strict_types = 1);
namespace App;
+/** @deprecated */
class Foo
{
use OldTrait;
}