Skip to content

Stdlib: ReflectionProperty::getAsymmetricVisibility() — set/get masks (ext/reflection/php_reflection.c) #5060

Description

@PurHur

Category

stdlib · php-src-strict · PHP 8.4 asymmetric visibility reflection

Problem

PHP 8.4 adds ReflectionProperty::getAsymmetricVisibility(): ?array returning visibility masks for get/set when they differ:

['get' => ReflectionProperty::IS_PUBLIC, 'set' => ReflectionProperty::IS_PRIVATE]

(or null when symmetric). This compiler registers ReflectionProperty but getAsymmetricVisibility() is undefined — callers fatal like any missing method.

Instance asymmetric properties compile and run; static asymmetric reflection tracked in #6772. This issue covers instance getAsymmetricVisibility() only.

php-src reference

Repro (failure today)

<?php
class C {
    public private(set) string $name = 'x';
    public string $sym = 'y';
}
$asym = new ReflectionProperty(C::class, 'name');
$sym = new ReflectionProperty(C::class, 'sym');

var_dump(method_exists($asym, 'getAsymmetricVisibility'));
var_export($asym->getAsymmetricVisibility());
echo "\n";
var_export($sym->getAsymmetricVisibility());
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
'
Property Zend PHP 8.4+ VM today
$name (public/private(set)) array with IS_PUBLIC get / IS_PRIVATE set undefined method or fatal
$sym (symmetric public) null not reached

Expected bitmask constants match ReflectionProperty::IS_* (same integers as Zend).

Scope (PHP-in-PHP first)

Path Work
ext/standard/VmReflection.php implement getAsymmetricVisibility() reading compiler asymmetric flags
lib/VM/BuiltinClasses.php register method on ReflectionProperty
lib/Compiler.php ensure /*phpc-asymmetric-set:*/ or ACC metadata available at link time
Tests test/compliance/cases/stdlib/reflection_property_asymmetric_visibility.phpt

No new C runtime.

Done when (php-src-strict)

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 3, 2026
  2. PurHur commented on Jun 6, 2026

    @PurHur
    OwnerAuthor

    Spec expansion (parity backlog run, Jun 2026)

    This issue is blocked on language surface until asymmetric visibility compiles — see #6861 (public private(set) parse fails today). Without #6861, repro sources using asymmetric properties never reach reflection.

    Dependency chain (claim order)

    1. Language: asymmetric visibility syntax (PHP 8.4 public private(set)) — parse fails Multiple access type modifiers #6861 — asymmetric visibility syntax + VM get/set enforcement
    2. Stdlib: ReflectionProperty::getAsymmetricVisibility() — set/get masks (ext/reflection/php_reflection.c) #5060 (this issue) — ReflectionProperty::getAsymmetricVisibility()
    3. Stdlib: ReflectionProperty::getAsymmetricVisibility() — static properties return wrong/null (ext/reflection/php_reflection.c) #6772 — static asymmetric properties return wrong/null (extends this API)
    4. Stdlib: get_class_vars() — static asymmetric properties missing from returned map (ext/standard/class.c) #6771 — get_class_vars() must expose static asymmetric entries

    Repro (still failing today)

    <?php
    class C {
        public private(set) string $name = 'x';
    }
    $r = new ReflectionProperty(C::class, 'name');
    var_export($r->getAsymmetricVisibility());
    echo "\n";
    # PHP 8.4+ reference
    php repro.php
    # array('set' => ReflectionProperty::IS_PRIVATE, 'get' => ReflectionProperty::IS_PUBLIC) — bitmask ints
    
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php repro.php 2>&1 | head -3
    '
    # today: fails at compile (#6861) or undefined method

    Symmetric control:

    class S { public string $name = 'x'; }
    var_export((new ReflectionProperty(S::class, 'name'))->getAsymmetricVisibility());
    // Zend: NULL

    php-src reference

    • ext/reflection/php_reflection.c — reflection_property_get_asymmetric_visibility
    • Zend/zend_compile.c — asymmetric ACC flags stored on property metadata

    Done when (unchanged + explicit)

    PHP-in-PHP: reflection metadata from compiler flags in lib/ / VmReflection.php; no C reflection tables.

  3. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  4. PurHur commented on Jun 12, 2026

    @PurHur
    OwnerAuthor

    Merged via #8199.

    Verification

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro-maintainer/reflection_get_asymmetric_visibility_5060.php
    vendor/bin/phpunit --filter reflection_property_asymmetric_visibility
    php bin/compile.php -l test/repro-maintainer/reflection_get_asymmetric_visibility_5060.php
    '

    → asymmetric instance/static return ['get'=>256,'set'=>1024] / ['get'=>256,'set'=>512]; symmetric null; PHPUnit OK; AOT lint exit 0.

    PHP path: lib/VM/Builtin/ReflectionPropertyGetAsymmetricVisibility.php + VmReflection::propertyVisibilityMeta() / visibilityToReflectionBitmask(). No C runtime changes.

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

    IMPORTANTCritical patharea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions