shipmonk/phpstan-rules
40 super-strict PHPStan rules from ShipMonk to plug gaps in extra-strict setups. Install via Composer, include rules.neon, then enable/disable or tune rules per-project. Targets tricky PHP edge cases like unsafe comparisons, casts, arrays, enums and more.
forbidCheckedExceptionInCallable and forbidArithmeticOperationOnNonNumber mitigate risks by catching edge cases early.enforceIteratorToArrayPreserveKeys prevent subtle bugs that could impact performance (e.g., unintended key loss in arrays).readonly, match expressions, and generics).forbidCast could break legacy array-to-object conversions)."This package lets us enforce industry-leading PHP code quality with minimal effort. By adopting ShipMonk’s strict PHPStan rules, we’ll catch critical bugs early—like unsafe type comparisons, unhandled exceptions in callbacks, or mutable public properties—reducing production incidents. It’s a low-cost, high-impact way to align our codebase with best practices, similar to how teams at ShipMonk (a logistics tech company) use it. The rules are configurable, so we can tailor them to our needs without sacrificing safety. This supports our goals of scalability and developer productivity by reducing technical debt."
*"This package extends PHPStan’s strictness with 40+ rules that ShipMonk uses in production. Key benefits:
readonly for public properties, reducing side effects.*Test suffix for tests) and array handling.
It’s zero-maintenance—just install and configure. We can phase in rules gradually (e.g., start with enforceNativeReturnTypehint and forbidCast), and the documentation shows exactly how to disable anything opinionated. This aligns with our quality-first culture and reduces fire drills from subtle bugs."*"Think of this as PHPStan on steroids. It catches edge cases native PHPStan misses, like:
>/< (which works in PHP but is error-prone).preserve_keys in iterator_to_array (a common source of data loss).if ($enum === Case1) elseif ($enum === Case2), it’ll nudge you to use match ($enum) instead—future-proofing your code against new enum cases."How can I help you explore Laravel packages today?