Skip to content

Refactor command handling to Pipeline middlewares#12

Merged
overclokk merged 13 commits into
masterfrom
change-middlewares-handler
May 18, 2026
Merged

Refactor command handling to Pipeline middlewares#12
overclokk merged 13 commits into
masterfrom
change-middlewares-handler

Conversation

@overclokk

Copy link
Copy Markdown
Contributor

Summary

This PR refactors the CLI command execution flow around italystrap/pipeline middlewares, updates the project baseline to PHP 8.2, and replaces Psalm static analysis with PHPStan.

The branch is 13 commits ahead of master and touches 131 files with 828 additions and 1,439 deletions.

Detailed changes

Command handling and application bootstrap

  • Replaces the internal ItalyStrap\Bus implementation with italystrap/pipeline.
  • Adds Infrastructure\Handler\ConsoleHandler as the console-facing handler that wraps a middleware pipeline and enforces integer command exit codes.
  • Refactors InitCommand, DumpCommand, ValidateCommand, and InfoCommand to receive a ConsoleHandler instead of direct domain handlers or the old bus interfaces.
  • Adds Symfony AsCommand attributes and command description constants for the CLI commands.
  • Moves command work from the previous Domain\Output handlers into Application\Middlewares:
    • Dump
    • Init
    • Info
    • Validate
    • SchemaJson
    • DeleteSchemaJson
  • Removes the event-based command output flow and the old output event classes. Command progress and validation messages are now emitted directly from middleware.
  • Adds ModuleApplication and ModuleInfrastructure to register command factories, middleware wiring, finder aliases, and shared infrastructure services through the modularized Empress container.
  • Simplifies Bootstrap so it builds the container modules, configures a Symfony ContainerCommandLoader, and registers the CLI commands through the container.

Public API and namespaces

  • Moves ThemeJson and SectionNames into the ItalyStrap\ThemeJsonGenerator\Api namespace.
  • Updates references across source, tests, docs, and fixtures to use the new API namespace.
  • Removes the old TJGConfig class.
  • Collapses InfoMessage into the generic Application\Message value object and removes InitMessage.
  • Moves filesystem helpers into infrastructure namespaces:
    • Helper\ConvertCase to Infrastructure\Filesystem\ConvertCase
    • Application\Commands\Utils\DataFromJsonTrait to Infrastructure\Filesystem\DataFromJsonTrait
  • Removes outdated namespace compatibility aliases and the old bus autoload bridge from namespace-bc-aliases.php.

Runtime behavior

  • dump now processes PHP entrypoint files through the middleware pipeline, builds the local injector for theme configuration, writes generated theme.json files, and optionally writes SCSS files.
  • init now creates PHP entrypoint files from existing JSON files through the new middleware path.
  • validate now runs schema deletion, schema creation/refresh, and JSON validation as a middleware chain.
  • Schema generation now refreshes theme.schema.json when missing or older than one week, and the --force option deletes the existing schema before recreation.
  • info now lists discovered JSON files through the middleware implementation.
  • Command errors are caught at the command boundary and returned as Symfony command failures.

Dependencies and tooling

  • Raises the minimum PHP requirement from >=7.4 to >=8.2.
  • Adds italystrap/pipeline and overclokk/auryn as runtime dependencies.
  • Switches italystrap/empress to the modularized development alias.
  • Upgrades lucatume/wp-browser to ^4.5 and updates Codeception modules to current major versions.
  • Removes vimeo/psalm and adds phpstan/phpstan.
  • Adds phpstan.neon at level 9, including the Auryn injector stub in stubs/auryn-injector.stub and excluding experimental classes from analysis.
  • Updates Composer scripts from psalm to stan, and updates the qa script to run PHPStan.
  • Updates Makefile targets from psalm to stan.

CI, Docker, and test environment

  • Updates GitHub Actions to PHP 8.2 and current action versions:
    • actions/checkout@v4
    • ramsey/composer-install@v3
  • Renames the test workflow from CI to Test.
  • Updates the test matrix to PHP 8.2 and WordPress 6.9.
  • Updates static analysis workflow triggers and execution from Psalm to PHPStan.
  • Updates Docker configuration to PHP 8.2 and WordPress 6, adds MySQL health checks, and waits for MySQL readiness before dependent services start.
  • Installs Composer directly in the WordPress Docker image and adds missing archive tools.
  • Updates Codeception configuration for the newer lucatume/wp-browser command and module namespaces.
  • Adjusts test database host handling for Docker and GitHub Actions.

Tests and cleanup

  • Removes unit tests for the deleted internal bus implementation.
  • Adds/updates middleware tests, including SchemaJsonTest for the new schema middleware.
  • Updates dump/init/validate tests to call middleware process() with a pipeline handler.
  • Updates functional tests to reference the new Application\Middlewares\Dump constant.
  • Updates fixtures and test namespaces for the new Api\ThemeJson location.
  • Applies PHP 8.4 nullable-parameter compatibility fixes and related type-safety cleanup across input settings, styles, filesystem, and message classes.
  • Removes unused output-event classes and the old domain validate handler.

Validation

  • composer run stan passed with PHPStan level 9.
  • composer run unit passed: 323 tests, 686 assertions.

Notes

  • This is a breaking internal/API cleanup: PHP 8.2 is now required, the public theme JSON classes moved to ItalyStrap\ThemeJsonGenerator\Api, Psalm commands/configuration were removed, and the old internal ItalyStrap\Bus code was deleted.

overclokk added 13 commits May 14, 2026 15:41
…le output for improved simplicity and maintainability
…ce, remove TJGConfig, and update references across the codebase
…t to 8.2, and adjust dependencies in composer configuration
…mprove Docker/Codeception configuration for compatibility with PHP 8.2 and lucatume/wp-browser ^4.5
…ndencies, and refine configuration for improved consistency
…sure proper file endings throughout the codebase
…ce, update references across codebase, and remove outdated namespace aliases
@overclokk overclokk merged commit 175b24e into master May 18, 2026
6 of 8 checks passed
@overclokk overclokk deleted the change-middlewares-handler branch May 18, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant