Skip to content

Feature/volt phase1#69

Merged
niden merged 18 commits intophalcon:masterfrom
niden-code:feature/volt-phase1
Apr 13, 2026
Merged

Feature/volt phase1#69
niden merged 18 commits intophalcon:masterfrom
niden-code:feature/volt-phase1

Conversation

@niden
Copy link
Copy Markdown
Member

@niden niden commented Apr 13, 2026

Summary

This PR delivers Phase 1 of the Volt parser modernisation effort: replacing loose, C-style PHP with idiomatic PHP 8.1+ constructs, encapsulating internal state, and establishing a comprehensive unit test suite.

What changed

Scanner layer

  • Opcode converted to a backed enum (int cases) — replaces 70+ bare integer constants
  • Token converted to a readonly class with constructor promotion — immutable value object
  • ScannerStatus introduced as a typed enum for scanner result codes (replacing raw integers)
  • State fully encapsulated: all public properties replaced with protected/private and accessor methods (get*, set*, increment*, decrement*, reset*)
  • Scanner updated to use all new accessors

Parser layer

  • Parser updated to use State accessors throughout; $state->setActiveToken(null) for typed nullable reset
  • Parser\Status properties tightened to private; constructor-promoted; setter return types corrected
  • resources/files/parser.php (lemon-generated) updated to use State getter methods for EOF error reporting

Exception

  • $statement property added with getStatement(): array accessor to carry the failing AST node alongside the message

Infrastructure

  • Tokens.php: null array key replaced with '' (PHP 8.5 compatibility)
  • phpstan-baseline.neon: PHP 8.5-only Compiler.php errors suppressed with reportUnmatched: false so 8.1–8.4 runs are unaffected
  • GitHub Actions workflow updated: coverage: none for phpcs job, coverage: xdebug for tests/coverage jobs, Codecov file:files:
  • Docker environment updated with PHP 8.1–8.5 images and matching docker-compose.yml

Test coverage added

File Tests
tests/unit/Scanner/OpcodeTest.php Opcode enum — all cases, fromOpcode(), label lookup
tests/unit/Scanner/TokenTest.php Token value object — all properties, readonly enforcement
tests/unit/Scanner/ScannerStatusTest.php ScannerStatus enum — all cases
tests/unit/Scanner/StateTest.php State — all getters/setters/incrementers
tests/unit/Parser/StatusTest.php Parser\Status — all methods and constants
tests/unit/ExceptionTest.php Exception — message, statement, code
tests/unit/Parser/ParserTest.php Parser — 37 tests covering every statement type, error path, and extends-mode restriction

31 files changed, ~3 000 lines added, ~840 removed.

Test plan

  • composer cs passes on PHP 8.1–8.5
  • composer analyze passes on PHP 8.1–8.5
  • composer test passes (372 tests, 3 intentional skips for Phase 2 Compiler work)
  • CI green on all matrix entries

@niden niden self-assigned this Apr 13, 2026
@niden niden added the enhancement New feature or request label Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@niden niden requested a review from Jeckerson April 13, 2026 02:59
@niden niden added this to Phalcon v6 Apr 13, 2026
@github-project-automation github-project-automation bot moved this to In progress in Phalcon v6 Apr 13, 2026
@niden niden merged commit f6791a2 into phalcon:master Apr 13, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Implemented in Phalcon v6 Apr 13, 2026
@niden niden deleted the feature/volt-phase1 branch April 13, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Implemented

Development

Successfully merging this pull request may close these issues.

2 participants