Skip to content

Stdlib: ReflectionProperty::getSettableType()/getReadableType() — PHP 8.4 asymmetric visibility probes missing (ext/reflection/php_reflection.c) #7053

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

PHP 8.4 adds reflection helpers for asymmetric property visibility (public private(set) int $x):

  • ReflectionProperty::getSettableType(): ?ReflectionType
  • ReflectionProperty::getReadableType(): ?ReflectionType

This compiler registers ReflectionProperty but does not expose these methods (method_exists → false). Workers already track asymmetric compile rules (#7013 closed), getAsymmetricVisibility() (#5060, #6977), and hook/raw APIs — the readable/settable type split is still missing.

php-src reference

Repro

<?php
class C {
    public private(set) int $x = 1;
}
$p = new ReflectionProperty(C::class, 'x');
var_dump(method_exists($p, 'getSettableType'));
var_dump(method_exists($p, 'getReadableType'));
if (method_exists($p, 'getSettableType')) {
    var_dump((string) $p->getReadableType(), (string) $p->getSettableType());
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "...repro..."   # both method_exists → false
php -r "...repro..."              # PHP 8.4+: both true, readable int / settable null or private
'
Check Zend 8.4+ VM today
getReadableType() registered yes missing ❌
getSettableType() registered yes missing ❌
Unit enum / hook property edge cases per php-src add compliance

Scope

Path Work
ext/reflection/ or lib/VM/Builtin/ReflectionProperty*.php register methods on VM ReflectionProperty
lib/JIT/Call/ReflectionProperty*.php optional JIT stubs if reflection invoked in hot paths
Tests test/compliance/cases/stdlib/reflection_property_readable_settable_type.phpt

Implement in PHP (ext/ + VM handlers); no new C in runtime/.

Done when

  • Repro method_exists true for both methods on PHP 8.4+ asymmetric property
  • Return types match Zend for public/private(set), protected/public(set), and plain typed props
  • ./script/ci-fast.sh --filter reflection_property_readable_settable_type green

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 6, 2026
  2. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-a — starting this run

  3. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    Merged via #8120.

    Verification:

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/reflection_property_readable_settable_type_7053.php
    vendor/bin/phpunit --filter reflection_property_readable_settable_type'

    Output: method_exists true for both probes; (string) getReadableType()/getSettableType() → int for public private(set) int $x; compliance phpt OK (2 tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions