symfony/polyfill-php81
Symfony Polyfill for PHP 8.1 features on older runtimes. Adds array_is_list, enum_exists, MYSQLI_REFRESH_REPLICA, ReturnTypeWillChange, and CURLStringFile (PHP 7.4+). Drop-in Composer dependency for wider compatibility.
symfony/var-dumper), requiring no architectural changes. The package’s opt-in, namespaced design (Php81\*) ensures zero coupling with Laravel’s core, making it ideal for incremental modernization.Php81\array_is_list), reducing collision risk with Laravel’s native PHP 8.1+ support (e.g., in Laravel 9+). This isolation is critical for mixed-version environments (e.g., legacy branches alongside PHP 8.1+ services).array_is_list) in new code while maintaining PHP 7.4–8.0 compatibility. Reduces friction for strangler pattern migrations or feature flags targeting older PHP versions.use Symfony\Polyfill\Php81\Php81;
if (Php81\array_is_list($request->input())) { ... }
No Laravel-specific bootstrapping (e.g., AppServiceProvider) or configuration files are needed.array_is_list in Laravel’s FormRequest classes.enum_exists to validate custom enums in Eloquent models without PHP 8.1.Php81\*) and avoid collisions with native PHP 8.1+ functions or Laravel’s internal polyfills.ReturnTypeWillChange may interact with Laravel’s internal method return type hints (e.g., in service containers), but this is non-blocking for most applications and limited to internal methods.array_is_list in high-throughput API routes).array_keys checks) if polyfill overhead exceeds thresholds.Fibers, read_only properties). Verify requirements against Symfony’s feature list before adoption.array_is_list, enum_exists) over niche use cases (e.g., MYSQLI_REFRESH_REPLICA).array_is_list([null, 1]) may return true unexpectedly in PHP 7.4 vs. PHP 8.1.symfony/polyfill-php81 in tests/Feature but not tests/Unit)?ramsey/array_is_list)? Audit composer.json for overlapping functionality.Str::of() enhancements) that could replace this?Php81\array_is_list vs. native array_is_list in a Laravel API handling 10K RPS.array_is_list logic) with lower overhead for critical paths?array_is_list).symfony/var-dumper, symfony/error-handler), so this requires no additional configuration.Assessment Phase:
array_keys($arr) === range(0, count($arr)-1) patterns (candidates for array_is_list).array_is_list in validation layers.MYSQLI_REFRESH_REPLICA or CURLStringFile (niche use cases).Integration:
composer require symfony/polyfill-php81
For testing only:
"require-dev": {
"symfony/polyfill-php81": "^1.37"
}
composer dump-autoload --optimize
How can I help you explore Laravel packages today?