Skip to content

fix(optimizer): handle internal class literals in get_parent_class - #44

Merged
matyhtf merged 1 commit into
swoole:masterfrom
UEhQZXI:fix/get-parent-class-internal-literals
Sep 1, 2026
Merged

fix(optimizer): handle internal class literals in get_parent_class#44
matyhtf merged 1 commit into
swoole:masterfrom
UEhQZXI:fix/get-parent-class-internal-literals

Conversation

@UEhQZXI

@UEhQZXI UEhQZXI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

get_parent_class() crashes during conversion when a string literal names an internal PHP class:

get_parent_class('RuntimeException');

The optimizer assumes every literal class name exists in the compilation symbol table and uses the non-null lookup, so internal classes produce an invalid lookup instead of falling back to runtime resolution.

Fix

Use the nullable class lookup for compile-time folding. Known project classes continue to fold at compile time, while internal class names use php::fn::get_parent_class().

Tests

  • Added focused code-generation coverage for internal class literals.
  • Extended get_parent_class() PHPT coverage for internal classes with and without parents.
  • Verified the PHPUnit, PHPT, and platform build workflows on PHP 8.4 and PHP 8.5.

@matyhtf
matyhtf merged commit 014d5d5 into swoole:master Sep 1, 2026
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