dg/bypass-finals
DG\BypassFinals lets you bypass PHP’s final classes and methods at runtime so you can mock, extend, or patch code that’s otherwise locked down—useful for testing legacy dependencies. Lightweight, Composer-ready, and works with popular test frameworks.
Architecture fit: The package aligns with Laravel's dependency injection patterns by enabling mocking of final vendor classes (e.g., third-party SDKs or legacy code), which is otherwise impossible. However, Laravel's core architecture avoids final where possible, so utility is limited to edge cases involving external dependencies. Integration feasibility: Requires Composer installation and bootstrap configuration (e.g., phpunit.xml or test bootstrap file). Works with PHPUnit/Mockery out-of-the-box but requires careful scoping to avoid production exposure. Technical risk: High due to NOASSERTION license (legal uncertainty), potential for false-positive tests (bypassed final behavior may differ from production), and PHP 8+ readonly compatibility risks. Key questions: How does it interact with OPcache? Is it compatible with Laravel's service container? What's the maintenance status given the unknown repository? Does it support PHP 8.2+ features?
Stack fit: Fully compatible with Laravel's testing stack (PHPUnit, Pest, Mockery) but requires explicit isolation to test environments only. Must avoid loading in production via environment checks. Migration path: Add to composer.json as dev dependency, then modify bootstrap/test.php or phpunit.xml to initialize the bypass before tests. Minimal code changes needed for existing tests targeting final classes. Compatibility: Works with Laravel 8+ and PHP 7.4+, but verify compatibility with PHP 8.2+ readonly semantics. Sequencing: Install → configure test bootstrap → run tests → ensure no production deployment includes the package (via CI checks or environment flags).
Maintenance: High risk due to unknown repository and NOASSERTION license; no clear support channels or version history. May break with PHP updates. Support: Limited community support (stars alone don't indicate active maintenance); debugging requires deep package knowledge. Scaling: Negligible performance impact in CI (single-pass bytecode manipulation), but large test suites may see ~5-10% slowdown. Failure modes: Accidental production use could cause runtime errors (e.g., final removal breaking type safety); false test passes if bypass logic conflicts with actual class behavior. Ramp-up: Requires team training on strictly test-only usage, documentation of "when to use" guidelines, and CI safeguards (e.g., fail builds if package is loaded outside testing environment).
How can I help you explore Laravel packages today?