website/errors/catch.deprecatedClass.md
<?php declare(strict_types = 1);
/** @deprecated Use NewException instead */
class OldException extends \Exception
{
}
try {
// ...
} catch (OldException $e) {
// ...
}
The catch clause references a class that has been marked with a @deprecated PHPDoc tag. The class is scheduled for removal or replacement, and any usage of it -- including catching it as an exception -- should be migrated to the recommended alternative.
This rule is provided by the phpstan-deprecation-rules package.
Replace the deprecated class with its recommended replacement as indicated in the deprecation message:
<?php declare(strict_types = 1);
try {
// ...
-} catch (OldException $e) {
+} catch (NewException $e) {
// ...
}