symfony/polyfill-php84
Symfony Polyfill for PHP 8.4 features, enabling newer core functions and APIs on older runtimes. Includes array_find/any/all, bcdivmod, Deprecated attribute, fpow, grapheme_str_split, mb_* trim/ucfirst/lcfirst, PDO subclasses, and ReflectionConstant.
array_find/array_all can replace or augment Laravel’s Collection methods (e.g., firstWhere, contains), reducing custom logic.mb_* fixes directly improve Laravel’s Str::of(), App::setLocale(), and form validation for multibyte strings (e.g., emojis, CJK).#[Deprecated]) in Laravel 9/10 without forcing a PHP version bump, critical for teams constrained by hosting (e.g., shared servers).bcdivmod for financial calculations)."symfony/polyfill-php84": "^1.38"), with no Laravel-specific configuration required. Autoloading handles the rest.array_find) will work without changes.grapheme_str_split fix requires PCRE ≥10.44. Laravel TPMs should audit hosting environments and add a runtime check (e.g., if (version_compare(PCRE_VERSION, '10.44') < 0) { Log::warning(...); }).// Test array_find performance in Laravel collections
$users = User::all()->toArray();
$start = microtime(true);
$admin = array_find($users, fn($u) => $u['role'] === 'admin');
$time = microtime(true) - $start;
Log::info("array_find time: {$time}s");
array_find behaves identically to Laravel’s Collection::firstWhere in edge cases (e.g., empty arrays, null values).array_find with associative arrays). Mitigation: Write unit tests for critical paths using Laravel’s PHPUnit and compare outputs with PHP 8.4.mb_trim for 20% of user-generated content in [Module X]").array_find replace any custom Laravel logic? If so, test for regressions.mbstring) that might conflict?HttpClient, StringUtils, or Validator, these polyfills are already expected dependencies.composer require symfony/polyfill-php84:^1.38
// Before (Laravel Collection)
$admin = User::where('role', 'admin')->first();
// After (Polyfill)
$users = User::all()->toArray();
$admin = array_find($users, fn($u) => $u['role'] === 'admin');
#[Deprecated] for Laravel custom packages:
#[Deprecated('Use App\Services\NewService instead')]
class LegacyService { ... }
array_find/array_all against Laravel’s Collection methods.mb_trim/mb_ucfirst with non-ASCII strings (e.g., Arabic, CJK).$data = range(1, 10000);
$start = microtime(true);
$result = array_find($data, fn($x) => $x % 2 === 0);
$time = microtime(true) - $start;
Log::info("array_find 10k items: {$time}s");
grapheme_str_split needs PCRE ≥10.44. Add a runtime check:
if (version_compare(PCRE_VERSION, '10.44') < 0) {
throw new RuntimeException('PCRE <10.44: grapheme_str_split polyfill unavailable.');
}
Collection methods but don’t replace them entirely (e.g., array_find lacks Laravel’s query builder integration).composer.json and test in staging.array_find, #[Deprecated]) in new development.composer update symfony/polyfill-php84
mb_trim null handling in v1.38.1). **How can I help you explore Laravel packages today?