Skip to content

Stdlib: class_has_method()/class_has_property()/class_has_constant() missing — PHP 8.4 (ext/standard/basic_functions.c) #9989

Closed

Description

@PurHur

Category

stdlib · php-src-strict · PHP 8.4+

Problem

PHP 8.4 added class_has_method(), class_has_property(), and class_has_constant() for introspecting class members without instantiating. All three are absent from this compiler — Call to undefined function at runtime.

php-src reference

Repro (failure today)

test/repro-maintainer/parity_class_has_probes.php:

<?php
declare(strict_types=1);

class C { public function m(): void {} }
class D { public int $p = 1; }
class E { public const X = 1; }

var_export(class_has_method(C::class, 'm'));
echo "\n";
var_export(class_has_property(D::class, 'p'));
echo "\n";
var_export(class_has_constant(E::class, 'X'));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/parity_class_has_probes.php 2>&1 | head -3'
Check Zend PHP 8.4+ bin/vm.php
class_has_method(C::class, 'm') true Call to undefined function
class_has_property(D::class, 'p') true (not reached)
class_has_constant(E::class, 'X') true (not reached)

Also verify optional $autoload and $allow_string args match Zend.

Scope (PHP-in-PHP first)

Layer Path
VM builtins ext/standard/class_has_method.php, class_has_property.php, class_has_constant.php — delegate to existing ClassEntry / reflection tables
Register ext/standard/Module.php behind CompilerVersion PHP 8.4 gate
JIT shared lowering or VM-only initially; document in capability matrix
Tests test/compliance/cases/stdlib/class_has_method.phpt (+ property/constant variants)

Reuse method_exists() / property_exists() / defined() internals where possible instead of new C runtime.

Done when

  • All three functions registered and return Zend-matching bool for present/absent members
  • $autoload = false skips autoload; invalid $allow_string throws TypeError
  • Enum/interface/trait edge cases match php-src (private/inherited members)
  • ./script/ci-fast.sh --filter class_has_method green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter class_has_method'

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 19, 2026

    @PurHur
    OwnerAuthor

    Merged via #10004

    Verification

    • Repro: `php bin/vm.php test/repro-maintainer/parity_class_has_probes.php` → three `true` lines
    • `vendor/bin/phpunit --filter class_has_method` → OK (6 tests: VM + JIT + allow_string TypeError)
    • `php bin/compile.php -l test/fixtures/aot/compile-only/class_has_functions.php` → exit 0

    Implementation reuses `VmReflection::classHasForReflection()` (ReflectionClass::has parity) with shared `VmClassHas` for autoload/allow_string; JIT literal lowering via `ReflectionBuiltinHelper`.

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-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions