Skip to content

Stdlib: array_key_exists() — TypeError for non-array second argument (ext/standard/array.c Z_PARAM_ARRAY) #4722

Description

@PurHur

Category

stdlib

Problem

PHP 8+ array_key_exists() accepts only array as the second parameter (Z_PARAM_ARRAY). Zend throws TypeError with per-argument naming. This compiler raises LogicException with a build-specific message (array_key_exists() second argument must be an array in this compiler build), breaking instanceof TypeError checks and message parity.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/array_key_exists_non_array.php
php bin/vm.php test/repro-maintainer/array_key_exists_non_array.php'

Zend: TypeError: array_key_exists(): Argument #2 ($array) must be of type array, C given

This compiler: LogicException: array_key_exists() second argument must be an array in this compiler build

Scope

  • ext/standard/array_key_exists.php — VM + JIT argument validation
  • Match Zend TypeError wording (#n ($name))

Done when

  • Repro prints Zend-matching TypeError on VM
  • ./script/ci-fast.sh --filter array_key_exists green when tests exist

Links

Activity

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions