Skip to content

PHP 8.1 support #322

Closed
Closed

Description

@SerafimArts

Hi!

I understand that PHP 8.1 is out of date. But it would be nice, since some OSS projects (including modern ones) require it as a min.

In fact, all that's required is simply removing the readonly classes.

Activity

  1. added theissue type on Sep 7, 2026
  2. roxblnfk commented on Sep 8, 2026

    @roxblnfk
    Member

    Turns out readonly class isn't the only 8.1 blocker. I found three more:

    1. ReflectionMethod::hasPrototype() — 8.2 method, used in attribute resolution.
    2. fn(): never => throw ... — arrow fn that only throws is a runtime bug in 8.1, fixed in 8.2.
    3. memory_reset_peak_usage() — 8.2 function, used by the bench plugin.

    So just dropping readonly compiles but blows up at runtime.

    My plan: don't touch the source. Keep it on 8.2 with readonly and the 8.2 APIs. Instead, in the 8.1 CI job I install Testo as usual (composer install --ignore-platform-req=php), then run the whole installed codebase through Rector's downgrade sets, then run the full test suite against the downgraded copy. Green on 8.1 means 8.1 works, without dragging compatibility shims into the real code.

    The downgrade is wired as a reusable GitHub action that lowers a folder to any PHP version: it installs Rector isolated (its own composer.json, so the project's deps stay untouched), rewrites the sources in place, then removes itself. So the flow is: install deps, run the action to downgrade, run tests.

    Eventually I want to package the whole thing into one simple action like "run your Testo tests on 8.1" action that hides all of this. Point it at your suite, it sets up the lower runtime, downgrades under the hood, runs Testo, done.

    Rector already downgrades readonly class, but not the three cases above, so I took them upstream:

    WDYT?

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

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions