Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[12.x] Add hash string helper #55767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.