Ran `make rector-fix` (deadCode + codeQuality prepared sets) over the PSR-4
class trees (Core/Domain/Cli/Infrastructure). Net -600 lines: dead-code removal
and the empty-if/else collapse (the feedback_simplify_empty_else pattern this
adoption targeted). 99 files mechanically transformed.
The output was reviewed against the full test suite + PHPStan + a targeted scan;
this commit is the CORRECTED pass (no broken state in history):
- FIX (Rector bug): its boolean inversion dropped the parens around an
assignment-in-condition — `if (($rKey = array_search(...)) === false)` became
`if ($rKey = array_search(...) !== false)`, assigning the bool to $rKey and
unsetting the wrong array offset. Restored parens in 7 sites (BouquetService,
ChannelService, CategoryService). PHPStan caught only 1 of the 7; the rest
were silent. Added BouquetServiceTest as a regression (proven to fail on the
broken form).
- FIX (pre-existing, same class): GroupService::removeGroupFromUsers had the
identical dropped-parens bug already in the tree — corrected here too.
- FIX: ServersCronJob::pingServer returns floor() (float) under an `: int`
return type — added an (int) cast.
- ACCEPT: LocallyCalledStaticMethodToNonStaticRector converted 25 locally-called
private static helpers to instance methods (behaviour-preserving; call sites
rewritten). Updated MonitorCommandTest's reflection helper to invoke on a
constructor-less instance.
Verified: PHPStan level 5 clean (0), suite 691 tests / 0 errors.
NOTE: do not re-run `make rector-fix` on this tree without first skipping the
inversion rule — the dropped-parens bug is deterministic and would return.
- The FPS check multiplied the current rate by the threshold percentage
without dividing by 100 (fps * 90 < baseline), so it only fired below
~1% of the baseline — never. It now restarts below fps_threshold% of
the baseline (90 when unset, as the fanout supervisor does).
- Priority backup probed every other source, including lower-ranked ones:
a stream on backup B moved down to C while the primary was still out.
Only sources ranked above the current one are considered.
- An on-demand start whose source cannot be probed now honours
on_demand_failure_exit instead of re-probing until the cron stops it.
- A stale force-source signal naming a missing index is ignored.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The label195 and label562 probe blocks each clamped the probed of_duration to
10s, wrote it to the stream's _.dur file and raised $rSegmentTime -- identical
seven-line cores. Extract them into a shared persistSegmentDuration() helper
returning [clamped probe, updated segment time], with unit tests (temp
STREAMS_PATH). No control-flow change; behaviour preserved.
Verified: phpstan level 5 green, phpunit 11 monitor tests green, make gates green.
The post-start block derived player compatibility, audio/video codec names and
the resolution (snapped to the nearest standard height) inline from the
stream_info JSON. Pull it into a pure resolveStreamCodecMeta() helper with unit
tests. No control-flow change; behaviour preserved.
Verified: phpstan level 5 green, phpunit 9 monitor tests green, make gates green.
The scheduled auto-restart check was three chained `if (!cond) goto label195;`
statements testing the configured days + HH:MM against the current
weekday/hour/minute. Replace them with a pure isAutoRestartDue() predicate
(injectable for tests) and a single `goto label195`. Two more gotos gone
(47 -> 45), and the schedule logic is unit tested.
Verified: phpstan level 5 green, phpunit 6 monitor tests green, make gates green.
First step of untangling MonitorCommand::execute()'s obfuscated goto control
flow. The FPS baseline computation flattened a "30/1" -> 30.0 rational parse
across five labels (label768/780/1047/1052/1057). Pull the pure parse into
parseFrameRate() with unit tests; the label768 entry and the label1847 exit are
kept so control flow is unchanged -- four labels and their gotos are gone.
Guards a zero denominator (PHP 8 would otherwise throw on "x/0") -- an input
ffprobe does not produce, so behaviour is unchanged in practice.
PHPStan cannot see the self::parseFrameRate call through the surrounding goto
maze and reports the method unused; baselined until the label768 region is
destructured, then the entry drops out.
Verified: phpstan level 5 green, phpunit 408/408, make gates green.