Repository navigation
chore: PHPStan level 8 clean-up and native type declarations - #145
Merged
Merged
Conversation
Bring the entire plugin to PHPStan level 8 (0 errors, no baseline, no suppressions) and add native parameter/return type declarations across all files. Genuine bugs uncovered and fixed along the way: - api_reportit_add_data_source() was missing its $selected_items parameter, so the bulk "Add Data Source" action never added anything. - A report-template data-source lookup passed a prepared-statement placeholder to db_fetch_assoc() (never bound); switched to db_fetch_assoc_prepared(). - Measurand formula-rename dependency propagation was broken by a $dependences/$dependencies variable typo. - The export action referenced an undefined show_export_wizard(); the call is now guarded. Verified: PHPStan level 8 = 0 errors, php -l clean on every touched file, full Pest suite 28 passed (255 assertions). Regenerated locales/po/cacti.pot (per-language .po/.mo left to Weblate).
TheWitness
requested review from
bmfmancini and
xmacan
and
a lite review from Copilot
September 28, 2026 21:22
…l-8-typing # Conflicts: # locales/po/cacti.pot
bmfmancini
previously approved these changes
Sep 29, 2026
…esult return, restore preset non-empty check
Member
Author
|
Thanks for the review — addressed all three inline comments in 3db9d2d:
|
bmfmancini
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Brings the entire plugin_reportit codebase to PHPStan level 8 with 0 errors (no baseline, no
@phpstan-ignore), and adds native parameter/return type declarations across all files.php -l: clean on every touched filein_array/array_searchstrict-param changes)locales/po/cacti.potregenerated (only source-location comments shifted; per-language.po/.moleft to Weblate)Genuine bugs found & fixed (please validate)
These are behavior-affecting fixes uncovered by the type analysis:
api_reportit_add_data_source()was declared as($id)but its body iterated a$selected_itemsvariable that was never passed in. Added the missing$selected_itemsparameter and updated the call site inreportit.php.db_fetch_assoc('… WHERE data_template_id = ?', [$id]), butdb_fetch_assoc()'s 2nd argument is$log(bool), not params — the?was never bound. Switched todb_fetch_assoc_prepared().$dependences/$dependenciesvariable typo meant renaming a measurand abbreviation never updated dependent formulas. Unified to$dependencies.show_export_wizard()—view.php?action=exportcalled a function that is defined nowhere (a latent fatal). The call is now guarded withfunction_exists().Intentional, documented deviations
view.phparchive/alias inert code:$archiveand$report_ds_aliasinshow_report()are initialized to[]and never populated (their source lookups are commented out / missing upstream). I annotated their intended types rather than populating them from$data, to avoid a speculative UI behavior change. The data-source alias substitution in the table view therefore remains inert exactly as before — flagging in case you want it wired up separately.system/upgrade.php: removed aforeachover a hard-coded empty$result_tablesarray (dead migration loop; the source fetch was already commented out).funct_export.php: the$no_formattingflag is assigned0in both branches of its if/else, so the "raw value" ternary branches were dead — collapsed to the formatted (get_unit()) branch.templates.php: dropped a stale URL 2nd argument todraw_actions_dropdown()(current signature is(array $actions, int $delete_action = 0)).Testing
phpstan analyse(level 8): 0 errorsphp -lon all 17 touched source files: clean