News

Typed Arr Getters Added in Laravel 12.11

Published
Typed Arr Getters Added in Laravel 12.11 image

Release updates

Never miss a Laravel release

Get an email whenever a new Laravel release lands.

The Laravel team released v12.11.0, which includes typed Arr getter methods, job payload additions, the FakeJob class now implements the Job contract, and more:

Typed Getters for Arr Helpers

Anthony Tibbs contributed typed getter helpers for the Arr support class for array, boolean, float, integer, and string. Each method will attempt to return the type and throw an exception if the data doesn't match types:

use Illuminate\Support\Arr;
$array = ['name' => 'Joe', 'languages' => ['PHP', 'Ruby']];
 
$value = Arr::array($array, 'languages'); // ['PHP', 'Ruby']
$value = Arr::array($array, 'name'); // throws InvalidArgumentException

See Pull Request #55567 for details.

CreatedAt and Original Delay Added to Job Payload

Taylor Otwell contributed adding the payload creation and job delay info to job payloads. The delay is the optional job delay in seconds and the createdAt is the timestamp of when the job payload is created:

$job->payload();
/*
Now includes: ['delay' => 5, 'createdAt' => 1745965273]
*/

See Pull Request #55529 for details.

Ensure Fake Job Implements the Job Contract

Tim MacDonald added the Illuminate\Contracts\Queue\Job contract to the FakeJob class used in tests to fake queue jobs:

The fake job is used in places where an implementation of the job contract is expected.

This ensures that the fake job supports strict typing of the job contract when, for example, listening for events and passing the job instance around.

See Pull Request #55574 for details.

Release notes

You can see the complete list of new features and updates below and the diff between 12.10.0 and 12.11.0 on GitHub. The following release notes are directly from the changelog:

v12.11.0

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article