php-src/Zend/tests/resource_key.phpt
Nikita Popov 776726da03 Add missing resource key warning for unset()
It was present on other operations, including isset(), but was
missing for unset().
2021-01-26 12:51:02 +01:00

37 lines
846 B
PHP

--TEST--
Behavior of resources as array keys
--FILE--
<?php
$r = fopen(__FILE__, 'r');
$a = [];
echo "Assign:";
$a[$r] = 1;
echo "Add assign:";
$a[$r] += 1;
echo "Inc:";
$a[$r]++;
echo "Get:";
var_dump($a[$r]);
echo "Isset:";
var_dump(isset($a[$r]));
echo "Unset:";
unset($a[$r]);
?>
--EXPECTF--
Assign:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Add assign:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Inc:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Get:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
int(3)
Isset:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
bool(true)
Unset:
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d