Skip to content

Move exitImmediately() to ForkedChild, a shadowed class in the API - #6793

Merged
ondrejmirtes merged 2 commits into
phpstan:2.3.xfrom
SanderMuller:turbo-runtime-exit
Oct 23, 2026
Merged

ondrejmirtes merged 2 commits into
phpstan:2.3.xfrom
SanderMuller:turbo-runtime-exit

Conversation

@SanderMuller

@SanderMuller SanderMuller commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Rector will fork its own parallel workers. A forked child has to end with _exit(), and only the turbo extension has it, as PHPStanTurbo\Runtime::exitImmediately(). That class is not part of the API, and the phar has no stub for it.

This moves exitImmediately() to PHPStan\Turbo\ForkedChild, a shadowed class marked @api. The native class in ForkedChild.cpp calls _exit() with the engine's exit status, as before. The PHP twin throws the new @api TurboNotActiveException. ForkedChildTerminator calls the new class and still checks TurboExtensionEnabler::isActive() first.

The class is not called Runtime. The differential tests declare a native twin as PHPStanTurbo\ plus its short name, which would collide with the bootstrap class PHPStanTurbo\Runtime. The other Runtime methods stay in analysis-stub.php: TurboExtensionEnabler calls them before shadowing is active, so they cannot go through a twin.

turbo-ext/tests/exit-immediately.php now calls the native class through the prefixed declaration and checks that the twin throws. When the native method does nothing, the test fails.

exitImmediately() declares never in PHPDoc only. PHP before 8.1 reads a native never as a class name, and the downgrade has no rule for it.

🤖 Generated with Claude Code

SanderMuller and others added 2 commits October 23, 2026 20:15
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PHP before 8.1 reads a native never as a class name, and the downgrade
has no rule for it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ondrejmirtes
ondrejmirtes merged commit f064084 into phpstan:2.3.x Oct 23, 2026
557 of 558 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you!

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.

2 participants