Skip to content

date: 2026-06-20 tags: [laravel, i18n, mutation-testing, equivalent-mutant] status: active graduated_to:

trans_choice auto-injects :count — passing ['count' => $count] is redundant

Symptom — A diff-scoped mutation survivor: pest-mutate replaced the replacement array in trans_choice($key, $count, ['count' => $count]) with [] and no test could kill it (dropped the diff gate to 93.48%).

Root cause — Laravel's trans_choice($key, $number, $replace) already merges count => $number into the replacements before applying them, so :count resolves from the number argument whether or not you pass ['count' => $count]. The explicit replacement is dead code → the mutation is genuinely equivalent, so a body assertion ('1 task slipped…') passes for both variants and can't kill it.

php
trans_choice(':count task|:count tasks', 1, [])               // => "1 task"
trans_choice(':count task|:count tasks', 1, ['count' => 1])   // => "1 task"  (identical)

Fix — Drop the redundant array: trans_choice($key, $count) (commit c3d36b8). The mutated expression no longer exists, so the survivor is gone — not suppressed.

Guard — Don't pass ['count' => $count] to trans_choice; rely on the auto-injected :count. (Removing dead code is the right kill for an equivalent mutant — never an @pest-mutate-ignore.) Singular/plural is still pinned by asserting both the one-item and many-item notification bodies.