You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until now the SuperfluousExceptionNaming sniff was enabled in Doctrine
Coding Standard, but every of our projects disabled this sniff in their
local phpcs.xml rule.
Doctrine does not actually follow this rule, instead we provide the
context of the exception in the name as a "prefix" similar to PHPs own
RuntimeException and so on.
This is done, because exceptions are used soley in the context of code
that reads like:
} catch (DBALException $e) {
}
If we allow classes named "Exception", then we introduce a developer
experience problem, because it potentially requires the user
to make an alias/renaming decision, increasing their mental load:
use OtherLibrary\Exception as OtherException;
use Doctrine\DBAL\Exception as DBALException;
use Exception;
} catch (OtherException $e) {
} catch (DBALException $e) {
} catch (Exception $e) {
}
Additionally it makes it hard for developers understanding catch clauses
when they cannot rely on the fact that "Exception" is the global one.
} catch (Exception $e) { // don't mess with user expectations
0 commit comments