Typed Translation Accessors in Laravel 13.15.0

最后更新于 经过

Typed Translation Accessors in Laravel 13.15.0 image

The Laravel team released v13.15.0 with typed translation accessors, JSON Schema deserialization, a dedicated Cloud queue driver, and a couple of security-related validation and routing fixes.

  • Typed trans()->string()trans()->array() accessors
  • JSON Schema array deserialization and multi-type union support
  • A dedicated Cloud queue driver with managed queue handling
  • A fix for a date_equals validation bypass and tighter route unserialization

什么是新的

Typed Translation Accessors

The translation helpers return broad types: __() 回报 array|string|null , 和 trans() 回报 Translator|array|string . That works in Blade, but it adds friction in strictly-typed code and static analysis. This release adds two typed accessors on the Translator to return a concrete type:

民众 功能 标签 () : 细绳
{
返回 反式 () -> 细绳 $this -> 姓名);
}
民众 功能 选项 () : 大批
{
返回 反式 () -> 大批 $this -> options_key);
}

The approach mirrors existing typed helpers like config()request() 。 看 #60443

JSON Schema Deserialization

JsonSchema component gained a fromArray() deserializer that turns a raw JSON Schema array back into Type objects, the inverse of serialization. The release also adds multi-type union support to the schema builder. See #60387#60455

Dedicated Cloud Queue Driver

Several changes land a dedicated queue driver for Laravel Cloud's managed queues. Managed queues are booted before service providers, the queue throws a ManagedQueueNotFoundException when a configured queue is missing, and FIFO queue name normalization was corrected. The request ID header was renamed from X-Request-IDCloud-Request-ID and is now output in logs. See #60181 , #60199 , #60276 , #60189 , #60166 , 和 #60316

Enums in Queue::route()

You can now pass enum cases to Queue::route() for both the queue name and the connection when routing jobs. See #60402

Security: date_equals Validation Bypass

date_equals rule used loose comparison. An invalid date string parses to null , 和 null == 0 evaluates to true, so an invalid date could pass validation against a reference date that parses to a falsy value (for example 1970-01-01 00:00:00 ). The fix uses strict comparison for the equal operator while keeping loose comparison for legitimate DateTime objects. See #60393

Security: Restricted Route Unserialization

Routing unserialization now restricts the classes it will accept, reducing the surface for object injection during route caching and resolution. See #60391

Number Helper Fixes

A few edge cases in the Number helper were corrected: Number::fileSize() now handles negative byte values, Number::trim() no longer returns null 为了 INFNAN , 和 Number::pairs() now handles negative step values gracefully while throwing an exception for a zero step to prevent infinite loops. See #60147 , #60322 , 和 #60324

其他修复和改进

  • Fixed infinite recursion when a model scope is defined with a private attribute, and when a middleware group references itself ( #59958 , #60002
  • queue:failed now shows the real class name ( #60279
  • 额外 Prohibitablecache:clearqueue:flush#60430
  • 制成 InvokedProcess macroable ( #60392
  • Ensured unchanged compiled Blade views are not left expired ( #60401
  • Added generics to DatabaseTransactionsManager getters and QueueRoutes::all()#60420 , #60447

参考

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Laravel 代码审查

几天内即可获得 Laravel 代码审查方面的专家指导

访问 Laravel 代码审查
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
绝不妥协标志

绝不妥协

来自 No Compromises 播客的两位经验丰富的开发者 Joel 和 Aaron 现在可以为您的 Laravel 项目提供服务。⬧ 固定费用 9500 美元/月。⬧ 无冗长的销售流程。⬧ 无需签订合同。⬧ 100% 退款保证。

绝不妥协
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
Refresh Your Laravel Database Without Dropping Every Table image

Refresh Your Laravel Database Without Dropping Every Table

阅读文章
JSON Schema Deserialization in Laravel 13.14 image

JSON Schema Deserialization in Laravel 13.14

阅读文章
Generate Short, URL-Safe IDs From Numbers With Sqids image

Generate Short, URL-Safe IDs From Numbers With Sqids

阅读文章
Scheduler List: A Web Dashboard for Laravel's Scheduled Tasks image

Scheduler List: A Web Dashboard for Laravel's Scheduled Tasks

阅读文章
Community Laravel Extension for Zed image

Community Laravel Extension for Zed

阅读文章
Advanced Eloquent Query Filtering with Filterable image

Advanced Eloquent Query Filtering with Filterable

阅读文章