Files
cacti/cli
91a1f170f8 fix(ci): fix PHPStan 2.3.6 findings and regenerate baseline (#8755)
* fix(ci): regenerate PHPStan baseline for phpstan 2.3.6

#8754 bumped phpstan/phpstan 2.3.5 -> 2.3.6, which reports more
array|bool offset-access occurrences than the baseline counts allow and
a few new always-true/false comparisons, failing the locked integration
job on develop. Regenerate the baseline with 2.3.6.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(phpstan): guard db_fetch_row results and drop dead comparisons

Instead of only baselining the new phpstan 2.3.6 findings, fix the code:

- Guard db_fetch_row_prepared() results (array|bool) with is_array()
  before reading offsets in aggregate_graphs, auth_changepassword,
  auth_profile, cli/add_device, cli/repair_database, color, data_input,
  graph_templates, install/upgrades/1_2_20, lib/api_tree, lib/auth,
  lib/html_reports, lib/plugins, lib/reports, lib/template and
  package_import. A missing row now skips/aborts instead of reading
  offsets on false.
- Remove always-true/false conditions: floor() > 0 in get_span(), the
  impossible '-' comparison in dsstats, the redundant == null after
  empty() in user_admin/user_group_admin, and the always-true
  $output == true in spikekill.
- Cast hexdec() to int before bcmul() in process_poller_output_batch so
  INF/NAN cannot reach bcmath.

Regenerate the baseline against the fixed code (2241 -> 2154 entries).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(changelog): add entry for PHPStan 2.3.6 fixes (#8756)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test(coverage): probe the row guards and dead-condition fixes

Add RowGuardMatrix, a fixture that loads the exact changed statements and
functions from the guarded files, keeps their original line numbers, and
runs them with a missing row and with a populated row so the changed-line
coverage gates see the new guards. Statements that end in exit() run in
dedicated modes.

Register the fixture in run_pr_change_tests.sh (100 percent gate) and
run_request_coverage.sh (80 percent gate), and let run_php_probe pass
arguments to a probe. Refresh the sink inventory baseline for the one
intentional redirect added to reports_item_edit().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test(coverage): limit the guards to files that are not mirrored copies

SonarCloud's new-code duplication gate counted the guard lines added to
cli/repair_database.php and install/upgrades/1_2_20.php (mirrored upgrade
logic) and to user_admin.php and user_group_admin.php (mirrored policy
tables). Leave those four files as they are on develop so their existing
baseline entries stay, drop their probes, and regenerate the baseline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: TheWitness <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-16 16:59:40 -05:00
..
2026-01-28 16:11:10 -05:00
2026-01-28 16:11:10 -05:00