1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

core: Deprecate using null as an array offset and when calling array_key_exists() (#19511)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists
This commit is contained in:
Alexandre Daubois
2025-09-04 23:12:24 +02:00
committed by GitHub
parent ff72fb81ed
commit 49e3956b70
27 changed files with 881 additions and 50 deletions

View File

@@ -10,6 +10,8 @@ Warning: Undefined variable $a in %s on line %d
Warning: Undefined variable $b in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
array(1) {
[""]=>

View File

@@ -9,7 +9,8 @@ unset($ref);
$arr[0][$arr[0]] = null;
var_dump($arr);
?>
--EXPECT--
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
array(1) {
[0]=>
array(1) {

View File

@@ -17,7 +17,11 @@ echo "ok\n";
?>
--EXPECTF--
Warning: Undefined variable $i in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
made it once
Warning: Undefined variable $i in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
ok

View File

@@ -42,6 +42,8 @@ bool(true)
Deprecated: Implicit conversion from float 0.6 to int loses precision in %s on line %d
bool(true)
bool(false)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d

View File

@@ -21,6 +21,8 @@ list(STDIN => $resource) = [];
?>
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Implicit conversion from float 1.5 to int loses precision in %s on line %d
string(0) ""
int(1)

View File

@@ -38,6 +38,8 @@ int(2)
Deprecated: Implicit conversion from float 0.0836 to int loses precision in %s on line %d
int(1)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
NULL

View File

@@ -132,6 +132,93 @@ OUTPUT;
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
Read before write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
NULL
Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(5)
Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(25)
Reference to dimension:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Value of reference:
int(25)
Value of container dimension after write to reference (should be int(100) if successful):
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(100)
unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
Warning: Trying to access array offset on null in %s on line %d
NULL
Nested write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Nested empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Nested null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(30)
Nested unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
OUTPUT;
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
Read before write:
Cannot access offset of type %s on ArrayObject
@@ -175,44 +262,86 @@ $EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT
const EXPECTED_OUTPUT_NULL_OFFSET = <<<OUTPUT
Read before write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 8
Warning: Undefined array key "" in %s on line 8
NULL
Write:
Read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 22
Warning: Undefined array key "" in %s on line 22
NULL
Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 29
Warning: Undefined array key "" in %s on line 29
isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 36
bool(false)
empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 42
bool(true)
null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 48
string(7) "default"
Reference to dimension:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 55
Value of reference:
NULL
Value of container dimension after write to reference (should be int(100) if successful):
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 60
int(100)
unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 67
Nested read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 74
Warning: Undefined array key "" in %s on line 74
Warning: Trying to access array offset on null in %s on line 74
NULL
Nested write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 81
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 81
Nested Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 88
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 88
Nested isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 95
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 95
bool(true)
Nested empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 101
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 101
bool(false)
Nested null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 107
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 107
int(30)
Nested unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line 114
OUTPUT;
const EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS = <<<OUTPUT
@@ -323,6 +452,7 @@ foreach ($offsets as $dimension) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
@@ -354,6 +484,7 @@ foreach ($offsets as $offset) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_NULL_OFFSET
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {

View File

@@ -132,6 +132,89 @@ OUTPUT;
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
Read before write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
NULL
Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(5)
Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(25)
Reference to dimension:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Value of reference:
int(25)
Value of container dimension after write to reference (should be int(100) if successful):
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(100)
unset():
Nested read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
Warning: Trying to access array offset on null in %s on line %d
NULL
Nested write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Nested empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Nested null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(30)
Nested unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
OUTPUT;
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
Read before write:
Cannot access offset of type %s on array
@@ -273,6 +356,7 @@ foreach ($offsets as $dimension) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_array_container_{$failuresNb}.txt", $varOutput);
@@ -300,6 +384,7 @@ foreach ($offsets as $offset) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_array_container_{$failuresNb}.txt", $varOutput);

View File

@@ -135,6 +135,89 @@ OUTPUT;
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
Read before write:
Warning: Trying to access array offset on false in %s on line 8
NULL
Write:
Deprecated: Automatic conversion of false to array is deprecated in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(5)
Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(25)
Reference to dimension:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Value of reference:
int(25)
Value of container dimension after write to reference (should be int(100) if successful):
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(100)
unset():
Nested read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
Warning: Trying to access array offset on null in %s on line %d
NULL
Nested write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Nested empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Nested null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(30)
Nested unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
OUTPUT;
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
Read before write:
@@ -280,6 +363,7 @@ foreach ($offsets as $dimension) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_false_container_{$failuresNb}.txt", $varOutput);
@@ -307,6 +391,7 @@ foreach ($offsets as $offset) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_false_container_{$failuresNb}.txt", $varOutput);

View File

@@ -131,6 +131,87 @@ OUTPUT;
$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_NULL_OFFSETS = <<<OUTPUT
Read before write:
Warning: Trying to access array offset on null in %s on line %d
NULL
Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(5)
Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(25)
Reference to dimension:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Value of reference:
int(25)
Value of container dimension after write to reference (should be int(100) if successful):
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(100)
unset():
Nested read:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
Warning: Trying to access array offset on null in %s on line %d
NULL
Nested write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested Read-Write:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Nested isset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Nested empty():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Nested null coalesce:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(30)
Nested unset():
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
OUTPUT;
$EXPECTED_OUTPUT_NULL_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_NULL_OFFSETS) . '$/s';
const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT
Read before write:
@@ -272,6 +353,7 @@ foreach ($offsets as $dimension) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_null_container_{$failuresNb}.txt", $varOutput);
@@ -299,6 +381,7 @@ foreach ($offsets as $offset) {
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
&& !preg_match($EXPECTED_OUTPUT_NULL_OFFSETS_REGEX, $varOutput)
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS
) {
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_null_container_{$failuresNb}.txt", $varOutput);

View File

@@ -0,0 +1,17 @@
--TEST--
No UAF on null offset
--FILE--
<?php
set_error_handler(function($errno, $errstr) {
global $ary;
$ary = null;
echo $errstr;
});
$ary[null] = 1;
echo "\nSuccess\n";
?>
--EXPECTF--
Using null as an array offset is deprecated, use an empty string instead
Success

View File

@@ -703,12 +703,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -730,12 +736,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -757,12 +769,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -784,12 +802,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -817,12 +841,18 @@ array(3) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(3) {
[1]=>
@@ -841,12 +871,18 @@ array(2) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(2) {
[2]=>
@@ -861,12 +897,18 @@ array(1) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(1) {
[3]=>
@@ -877,12 +919,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -908,12 +956,18 @@ array(2) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(2) {
[1]=>
@@ -928,12 +982,18 @@ array(1) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(1) {
[2]=>
@@ -944,12 +1004,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -973,12 +1039,18 @@ array(1) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(1) {
[2]=>
@@ -989,12 +1061,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -1018,12 +1096,18 @@ array(1) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(1) {
["Age"]=>
@@ -1034,12 +1118,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -1069,12 +1159,18 @@ array(4) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(4) {
[1]=>
@@ -1097,12 +1193,18 @@ array(3) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(3) {
["One"]=>
@@ -1121,12 +1223,18 @@ array(2) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(2) {
[2]=>
@@ -1141,12 +1249,18 @@ array(1) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(1) {
[""]=>
@@ -1157,12 +1271,18 @@ array(0) {
}
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(false)
Warning: Undefined variable $key_val in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
array(0) {
}
@@ -1175,11 +1295,11 @@ bool(true)
*** Testing unset(), empty() & isset() with resource variables ***
-- Iteration 1 --
resource(%d) of type (stream)
resource(5) of type (stream)
bool(true)
bool(false)
bool(true)
resource(%d) of type (stream)
resource(5) of type (stream)
bool(false)
bool(true)
bool(false)
@@ -1188,11 +1308,11 @@ bool(false)
Warning: Undefined variable $resource in %s on line %d
NULL
-- Iteration 2 --
resource(%d) of type (stream)
resource(6) of type (stream)
bool(true)
bool(false)
bool(true)
resource(%d) of type (stream)
resource(6) of type (stream)
bool(false)
bool(true)
bool(false)
@@ -1207,7 +1327,7 @@ bool(false)
bool(true)
*** Testing unset(), empty() & isset() with objects ***
object(Point)#%d (3) {
object(Point)#1 (3) {
["x"]=>
int(30)
["y"]=>
@@ -1229,7 +1349,7 @@ bool(false)
Warning: Undefined variable $lable in %s on line %d
bool(true)
object(Point)#%d (3) {
object(Point)#1 (3) {
["x"]=>
int(30)
["y"]=>
@@ -1237,7 +1357,7 @@ object(Point)#%d (3) {
["lable"]=>
string(6) "Point1"
}
object(Point)#%d (2) {
object(Point)#1 (2) {
["y"]=>
int(40)
["lable"]=>
@@ -1245,7 +1365,7 @@ object(Point)#%d (2) {
}
bool(false)
bool(true)
object(Point)#%d (0) {
object(Point)#1 (0) {
}
bool(true)
bool(false)
@@ -1266,7 +1386,7 @@ array(3) {
[2]=>
string(9) "testPoint"
}
object(Point)#%d (3) {
object(Point)#1 (3) {
["x"]=>
int(5)
["y"]=>

View File

@@ -2629,6 +2629,21 @@ static zend_never_inline uint8_t slow_index_convert(HashTable *ht, const zval *d
ZEND_FALLTHROUGH;
}
case IS_NULL:
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
GC_TRY_ADDREF(ht);
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
zend_array_destroy(ht);
return IS_NULL;
}
if (EG(exception)) {
return IS_NULL;
}
value->str = ZSTR_EMPTY_ALLOC();
return IS_STRING;
case IS_DOUBLE:
@@ -2699,6 +2714,21 @@ static zend_never_inline uint8_t slow_index_convert_w(HashTable *ht, const zval
ZEND_FALLTHROUGH;
}
case IS_NULL:
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
GC_TRY_ADDREF(ht);
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) != 1) {
if (!GC_REFCOUNT(ht)) {
zend_array_destroy(ht);
}
return IS_NULL;
}
if (EG(exception)) {
return IS_NULL;
}
value->str = ZSTR_EMPTY_ALLOC();
return IS_STRING;
case IS_DOUBLE:
@@ -3192,7 +3222,22 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable
num_idx:
return zend_hash_index_find(ht, hval);
} else if (Z_TYPE_P(offset) == IS_NULL) {
str_idx:
null_undef_idx:
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
GC_TRY_ADDREF(ht);
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
zend_array_destroy(ht);
return NULL;
}
if (EG(exception)) {
return NULL;
}
return zend_hash_find_known_hash(ht, ZSTR_EMPTY_ALLOC());
} else if (Z_TYPE_P(offset) == IS_FALSE) {
hval = 0;
@@ -3206,7 +3251,7 @@ str_idx:
goto num_idx;
} else if (/*OP2_TYPE == IS_CV &&*/ Z_TYPE_P(offset) == IS_UNDEF) {
ZVAL_UNDEFINED_OP2();
goto str_idx;
goto null_undef_idx;
} else {
zend_illegal_array_offset_isset(offset);
return NULL;
@@ -3327,6 +3372,9 @@ num_key:
} else if (Z_TYPE_P(key) <= IS_NULL) {
if (UNEXPECTED(Z_TYPE_P(key) == IS_UNDEF)) {
ZVAL_UNDEFINED_OP1();
} else {
ZEND_ASSERT(Z_TYPE_P(key) == IS_NULL);
zend_error(E_DEPRECATED, "Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead");
}
str = ZSTR_EMPTY_ALLOC();
goto str_key;

View File

@@ -501,8 +501,17 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim,
}
ZEND_FALLTHROUGH;
case IS_NULL:
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
retval = zend_hash_find(ht, ZSTR_EMPTY_ALLOC());
if (!retval) {
ZVAL_NULL(result);
} else {
ZVAL_COPY_DEREF(result, retval);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!retval) {
zend_error(E_WARNING, "Undefined array key \"\"");
}
return;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
if (!zend_is_long_compatible(Z_DVAL_P(dim), hval)) {
@@ -643,8 +652,16 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim
}
ZEND_FALLTHROUGH;
case IS_NULL:
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
retval = zend_hash_find(ht, ZSTR_EMPTY_ALLOC());
if (!retval) {
ZVAL_NULL(result);
} else {
ZVAL_COPY_DEREF(result, retval);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
return;
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
if (!zend_is_long_compatible(Z_DVAL_P(dim), hval)) {
@@ -770,9 +787,17 @@ static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *d
return 0;
}
ZEND_FALLTHROUGH;
case IS_NULL:
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_NULL: {
int result = 0;
retval = zend_hash_find(ht, ZSTR_EMPTY_ALLOC());
if (retval) {
result = Z_TYPE_P(retval) > IS_NULL;
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
return result;
}
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(dim));
if (!zend_is_long_compatible(Z_DVAL_P(dim), hval)) {
@@ -879,6 +904,32 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di
}
ZEND_FALLTHROUGH;
case IS_NULL:
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
GC_TRY_ADDREF(ht);
execute_data = EG(current_execute_data);
opline = EX(opline);
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) != 1) {
if (!GC_REFCOUNT(ht)) {
zend_array_destroy(ht);
}
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
if (EG(exception)) {
ZVAL_UNDEF(EX_VAR(opline->result.var));
} else {
ZVAL_NULL(EX_VAR(opline->result.var));
}
}
return NULL;
}
if (EG(exception)) {
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
ZVAL_UNDEF(EX_VAR(opline->result.var));
}
return NULL;
}
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:
@@ -1012,6 +1063,36 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim
}
ZEND_FALLTHROUGH;
case IS_NULL:
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
GC_TRY_ADDREF(ht);
execute_data = EG(current_execute_data);
opline = EX(opline);
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) != 1) {
if (!GC_REFCOUNT(ht)) {
zend_array_destroy(ht);
}
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
if (EG(exception)) {
ZVAL_UNDEF(EX_VAR(opline->result.var));
} else {
ZVAL_NULL(EX_VAR(opline->result.var));
}
}
if (opline->opcode == ZEND_ASSIGN_DIM
&& ((opline+1)->op1_type & (IS_VAR | IS_TMP_VAR))) {
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
}
return NULL;
}
if (EG(exception)) {
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
ZVAL_UNDEF(EX_VAR(opline->result.var));
}
return NULL;
}
offset_key = ZSTR_EMPTY_ALLOC();
goto str_index;
case IS_DOUBLE:

View File

@@ -15,7 +15,10 @@ $a = [];
$a[test()] ??= 1;
var_dump($a);
?>
--EXPECT--
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
array(1) {
[""]=>
int(1)

View File

@@ -30,7 +30,7 @@ $x=2;
$y="x";
foo($x.$y);
?>
--EXPECT--
--EXPECTF--
int(1)
int(3)
int(2)
@@ -38,6 +38,8 @@ int(1)
int(3)
int(1)
int(2)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(4)
int(5)
int(5)

View File

@@ -280,6 +280,7 @@ static zend_result get_hash_key(spl_hash_key *key, spl_array_object *intern, zva
try_again:
switch (Z_TYPE_P(offset)) {
case IS_NULL:
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
key->key = ZSTR_EMPTY_ALLOC();
return SUCCESS;
case IS_STRING:

View File

@@ -26,6 +26,8 @@ var_dump($a[$fp]);
fclose($fp);
?>
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "epic_magic" in %s on line %d
NULL

View File

@@ -8,8 +8,12 @@ var_dump($y[NULL]);
var_dump($y[NULL]++);
?>
--EXPECTF--
Warning: Undefined array key "" in %s on line %d
NULL
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
NULL
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Warning: Undefined array key "" in %s on line %d
NULL

View File

@@ -6981,6 +6981,7 @@ PHP_FUNCTION(array_key_exists)
RETVAL_BOOL(zend_hash_index_exists(ht, Z_LVAL_P(key)));
break;
case IS_NULL:
zend_error(E_DEPRECATED, "Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead");
RETVAL_BOOL(zend_hash_exists(ht, ZSTR_EMPTY_ALLOC()));
break;
case IS_DOUBLE:

View File

@@ -82,7 +82,7 @@ try {
echo "Done\n";
?>
--EXPECT--
--EXPECTF--
*** Testing basic functionalities ***
-- Iteration 1 --
bool(true)
@@ -104,7 +104,11 @@ bool(true)
** Variation loop 1 **
-- Iteration 1 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -112,7 +116,11 @@ bool(false)
bool(true)
-- Iteration 2 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -120,7 +128,11 @@ bool(false)
bool(true)
-- Iteration 3 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -128,7 +140,11 @@ bool(false)
bool(true)
-- Iteration 4 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -136,7 +152,11 @@ bool(false)
bool(true)
-- Iteration 5 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -144,7 +164,11 @@ bool(false)
bool(false)
-- Iteration 6 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -152,7 +176,11 @@ bool(false)
bool(false)
-- Iteration 7 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -162,7 +190,11 @@ bool(true)
** Variation loop 2 **
-- Iteration 1 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -170,7 +202,11 @@ bool(false)
bool(false)
-- Iteration 2 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -178,7 +214,11 @@ bool(false)
bool(false)
-- Iteration 3 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)
@@ -186,7 +226,11 @@ bool(false)
bool(true)
-- Iteration 4 --
bool(true)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
bool(false)
bool(true)
@@ -194,7 +238,11 @@ bool(false)
bool(true)
-- Iteration 5 --
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
bool(false)
bool(false)

View File

@@ -105,9 +105,13 @@ bool(false)
bool(false)
-- Iteration 5 --
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
-- Iteration 6 --
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
-- Iteration 7 --
@@ -144,9 +148,13 @@ bool(true)
Cannot access offset of type classA on array
-- Iteration 18 --
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
-- Iteration 19 --
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(false)
-- Iteration 20 --

View File

@@ -36,54 +36,110 @@ foreach($array as $name => $input) {
echo "Done";
?>
--EXPECT--
--EXPECTF--
*** Testing array_key_exists() : usage variations ***
-- Key in $search array is : null --
Iteration 1: bool(true)
Iteration 2: bool(true)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
-- Key in $search array is : NULL --
Iteration 1: bool(true)
Iteration 2: bool(true)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
-- Key in $search array is : empty single quoted string --
Iteration 1: bool(true)
Iteration 2: bool(true)
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
-- Key in $search array is : empty double quoted string --
Iteration 1: bool(true)
Iteration 2: bool(true)
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
-- Key in $search array is : undefined variable --
Iteration 1: bool(true)
Iteration 2: bool(true)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
-- Key in $search array is : unset variable --
Iteration 1: bool(true)
Iteration 2: bool(true)
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Iteration 1:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 2:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 3: bool(true)
Iteration 4: bool(true)
Iteration 5: bool(true)
Iteration 6: bool(true)
Iteration 5:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Iteration 6:
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
Done

View File

@@ -7,5 +7,8 @@ Bug #20865 (array_key_exists and NULL key)
var_dump(array_key_exists(NULL, $ta));
?>
--EXPECT--
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)

View File

@@ -0,0 +1,13 @@
--TEST--
Deprecate using null as key in array_key_exists()
--FILE--
<?php
$arr = ['foo' => 'bar', '' => 'baz'];
var_dump(array_key_exists(null, $arr));
var_dump(array_key_exists('', $arr));
?>
--EXPECTF--
Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in %s on line %d
bool(true)
bool(true)

View File

@@ -0,0 +1,27 @@
--TEST--
Deprecate using null as array offset
--FILE--
<?php
$arr = ['foo' => 'bar', '' => 'baz'];
echo $arr[null] . "\n";
$arr[null] = 'new_value';
echo $arr[''] . "\n";
var_dump(isset($arr[null]));
unset($arr[null]);
var_dump(isset($arr['']));
?>
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
baz
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
new_value
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
bool(true)
bool(false)