From 6e9eb751b29ca7637296891bc7d1042d438ca7c8 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sat, 19 Sep 2026 10:03:25 -0400 Subject: [PATCH] ci: fix bootstrap redeclare fatal, add coverage driver, bump PHP floor to 8.2 - tests/bootstrap-unit.php: stop stubbing validateRequestVars() globally; monitor_controller.php declares it unconditionally, so the stub caused a Cannot redeclare fatal once a test loaded plugin source via loadPluginSource()/monitor_test_load(). - .github/workflows/plugin-ci-workflow.yml: add coverage: pcov to the setup-php step so the Pest --coverage-clover report has a driver to run against. - Document the PHP 8.2 floor (matrix is already 8.2-8.4) in copilot-instructions.md, the php-developer agent, and the hexagonal-monitor ADR, replacing stale PHP 8.1 references now that PHP 8.1 is no longer tested. - Verified apache2/libapache2-mod-php do not need to be re-added to the Install System Dependencies step: apache2 ships preinstalled on the ubuntu-latest runner image and shivammathur/setup-php configures the matching Apache PHP module for the selected matrix version. --- .github/agents/php-developer.agent.md | 2 +- .github/copilot-instructions.md | 2 +- .github/workflows/plugin-ci-workflow.yml | 1 + docs/architecture/0001-hexagonal-monitor.md | 2 +- tests/bootstrap-unit.php | 7 +++---- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/agents/php-developer.agent.md b/.github/agents/php-developer.agent.md index 4153ea3..9174c9d 100644 --- a/.github/agents/php-developer.agent.md +++ b/.github/agents/php-developer.agent.md @@ -7,7 +7,7 @@ model: "Claude Sonnet 4.5" # PHP Developer You are a PHP Developer agent. Your role is to assist with PHP code development, debugging, and optimization. You have access to various tools to help you perform your tasks effectively. -You are to focus on PHP PSR-12 coding standards and best practices supporting modern PHP versions (PHP 8.1 and above). +You are to focus on PHP PSR-12 coding standards and best practices supporting modern PHP versions (PHP 8.2 and above). Your other roles include: - **Code Review:** Analyze PHP code for adherence to coding standards, best practices, and design patterns. - **Debugging:** Identify and resolve bugs or issues in PHP code. diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 040ae03..7e31947 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -13,7 +13,7 @@ When generating code for this repository: ## Technology Stack ### Core Technologies -- **PHP**: 8.1+ (CI matrix tests 8.1-8.4) +- **PHP**: 8.2+ (CI matrix tests 8.2-8.4) - **Platform**: Cacti Plugin Architecture (Cacti 1.2.15+) - **Database**: MariaDB 10.6+ with InnoDB engine - **Dependency**: Requires the `thold` plugin (>= 1.2.1) to be installed diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index 35bb2c6..b858db2 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -80,6 +80,7 @@ jobs: with: php-version: ${{ matrix.php }} extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp + coverage: pcov ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York" - name: Check PHP version diff --git a/docs/architecture/0001-hexagonal-monitor.md b/docs/architecture/0001-hexagonal-monitor.md index d1ffb62..99c0759 100644 --- a/docs/architecture/0001-hexagonal-monitor.md +++ b/docs/architecture/0001-hexagonal-monitor.md @@ -35,7 +35,7 @@ The target contains the following responsibilities: poller hook, and the existing Monitor web UI. Domain code must not access request variables, sessions, globals, SQL, the -filesystem, or Cacti helper functions. New code targets PHP 8.1, the +filesystem, or Cacti helper functions. New code targets PHP 8.2, the baseline this repository's CI tests against. ## State and delivery rules diff --git a/tests/bootstrap-unit.php b/tests/bootstrap-unit.php index c599982..e8a5cd1 100644 --- a/tests/bootstrap-unit.php +++ b/tests/bootstrap-unit.php @@ -254,10 +254,9 @@ function test_set_request(array $vars): void { $GLOBALS['__test_request'] = $vars; } -if (!function_exists('validateRequestVars')) { - function validateRequestVars($section, $filter = array()) { - } -} +// validateRequestVars() is not stubbed here: monitor_controller.php declares +// it unconditionally, so a global stub would fatal with a redeclare error +// once a test loads that file via loadPluginSource()/monitor_test_load(). if (!function_exists('form_input_validate')) { function form_input_validate($value, $name, $regex, $optional, $error) {