website/errors/method.deprecatedTrait.md
<?php declare(strict_types = 1);
/** @deprecated Use NewHelper instead */
trait OldHelper
{
public function help(): void {}
}
class Foo
{
/** @param OldHelper $x */
public function doFoo($x): void
{
$x->help();
}
}
This error is reported by the phpstan-deprecation-rules extension.
A method is called on a value whose type is a deprecated trait. The trait has been marked with @deprecated, indicating it is scheduled for removal. Calling methods on deprecated trait types means the code depends on functionality that will eventually be removed.
Replace the deprecated trait type with its recommended replacement:
class Foo
{
- /** @param OldHelper $x */
+ /** @param NewHelper $x */
public function doFoo($x): void
{
$x->help();
}
}