refactor: safe PHP 7.4 modernization#252
refactor: safe PHP 7.4 modernization#252somethingwithproof wants to merge 6 commits intoCacti:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the FlowView plugin PHP code for PHP 7.4 by enabling strict typing and updating legacy array syntax across the plugin and bundled Net_DNS2 library.
Changes:
- Added
declare(strict_types=1);to many PHP entrypoints and library files. - Replaced
array(...)with[...]across plugin code (and some helper defaults). - Updated various prepared-statement parameter arrays to short syntax.
Reviewed changes
Copilot reviewed 111 out of 111 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| themes/index.php | Adds strict types declaration. |
| setup.php | Adds strict types; converts several arrays to short syntax. |
| service/index.php | Adds strict types declaration. |
| run_schedule.php | Converts CLI option arrays and prepared-statement params to short syntax. |
| repair_tables.php | Adds strict types declaration. |
| Net/DNS2/Updater.php | Adds strict types; modifies duplicate-RR checks (currently introduces syntax errors). |
| Net/DNS2/Socket.php | Adds strict types declaration. |
| Net/DNS2/RR/ZONEMD.php | Adds strict types declaration. |
| Net/DNS2/RR/X25.php | Adds strict types declaration. |
| Net/DNS2/RR/WKS.php | Adds strict types declaration. |
| Net/DNS2/RR/URI.php | Adds strict types declaration. |
| Net/DNS2/RR/TYPE65534.php | Adds strict types declaration. |
| Net/DNS2/RR/TXT.php | Adds strict types declaration. |
| Net/DNS2/RR/TSIG.php | Adds strict types declaration. |
| Net/DNS2/RR/TLSA.php | Adds strict types declaration. |
| Net/DNS2/RR/TKEY.php | Adds strict types declaration. |
| Net/DNS2/RR/TALINK.php | Adds strict types declaration. |
| Net/DNS2/RR/TA.php | Adds strict types declaration. |
| Net/DNS2/RR/SSHFP.php | Adds strict types declaration. |
| Net/DNS2/RR/SRV.php | Adds strict types declaration. |
| Net/DNS2/RR/SPF.php | Adds strict types declaration. |
| Net/DNS2/RR/SOA.php | Adds strict types declaration. |
| Net/DNS2/RR/SMIMEA.php | Adds strict types declaration. |
| Net/DNS2/RR/SIG.php | Adds strict types declaration. |
| Net/DNS2/RR/RT.php | Adds strict types declaration. |
| Net/DNS2/RR/RRSIG.php | Adds strict types declaration. |
| Net/DNS2/RR/RP.php | Adds strict types declaration. |
| Net/DNS2/RR/PX.php | Adds strict types declaration. |
| Net/DNS2/RR/PTR.php | Adds strict types declaration. |
| Net/DNS2/RR/OPT.php | Adds strict types declaration. |
| Net/DNS2/RR/OPENPGPKEY.php | Adds strict types declaration. |
| Net/DNS2/RR/NSEC3PARAM.php | Adds strict types declaration. |
| Net/DNS2/RR/NSEC3.php | Adds strict types declaration. |
| Net/DNS2/RR/NSEC.php | Adds strict types declaration. |
| Net/DNS2/RR/NSAP.php | Adds strict types declaration. |
| Net/DNS2/RR/NS.php | Adds strict types declaration. |
| Net/DNS2/RR/NIMLOC.php | Adds strict types declaration. |
| Net/DNS2/RR/NID.php | Adds strict types declaration. |
| Net/DNS2/RR/NAPTR.php | Adds strict types declaration. |
| Net/DNS2/RR/MX.php | Adds strict types declaration. |
| Net/DNS2/RR/LP.php | Adds strict types declaration. |
| Net/DNS2/RR/LOC.php | Adds strict types declaration. |
| Net/DNS2/RR/L64.php | Adds strict types declaration. |
| Net/DNS2/RR/L32.php | Adds strict types declaration. |
| Net/DNS2/RR/KX.php | Adds strict types declaration. |
| Net/DNS2/RR/KEY.php | Adds strict types declaration. |
| Net/DNS2/RR/ISDN.php | Adds strict types declaration. |
| Net/DNS2/RR/IPSECKEY.php | Adds strict types declaration. |
| Net/DNS2/RR/HIP.php | Adds strict types declaration. |
| Net/DNS2/RR/HINFO.php | Adds strict types declaration. |
| Net/DNS2/RR/EUI64.php | Adds strict types declaration. |
| Net/DNS2/RR/EUI48.php | Adds strict types declaration. |
| Net/DNS2/RR/EID.php | Adds strict types declaration. |
| Net/DNS2/RR/DS.php | Adds strict types declaration. |
| Net/DNS2/RR/DNSKEY.php | Adds strict types declaration. |
| Net/DNS2/RR/DNAME.php | Adds strict types declaration. |
| Net/DNS2/RR/DLV.php | Adds strict types declaration. |
| Net/DNS2/RR/DHCID.php | Adds strict types declaration. |
| Net/DNS2/RR/CSYNC.php | Adds strict types declaration. |
| Net/DNS2/RR/CNAME.php | Adds strict types declaration. |
| Net/DNS2/RR/CERT.php | Adds strict types declaration. |
| Net/DNS2/RR/CDS.php | Adds strict types declaration. |
| Net/DNS2/RR/CDNSKEY.php | Adds strict types declaration. |
| Net/DNS2/RR/CAA.php | Adds strict types declaration. |
| Net/DNS2/RR/AVC.php | Adds strict types declaration. |
| Net/DNS2/RR/ATMA.php | Adds strict types declaration. |
| Net/DNS2/RR/APL.php | Adds strict types declaration. |
| Net/DNS2/RR/ANY.php | Adds strict types declaration. |
| Net/DNS2/RR/AMTRELAY.php | Adds strict types declaration. |
| Net/DNS2/RR/AFSDB.php | Adds strict types declaration. |
| Net/DNS2/RR/AAAA.php | Adds strict types declaration. |
| Net/DNS2/RR/A.php | Adds strict types declaration. |
| Net/DNS2/RR.php | Adds strict types declaration. |
| Net/DNS2/Resolver.php | Adds strict types declaration. |
| Net/DNS2/Question.php | Adds strict types declaration. |
| Net/DNS2/PrivateKey.php | Adds strict types declaration. |
| Net/DNS2/Packet/Response.php | Adds strict types declaration. |
| Net/DNS2/Packet/Request.php | Adds strict types declaration. |
| Net/DNS2/Packet.php | Adds strict types declaration. |
| Net/DNS2/Notifier.php | Adds strict types; modifies duplicate-RR checks (currently introduces syntax errors). |
| Net/DNS2/Names.php | Adds strict types declaration. |
| Net/DNS2/Lookups.php | Adds strict types declaration. |
| Net/DNS2/Header.php | Adds strict types declaration. |
| Net/DNS2/Exception.php | Adds strict types declaration. |
| Net/DNS2/Cache/Shm.php | Adds strict types; adjusts cache decode checks (currently introduces syntax errors). |
| Net/DNS2/Cache/File.php | Adds strict types; adjusts cache decode checks (currently introduces syntax errors). |
| Net/DNS2/Cache.php | Adds strict types declaration. |
| Net/DNS2/BitMap.php | Adds strict types declaration. |
| Net/DNS2.php | Adds strict types; updates servers input-type check (currently introduces syntax errors). |
| locales/po/index.php | Adds strict types declaration. |
| locales/LC_MESSAGES/index.php | Adds strict types declaration. |
| locales/index.php | Adds strict types declaration. |
| irr_tables.php | Adds strict types declaration. |
| index.php | Adds strict types declaration. |
| images/index.php | Adds strict types declaration. |
| functions.php | Adds strict types; large-scale short array syntax refactor (currently introduces syntax errors in array/type checks). |
| functions-pre13.php | Adds strict types; updates default params and prepared-statement arrays to short syntax. |
| flowview.php | Adds strict types; converts override/validation arrays to short syntax. |
| flowview_upgrade.php | Converts prepared statement params and array_rekey args to short syntax. |
| flowview_schedules.php | Adds strict types; converts UI/validation arrays and prepared-statement params to short syntax. |
| flowview_runner.php | Converts prepared-statement params to short syntax. |
| flowview_process.php | Converts CLI option arrays and various arrays to short syntax. |
| flowview_filters.php | Adds strict types; converts filter validation arrays and prepared-statement params to short syntax. |
| flowview_devices.php | Adds strict types; converts UI/validation arrays and prepared-statement params to short syntax. |
| flowview_databases.php | Adds strict types; converts many arrays to short syntax (currently introduces syntax errors in membership checks). |
| flowview_cleanup.php | Converts prepared-statement params to short syntax. |
| flowview_bulkarin.php | Converts working arrays and prepared-statement params to short syntax. |
| flow_collector.php | Converts CLI option arrays and large field-map arrays to short syntax. |
| fixprivate.php | Adds strict types declaration. |
| database.php | Adds strict types; converts default params/arrays to short syntax (currently introduces syntax errors in membership checks). |
| arrays.php | Adds strict types; converts numerous mapping arrays and form config arrays to short syntax. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Net/DNS2/Updater.php
Outdated
| // add the RR to the "update" section | ||
| // | ||
| if (!in_array($rr, $this->_packet->authority)) { | ||
| if (!in_[$rr, $this->_packet->authority]) { |
There was a problem hiding this comment.
in_[$rr, $this->_packet->authority] is invalid PHP syntax and will cause a parse error. This should remain in_array($rr, $this->_packet->authority) (as before) so duplicate RRs are detected correctly.
Net/DNS2/Updater.php
Outdated
| // add the RR to the "update" section | ||
| // | ||
| if (!in_array($rr, $this->_packet->authority)) { | ||
| if (!in_[$rr, $this->_packet->authority]) { |
There was a problem hiding this comment.
in_[$rr, $this->_packet->authority] is invalid PHP syntax and will cause a parse error. Replace with in_array($rr, $this->_packet->authority).
Net/DNS2/Updater.php
Outdated
| // add the RR to the "update" section | ||
| // | ||
| if (!in_array($rr, $this->_packet->authority)) { | ||
| if (!in_[$rr, $this->_packet->authority]) { |
There was a problem hiding this comment.
in_[$rr, $this->_packet->authority] is invalid PHP syntax and will cause a parse error. Replace with in_array($rr, $this->_packet->authority).
Net/DNS2/Updater.php
Outdated
| // add the RR to the "update" section | ||
| // | ||
| if (!in_array($rr, $this->_packet->authority)) { | ||
| if (!in_[$rr, $this->_packet->authority]) { |
There was a problem hiding this comment.
in_[$rr, $this->_packet->authority] is invalid PHP syntax and will cause a parse error. Replace with in_array($rr, $this->_packet->authority).
Net/DNS2/Updater.php
Outdated
| // add the RR to the "prerequisite" section | ||
| // | ||
| if (!in_array($rr, $this->_packet->answer)) { | ||
| if (!in_[$rr, $this->_packet->answer]) { |
There was a problem hiding this comment.
in_[$rr, $this->_packet->answer] is invalid PHP syntax and will cause a parse error. Replace with in_array($rr, $this->_packet->answer).
functions.php
Outdated
| if (!is_[$details['files']]) { | ||
| $details['files'] = [$details['files']]; |
There was a problem hiding this comment.
!is_[$details['files']] is invalid PHP syntax and will cause a parse error. Replace with !is_array($details['files']) so single-file sources are wrapped into an array safely.
functions.php
Outdated
| if ($irr_column != '' && in_[$irr_column, $supported_sections, true]) { | ||
| $prev_section = $section; |
There was a problem hiding this comment.
in_[$irr_column, $supported_sections, true] is invalid PHP syntax and will cause a parse error. Replace with in_array($irr_column, $supported_sections, true) so section detection works.
functions.php
Outdated
| } elseif (in_[$irr_column, $unsupported_sections, true]) { | ||
| $skip = true; |
There was a problem hiding this comment.
in_[$irr_column, $unsupported_sections, true] is invalid PHP syntax and will cause a parse error. Replace with in_array($irr_column, $unsupported_sections, true) so unsupported sections are skipped correctly.
database.php
Outdated
| } | ||
|
|
||
| if (!in_array($table, $tables)) { | ||
| if (!in_[$table, $tables]) { |
There was a problem hiding this comment.
in_[$table, $tables] is invalid PHP syntax and will cause a parse error. Replace with in_array($table, $tables) so table existence checks work.
flowview_databases.php
Outdated
| if (in_[$c, $search, true]) { | ||
| form_selectable_cell(filter_value($result[$c], get_request_var('filter')), $i, '', $align); |
There was a problem hiding this comment.
in_[$c, $search, true] is invalid PHP syntax and will cause a parse error. Replace with in_array($c, $search, true) so searchable columns are handled correctly.
Revert corrupted function calls introduced by refactoring tool: - is_[$x] -> is_array($x) - in_[$x, ...] -> in_array($x, ...) - xml2[$x] -> xml2array($x) Also remove accidentally committed .omc session files and add .omc/ to .gitignore. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Revert bulk array()->[] rewrite damage affecting: - is_array, in_array, xml2array - call_user_func_array, filter_var_array - Function declarations with _array suffix Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Converted to draft to serialize the stack in this repo. Blocked by #250; will un-draft after that merges to avoid cross-PR merge conflicts. |
This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.