mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
fe2dc2b481
(And any PECLs returning `zend_empty_array` in the handler->get_properties
overrides)
Closes GH-9697
This is similar to the fix used in d9651a9419
for array_walk.
This should make it safer for php-src (and PECLs, long-term) to return
the empty immutable array in `handler->get_properties` to avoid wasting memory.
See https://github.com/php/php-src/issues/9697#issuecomment-1273613175
The only possible internal iterator position for the empty array is at the end
of the empty array (nInternalPointer=0).
The `zend_hash*del*` helpers will always set nInternalPointer to 0 when an
array becomes empty,
regardless of previous insertions/deletions/updates to the array.
21 lines
364 B
PHP
21 lines
364 B
PHP
--TEST--
|
|
FFI: Test deprecated use of array helper functions on FFI classes doesn't crash
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
|
$data = FFI::new('int');
|
|
var_dump(reset($data));
|
|
var_dump(end($data));
|
|
var_dump(next($data));
|
|
var_dump(prev($data));
|
|
?>
|
|
--EXPECTF--
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|