ci: pin the plugin floor to Cacti 1.2's, which is exactly PHP 8.0 - #373
Open
somethingwithproof wants to merge 2 commits into
Open
ci: pin the plugin floor to Cacti 1.2's, which is exactly PHP 8.0#373somethingwithproof wants to merge 2 commits into
somethingwithproof wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens the plugin’s declared Cacti 1.2 compatibility by enforcing an effective PHP 7.4 syntax floor in CI (via PHP 7.4 linting), and replaces a brittle regex-based PHP compatibility test with a token-based guard that scans all runtime PHP files for PHP 8-only function calls.
Changes:
- Add a dedicated
php74-floorCI job that runsphp -lunder PHP 7.4 across all non-test, non-vendor PHP files. - Replace the removed
Php74CompatibilityTestwith a new token-walkingPhp80FunctionGuardTestthat scans the runtime tree for PHP 8-only function calls. - Update several security tests’ string-prefix/contains checks to use
str_starts_with/str_contains.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/plugin-ci-workflow.yml |
Adds the php74-floor job to enforce PHP 7.4 syntax compatibility via linting. |
tests/Security/AuthGuardTest.php |
Refactors prefix/substring checks to PHP 8 string helpers. |
tests/Security/OutputEscapingTest.php |
Refactors comment detection / substring checks to PHP 8 string helpers. |
tests/Security/PreparedStatementConsistencyTest.php |
Refactors comment-line detection to str_starts_with. |
tests/Security/Php74CompatibilityTest.php |
Removes the prior regex-based PHP compatibility test. |
tests/Security/Php80FunctionGuardTest.php |
Adds token-based scanning of runtime PHP files for PHP 8-only function calls. |
Suppressed comments (1)
tests/Security/Php80FunctionGuardTest.php:67
- The token walker will currently flag method/static calls like Foo::str_contains() as “PHP 8 function calls”, and it can also misclassify
function &str_contains(...)as a call because&sits between T_FUNCTION and the name. Skipping::/->/newcontexts and ignoring&while searching backwards avoids these false positives.
for ($back = $index - 1; $back >= 0; $back--) {
$prior = $tokens[$back];
if (is_array($prior) && in_array($prior[0], [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT], true)) {
continue;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1.2 ships include/vendor/composer/platform_check.php and reaches it from global.php at boot, so it throws below PHP_VERSION_ID 80000; the 5.4.0 in CACTI_PHP_VERSION_MINIMUM is read by nothing. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof
force-pushed
the
chore/php-floor-guard
branch
from
August 20, 2026 02:51
fdd14d3 to
085e2a5
Compare
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
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.
INFOdeclarescompat = 1.2.17, and nothing enforced what that implies.The Cacti 1.2 floor is exactly PHP 8.0.0. Cacti 1.2 commits and ships
include/vendor/composer/platform_check.php;autoload_real.php:25requires it, andglobal.php:556loads that autoloader at boot. It throws aRuntimeExceptionwhenPHP_VERSION_ID < 80000. So a 1.2 install cannot boot below 8.0.CACTI_PHP_VERSION_MINIMUMstill says5.4.0, but it is dead metadata. It appears exactly once in the whole 1.2 tree, at its own definition, and no code reads it.composer.jsonon 1.2.x agrees with the platform check at>=8.0.So PHP 8.0 syntax and functions are correct here, and 8.1 and later are not. This PR makes the plugin match that exactly.
php80-floorCI job. Runsphp -lunder 8.0 over every runtime file, which rejects enums,readonly,never, first-class callables and pure intersection types exactly, with no pattern to maintain and no false positives. The existing matrix starts at 8.1, where all of those lint clean, so nothing could catch them before.Php81FunctionGuardTest.php -lcannot see a call to a function that does not exist yet, so post-8.0 function names are checked separately:array_is_list,enum_exists,fsync,json_validate,mb_str_padand the 8.4 array helpers. It walks tokens rather than raw text, so comments and string literals cannot trigger it; it skipsfunctiondeclarations so a polyfill does not flag itself; and it catches fully-qualified calls like\array_is_list().This replaces
Php74CompatibilityTest, which checked four hardcoded paths with regexes over raw file text. It was one major version too strict, banningstr_contains()andmatchthat 1.2 supports, while missing every runtime file outside its four, and it would have flagged the wordmatch(inside a comment. Coverage goes from 4 files to all 28.Two
strpos()calls becomestr_contains()ininclude/functions.php, now that the floor is established. Both are exact substitutions.Verification:
Raised separately, because neither belongs here: no CI job runs the Pest suite at all, and
composer.jsonhas noscriptsblock although the workflow callscomposer run-script lint.