
Laravel 8.22 Released
The Laravel team released 8.22 yesterday with a new event fake assertion, a collection method to reduce associative arrays to a single value, and the latest changes in the 8.x branch:
Assert Nothing Dispatched
@danilopolani contributed event assertion assertNothingDispatched
to the fake event instance:
Event::fake();
// Function that should NOT dispatch any event
Event::assertNothingDispatched();
Reduce with Keys Collection Method
Mo Khosh contributed a reduceWithKeys
method to collections (and lazy collections) to reduce an associative collection to a single value.
Similar to
map
andmapWithKeys
, this augmentsreduce
to pass associative arrays’ keys to its callback. We can’t do that currently because PHP’s array_reduce doesn’t pass array keys to its callback.
Here’s an example from the pull request:
$data = collect([
'name' => 'Mo Khosh',
'username' => 'mokhosh',
]);
return $data->reduceWithKeys(function($carry, $value, $key) {
return $carry . $key . ': ' . $value . PHP_EOL;
});
Release Notes
You can see the full list of new features and updates below and the diff between 8.21.0 and 8.22.0 on GitHub. The following release notes are directly from the changelog:
v8.22.0
Added
- Added new lines to
DetectsLostConnections
(#35752, #35790) - Added
Fakes\EventFake::assertNothingDispatched()
(#35835) - Added reduce with keys to collections and lazy collections (#35839)
Fixed
- Fixed error from missing null check on PHP 8 in
Validation\Concerns\ValidatesAttributes::validateJson()
(#35797) - Fix bug with RetryCommand (4415b94, #35828)
- Fixed
Illuminate\Testing\PendingCommand::expectsTable()
(#35820) - Fixed
morphTo()
attempting to map an empty string morph type to an instance (#35824)
Changes
- Update
Illuminate\Http\Resources\CollectsResources::collects()
(1fa20dd) - “null” constraint prevents aliasing SQLite ROWID (#35792)
- Allow strings to be passed to the
report
function (#35803)
Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.
Laravel Jobs

- Software Developer
-
Remote (US & Canada)
Alley - 😎 Laravel Developer
-
Remote
Jogg, Inc - Junior, Mid, and Senior Software Engineers. Laravel / Vue. Saint Petersburg, FL
-
Saint Petersburg, FL and Remote
ShineOn - Senior PHP Developer (Laravel)
-
Remote
The Interaction Design Foundation - Fullstack Laravel Engineer (Munich/Remote) 💻
-
Munich, Germany or Remote
AirLST GmbH
Organize Laravel Applications With Actions
The Laravel actions package provides a new way to organize your Laravel applications’ logic by focusing on *act…
Tutorial: Moving live projects from Forge to Envoyer
Have you ever wanted to switch live projects from Forge to Envoyer for deployments?In this tutorial, learn the the st…