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 {