leovie/php-token-normalize
A PHP library for normalizing PHP tokens, making it easier to compare, analyze, or process code consistently. Useful for static analysis, duplicate detection, obfuscation checks, and tooling that needs a stable token representation.
$a → $var1, $b → $var2, preserving identity); it now collapses every variable to $x. Concretely, $x + $x and $x + $y become identical token streams. That is a deliberate loosening of the equivalence relation, and it moves the feature you are building:
$a = $b; $c = $a; and $a = $b; $c = $b; now normalize the same. If this gate is supposed to catch real regressions, v3.0.0 weakens it.Consider it when:
Look elsewhere when:
token_get_all() may be simpler than adopting any dependency.For executives (one paragraph): This is a small, permissively licensed (BSD-3) utility that does one narrow job: normalizing PHP token sequences so two pieces of code can be compared for semantic rather than textual equivalence. It remains a cheap enabler for code-health features on the roadmap — duplicate-code detection in CI, semantic diffing for migration work, similarity scoring. Two things changed with the new 3.0 release. First, the maintenance picture is better than we thought: the project has continued shipping releases and versioned a behavior change correctly as a major version. Second, that change made the comparison deliberately looser — it now treats every variable as interchangeable, which will make duplicate-code detection noisier and, more importantly, makes a "did this refactor change behavior?" check less reliable. The recommendation is unchanged in shape and firmer in reason: do not adopt as a live dependency, vendor the source, pin the exact version we review, add our own tests, and own it. If we need the previous, stricter behavior, we patch it — the change is small.
For engineering (the ask):
$x — and mark every use case where variable identity mattered as a behavioral regression versus what we specified.token_get_all() — a few days — rather than seeking another third-party package, since we would be maintaining this either way.Bottom line: still useful, still ours to own — and the new release changes the equivalence semantics enough that our feature specs and thresholds must be revisited before we ship anything on top of it.
How can I help you explore Laravel packages today?