Skip to content

Stop importing the php82 polyfill in DefaultSchemaFilesProviderTest - #46

Closed
Steveb-p wants to merge 1 commit into
4.6from
ci-disable-phpstan-parallel-on-php74
Closed

Stop importing the php82 polyfill in DefaultSchemaFilesProviderTest#46
Steveb-p wants to merge 1 commit into
4.6from
ci-disable-phpstan-parallel-on-php74

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator
🎫 Issue IBX-XXXXX

Description:

PHPStan dies on PHP 7.4 before reporting anything, so every PR against 4.6 fails the
Tests (7.4) job regardless of what it changes — currently #42, #43 and #44, one of which is an
eleven-line change to a single method:

Child process error (exit code 255): PHP Fatal error: Cannot redeclare
Ibexa\PolyfillPhp82\iterator_to_array() (previously declared in
vendor/ibexa/polyfill-php82/src/iterator_to_array.php:18) ... while running parallel worker

ibexa/polyfill-php82 v1.0.1 lists src/iterator_to_array.php in both autoload.files and
autoload.psr-4 (Ibexa\PolyfillPhp82\src/), and the function has no function_exists()
guard. Analysing the use function Ibexa\PolyfillPhp82\iterator_to_array; in
DefaultSchemaFilesProviderTest makes PHPStan probe for a class of that name; PSR-4 resolves it
to the same file autoload.files already loaded, and the second include is fatal. The "parallel
worker" wording is a red herring — it's where the probe happens to land, not the cause.

The polyfill isn't needed in that test: getSchemaFiles() is a generator, so it's always
Traversable and the native iterator_to_array() accepts it on every supported version.
Asserting that first keeps level 8 happy about the declared iterable return type. It was the
only usage in the repo.

Worth fixing the autoload overlap in ibexa/polyfill-php82 too — any package importing that
function hits the same wall on 7.4 — but that shouldn't keep this branch red in the meantime. I
can open that separately if you'd like.

@Steveb-p
Steveb-p force-pushed the ci-disable-phpstan-parallel-on-php74 branch from cd8da48 to 8234de3 Compare September 8, 2026 19:54
PHPStan dies on PHP 7.4 before reporting anything, so every PR against this branch fails the
"Tests (7.4)" job regardless of its contents:

    Child process error (exit code 255): PHP Fatal error: Cannot redeclare
    Ibexa\PolyfillPhp82\iterator_to_array() ... while running parallel worker

ibexa/polyfill-php82 v1.0.1 lists src/iterator_to_array.php in *both* autoload.files and
autoload.psr-4 ("Ibexa\PolyfillPhp82\" => "src/"), and the function carries no function_exists()
guard. Analysing the `use function Ibexa\PolyfillPhp82\iterator_to_array;` in this test makes
PHPStan probe for a class of that name; PSR-4 resolves it to the same file that autoload.files
already loaded, and including it a second time is fatal.

The polyfill isn't needed here anyway: getSchemaFiles() is a generator, so it's always Traversable
and the native iterator_to_array() accepts it on every supported version. Asserting that first
keeps level 8 happy about the declared `iterable` return type. This was the only usage in the repo.

The underlying autoload overlap is worth fixing in ibexa/polyfill-php82 -- any package importing
this function hits the same wall on 7.4 -- but that shouldn't keep this branch red meanwhile.
@Steveb-p
Steveb-p force-pushed the ci-disable-phpstan-parallel-on-php74 branch from 8234de3 to 1b5d965 Compare September 8, 2026 19:57
@Steveb-p Steveb-p changed the title Disable PHPStan's parallel workers on PHP 7.4 Stop importing the php82 polyfill in DefaultSchemaFilesProviderTest Sep 8, 2026
@Steveb-p

Steveb-p commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by ibexa/polyfill-php82#7, which fixes the root cause rather than sidestepping it here.

The fatal came from ibexa/polyfill-php82 v1.0.1 listing src/iterator_to_array.php in both autoload.files and autoload.psr-4, with no function_exists() guard — so PHPStan probing the imported function as a class name included the file twice. #7 adds the guard, which fixes it for every package importing that function rather than just this one.

#42, #43 and #44 now carry a temporary dependencies.json pointing at that branch and are green on 7.4, so dropping the import here isn't needed.

@Steveb-p Steveb-p closed this Sep 8, 2026
@Steveb-p
Steveb-p deleted the ci-disable-phpstan-parallel-on-php74 branch September 8, 2026 21:40
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