Skip to content

fix(compiler): preserve signatures for typed property method calls - #104

Open
yavon007 wants to merge 1 commit into
swoole:masterfrom
yavon007:codex/typed-property-method-calls
Open

fix(compiler): preserve signatures for typed property method calls#104
yavon007 wants to merge 1 commit into
swoole:masterfrom
yavon007:codex/typed-property-method-calls

Conversation

@yavon007

Copy link
Copy Markdown
Contributor

fix(compiler): preserve signatures for typed property method calls

Calls such as $this->target->record($events) were lowered dynamically even when
target had a non-nullable declared project class. This bypassed the known
parameter signature: an array &$events argument emitted a by-reference warning
and lost its writes. It also routed eligible calls through Zend wrappers.

Materialize the property receiver once before argument evaluation, record its
declared object type, and reuse existing direct-call eligibility and argument
lowering. Do not mark the receiver as an exact runtime class; existing override,
abstract-class, visibility and magic-call handling remain in effect. Nullable and
unknown property types retain their current paths.

Validation:

  • Baseline runtime fixture produced two reference warnings and an empty events
    array; the candidate matches PHP, including named arguments, receiver replacement
    during argument evaluation, subclass dispatch, nullsafe access, getter invoked
    once, and uninitialized-property errors.
  • Targeted PHPUnit: 25 tests, 83 assertions passed.
  • New compiled PHPT passed.
  • Existing dungeon: 51 behavioral assertions passed with identical output.
  • Alternating five-run O2 benchmarks with identical outputs: one million property
    calls, 29.97 → 22.63 ms median (24.5% lower). Normal dungeon, 485.27 → 473.70 ms
    (2.4%); exception-heavy dungeon, 1216.81 → 1226.59 ms (no improvement).

The application-scale performance result is modest; this change primarily restores
known call signatures and removes an unnecessary runtime dispatch where the
existing devirtualizer permits it. Benchmark environment: Linux ARM64 container,
PHP 8.5.10 ZTS, PHPX 4b3a472, baseline TypePHP a1782233.

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