Home >PHP Framework >Laravel >Laravel 10 is coming with new features?

Laravel 10 is coming with new features?

藏色散人
藏色散人forward
2022-12-01 16:06:162090browse

Laravel 10 is coming? When will Laravel 10 be released?

According to the Support Policy document, Laravel 10 will be released on February 7, 2023.

This is a tall order considering the size of the Laravel ecosystem, and Laravel prioritizes backwards compatibility. [Recommended: laravel video tutorial]

Laravel 10 will use native PHP type declarations in any generated code that exists in user space:

Adding types brings the latest PHP type hinting capabilities to Laravel projects without breaking backward compatibility at the framework level:

  • Return types

  • Method arguments

  • Remove redundant comments where possible

  • ##Allow user land types in closure arguments

  • Do not include type attributes

For example, if the return type of a skeleton method is "array", there may be annotations to use it when it cannot be implemented through the native type. When providing clear types:

/**
 * Get the host patterns that should be trusted.
 *
 * @return array<int, string>
 */
public function hosts(): array
{
    return [
        &#39;laravel.test&#39;,
    ];
}

In the above example, the IDE will know the shape of the array, which is information that is not possible in PHP's native type design.

In addition, all code generated by the framework will follow the same type hinting guidelines mentioned above, which means that when you create files using the "make" command, they will include native type hints in the same way as above.

The above is the detailed content of Laravel 10 is coming with new features?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete