Skip to content

refactor: declare strict types in first-party files - #155

Draft
somethingwithproof wants to merge 7 commits into
Cacti:developfrom
somethingwithproof:refactor/modernization
Draft

refactor: declare strict types in first-party files#155
somethingwithproof wants to merge 7 commits into
Cacti:developfrom
somethingwithproof:refactor/modernization

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Apr 9, 2026

Copy link
Copy Markdown
Member

Adds declare(strict_types=1); to the 23 first-party PHP files.

Reduced from the original branch. Removed:

  • 48 vendored Horde Text/ files, where the whole change was 47 blank lines and three tweaks inside doc comments. Modernising a vendored library forks it for no functional gain.
  • A duplicate unserialize() hardening already carried by hardening: prepared statements, path containment, and output escaping #153.
  • tests/Unit/TextDiffTest.php, which had no composer.json, no Pest and no phpunit config on this branch, so it could not run.
  • A local tooling directory from .gitignore.

This needs manual validation before merge. strict_types is a runtime behaviour change, not a formatting one: it turns silent scalar coercion into TypeError at every call into an internal function. CI passes on 8.1 through 8.4, but the integration job only installs the plugin and runs the poller. It never loads router-devices.php, router-compare.php, router-accounts.php or router-devtypes.php, which is where request variables reach internal functions and where a coercion failure would surface.

Suggest merging #153 first, then exercising each UI tab against this branch.

Copilot AI review requested due to automatic review settings April 9, 2026 21:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aims to “modernize” the routerconfigs plugin and its vendored Horde Text/* utilities by adding declare(strict_types=1); broadly, plus some array-syntax updates and a new unit test file.

Changes:

  • Add declare(strict_types=1); across many plugin and Text/* library files.
  • Update some examples/docs to short array syntax ([]).
  • Add a new tests/Unit/TextDiffTest.php test file.

Reviewed changes

Copilot reviewed 75 out of 75 changed files in this pull request and generated 23 comments.

Show a summary per file
File Description
Text/Util/Variables.php Adds strict_types; modifies sanitization logic (currently introduces invalid syntax).
Text/Util/Util.php Adds strict_types; modifies magic-quotes handling (currently introduces invalid syntax).
Text/Util/String/Transliterate.php Adds strict_types.
Text/Util/String.php Adds strict_types; modifies charset conversion logic (currently introduces invalid syntax).
Text/Util/Domhtml.php Adds strict_types.
Text/Util/Array/Sort/Helper.php Adds strict_types.
Text/Util/Array.php Adds strict_types; updates doc examples to [].
Text/Translation/Handler/Gettext.php Adds strict_types.
Text/Translation/Handler.php Adds strict_types.
Text/Translation/Exception.php Adds strict_types.
Text/Translation/Autodetect.php Adds strict_types.
Text/Translation.php Adds strict_types.
Text/index.php Adds strict_types.
Text/Exception/Wrapped.php Adds strict_types.
Text/Exception/Translation.php Adds strict_types.
Text/Exception/PermissionDenied.php Adds strict_types.
Text/Exception/Pear.php Adds strict_types.
Text/Exception/NotFound.php Adds strict_types.
Text/Exception/LastError.php Adds strict_types; modifies last-error detection (currently introduces invalid syntax).
Text/Exception.php Adds strict_types.
Text/Diff/ThreeWay/Op/Copy.php Adds strict_types.
Text/Diff/ThreeWay/Op/Base.php Adds strict_types.
Text/Diff/ThreeWay/index.php Adds strict_types.
Text/Diff/ThreeWay/BlockBuilder.php Adds strict_types.
Text/Diff/ThreeWay.php Adds strict_types.
Text/Diff/Renderer/Unified/index.php Adds strict_types.
Text/Diff/Renderer/Unified/Colored.php Adds strict_types.
Text/Diff/Renderer/Unified.php Adds strict_types.
Text/Diff/Renderer/table.php Adds strict_types; modifies block checks (currently introduces invalid syntax) and has an array/string accumulation bug.
Text/Diff/Renderer/Inline.php Adds strict_types.
Text/Diff/Renderer/index.php Adds strict_types.
Text/Diff/Renderer/Context.php Adds strict_types.
Text/Diff/Renderer.php Adds strict_types; modifies array checks (currently introduces invalid syntax).
Text/Diff/Op/index.php Adds strict_types.
Text/Diff/Op/Delete.php Adds strict_types.
Text/Diff/Op/Copy.php Adds strict_types; modifies constructor check (currently introduces invalid syntax).
Text/Diff/Op/Change.php Adds strict_types.
Text/Diff/Op/Base.php Adds strict_types.
Text/Diff/Op/Add.php Adds strict_types.
Text/Diff/Mapped.php Adds strict_types; modifies mapped reconstruction checks (currently introduces invalid syntax).
Text/Diff/index.php Adds strict_types.
Text/Diff/Exception.php Adds strict_types.
Text/Diff/Engine/xdiff.php Adds strict_types.
Text/Diff/Engine/string.php Adds strict_types; updates doc example to [].
Text/Diff/Engine/shell.php Adds strict_types.
Text/Diff/Engine/native.php Adds strict_types.
Text/Diff/Engine/index.php Adds strict_types.
Text/Diff.php Adds strict_types; modifies diff-engine invocation (currently introduces invalid syntax).
tests/Unit/TextDiffTest.php Adds new diff-related unit tests (uses BDD helpers without an apparent runner/deps in repo).
setup.php Adds strict_types.
router-download.php Adds strict_types; modifies option normalization checks (currently introduces invalid syntax).
router-devtypes.php Adds strict_types.
router-devices.php Adds strict_types.
router-compare.php Adds strict_types.
router-backups.php Adds strict_types.
router-accounts.php Adds strict_types.
locales/LC_MESSAGES/index.php Adds strict_types.
locales/index.php Adds strict_types.
index.php Adds strict_types.
include/index.php Adds strict_types.
include/functions.php Adds strict_types.
include/constants.php Adds strict_types.
include/arrays.php Adds strict_types.
HordeTextInclude.php Adds strict_types.
classes/PHPTelnet.php Adds strict_types.
classes/PHPSsh.php Adds strict_types.
classes/PHPShellConnection.php Adds strict_types.
classes/PHPSftp.php Adds strict_types.
classes/PHPScp.php Adds strict_types.
classes/PHPConnection.php Adds strict_types; modifies debug buffer handling (currently introduces invalid syntax; also has a typo in fallback variable name).
classes/LinePrompt.php Adds strict_types.
classes/Interfaces.php Adds strict_types.
classes/index.php Adds strict_types.
.omc/sessions/cd2e76a2-f441-4241-8c06-34bd5c7183a2.json Adds tooling session artifact file (should not be committed).
.omc/sessions/13ee8baf-af79-4f4a-8055-94addbce1910.json Adds tooling session artifact file (should not be committed).
Comments suppressed due to low confidence (1)

Text/Util/String.php:72

  • Invalid PHP syntax introduced: is_[$input] will not parse. This needs to be is_array($input) (or otherwise restore the previous array-detection logic).

Comment thread Text/Util/Variables.php Outdated
Comment thread Text/Util/Util.php
Comment thread Text/Util/String.php
Comment thread Text/Util/String.php
Comment thread Text/Diff.php Outdated
Comment thread router-download.php
Comment thread classes/PHPConnection.php
Comment thread tests/Unit/TextDiffTest.php Outdated
Comment thread .omc/sessions/cd2e76a2-f441-4241-8c06-34bd5c7183a2.json Outdated
Comment thread .omc/sessions/13ee8baf-af79-4f4a-8055-94addbce1910.json Outdated
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>
@somethingwithproof
somethingwithproof marked this pull request as draft April 11, 2026 00:10
@somethingwithproof

Copy link
Copy Markdown
Member Author

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

@somethingwithproof somethingwithproof changed the title refactor: safe PHP 7.4 modernization refactor: declare strict types in first-party files Aug 20, 2026
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