8000 [12.x] Add `hash` string helper by istiak-tridip · Pull Request #55767 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Conversation

istiak-tridip
Copy link
Contributor
@istiak-tridip istiak-tridip commented May 17, 2025

This PR adds a new hash method to the Illuminate\Support\Stringable class to simplify fluent string hashing and improve DX.

Why?

Currently, hashing with algorithms like xxh3 (which doesn't have a dedicated hash function) within a fluent chain can be verbose using pipe():

$appId = str('secret-unique-key')
    ->pipe(fn(Stringable $str) => hash('xxh3', (string) $str))
    ->limit(10)
    ->prepend('app-');

This new hash() method provides a more direct and readable alternative:

$appId = str('secret-unique-key')
    ->hash('xxh3')
    ->limit(10)
    ->prepend('app-');

@taylorotwell taylorotwell merged commit a720cbe into laravel:12.x May 19, 2025
27 of 28 checks passed
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.

2 participants
0