From 62983e7c00d9db151c1854b574b6420b5ab9dc56 Mon Sep 17 00:00:00 2001 From: PurHur Date: Fri, 10 Jul 2026 19:19:06 +0000 Subject: [PATCH] Stdlib: advertise readonly() on PHP_COMPILER_PROFILE=8.4 (#17693) Forward 8.4 profile now matches Zend introspection: function_exists('readonly') returns true while reference 8.4.0-dev profile keeps the phantom gate. Co-authored-by: Cursor --- lib/CompilerVersion.php | 12 ++++++++---- test/unit/ForwardProfilePhantomIntrospectionTest.php | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/CompilerVersion.php b/lib/CompilerVersion.php index 405622de198..5bb285a988b 100644 --- a/lib/CompilerVersion.php +++ b/lib/CompilerVersion.php @@ -1318,14 +1318,18 @@ public static function supportsReadonlyBuiltin(): bool } /** - * readonly() visible to function_exists() — stable runtime only (#16357, re-#16292). + * readonly() visible to function_exists() — stable runtime or forward 8.4+ profile (#16357, #17693). * - * Callable under forward profile via {@see supportsReadonlyBuiltin()}; withheld from introspection on 8.4.0-dev - * reference harness like Zend 8.2. + * Withheld on 8.4.0-dev reference profile (matches Zend 8.2 phantom gate). Callable and advertised when + * {@see supportsReadonlyBuiltin()} is true (stable 8.4.0+ or explicit {@code PHP_COMPILER_PROFILE=8.4}). */ public static function advertisesReadonlyBuiltin(): bool { - return version_compare(self::VERSION, '8.4.0', '>='); + if (version_compare(self::VERSION, '8.4.0', '>=')) { + return true; + } + + return version_compare(self::languageProfileVersion(), '8.4.0', '>='); } /** diff --git a/test/unit/ForwardProfilePhantomIntrospectionTest.php b/test/unit/ForwardProfilePhantomIntrospectionTest.php index 3e7e616721f..27eb12eb480 100644 --- a/test/unit/ForwardProfilePhantomIntrospectionTest.php +++ b/test/unit/ForwardProfilePhantomIntrospectionTest.php @@ -270,19 +270,19 @@ public function testZendThreadIdAdvertisedOnForwardProfile84(): void } } - public function testReadonlyCallableButNotAdvertisedOnForwardProfile(): void + public function testReadonlyAdvertisedOnForwardProfile84(): void { $prev = getenv('PHP_COMPILER_PROFILE'); putenv('PHP_COMPILER_PROFILE=8.4'); try { $this->assertTrue(CompilerVersion::supportsReadonlyBuiltin()); - $this->assertFalse(CompilerVersion::advertisesReadonlyBuiltin()); - $this->assertFalse(BuiltinIntrospectionPolicy::functionIsAdvertised('readonly')); + $this->assertTrue(CompilerVersion::advertisesReadonlyBuiltin()); + $this->assertTrue(BuiltinIntrospectionPolicy::functionIsAdvertised('readonly')); $runtime = new Runtime(); $ctx = $runtime->vmContext; $this->assertTrue(isset($ctx->functions['readonly'])); - $this->assertFalse( + $this->assertTrue( \PHPCompiler\ext\standard\VmReflection::functionExists($ctx, 'readonly') ); } finally {