Prepare 1.1.0: slugify() and hash() - #7
Closed
mohaelmrabet wants to merge 2 commits into
Closed
Conversation
Both were being written by hand at call sites, on top of tokenize(), which is how two callers end up with different answers for the same string. slugify() joins the tokens the normalizer already produces; hash() digests that slug, so two strings this package considers equivalent — casing, typographic apostrophes, collapsed spacing, trailing punctuation — always hash alike. That equivalence is the point: it makes the hash usable as a deduplication or lookup key.
The README pointed readers at cocur/slugify for slugs, so the new method needed that table to say what it does differently: it folds in the original script rather than forcing ASCII. The hash is documented as a fingerprint and not a secret, since an unsalted digest invites the wrong reading.
Contributor
Author
|
Fermée sans merge : le package n'est pas un générateur de slug. Cette frontière est déjà écrite dans son README — il produit une clé de comparaison dans le script d'origine, et renvoie à L'origine de la demande, ADR-0042 §4 côté Concio, a été corrigée en conséquence. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two methods that were already being written by hand on top of
tokenize()at call sites — which is how two callers end up with different answers for the same string.slugify(string $text, string $separator = '-')Joins the tokens
tokenize()already produces, so a slug can never disagree with the rest of the package about where a word ends. Text that normalizes to nothing yields an empty string.It is not an ASCII slugger. Non-Latin input stays in its own script, folded but not transliterated — the same distinction the README already draws against
cocur/slugify, so that table gained a row rather than being contradicted:hash(string $text, string $algo = 'sha256')Digests the slug. Two strings this package considers equivalent — casing, typographic apostrophes, collapsed spacing, trailing punctuation — always produce the same digest, which is what makes it usable as a deduplication or lookup key:
Documented as a fingerprint and not a secret: unsalted and deterministic by design, never a password hash. An unsalted digest invites the wrong reading, so both the PHPDoc and the README say so plainly.
Scope
No behaviour changed.
normalize(),tokenize()andanalyze()are untouched, and both additions are pure functions ofnormalize()— nothing folds text a second way.52 tests green, PHPStan clean at max level.
Release
Prepares v1.1.0 (additive, minor).
CHANGELOG.mdis written for it; tag after merge.