mnapoli/hard-mode
Hard Mode is a small PHP library by Matthieu Napoli that encourages writing more explicit, robust code by making certain “bad practices” harder or impossible at runtime. Useful for catching hidden assumptions and improving code quality in existing projects.
composer require --dev mnapoli/hard-modeHardMode::enable(); early in your bootstrap (e.g., in public/index.php or a dedicated bootstrap/hard-mode.php loaded before application boot)$arr['missing_key'] without isset(), or string concatenation with null.HardMode::enable() in an environment-gated block (e.g., if ($env === 'local' || $env === 'ci')) to avoid breaking production if misconfigured, or use it permanently in non-production environments only.HardMode::enable(['strictTypes' => true, 'nullToCoercible' => true])) if全量 activation is too aggressive for legacy code.HardMode\RuntimeException), then fix code to be explicit (e.g., add null checks, typed parameters).notice → exception for array access on undefined keys) may break legacy code unexpectedly; use in staging/CI first, not production.Undefined array key "foo" as exception); use stack traces or structured logging to trace problematic lines. Consider custom ErrorHandler if needed for nicer reporting.set_exception_handler()), turning HardMode into a reporting layer rather than a hard blocker.@ operator only as a last resort and file technical debt tickets to fix them explicitly.How can I help you explore Laravel packages today?