Skip to content

Upgrade php 8.3#2

Merged
adrianmiu merged 7 commits into
masterfrom
upgrade-php-8.3
Jun 6, 2026
Merged

Upgrade php 8.3#2
adrianmiu merged 7 commits into
masterfrom
upgrade-php-8.3

Conversation

@adrianmiu

Copy link
Copy Markdown
Contributor

Summary

Modernizes the library to PHP 8.3+, refreshes the dev tooling, and adds an optional Laravel integration. Six commits, each self-contained.

Core upgrade

  • Drop PHP 8.0–8.2; support PHP 8.3 / 8.4 / 8.5.
  • Dev tooling: PHPUnit 9 → 12, PHPStan 1 → 2 (kept at level 9), added Rector 2.
  • Modernized source (behaviour-preserving): #[\Override] attributes, readonly value objects, ::class over get_class(), constructor promotion, native types.
  • phpunit.xml migrated to the v12 schema.
  • Dockerfile bumped to php:8.3-fpm — also fixes two pre-existing bugs in it (a swallowed Composer install and a clobbered xdebug ini that disabled coverage).
  • CI matrix → 8.3/8.4/8.5; cache key now includes the PHP version + composer.json hash so each leg resolves its own deps.

Laravel integration (optional, Sirius\Invokator\Laravel)

The core stays framework-agnostic; the bridge only loads inside a Laravel app and is auto-discovered.

  • SiriusInvokatorServiceProvider injects Laravel's container into the Invoker as its PSR-11 container; processors and the event dispatcher are registered as singletons so registrations persist.
  • Invokator facade + do_* helpers (do_pipeline / do_action / do_filter / do_middleware / do_event, prefixed to avoid clashing with Laravel's event()/action()).
  • @do_action Blade directive; filters via {{ do_filter(...) }}.
  • Define vs. run overload (pipeline('id') returns a builder; pipeline('id', ...$args) runs). Events use PSR-14 object dispatch.
  • Tested with orchestra/testbench across the full 8.3/8.4/8.5 matrix.

Fix

  • Invoker::getActualCallable() now guards the container lookup with has(), so plain function-name string callables ('trim') and Class::method strings work with strict PSR-11 containers (e.g.
    Laravel's), not just the lenient test container. Behaviour-preserving for existing usage and PSR-11 correct.

Tooling & docs

  • php-cs-fixer config (.php-cs-fixer.dist.php) that imports and shortens fully-qualified class names, applied across src/.
  • New documentation pages: Upgrading to 2.0 and Laravel integration.

⚠ Breaking changes

  • PHP 8.3+ required (1.x stays for older PHP).
  • Value-object properties are now readonly — a minor BC break if any consumer reassigned them after construction. See the Upgrading to 2.0 doc.

Testing

  • 38 tests pass on PHP 8.3, 8.4 and 8.5.
  • PHPStan level 9 clean, Rector idempotent, php-cs-fixer clean.
  • All verified inside the project's Docker environment.

adrianmiu and others added 7 commits June 6, 2026 13:52
Drop PHP 8.0-8.2 in favor of PHP 8.3/8.4/8.5 and upgrade the dev tooling:
PHPUnit 9 -> 12, PHPStan 1 -> 2, and add Rector 2.

- composer.json: php ^8.3; phpunit ^12, phpstan ^2, rector ^2; move
  friendsofphp/php-cs-fixer out of tools/ into require-dev; add rector
  scripts; fix csfix to use php-cs-fixer's --rules=@psr2.
- phpunit.xml: migrate to the PHPUnit 12 schema (drop removed attributes,
  move source coverage into <source>).
- phpstan.neon: drop removed checkGenericClassInNonGenericObjectType key.
- rector.php: PHP 8.3 set + code-quality/dead-code/type-declaration/
  early-return; skip ReadOnlyPropertyRector and CallableCollection promotion.
- src: #[\Override] attributes, readonly value objects, ::class over
  get_class(), constructor promotion, typed properties, strict_types.
- Dockerfile: base php:8.3-fpm; fix two pre-existing bugs (swallowed
  Composer install and clobbered xdebug ini that disabled coverage).
- CI: matrix 8.3/8.4/8.5, bump actions to v4, drop deprecated --no-suggest,
  run rector:dry; docs.yml pins PHP via setup-php.

Note: making value-object properties readonly is a minor BC break.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Document the consumer-facing changes for 2.0 (PHP 8.3+ requirement and the
readonly value objects) and wire it into the couscous menu.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…iners

Invoker::getActualCallable() looked up every callable-looking string in the
container without first checking has(). A spec-compliant PSR-11 container (such
as Laravel's) throws NotFoundException when get() is called for an unbound id,
so a plain function name like 'trim' or a 'Class::method' string would blow up
instead of being used directly.

Guard the container lookup with has() so unbound callable strings fall through
and are used as-is, while bound callable names still resolve from the container.
This is behaviour-preserving for the lenient test container (has() already
returns false for unbound ids) and makes the lookup PSR-11 correct.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Provide a first-class, optional Laravel bridge under Sirius\Invokator\Laravel
(core stays framework-agnostic):

- SiriusInvokatorServiceProvider wires Laravel's container into the Invoker as
  its PSR-11 container and registers the processors and event dispatcher as
  singletons so registrations persist.
- Invokator facade + InvokatorManager: pipeline/action/filter/middleware
  ('id') return a chainable Registrar to define callables, or run when given
  args; events use PSR-14 object dispatch (event(Class)->add(), dispatch()).
- do_pipeline/do_action/do_filter/do_middleware/do_event global helpers
  (do_-prefixed to avoid clashing with Laravel's event()/action()), loaded from
  the provider so non-Laravel users get no global pollution.
- @do_action Blade directive.

Tested with orchestra/testbench across the CI matrix; the CI cache key now
includes the PHP version and composer.json hash so each leg resolves its own
dependencies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move php-cs-fixer to a committed .php-cs-fixer.dist.php config that layers
fully_qualified_strict_types (import_symbols), no_unused_imports and
ordered_imports on top of @psr12, and point the csfix script at it. Apply the
result: FQCN references (including the FQN return types Rector emitted) are
imported and shortened across src/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a docs page covering installation/auto-discovery, the Invokator facade
(define vs run, pipelines/actions/filters/middlewares, PSR-14 events), the do_*
helpers, the @do_action Blade directive, and how string callables are resolved
through Laravel's container. Add an "Integrations" section to the couscous menu.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PHPStan level 9 on PHP 8.4/8.5 reports missingType.iterableValue for the
__serialize(): array return type, because the SplPriorityQueue parent stub
differs there and no typed return is inherited. Declare the value type
explicitly so analysis passes on every supported PHP version.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adrianmiu adrianmiu merged commit 8ceeab1 into master Jun 6, 2026
3 checks passed
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