thecodingmachine/safe). This aligns with projects prioritizing type safety, runtime security, and compliance (e.g., fintech, healthcare, CLI tools).safe might be used for dynamic operations).safe usage (e.g., Artisan::call(), shell commands). The package will flag these unless explicitly whitelisted.app()->make() with unsafe parameters) may trigger violations.safe under the hood (e.g., spatie/laravel-medialibrary). Requires vendor-level analysis or selective whitelisting.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| False Positives | Medium | Configure phpstan.neon to whitelist known-safe usages (e.g., internal microservices). |
| Breaking Changes | Low | 1.0.0 is a stable release with no breaking changes. Backward-compatible (MIT license). |
| Performance Overhead | Low | Static analysis adds negligible runtime cost; only affects dev/test phases. |
| Third-Party Dependency | High | Risk of flagging legitimate safe usage in dependencies. Requires granular whitelisting. |
| Lack of Adoption | Medium | New package (0 stars); validate with internal security audits before widespread use. |
Security Policy Alignment:
safe usage, or is this a proactive measure?Laravel’s Filesystem abstractions)?Impact Assessment:
safe or similar patterns (e.g., eval(), shell_exec())?safe? Can they be replaced or patched?Tooling Maturity:
False Positive Handling:
Long-Term Maintenance:
safe is deprecated upstream)?phpstan/phpstan in composer.json).safe is heavily used in inter-service communication (may require architectural refactoring).Assessment Phase (1-2 weeks):
safe usage (tools: composer why, roave/security-advisories).phpstan.neon.Pilot Phase (2-4 weeks):
safe with Laravel’s Storage facade).Rollout Phase (4-8 weeks):
safe usage in internal libraries (replace with custom wrappers).safe with Laravel’s Process facade or Symfony/Process.app()->bound() checks instead of dynamic safe calls.{{ }} with user input; use {{{ }}} with sanitization.includes:
- vendor/wyrihaximus/phpstan-no-safe/extension.neon
level: max
whitelistPaths:
- src/Exceptions/WhitelistedSafeUsage.php # Custom exceptions for approved uses
spatie/laravel-medialibrary) uses safe, consider:
safe dependency.| Phase | Action Items | Dependencies |
|---|---|---|
| Pre-Integration | Audit codebase for safe usage; assess third-party impact. |
Security team, DevOps. |
| Tooling Setup | Add PHPStan extension to composer.json; configure phpstan.neon. |
CI/CD pipeline ownership. |
| Pilot Rollout | Test in a non-production module; refactor violations. | Backend team. |
| Full Rollout | Enable for all modules; update docs; train teams. | QA, Documentation team. |
| Post-Launch | Monitor false positives; refine whitelists; plan for future PHPStan updates. | Security team, TPM. |
phpstan.neon may accumulate custom whitelists, making it hard to maintain.thecodingmachine/safe or PHPStan releases breaking changes, the extension may need updates.composer.json until stability is confirmed.safe is blocked and how to refactor.Storage::disk()->put() instead of safe").How can I help you explore Laravel packages today?