Skip to content

Adopt PHP 8.3 and enforceable PHP standards (umbrella) #315

Description

@somethingwithproof

Goal

Establish one enforceable PHP standard for MacTrack 1.3 while modernizing legacy code incrementally and without repository-wide formatting churn.

Required baseline

  • Require PHP >=8.3 in Composer and test the supported PHP range in CI.
  • Use PER Coding Style 3.x for new namespaced code under src/ and for files deliberately migrated to the modern architecture.
  • Keep Cacti coding style for small edits to unmigrated legacy files; perform formatting-only migrations separately from behavior changes.
  • Use PSR-4 autoloading with Cacti\Mactrack\ mapped to src/.
  • Add declare(strict_types=1) to every new PHP file and to legacy files as they are migrated.
  • Prefer native parameter, property, and return types. Reserve PHPDoc for generics, array shapes, contracts, and behavior the type system cannot express.
  • Use one committed automatic formatting configuration and enforce it in CI.
  • Reach PHPStan level 8 with zero new findings. The baseline may shrink but must not grow.
  • Standardize on PHPStan after Psalm parity is confirmed; do not maintain two overlapping static-analysis policies indefinitely.
  • Require 100% line coverage for new application code and regression tests for every defect fixed.
  • Require Docker integration tests for scanners, SNMP behavior, database migrations, scheduled/poller execution, and dependency failure paths.
  • Manage dependencies only through Composer; commit the lock file and run composer validate --strict plus a clean composer install --no-dev test.
  • Use prepared SQL, context-appropriate output escaping, validated CLI input, structured exceptions, and fail-closed dependency handling.
  • Introduce a PSR-3-compatible MacTrack logging adapter backed by Cacti cacti_log() rather than coupling new services directly to globals.

Migration policy

Do not reformat the whole legacy plugin in one functional change. Apply the modern standard to src/, tests, and explicitly migrated files. This preserves useful blame history and avoids unnecessary conflicts with active maintenance branches.

Suggested order

  1. Align Composer and CI on PHP 8.3.
  2. Commit formatter/coding-standard configuration scoped to new and migrated code.
  3. Complete PHPStan level 6 (PHPStan level 6 compliance #311), then level 8 (PHPStan level 8 compliance #312), without baseline growth.
  4. Continue the service and scanner migration in PHP 8+ modernization (grouped) #304.
  5. Add the logging adapter and migrate new services to it.
  6. Retire redundant Psalm enforcement once PHPStan provides equivalent coverage.

Related work

Acceptance criteria

  • Composer, CI, formatting, static analysis, and test policies agree on the same PHP 8.3+ contract.
  • New namespaced application code is PSR-4, strict-typed, PER-CS compliant, and fully covered.
  • Production scanner and migration paths are exercised with the tools and services used in production.
  • No repository-wide formatting churn is mixed with behavioral changes.
  • All linked implementation issues are complete or explicitly deferred with rationale.

References

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions