Skip to content

Respect @api on class constants and traits, and mark the turbo worker lookup as API - #6791

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

ondrejmirtes merged 2 commits into
phpstan:2.3.xfrom
SanderMuller:turbo-worker-api

Conversation

@SanderMuller

@SanderMuller SanderMuller commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Rector includes phpstan.phar and starts its own workers. To give them the turbo extension, it uses the same -d flags that ProcessHelper adds. This marks the members it needs as @api:

  • TurboExtensionSelector::findExtensionForWorkers() and EXTENSION_PATH_INI, for the two worker flags.
  • TurboExtensionEnabler::isActive(), for Rector's forked workers.

ApiClassConstFetchRule now also accepts @api on the constant itself or on its declaring class, as the method rules do. ApiTraitUseRule accepts @api on the trait, and LateResolvableTypeTrait gets it.

phpstan/phpstan#15526 tests the lookup from a program that includes the phar, with and without pcntl.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
*/
public const MINIMUM_PHP_VERSION_ID = 80300;

/** @api */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApiClassConstFetchRule needs to be improved to actually point out BC-covered and not-covered constants.

Feel free to also improve ApiTraitUseRule. LateResolvableTypeTrait should gain @api, the rule shouldn't report it, but using other traits should.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f9e96a0. The constant rule now accepts @api on the constant or on its declaring class, as the method rules do. The trait rule accepts @api on the trait, and LateResolvableTypeTrait has it now.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SanderMuller SanderMuller changed the title Mark the turbo worker extension lookup and isActive() as API Respect @api on class constants and traits, and mark the turbo worker lookup as API Oct 23, 2026
@ondrejmirtes
ondrejmirtes merged commit 486821c into phpstan:2.3.x Oct 23, 2026
990 of 994 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