Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Shadow ScopeContext, IsSuperTypeOfResult and AcceptsResult natively
Three value classes called 18M times per self-analysis run (ScopeContext
10.6M, IsSuperTypeOfResult 6.8M, AcceptsResult 0.6M) get PHPStanTurbo
twins: state in declared property slots, singletons per request
(RINIT/RSHUTDOWN), lazy reasons and decorateReasons() through real
Closures so instanceof Closure keeps holding.

Measured on src/Analyser + src/Rules + src/Type, single-threaded,
ABBA x3 against the PHP twins with the same .so: -1.40% user CPU
(paired t = -2.47), matching the 40ns-per-absorbed-frame estimate.
Analysis output byte-identical; smoke, signature parity and the
NodeScopeResolver/Type/Rules test suites green.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FSCEwuXjDzsNw2wSNsDW6D
  • Loading branch information
ondrejmirtes and claude committed Sep 21, 2026
commit a508b1a705634e779d5401abc9619844ab1a3b52
2 changes: 2 additions & 0 deletions src/Analyser/ScopeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use PHPStan\Reflection\ClassReflection;
use PHPStan\ShouldNotHappenException;
use PHPStan\Turbo\ShadowedByTurboExtension;

#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ScopeContext.cpp')]
final class ScopeContext
{

Expand Down
2 changes: 2 additions & 0 deletions src/Type/AcceptsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Turbo\ShadowedByTurboExtension;
use function array_merge;
use function array_unique;
use function array_values;
Expand All @@ -25,6 +26,7 @@
*
* @api
*/
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/AcceptsResult.cpp')]
final class AcceptsResult
{

Expand Down
2 changes: 2 additions & 0 deletions src/Type/IsSuperTypeOfResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Turbo\ShadowedByTurboExtension;
use function array_map;
use function array_merge;
use function array_unique;
Expand Down Expand Up @@ -34,6 +35,7 @@
*
* @api
*/
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/IsSuperTypeOfResult.cpp')]
final class IsSuperTypeOfResult
{

Expand Down
2 changes: 1 addition & 1 deletion turbo-ext/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (PHP_PHPSTAN_TURBO != "no") {
// directory by splitting on backslashes only — with forward slashes the
// objects compile flat while the link list expects the subpath
EXTENSION("phpstan_turbo",
"src\\main.cpp src\\support.cpp src\\ArenaCache.cpp src\\CombinationsHelper.cpp src\\ConditionalExpressionHolder.cpp src\\ExpressionResultStorage.cpp src\\ExpressionTypeHolder.cpp src\\NodeScanner.cpp src\\NodeTraverser.cpp src\\PharForkGuard.cpp src\\PhpFileCleaner.cpp src\\ScopeOps.cpp src\\Shadow.cpp src\\SymbolFinderInFiles.cpp src\\TrinaryLogic.cpp src\\TrustedTypes.cpp src\\TypeCombinatorCache.cpp",
"src\\main.cpp src\\support.cpp src\\AcceptsResult.cpp src\\ArenaCache.cpp src\\CombinationsHelper.cpp src\\ConditionalExpressionHolder.cpp src\\ExpressionResultStorage.cpp src\\ExpressionTypeHolder.cpp src\\IsSuperTypeOfResult.cpp src\\NodeScanner.cpp src\\NodeTraverser.cpp src\\PharForkGuard.cpp src\\PhpFileCleaner.cpp src\\ScopeContext.cpp src\\ScopeOps.cpp src\\Shadow.cpp src\\SymbolFinderInFiles.cpp src\\TrinaryLogic.cpp src\\TrustedTypes.cpp src\\TypeCombinatorCache.cpp",
true,
flags);
ADD_SOURCES(configure_module_dirname + "/src/parser",
Expand Down
Loading