Commit d40955d
committed
Fix null-safety + ballot-integrity bugs; web_engine clean at PHPStan level 8
Resolves the final 7 level-8 findings, all genuine (not annotation gaps):
- BallotController::vote()/voteComponent(): removed a redundant, null-unsafe
re-fetch `Vote::find(['code'=>..,'ballot_id'=>..])->first()` (find() with an
array treats the values as primary keys, so ballot_id was ignored and the
result was ?Vote used unguarded). The vote is already fetched and validated
at the top of each method; reuse it.
- SECURITY: the guard `!$vote->ballot->id == $ballot->id` had an operator-
precedence bug (`!$vote->ballot->id` bound first), making the ballot-match
check dead code — a voting code for one ballot could be submitted against
another. Fixed to `$vote->ballot->id !== $ballot->id`.
- Controller::getOwner(): Auth::user() is ?ApiUser; narrowed via @var (all
callers run behind auth.api middleware, so non-null at runtime).
- BallotService::resultsCsv(): pass `$vote->values ?? []` to valuesToCsv()
(castVotes() already filters non-null, so the fallback never triggers).
web_engine now passes PHPStan level 8 (domain code; framework scaffolding
excluded) with zero baseline/ignore entries. Tests: 24 passed.1 parent 070b39c commit d40955d
3 files changed
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | 84 | | |
86 | | - | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
| |||
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | | - | |
| 102 | + | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
120 | 118 | | |
121 | 119 | | |
122 | 120 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
0 commit comments