Skip to content

[12.x] Refactor: use match expression#58824

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
alipowerful7:refactor/match
Feb 14, 2026
Merged

[12.x] Refactor: use match expression#58824
taylorotwell merged 2 commits intolaravel:12.xfrom
alipowerful7:refactor/match

Conversation

@alipowerful7
Copy link
Contributor

@alipowerful7 alipowerful7 commented Feb 14, 2026

Refactor conditional statements to use match expressions

Changes

  • Refactored formatMessage() method to use PHP 8 match expression instead of if-elseif-else
  • Refactored constructor in merge value class to use match expression for type checking
  • Added return type declaration to formatMessage() method

Benefits

  • More concise and readable code
  • Better type safety with strict comparison in match
  • Eliminates potential for missing return statements
  • Follows modern PHP 8+ best practices

@alipowerful7
Copy link
Contributor Author

Un related test failed

* @return string
*/
protected function formatMessage($message)
protected function formatMessage($message): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native types are usually added to master 😉

@taylorotwell taylorotwell merged commit 48cb8c5 into laravel:12.x Feb 14, 2026
45 of 70 checks passed
@alipowerful7 alipowerful7 deleted the refactor/match branch February 15, 2026 14:57
DarkGhostHunter pushed a commit to DarkGhostHunter/laravel-framework that referenced this pull request Feb 22, 2026
* refactor: match

* Update Logger.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants