Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/CompilerVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '>=');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/unit/ForwardProfilePhantomIntrospectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down