Skip to content

Regression: array_search() null needle — returns false not int key 0 (ext/standard/array.c) #11547

Closed

Description

@PurHur

Summary

array_search(null, [null]) must return 0 (int key of the sole null element). VM returns false, while in_array(null, [null]) and strict in_array(null, [null], true) are both true.

Distinct from #11058 (null needle + inline haystack literal breaks in_array) — this repro uses a variable haystack and isolates array_search return type.

php-src reference: ext/standard/array.c — php_array_search.

PHP implementation target: ext/standard/ array builtins + shared VM search helpers (lib/VM/).

Repro

test/repro/maintainer_gap_in_array_null_loose.php:

php test/repro/maintainer_gap_in_array_null_loose.php
# Zend: true / true / 0

php bin/vm.php test/repro/maintainer_gap_in_array_null_loose.php
# VM: FAIL ... search=false

Done when (php-src-strict)

  • Repro prints true / true / 0 on VM.
  • array_search still returns false when needle absent; strict mode unchanged.
  • Targeted compliance guard.

North star #1492 · related #11058, #9702

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11547, #11337)

  3. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    Checked on current master: php bin/vm.php test/repro/maintainer_gap_in_array_null_loose.php prints true / true / 0 (exit 0), and php bin/compile.php -l test/repro/maintainer_gap_in_array_null_loose.php succeeds.

    AOT runtime for in_array/array_search still crashes in general (tracked in #11553). This specific repro appears already fixed.

  4. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11337, #11547, #11553)\n\nWorking on array_search() null needle regression + related AOT behavior. Will verify VM + AOT repro(s) and merge fix.

  5. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11547, #11058, #11337)

  6. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    No change this run — repro already green on master (true / true / 0). Regression tracked under #10321 / merged #11613 for related strict: named binding.

  7. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11547, #11636, #11603)

  8. PurHur commented on Jun 28, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #10178, #11547)

  9. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Closing as stale: repro green on master 2026-06-30 (verified by PHP Runtime migration run after #14222).

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