View Issue Details

IDProjectCategoryView StatusLast Update
0002428XdebugUncategorizedpublic2026-05-29 12:39
Reportererjot Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version3.5.1 
Summary0002428: XDEBUG_MODE=develop and set_error_handler for deprecated null key in array
Description

when an error handler is added in the code, the array does not support null keys (which are deprecated as of 8.5.x)

Steps To Reproduce

➜ ~ XDEBUG_MODE=off php php85-nullkey-min.php
{
"php": "8.5.6",
"iterations": 100,
"lost_dropped": 0,
"kept_ok": 100
}

OK!

➜ ~ XDEBUG_MODE=off php php85-nullkey-min.php attach
attach error handler
{
"php": "8.5.6",
"iterations": 100,
"lost_dropped": 0,
"kept_ok": 100
}

OK!

➜ ~ XDEBUG_MODE=develop php php85-nullkey-min.php
{
"php": "8.5.6",
"iterations": 100,
"lost_dropped": 0,
"kept_ok": 100
}

#OK!

➜ ~ XDEBUG_MODE=develop php php85-nullkey-min.php attach
attach error handler
{
"php": "8.5.6",
"iterations": 100,
"lost_dropped": 100,
"kept_ok": 0

WRONG!! kept_ok == 0, lost_droppped = 100!

Additional Information

PHP 8.5.6 (cli) (built: May 5 2026 21:19:36) (NTS)
Copyright (c) The PHP Group
Built by Shivam Mathur
Zend Engine v4.5.6, Copyright (c) Zend Technologies
with Xdebug v3.5.1, Copyright (c) 2002-2026, by Derick Rethans
with Zend OPcache v8.5.6, Copyright (c), by Zend Technologies

TagsNo tags attached.
Attached Files
php85-nullkey-min.php (1,100 bytes)   
<?php

error_reporting(0);


function leaf(array $index)         // by-value copy-on-write array param
{
    $index[null] = true;            // emits E_DEPRECATED on PHP 8.5

    return $index;
}

if ($argc != 1) {
echo "attach error handler\n";
set_error_handler(static function ($errno, $errstr) {
    try {
        throw new Exception('handled');   // exception machinery during the deprecation
    } catch (\Throwable $e) {
        // swallow
    }

    return true;
});

}

$lost = 0;
$kept = 0;
$firstSamples = [];

for ($i = 0; $i < 100; $i++) {
    $src = [];
    $keys = array_keys(leaf($src['missing'] ?? []));   // `?? []` => fresh COW empty array
    if ($keys === []) {
        $lost++;
    } else {
        $kept++;
    }
    if ($i < 8) {
        $firstSamples[$i] = $keys;
    }
}

echo json_encode([
    'php'           => PHP_VERSION,
    'iterations'    => 100,
    'lost_dropped'  => $lost,   // how many times `$arr[null]=true` produced []
    'kept_ok'       => $kept,   // how many times it produced [""]
//    'first_samples' => $firstSamples,
], JSON_PRETTY_PRINT), PHP_EOL;
php85-nullkey-min.php (1,100 bytes)   
Operating System
PHP Version8.5.0-8.5.4

Activities

Issue History

Date Modified Username Field Change
2026-05-29 12:39 erjot New Issue
2026-05-29 12:39 erjot File Added: php85-nullkey-min.php