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

ext/spl: Deprecate ArrayObject and ArrayIterator with objects (#19420)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_arrayobject_and_arrayiterator_with_objects

This also moves tests into a subfolder.
This commit is contained in:
Gina Peter Banyard
2025-08-14 12:38:57 +01:00
committed by GitHub
parent 9c754baa99
commit fb87b14b6c
120 changed files with 353 additions and 136 deletions

View File

@@ -20,5 +20,6 @@ $action->filter();
$action->filter();
?>
DONE
--EXPECT--
--EXPECTF--
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
DONE

View File

@@ -19,7 +19,8 @@ foreach ($obj as $k => &$v) {
var_dump($obj);
?>
--EXPECT--
--EXPECTF--
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
object(A)#1 (1) {
["foo"]=>
&string(2) "42"

View File

@@ -30,8 +30,11 @@ foreach ($obj as $k => &$v) {
var_dump($obj);
?>
--EXPECT--
--EXPECTF--
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
Cannot assign array to reference held by property A::$foo of type string
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
Cannot assign array to reference held by property A::$foo of type string
object(A)#1 (1) {
["foo"]=>

View File

@@ -22,7 +22,8 @@ try {
var_dump($obj);
?>
--EXPECT--
--EXPECTF--
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
Cannot acquire reference to readonly property A::$foo
object(A)#1 (1) {
["foo"]=>

View File

@@ -984,6 +984,12 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
}
}
} else {
php_error_docref(NULL, E_DEPRECATED,
"Using an object as a backing array for %s is deprecated, as it allows violating class constraints and invariants",
instanceof_function(Z_OBJCE_P(object), spl_ce_ArrayIterator) ? "ArrayIterator" : "ArrayObject");
if (UNEXPECTED(EG(exception))) {
return;
}
if (Z_OBJ_HT_P(array) == &spl_handler_ArrayObject) {
ZVAL_COPY_VALUE(&garbage, &intern->array);
if (just_array) {

View File

@@ -9,7 +9,8 @@ $c = clone $b;
var_dump($c);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#3 (1) {
["storage":"ArrayObject":private]=>
array(3) {

View File

@@ -11,5 +11,7 @@ new ArrayObject(Foo::Bar);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Fatal error: Uncaught InvalidArgumentException: Enums are not compatible with ArrayObject in %s:%d
%a

View File

@@ -21,7 +21,8 @@ var_dump(get_object_vars($ao));
var_dump($ao->getObjectVars());
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
array(0) {
}
array(1) {

View File

@@ -10,7 +10,8 @@ $ao['a'] = 42;
var_dump($arr);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
array(2) {
["a"]=>
int(1)

View File

@@ -12,5 +12,6 @@ try {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Overloaded object of type SplFixedArray is not compatible with ArrayObject

View File

@@ -12,7 +12,8 @@ try {
var_dump($ao);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Overloaded object of type DateInterval is not compatible with ArrayObject
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>

View File

@@ -1,5 +1,5 @@
--TEST--
When ArrayObject wraps an object, we should use proptable canonicalization
When ArrayObject wraps an object, we should use prop table canonicalization
--FILE--
<?php
@@ -15,7 +15,8 @@ unset($ao[0]);
var_dump($o);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(stdClass)#1 (1) {
["0"]=>
int(1)

View File

@@ -29,6 +29,7 @@ var_dump($ao5);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
object(stdClass)#1 (2) {
@@ -38,6 +39,8 @@ object(ArrayObject)#2 (1) {
int(2)
}
}
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#3 (1) {
["storage":"ArrayObject":private]=>
object(ArrayObject)#2 (1) {
@@ -51,6 +54,8 @@ object(ArrayObject)#3 (1) {
}
}
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: Creation of dynamic property ArrayObject::$a is deprecated in %s on line %d
Deprecated: Creation of dynamic property ArrayObject::$b is deprecated in %s on line %d

View File

@@ -16,6 +16,8 @@ var_dump((array) $c);
--EXPECTF--
Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d
array(3) {
[0]=>
@@ -26,6 +28,8 @@ array(3) {
int(3)
}
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: Creation of dynamic property ArrayObject::$prop is deprecated in %s on line %d
array(1) {
["prop"]=>

View File

@@ -16,7 +16,7 @@ var_dump(new ArrayObject(array('key1' => 'val1')));
echo "--> Nested ArrayObject argument:\n";
var_dump(new ArrayObject(new ArrayObject($a)));
?>
--EXPECT--
--EXPECTF--
--> No arguments:
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
@@ -24,6 +24,8 @@ object(ArrayObject)#1 (1) {
}
}
--> Object argument:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
object(stdClass)#1 (1) {
@@ -40,6 +42,10 @@ object(ArrayObject)#2 (1) {
}
}
--> Nested ArrayObject argument:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
object(ArrayObject)#3 (1) {

View File

@@ -48,6 +48,8 @@ function testAccess($c, $ao) {
?>
--EXPECTF--
--> Access prop on instance of ArrayObject:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:
@@ -78,6 +80,8 @@ object(C)#1 (0) {
}
--> Access prop on instance of MyArrayObject:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:

View File

@@ -48,6 +48,8 @@ function testAccess($c, $ao) {
?>
--EXPECTF--
--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:
@@ -78,6 +80,8 @@ object(C)#1 (0) {
}
--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:

View File

@@ -48,6 +48,8 @@ function testAccess($c, $ao) {
?>
--EXPECTF--
--> Access prop on instance of ArrayObject with ArrayObject::ARRAY_AS_PROPS:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:
@@ -76,6 +78,8 @@ object(C)#1 (0) {
}
--> Access prop on instance of MyArrayObject with ArrayObject::ARRAY_AS_PROPS:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:

View File

@@ -48,6 +48,8 @@ function testAccess($c, $ao) {
?>
--EXPECTF--
--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:
@@ -76,6 +78,8 @@ object(C)#1 (0) {
}
--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
- Iteration:
prop=>C::prop.orig
- Read:

View File

@@ -10,7 +10,8 @@ $ao = new ArrayObject($o);
$ao->asort();
var_dump($a, $o, $ao);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
array(2) {
[0]=>
int(2)

View File

@@ -20,8 +20,10 @@ $ao1 = new ArrayObject($c);
var_dump($ao1->asort());
var_dump($ao1, $c);
?>
--EXPECT--
--EXPECTF--
*** Testing ArrayObject::asort() : basic functionality ***
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
bool(true)
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>

View File

@@ -17,7 +17,8 @@ $ao1['new.ao1'] = 'new element added to ao1';
$ao2['new.ao2'] = 'new element added to ao2';
var_dump($c, $ao1, $ao2);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(C)#1 (3) {
["p1"]=>
string(32) "new prop added to c before clone"

View File

@@ -23,7 +23,10 @@ $clonedOuterArrayObject['new.coAO'] = 'new element added to $clonedOuterArrayObj
var_dump($wrappedObject, $innerArrayObject, $outerArrayObject, $clonedOuterArrayObject);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(C)#1 (5) {
["p"]=>
string(9) "C::p.orig"

View File

@@ -45,6 +45,8 @@ object(ArrayObject)#%d (1) {
}
--> exchangeArray(normal object):
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
string(18) "normal object prop"
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
@@ -55,6 +57,8 @@ object(ArrayObject)#%d (1) {
}
--> exchangeArray(ArrayObject):
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
string(19) "ArrayObject element"
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
@@ -68,6 +72,8 @@ object(ArrayObject)#%d (1) {
}
--> exchangeArray(ArrayIterator):
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
string(21) "ArrayIterator element"
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
@@ -81,6 +87,10 @@ object(ArrayObject)#%d (1) {
}
--> exchangeArray(nested ArrayObject):
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
string(26) "nested ArrayObject element"
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
@@ -94,4 +104,4 @@ object(ArrayObject)#%d (1) {
}
}
}
}
}

View File

@@ -3,7 +3,7 @@ SPL: ArrayObject::exchangeArray() basic usage with object as underlying data sto
--FILE--
<?php
#[AllowDynamicProperties]
#%dAllowDynamicProperties]
class C {
public $pub1 = 'public1';
}
@@ -52,6 +52,14 @@ var_dump($ao, $original, $copy);
?>
--EXPECTF--
--> exchangeArray() with objects:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: Creation of dynamic property C::$addedToSwapIn is deprecated in %s on line %d
Deprecated: Creation of dynamic property C::$addedToOriginal is deprecated in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
object(C)#3 (2) {
@@ -82,8 +90,12 @@ array(2) {
--> exchangeArray() with no arg:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Exception: ArrayObject::exchangeArray() expects exactly 1 argument, 0 given
Deprecated: Creation of dynamic property C::$addedToOriginal is deprecated in %s on line %d
Warning: Undefined variable $copy in %s on line %d
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
@@ -104,8 +116,12 @@ NULL
--> exchangeArray() with bad arg type:
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
ArrayObject::exchangeArray(): Argument #1 ($array) must be of type array, null given
Deprecated: Creation of dynamic property C::$addedToOriginal is deprecated in %s on line %d
Warning: Undefined variable $copy in %s on line %d
object(ArrayObject)#3 (1) {
["storage":"ArrayObject":private]=>

View File

@@ -0,0 +1,36 @@
--TEST--
SPL: ArrayObject::getFlags() basic usage
--FILE--
<?php
$ao = new ArrayObject(new ArrayObject(new stdClass));
var_dump($ao->getFlags());
$ao = new ArrayObject(new ArrayObject(array(1,2,3)), ArrayObject::STD_PROP_LIST);
var_dump($ao->getFlags());
$ao = new ArrayObject(new ArrayIterator(new ArrayObject()), ArrayObject::ARRAY_AS_PROPS);
var_dump($ao->getFlags());
$ao = new ArrayObject(new ArrayObject(), ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
var_dump($ao->getFlags());
$cao = clone $ao;
var_dump($cao->getFlags());
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(0)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(1)
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
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(2)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(3)
int(3)

View File

@@ -0,0 +1,30 @@
--TEST--
SPL: ArrayObject::getFlags() - ensure flags are passed on to nested array objects and iterators.
--FILE--
<?php
$ao = new ArrayObject(array(), ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
var_dump($ao->getFlags());
$ao2 = new ArrayObject($ao);
var_dump($ao2->getFlags());
var_dump($ao2->getIterator()->getFlags());
$ai = new ArrayIterator($ao);
var_dump($ai->getFlags());
$ao2 = new ArrayObject($ao, 0);
var_dump($ao2->getFlags());
?>
--EXPECTF--
int(3)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(3)
int(3)
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)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
int(0)

View File

@@ -20,8 +20,10 @@ $ao1 = new ArrayObject($c);
var_dump($ao1->ksort());
var_dump($ao1, $c);
?>
--EXPECT--
--EXPECTF--
*** Testing ArrayObject::ksort() : basic functionality ***
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
bool(true)
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>

View File

@@ -68,6 +68,8 @@ echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
Original wrapped object:
object(UsesMagic)#1 (5) {

View File

@@ -68,6 +68,8 @@ echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
Deprecated: Creation of dynamic property ArrayObject::$a is deprecated in %s on line %d

View File

@@ -68,6 +68,8 @@ echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
Original wrapped object:
object(UsesMagic)#1 (5) {

View File

@@ -71,6 +71,8 @@ echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
Original wrapped object:
object(C)#1 (5) {

View File

@@ -70,7 +70,9 @@ var_dump($obj);
echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
In UsesMagic::__set(a,changed)
In UsesMagic::__set(dynamic,new)

View File

@@ -71,6 +71,8 @@ echo " Wrapping ArrayObject:\n";
var_dump($ao);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Write existent, non-existent and dynamic:
Original wrapped object:
object(C)#1 (5) {

View File

@@ -18,6 +18,7 @@ var_dump($arrayObject);
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
object(ArrayObject)#1 (1) {

View File

@@ -35,7 +35,7 @@ foreach($test as $key => $val)
}
?>
--EXPECT--
--EXPECTF--
test Object
(
[pub] => public
@@ -44,6 +44,8 @@ test Object
[imp] => implicit
[dyn] => dynamic
)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
ArrayObject Object
(
[storage:ArrayObject:private] => test Object

View File

@@ -39,7 +39,7 @@ foreach($test as $key => $val)
}
?>
--EXPECT--
--EXPECTF--
test Object
(
[pub] => public
@@ -48,6 +48,8 @@ test Object
[imp] => implicit
[dyn] => dynamic
)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
ArrayIterator Object
(
[storage:ArrayIterator:private] => ArrayObject Object
@@ -64,6 +66,8 @@ ArrayIterator Object
)
)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
pub => public
imp => implicit
dyn => dynamic

View File

@@ -39,7 +39,7 @@ foreach($it as $key => $val)
var_dump($it->count());
?>
--EXPECT--
--EXPECTF--
===Array===
int(3)
zero=>0
@@ -50,6 +50,8 @@ 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)

View File

@@ -70,6 +70,8 @@ var_dump($o->{0}); /* doesn't wotk anyway */
3=>three
4=>four
===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
zero=>0
one=>1
two=>2

View File

@@ -177,6 +177,8 @@ array(3) {
ArrayObjectEx::show()
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -245,6 +247,8 @@ array(1) {
===FOREACH===
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -366,6 +370,8 @@ array(3) {
ArrayObjectEx::show()
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -434,6 +440,8 @@ array(1) {
===FOREACH===
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -512,6 +520,8 @@ int(1)
bool(true)
#####EXCHANGE#####
ArrayObjectEx::exchange()
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
===CHECK===
ArrayObjectEx::setFlags(0)
ArrayObjectEx::dump()
@@ -548,6 +558,8 @@ array(3) {
ArrayObjectEx::show()
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -607,6 +619,8 @@ array(1) {
===FOREACH===
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -710,6 +724,8 @@ array(3) {
ArrayObjectEx::show()
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>
@@ -769,6 +785,8 @@ array(1) {
===FOREACH===
ArrayObjectEx::getIterator()
ArrayIteratorEx::__construct()
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
ArrayIteratorEx::dump()
array(3) {
["Flags"]=>

View File

@@ -45,6 +45,8 @@ var_dump($b);
?>
--EXPECTF--
==ArrayObject===
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(MyArrayObject)#%d (1) {
["bar"]=>
string(3) "baz"
@@ -56,6 +58,8 @@ object(MyArrayObject)#%d (2) {
string(3) "Foo"
}
==ArrayIterator===
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
object(MyArrayIterator)#%d (1) {
["bar"]=>
string(3) "baz"

View File

@@ -10,7 +10,10 @@ print_r($obj1);
echo "$s\n";
print_r($obj2);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: ArrayObject::__unserialize(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
ArrayObject Object
(
[storage:ArrayObject:private] => ArrayObject Object

View File

@@ -21,7 +21,9 @@ foreach ($obj as $v) {
var_dump($v);
}
?>
--EXPECT--
--EXPECTF--
string(3) "bar"
string(3) "bar"
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
string(3) "bar"

View File

@@ -14,5 +14,6 @@ $i->next();
?>
===DONE===
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
===DONE===

View File

@@ -84,14 +84,22 @@ test_array($array, 'Protected Property');
test_array($array, 'Public Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
test_array($array, 'Protected Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
?>
--EXPECT--
--EXPECTF--
===Default with array===
1 => apple
1 => grape
===Public Property===
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
title => apple
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
title => grape
===Protected Property===
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
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
===Public Property New===
1 => apple
1 => grape

View File

@@ -17,7 +17,8 @@ var_dump($a->exchangeArray(array('a'=>1,'b'=>1,'c'=>1)));
echo "Done\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
array(3) {
["a"]=>
NULL

View File

@@ -20,7 +20,7 @@ foreach (new RecursiveIteratorIterator($rai) as $t) {
var_dump($t);
}
?>
--EXPECT--
--EXPECTF--
string(1) "z"
object(stdClass)#1 (0) {
}
@@ -28,5 +28,7 @@ string(1) "q"
string(1) "s"
Second:
string(1) "z"
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
string(1) "q"
string(1) "s"

View File

@@ -39,7 +39,8 @@ $ai->rewind();
$ai->seek(0);
showFirstTwoItems($ai);
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
--> Show the first two items:
pub1 => public1
pub2 => public2

View File

@@ -18,6 +18,8 @@ function testAccess($c, $ao) {
}
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Warning: Undefined property: C::$prop in %s on line %d
Warning: Undefined array key "prop" in %s on line %d

View File

@@ -28,5 +28,6 @@ $obj = new ObjB(new ArrayObject());
var_dump($obj == unserialize(serialize($obj)));
?>
--EXPECT--
--EXPECTF--
Deprecated: ArrayIterator::__unserialize(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d
bool(true)

View File

@@ -0,0 +1,16 @@
--TEST--
Fixed bug #69845 (ArrayObject with ARRAY_AS_PROPS broken)
--FILE--
<?php
for ($i = 0; $i<2; $i++) {
$data = new \ArrayObject(new stdClass(), ArrayObject::ARRAY_AS_PROPS);
$data->itemType = 'bulletin';
var_dump(!is_null($data['itemType']));
}
?>
--EXPECTF--
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
bool(true)
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
bool(true)

View File

@@ -9,6 +9,8 @@ $data = unserialize($exploit);
var_dump($data);
?>
--EXPECTF--
Deprecated: ArrayObject::unserialize(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Deprecated: Creation of dynamic property ArrayObject::$0 is deprecated in %s on line %d
Fatal error: Uncaught InvalidArgumentException: Overloaded object of type DateInterval is not compatible with ArrayObject in %s

View File

@@ -19,7 +19,8 @@ foreach($iterator as $k=>$v) {
}
?>
--EXPECT--
--EXPECTF--
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
Expect to see all keys in ->props here:
props
hello

View File

@@ -93,13 +93,20 @@ var_dump($selfArray['foo']);
?>
--EXPECTF--
0 => test1
1 => test2
Deprecated: ArrayIterator::__unserialize(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d
0 => test1
1 => test2
Deprecated: ArrayIterator::__unserialize(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d
0 => test1
1 => test2
Deprecated: ArrayObject::unserialize(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
Warning: Undefined array key "foo" in %s on line %d
NULL
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
object(SelfArray)#9 (1) {
["foo"]=>
string(3) "bar"

View File

@@ -62,7 +62,8 @@ $example->bugySetMethod(5, 'must be here');
var_dump(json_encode($example));
var_dump(json_encode($b));
?>
--EXPECT--
--EXPECTF--
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
string(51) "{"test":{"a":{"2":"","3":"","4":"","5":"in here"}}}"
string(51) "{"test":{"a":{"2":"","3":"","4":"","5":"in here"}}}"
string(56) "{"test":{"b":{"2":"","3":"","4":"","5":"must be here"}}}"

Some files were not shown because too many files have changed in this diff Show More