adriansuter/php-autoload-override
Override fully qualified global function calls inside class methods so you can mock them in tests. Works with PHP 8.2+ and Composer PSR-4 autoloading; integrates via a PHPUnit bootstrap using OverrideFactory to map functions (e.g., rand) to real implementations.
Added MockRegistry (src/MockRegistry.php)
A scoped, type-safe alternative to the $GLOBALS pattern used inside override closures. Supports per-class overrides, a global fallback, and granular reset methods. Existing $GLOBALS usage remains fully supported.
Added OverrideFactory (src/OverrideFactory.php)
A fluent builder that reduces bootstrap scripts to concise declarations. Accepts real function implementations as first-class callables and applies the lazy MockRegistry pattern automatically. Supports apply() for direct registration and build() for returning the raw declarations array.
Updated documentation
$GLOBALS to MockRegistry and OverrideFactory^2.0phpunit.xml.dist snippet#[Test], assertSame, void return types)phpstan added.Version 1 is feature complete.
How can I help you explore Laravel packages today?