refactor: declare strict types in first-party files - #155
Draft
somethingwithproof wants to merge 7 commits into
Draft
refactor: declare strict types in first-party files#155somethingwithproof wants to merge 7 commits into
somethingwithproof wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
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 andText/*library files. - Update some examples/docs to short array syntax (
[]). - Add a new
tests/Unit/TextDiffTest.phptest 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 beis_array($input)(or otherwise restore the previous array-detection logic).
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
marked this pull request as draft
April 11, 2026 00:10
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. |
# Conflicts: # include/functions.php
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.
Adds
declare(strict_types=1);to the 23 first-party PHP files.Reduced from the original branch. Removed:
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.unserialize()hardening already carried by hardening: prepared statements, path containment, and output escaping #153.tests/Unit/TextDiffTest.php, which had nocomposer.json, no Pest and no phpunit config on this branch, so it could not run..gitignore.This needs manual validation before merge.
strict_typesis a runtime behaviour change, not a formatting one: it turns silent scalar coercion intoTypeErrorat 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 loadsrouter-devices.php,router-compare.php,router-accounts.phporrouter-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.