Friday, September 15, 2023
HomePHPLaravel 10.19 Launched|Laravel Information

Laravel 10.19 Launched|Laravel Information


Today, the Laravel group launched v10.19 with a collection portion approach, customized occasion exploration course resolution, vibrant line up audience hold-up, as well as a lot more:

Word cover string approach

Josh Bonnick added a wordWrap approach to the Laravel String API, which divides strings within a string utilizing a personality limitation. This approach is a wrapper for PHP’s wordwrap feature:

usage IlluminateSupportStr;

$ message = " A long woooooooooooord."

// Str

Str:: wordWrap( string: $message, personalities: 8);

/ *

A really

long

wooooooo

ooooord.

*/

// Stringable

str($ message)->> wordWrap( string: $message, personalities: 8);

Include portion approach to collections

Wendell Adriel added a portion() approach to collections that permits you to determine a percent based upon customized reasoning utilizing a fact examination:

$ collection = brand-new $collection([

['name' => 'Taylor', 'foo' => 'foo'],

['name' => 'Nuno', 'foo' => 'bar'],

['name' => 'Dries', 'foo' => 'bar'],

['name' => 'Jess', 'foo' => 'baz'],

];

$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' foo'); // 25.00

$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' bar'); // 50.00

$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' baz'); // 25.00

$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' examination'); // 0.00

Capability to personalize course resolution in Occasion exploration

@bastien- phi added the capacity to personalize course resolution for Occasion exploration:

This public relations includes the capacity to personalize the method the translation is done as well as opens occasion exploration in such DDD frameworks.

Below’s an instance of a customized callback in Pull Demand # 48031‘s examinations, which shows exactly how this can be utilized:

usage IlluminateFoundationEventsDiscoverEvents;

DiscoverEvents:: guessClassNamesUsing( feature ( SplFileInfo $documents, $basePath) {

return Str:: of($ documents->> getRealPath())

->> after($ basePath DIRECTORY_SEPARATOR)

->> prior to('. php')

->> change( DIRECTORY_SEPARATOR, ' ')

->> ucfirst()

->> prepend(' Light Up ')

->> toString();

} );

Specify audience hold-up dynamically

@CalebW added assistance for audiences to specify a withDelay() approach that can establish line up audience hold-up:

course Audience executes ShouldQueue

{

public feature __ conjure up( Occasion $occasion): gap

{

// ...

}

public feature withDelay( Occasion $occasion): int

{

return $occasion->> fooBar

? <: <

; } } Include vibrant return kinds to the rescue assistant Choraimy Kroonstuiver

added a PHPDoc upgrade to aid fixed evaluation devices recognize the common return kinds of the

rescue()

assistant. There are no code instances to see right here, yet the upgraded Docblock looks as succeeds this upgrade:

/ ** * Capture a possible exemption as well as return a default worth. * * @template TRescueValue

* @template TRescueFallback

*

*

@param

callable

():

TRescueValue $ callback * @ param ( callable

( Throwable): TRescueFallback)| TRescueFallback $ rescue * @ param bool|

callable $ record * @ return TRescueValue|

TRescueFallback */ feature rescue(

callable

$callback, $rescue = void, $record = real ) {// ... }

// Instances:

assertType

(

' int|null'

,

rescue( fn () => > 123)); assertType(' int',

rescue( fn () => > 123, 345)); assertType(' int',

rescue( fn () => > 123, fn () => > 345)); You can discover more regarding Generics By Instances on the PHPStan blog site. Include matter debate to createMany as well as createManyQuietly

Jordan Welch added the capacity to pass an integer to createMany()

as well as

createManyQuietly() on version manufacturing facilities to produce that variety of designs: // Prior To: $ individuals = Customer

::

manufacturing facility() ->> createMany(, , ]; [[]// After: []$ individuals [] =

Customer

::

manufacturing facility() ->> createMany( 3); $ this->> assertCount

(

3, $individuals);$ this->> assertInstanceOf(

EloquentCollection:: course, $individuals); Launch notes You can see the full listing of brand-new attributes as well as updates listed below as well as the diff in between 10.18.0 as well as 10.19.0 on GitHub. The complying with launch notes are straight from the

changelog

: v10.19.0 Repair typo in upgrade HasUniqueIds by

@iamcarlos94

RELATED ARTICLES

Most Popular

Recent Comments