Skip to content

[perf] Read caller class name off node in ExportToReflectionFunctionRector - #8724

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-export-reflection-name-type
Oct 20, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-export-reflection-name-type

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The rule rewrites ReflectionFunction::export('foo') to new ReflectionFunction('foo'). To confirm the static-call target is ReflectionFunction (or an ancestor) it read the caller type with getType($node->class), which runs the type resolver over a node whose class name is already known.

A concrete class name is read straight off the node as new ObjectType($name); the isSuperTypeOf() check that follows is unchanged, so the decision is identical. self/static/parent depend on the enclosing class, so those fall back to getType().

Bench bench/export_to_reflection_function_name_type_bench.php over 9000 refactor() calls:

  • before: 13.65 us/call
  • after: 9.29 us/call (~1.47x)

Added a skip fixture for export() on an unrelated class to pin that the node path still bails correctly.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) October 20, 2026 10:16
@TomasVotruba
TomasVotruba disabled auto-merge October 20, 2026 10:20
@TomasVotruba
TomasVotruba merged commit 3b02457 into main Oct 20, 2026
48 of 49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-export-reflection-name-type branch October 20, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant