mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_arrayobject_and_arrayiterator_with_objects This also moves tests into a subfolder.
63 lines
948 B
PHP
63 lines
948 B
PHP
--TEST--
|
|
SPL: ArrayIterator::count
|
|
--FILE--
|
|
<?php
|
|
|
|
echo "===Array===\n";
|
|
|
|
$a = array('zero' => 0, 'one' => 1, 'two' => 2);
|
|
$it = new ArrayIterator($a);
|
|
|
|
var_dump($it->count());
|
|
foreach($it as $key => $val)
|
|
{
|
|
echo "$key=>$val\n";
|
|
var_dump($it->count());
|
|
}
|
|
var_dump($it->count());
|
|
|
|
echo "===Object===\n";
|
|
|
|
class test
|
|
{
|
|
public $zero = 0;
|
|
protected $pro;
|
|
public $one = 1;
|
|
private $pri;
|
|
public $two = 2;
|
|
}
|
|
|
|
$o = new test;
|
|
$it = new ArrayIterator($o);
|
|
|
|
var_dump($it->count());
|
|
foreach($it as $key => $val)
|
|
{
|
|
echo "$key=>$val\n";
|
|
var_dump($it->count());
|
|
}
|
|
var_dump($it->count());
|
|
|
|
?>
|
|
--EXPECTF--
|
|
===Array===
|
|
int(3)
|
|
zero=>0
|
|
int(3)
|
|
one=>1
|
|
int(3)
|
|
two=>2
|
|
int(3)
|
|
int(3)
|
|
===Object===
|
|
|
|
Deprecated: ArrayIterator::__construct(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d
|
|
int(3)
|
|
zero=>0
|
|
int(3)
|
|
one=>1
|
|
int(3)
|
|
two=>2
|
|
int(3)
|
|
int(3)
|