View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002428 | Xdebug | Uncategorized | public | 2026-05-29 12:39 | 2026-05-29 12:39 |
| Reporter | erjot | Assigned To | |||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | new | Resolution | open | ||
| Product Version | 3.5.1 | ||||
| Summary | 0002428: 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 OK!➜ ~ XDEBUG_MODE=off php php85-nullkey-min.php attach OK!➜ ~ XDEBUG_MODE=develop php php85-nullkey-min.php #OK! ➜ ~ XDEBUG_MODE=develop php php85-nullkey-min.php attach WRONG!! kept_ok == 0, lost_droppped = 100! | ||||
| Additional Information | PHP 8.5.6 (cli) (built: May 5 2026 21:19:36) (NTS) | ||||
| Tags | No 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;
| ||||
| Operating System | |||||
| PHP Version | 8.5.0-8.5.4 | ||||