Skip to content

refactor: safe PHP 7.4 modernization#43

Draft
somethingwithproof wants to merge 4 commits intoCacti:developfrom
somethingwithproof:refactor/modernization
Draft

refactor: safe PHP 7.4 modernization#43
somethingwithproof wants to merge 4 commits intoCacti:developfrom
somethingwithproof:refactor/modernization

Conversation

@somethingwithproof
Copy link
Copy Markdown

This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.

Copilot AI review requested due to automatic review settings April 9, 2026 21:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the HMIB plugin’s PHP code by enabling strict typing and updating legacy array syntax to PHP 7.4-friendly constructs across core entrypoints, pollers, SNMP helpers, and locale/template index stubs.

Changes:

  • Added declare(strict_types=1); to multiple PHP entrypoints/files.
  • Replaced array(...) with short array syntax [...] in various functions (DB calls, config arrays, helpers).
  • Introduced two .omc/sessions/*.json files into the repo.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
templates/index.php Adds strict types declaration.
snmp.php Adds strict types; converts arrays; introduces invalid is_[...] syntax (parse errors).
snmp_functions.php Adds strict types declaration.
setup.php Adds strict types; converts arrays to short syntax.
poller_hmib.php Converts prepared-statement parameter arrays to short syntax.
poller_graphs.php Converts prepared-statement parameter arrays and local arrays to short syntax.
locales/LC_MESSAGES/index.php Adds strict types declaration.
locales/index.php Adds strict types declaration.
index.php Adds strict types declaration.
hmib.php Converts many filter/config arrays to short syntax.
hmib_types.php Adds strict types; converts arrays; introduces invalid is_[...] / in_[...] syntax (parse errors).
.omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json New tooling/session artifact committed (should not be in source).
.omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json New tooling/session artifact committed (should not be in source).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread snmp.php
Comment on lines 138 to 141
/* fix for multi-line snmp output */
if (is_array($snmp_value)) {
if (is_[$snmp_value]) {
$snmp_value = implode(' ', $snmp_value);
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_[$snmp_value] is invalid PHP and will cause a parse error. This should be the standard is_array($snmp_value) check (and keep the existing implode behavior).

Copilot uses AI. Check for mistakes.
Comment thread snmp.php Outdated
if (isset($snmp_value)) {
/* fix for multi-line snmp output */
if (is_array($snmp_value)) {
if (is_[$snmp_value]) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_[$snmp_value] is invalid PHP and will cause a parse error. Replace with is_array($snmp_value) (or equivalent) before calling implode.

Suggested change
if (is_[$snmp_value]) {
if (is_array($snmp_value)) {

Copilot uses AI. Check for mistakes.
Comment thread snmp.php Outdated

/* check for bad entries */
if (is_array($temp_array) && sizeof($temp_array)) {
if (is_[$temp_array] && sizeof($temp_array)) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_[$temp_array] is invalid PHP and will cause a parse error. This should be is_array($temp_array) (and then the size check) before iterating.

Suggested change
if (is_[$temp_array] && sizeof($temp_array)) {
if (is_array($temp_array) && sizeof($temp_array)) {

Copilot uses AI. Check for mistakes.
Comment thread snmp.php Outdated

/* check for bad entries */
if (is_array($temp_array) && sizeof($temp_array)) {
if (is_[$temp_array] && sizeof($temp_array)) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_[$temp_array] is invalid PHP and will cause a parse error. Replace with is_array($temp_array) before checking sizeof() and iterating.

Suggested change
if (is_[$temp_array] && sizeof($temp_array)) {
if (is_array($temp_array) && sizeof($temp_array)) {

Copilot uses AI. Check for mistakes.
Comment thread hmib_types.php Outdated
?><form method='post' action='hmib_types.php?action=import' enctype='multipart/form-data'><?php

if ((isset($_SESSION['import_debug_info'])) && (is_array($_SESSION['import_debug_info']))) {
if ((isset($_SESSION['import_debug_info'])) && (is_[$_SESSION['import_debug_info']])) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_[$_SESSION['import_debug_info']] is invalid PHP and will cause a parse error. This should be is_array($_SESSION['import_debug_info']).

Suggested change
if ((isset($_SESSION['import_debug_info'])) && (is_[$_SESSION['import_debug_info']])) {
if ((isset($_SESSION['import_debug_info'])) && (is_array($_SESSION['import_debug_info']))) {

Copilot uses AI. Check for mistakes.
Comment thread hmib_types.php Outdated

foreach($line_array as $line_item) {
if (in_array($j, $insert_columns)) {
if (in_[$j, $insert_columns]) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in_[$j, $insert_columns] is invalid PHP and will cause a parse error. This should be in_array($j, $insert_columns).

Suggested change
if (in_[$j, $insert_columns]) {
if (in_array($j, $insert_columns)) {

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "df36c0d4-5118-49a8-b66b-5f851e645aa8",
"ended_at": "2026-04-09T10:29:57.868Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
} No newline at end of file
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an editor/tooling session artifact (.omc/sessions/...). It should not be committed to the plugin source; remove this file from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent reintroduction.

Suggested change
{
"session_id": "df36c0d4-5118-49a8-b66b-5f851e645aa8",
"ended_at": "2026-04-09T10:29:57.868Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "c0ab85d1-d888-4fad-b941-516cdad3f729",
"ended_at": "2026-04-09T10:42:29.076Z",
"reason": "other",
"agents_spawned": 1,
"agents_completed": 0,
"modes_used": []
} No newline at end of file
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an editor/tooling session artifact (.omc/sessions/...). It should not be committed; remove from the PR and ignore the directory going forward (e.g., via .gitignore).

Suggested change
{
"session_id": "c0ab85d1-d888-4fad-b941-516cdad3f729",
"ended_at": "2026-04-09T10:42:29.076Z",
"reason": "other",
"agents_spawned": 1,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
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>
…ction declarations

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof marked this pull request as draft April 11, 2026 00:09
@somethingwithproof
Copy link
Copy Markdown
Author

Converted to draft to serialize the stack in this repo. Blocked by #40; will un-draft after that merges to avoid cross-PR merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants