Skip to content

Stdlib: array_column() reads private props via __get — Zend returns empty (ext/standard/array.c) #23511

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

For object rows, php-src array_column() reads declared visible properties only — it does not invoke __get. When the column is a private property exposed only through __get, Zend returns an empty array; the VM currently invokes magic and returns values.

Repro Zend 8.2.32 (2026-07-26) VM
array_column([new R('x'), new R('y')], 'name') with private $name + __get [] ["x","y"]

Public constructor-promoted properties already match Zend.

php-src reference

PHP implementation target

  • ext/standard/ArrayColumnJitHelper.php / lib/JIT/Builtin/ArrayColumnRuntime.php — object column fetch must use non-magic property presence (declared props / property_exists semantics matching Zend), not __get
  • ext/standard/array_column.php — keep VM entry on the same helper
  • No new C in runtime/

Repro

./script/docker-exec.sh -- bash -lc 'cat >/tmp/acol.php <<'"'"'PHP'"'"'
<?php
class R {
  private $name;
  public function __construct(string $n) { $this->name = $n; }
  public function __get(string $k): string { return $this->name; }
}
echo json_encode(array_column([new R("x"), new R("y")], "name")), "\n";
PHP
env -u PHP_COMPILER_PROFILE php /tmp/acol.php
env -u PHP_COMPILER_PROFILE php bin/vm.php /tmp/acol.php'

Done when

  • VM/JIT match Zend ([]) for private-column + __get rows
  • Public/promoted object properties still extract as today
  • Compliance .phpt under test/compliance/cases/stdlib/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    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 Jul 26, 2026
  2. PurHur commented on Jul 26, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #23552, #23431, #23565, #23511, #23572, #23573)

    Working #23552 first (array_walk object visibility + mangling; also covers #23431 done-when). Sequential PRs; merge before next.

  3. PurHur commented on Jul 26, 2026

    @PurHur
    OwnerAuthor

    Merged #23620

    Verification: Zend + VM repro both []; phpunit --filter array_column_private_get|ArrayColumnRuntimeShrink OK (7 tests).

    Fix: ArrayColumnJitHelper reads only public declared/dynamic properties; never __get.

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 machinebugSomething isn't workingimplementation-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