From 16872310d56b33aceb9b107bdd3d7db072c51c9e Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 9 Aug 2025 11:36:14 +0100 Subject: [PATCH] ext/spl: Deprecate SplObjectStorage::contains(), SplObjectStorage::attach(), and SplObjectStorage::detach() (#19424) RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach --- Zend/tests/enum/spl-object-storage.phpt | 4 +-- ext/spl/spl_observer.c | 1 + ext/spl/spl_observer.stub.php | 3 ++ ext/spl/spl_observer_arginfo.h | 30 ++++++++++++++++--- .../SplObjectStorage_coalesce.phpt | 18 +++++++---- ...plObjectStorage_removeAllExcept_basic.phpt | 12 ++++---- .../SplObjectStorage_seek.phpt | 4 +-- ext/spl/tests/SplObjectStorage/bug49263.phpt | 4 +-- ext/spl/tests/SplObjectStorage/bug53071.phpt | 4 +-- ext/spl/tests/SplObjectStorage/bug67582.phpt | 2 +- ext/spl/tests/SplObjectStorage/bug69108.phpt | 2 +- ext/spl/tests/SplObjectStorage/bug69227.phpt | 2 +- .../tests/{ => SplObjectStorage}/gh14639.phpt | 2 +- .../{ => SplObjectStorage}/observer_001.phpt | 0 .../{ => SplObjectStorage}/observer_002.phpt | 6 ++-- .../{ => SplObjectStorage}/observer_003.phpt | 2 +- .../{ => SplObjectStorage}/observer_004.phpt | 2 +- .../{ => SplObjectStorage}/observer_005.phpt | 2 +- .../{ => SplObjectStorage}/observer_006.phpt | 8 ++--- .../{ => SplObjectStorage}/observer_007.phpt | 0 .../{ => SplObjectStorage}/observer_008.phpt | 14 ++++----- .../{ => SplObjectStorage}/observer_009.phpt | 4 +-- .../{ => SplObjectStorage}/observer_010.phpt | 0 23 files changed, 80 insertions(+), 46 deletions(-) rename ext/spl/tests/{ => SplObjectStorage}/SplObjectStorage_seek.phpt (97%) rename ext/spl/tests/{ => SplObjectStorage}/gh14639.phpt (94%) rename ext/spl/tests/{ => SplObjectStorage}/observer_001.phpt (100%) rename ext/spl/tests/{ => SplObjectStorage}/observer_002.phpt (96%) rename ext/spl/tests/{ => SplObjectStorage}/observer_003.phpt (93%) rename ext/spl/tests/{ => SplObjectStorage}/observer_004.phpt (97%) rename ext/spl/tests/{ => SplObjectStorage}/observer_005.phpt (97%) rename ext/spl/tests/{ => SplObjectStorage}/observer_006.phpt (95%) rename ext/spl/tests/{ => SplObjectStorage}/observer_007.phpt (100%) rename ext/spl/tests/{ => SplObjectStorage}/observer_008.phpt (71%) rename ext/spl/tests/{ => SplObjectStorage}/observer_009.phpt (87%) rename ext/spl/tests/{ => SplObjectStorage}/observer_010.phpt (100%) diff --git a/Zend/tests/enum/spl-object-storage.phpt b/Zend/tests/enum/spl-object-storage.phpt index 7c72299c348..10da018b842 100644 --- a/Zend/tests/enum/spl-object-storage.phpt +++ b/Zend/tests/enum/spl-object-storage.phpt @@ -16,8 +16,8 @@ $storage[Foo::Baz] = 'Baz'; var_dump($storage[Foo::Bar]); var_dump($storage[Foo::Baz]); -var_dump($storage->contains(Foo::Bar)); -var_dump($storage->contains(Foo::Qux)); +var_dump($storage->offsetExists(Foo::Bar)); +var_dump($storage->offsetExists(Foo::Qux)); $serialized = serialize($storage); var_dump($serialized); diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 4eeb3371027..540e5c2c0ff 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -25,6 +25,7 @@ #include "zend_smart_str.h" #include "zend_interfaces.h" #include "zend_exceptions.h" +#include "zend_attributes.h" #include "php_spl.h" /* For php_spl_object_hash() */ #include "spl_observer.h" diff --git a/ext/spl/spl_observer.stub.php b/ext/spl/spl_observer.stub.php index 9e78272cf35..1a3c1f68433 100644 --- a/ext/spl/spl_observer.stub.php +++ b/ext/spl/spl_observer.stub.php @@ -23,12 +23,15 @@ interface SplSubject class SplObjectStorage implements Countable, SeekableIterator, Serializable, ArrayAccess { /** @tentative-return-type */ + #[\Deprecated(since: '8.5', message: "use method SplObjectStorage::offsetSet() instead")] public function attach(object $object, mixed $info = null): void {} /** @tentative-return-type */ + #[\Deprecated(since: '8.5', message: "use method SplObjectStorage::offsetUnset() instead")] public function detach(object $object): void {} /** @tentative-return-type */ + #[\Deprecated(since: '8.5', message: "use method SplObjectStorage::offsetExists() instead")] public function contains(object $object): bool {} /** @tentative-return-type */ diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h index be12c594e01..ae648edd7e8 100644 --- a/ext/spl/spl_observer_arginfo.h +++ b/ext/spl/spl_observer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a846c9dd240b6f0666cd5e805abfacabe360cf4c */ + * Stub hash: 9dfd8bcf8946cbee550c9a46da07c424c3505408 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplObserver_update, 0, 1, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0) @@ -185,9 +185,9 @@ static const zend_function_entry class_SplSubject_methods[] = { }; static const zend_function_entry class_SplObjectStorage_methods[] = { - ZEND_ME(SplObjectStorage, attach, arginfo_class_SplObjectStorage_attach, ZEND_ACC_PUBLIC) - ZEND_ME(SplObjectStorage, detach, arginfo_class_SplObjectStorage_detach, ZEND_ACC_PUBLIC) - ZEND_ME(SplObjectStorage, contains, arginfo_class_SplObjectStorage_contains, ZEND_ACC_PUBLIC) + ZEND_ME(SplObjectStorage, attach, arginfo_class_SplObjectStorage_attach, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) + ZEND_ME(SplObjectStorage, detach, arginfo_class_SplObjectStorage_detach, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) + ZEND_ME(SplObjectStorage, contains, arginfo_class_SplObjectStorage_contains, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) ZEND_ME(SplObjectStorage, addAll, arginfo_class_SplObjectStorage_addAll, ZEND_ACC_PUBLIC) ZEND_ME(SplObjectStorage, removeAll, arginfo_class_SplObjectStorage_removeAll, ZEND_ACC_PUBLIC) ZEND_ME(SplObjectStorage, removeAllExcept, arginfo_class_SplObjectStorage_removeAllExcept, ZEND_ACC_PUBLIC) @@ -258,6 +258,28 @@ static zend_class_entry *register_class_SplObjectStorage(zend_class_entry *class class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); zend_class_implements(class_entry, 4, class_entry_Countable, class_entry_SeekableIterator, class_entry_Serializable, class_entry_ArrayAccess); + + zend_attribute *attribute_Deprecated_func_attach_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "attach", sizeof("attach") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&attribute_Deprecated_func_attach_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_5)); + attribute_Deprecated_func_attach_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_attach_0_arg1_str = zend_string_init("use method SplObjectStorage::offsetSet() instead", strlen("use method SplObjectStorage::offsetSet() instead"), 1); + ZVAL_STR(&attribute_Deprecated_func_attach_0->args[1].value, attribute_Deprecated_func_attach_0_arg1_str); + attribute_Deprecated_func_attach_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + + zend_attribute *attribute_Deprecated_func_detach_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "detach", sizeof("detach") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&attribute_Deprecated_func_detach_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_5)); + attribute_Deprecated_func_detach_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_detach_0_arg1_str = zend_string_init("use method SplObjectStorage::offsetUnset() instead", strlen("use method SplObjectStorage::offsetUnset() instead"), 1); + ZVAL_STR(&attribute_Deprecated_func_detach_0->args[1].value, attribute_Deprecated_func_detach_0_arg1_str); + attribute_Deprecated_func_detach_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + + zend_attribute *attribute_Deprecated_func_contains_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "contains", sizeof("contains") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&attribute_Deprecated_func_contains_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_5)); + attribute_Deprecated_func_contains_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + zend_string *attribute_Deprecated_func_contains_0_arg1_str = zend_string_init("use method SplObjectStorage::offsetExists() instead", strlen("use method SplObjectStorage::offsetExists() instead"), 1); + ZVAL_STR(&attribute_Deprecated_func_contains_0->args[1].value, attribute_Deprecated_func_contains_0_arg1_str); + attribute_Deprecated_func_contains_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + return class_entry; } diff --git a/ext/spl/tests/SplObjectStorage/SplObjectStorage_coalesce.phpt b/ext/spl/tests/SplObjectStorage/SplObjectStorage_coalesce.phpt index 5a89b46be6b..d4075018d34 100644 --- a/ext/spl/tests/SplObjectStorage/SplObjectStorage_coalesce.phpt +++ b/ext/spl/tests/SplObjectStorage/SplObjectStorage_coalesce.phpt @@ -19,15 +19,17 @@ var_dump(isset($s[$o2])); var_dump(empty($s[$o2])); $s[$o2] = null; var_dump($s[$o2] ?? new stdClass()); -echo "check isset/empty/contains for null. offsetExists returns true as long as the entry is there.\n"; +echo "check isset/empty/contains/offsetExists for null. offsetExists returns true as long as the entry is there.\n"; var_dump(isset($s[$o2])); var_dump(empty($s[$o2])); var_dump($s->contains($o2)); -echo "check isset/empty/contains for false.\n"; +var_dump($s->offsetExists($o2)); +echo "check isset/empty/contains/offsetExists for false.\n"; $s[$o2] = false; var_dump(isset($s[$o2])); var_dump(empty($s[$o2])); var_dump($s->contains($o2)); +var_dump($s->offsetExists($o2)); try { $s['invalid'] = 123; } catch (Error $e) { @@ -56,18 +58,24 @@ bool(false) bool(true) object(stdClass)#4 (0) { } -check isset/empty/contains for null. offsetExists returns true as long as the entry is there. +check isset/empty/contains/offsetExists for null. offsetExists returns true as long as the entry is there. bool(true) bool(true) + +Deprecated: Method SplObjectStorage::contains() is deprecated since 8.5, use method SplObjectStorage::offsetExists() instead in %s on line %d bool(true) -check isset/empty/contains for false. bool(true) +check isset/empty/contains/offsetExists for false. +bool(true) +bool(true) + +Deprecated: Method SplObjectStorage::contains() is deprecated since 8.5, use method SplObjectStorage::offsetExists() instead in %s on line %d bool(true) bool(true) TypeError: SplObjectStorage::offsetSet(): Argument #1 ($object) must be of type object, string given TypeError: SplObjectStorage::offsetExists(): Argument #1 ($object) must be of type object, string given -Notice: Indirect modification of overloaded element of SplObjectStorage has no effect in %s on line 38 +Notice: Indirect modification of overloaded element of SplObjectStorage has no effect in %s on line %d object(SplObjectStorage)#1 (1) { ["storage":"SplObjectStorage":private]=> array(2) { diff --git a/ext/spl/tests/SplObjectStorage/SplObjectStorage_removeAllExcept_basic.phpt b/ext/spl/tests/SplObjectStorage/SplObjectStorage_removeAllExcept_basic.phpt index a6059da2958..fa7fdf367fa 100644 --- a/ext/spl/tests/SplObjectStorage/SplObjectStorage_removeAllExcept_basic.phpt +++ b/ext/spl/tests/SplObjectStorage/SplObjectStorage_removeAllExcept_basic.phpt @@ -10,16 +10,16 @@ $b = (object) 'b'; $c = (object) 'c'; $foo = new SplObjectStorage; -$foo->attach($a); -$foo->attach($b); +$foo->offsetSet($a); +$foo->offsetSet($b); $bar = new SplObjectStorage; -$bar->attach($b); -$bar->attach($c); +$bar->offsetSet($b); +$bar->offsetSet($c); $foo->removeAllExcept($bar); -var_dump($foo->contains($a)); -var_dump($foo->contains($b)); +var_dump($foo->offsetExists($a)); +var_dump($foo->offsetExists($b)); ?> --EXPECT-- diff --git a/ext/spl/tests/SplObjectStorage_seek.phpt b/ext/spl/tests/SplObjectStorage/SplObjectStorage_seek.phpt similarity index 97% rename from ext/spl/tests/SplObjectStorage_seek.phpt rename to ext/spl/tests/SplObjectStorage/SplObjectStorage_seek.phpt index f51a285d060..ce21b2a621f 100644 --- a/ext/spl/tests/SplObjectStorage_seek.phpt +++ b/ext/spl/tests/SplObjectStorage/SplObjectStorage_seek.phpt @@ -64,8 +64,8 @@ var_dump($storage->current()); echo "--- With holes cases ---\n"; -$storage->detach($b); -$storage->detach($d); +$storage->offsetUnset($b); +$storage->offsetUnset($d); foreach (range(0, 2) as $index) { $storage->seek($index); diff --git a/ext/spl/tests/SplObjectStorage/bug49263.phpt b/ext/spl/tests/SplObjectStorage/bug49263.phpt index 23bd0b272a7..a8088f18079 100644 --- a/ext/spl/tests/SplObjectStorage/bug49263.phpt +++ b/ext/spl/tests/SplObjectStorage/bug49263.phpt @@ -7,8 +7,8 @@ $o2 = new stdClass; $s = new SplObjectStorage(); -$s->attach($o1, array('prev' => 2, 'next' => $o2)); -$s->attach($o2, array('prev' => $o1)); +$s->offsetSet($o1, array('prev' => 2, 'next' => $o2)); +$s->offsetSet($o2, array('prev' => $o1)); $ss = serialize($s); unset($s,$o1,$o2); diff --git a/ext/spl/tests/SplObjectStorage/bug53071.phpt b/ext/spl/tests/SplObjectStorage/bug53071.phpt index e3bd5e1155b..0f0800d13ef 100644 --- a/ext/spl/tests/SplObjectStorage/bug53071.phpt +++ b/ext/spl/tests/SplObjectStorage/bug53071.phpt @@ -13,8 +13,8 @@ function LimitedScope() $myB = new SplObjectStorage(); $myC = new myClass(); $myC->member = $myA; // myC has a reference to myA - $myB->Attach($myC); // myB attaches myC - $myA->member = $myB; // myA has myB, comleting the cycle + $myB->offsetSet($myC); // myB attaches myC + $myA->member = $myB; // myA has myB, completing the cycle } LimitedScope(); var_dump(gc_collect_cycles()); diff --git a/ext/spl/tests/SplObjectStorage/bug67582.phpt b/ext/spl/tests/SplObjectStorage/bug67582.phpt index dc0cd532321..86a11e516ae 100644 --- a/ext/spl/tests/SplObjectStorage/bug67582.phpt +++ b/ext/spl/tests/SplObjectStorage/bug67582.phpt @@ -11,7 +11,7 @@ class MyObjectStorage extends SplObjectStorage { class TestObject {} $list = new MyObjectStorage(); -$list->attach(new TestObject()); +$list->offsetSet(new TestObject()); foreach($list as $x) var_dump($list->offsetExists($x)); diff --git a/ext/spl/tests/SplObjectStorage/bug69108.phpt b/ext/spl/tests/SplObjectStorage/bug69108.phpt index 3122da599c6..3579164791d 100644 --- a/ext/spl/tests/SplObjectStorage/bug69108.phpt +++ b/ext/spl/tests/SplObjectStorage/bug69108.phpt @@ -9,7 +9,7 @@ $b = new SplObjectStorage(); for ($i = 10000; $i > 0; $i--) { $object = new StdClass(); $a[] = $object; - $b->attach($object); + $b->offsetSet($object); } $c = serialize(array($a, $b)); diff --git a/ext/spl/tests/SplObjectStorage/bug69227.phpt b/ext/spl/tests/SplObjectStorage/bug69227.phpt index 812d8bafd8a..5a527d17df3 100644 --- a/ext/spl/tests/SplObjectStorage/bug69227.phpt +++ b/ext/spl/tests/SplObjectStorage/bug69227.phpt @@ -6,7 +6,7 @@ zend.enable_gc=1 attach($s); +$s->offsetSet($s); gc_collect_cycles(); echo "ok"; ?> diff --git a/ext/spl/tests/gh14639.phpt b/ext/spl/tests/SplObjectStorage/gh14639.phpt similarity index 94% rename from ext/spl/tests/gh14639.phpt rename to ext/spl/tests/SplObjectStorage/gh14639.phpt index 1b6f621d27b..41260855b25 100644 --- a/ext/spl/tests/gh14639.phpt +++ b/ext/spl/tests/SplObjectStorage/gh14639.phpt @@ -14,7 +14,7 @@ $b = new SplObjectStorage(); for ($i = 10000; $i > 0; $i--) { $object = new StdClass(); $object->a = str_repeat("a", 2); - $b->attach($object); + $b->offsetSet($object); } ?> --EXPECTF-- diff --git a/ext/spl/tests/observer_001.phpt b/ext/spl/tests/SplObjectStorage/observer_001.phpt similarity index 100% rename from ext/spl/tests/observer_001.phpt rename to ext/spl/tests/SplObjectStorage/observer_001.phpt diff --git a/ext/spl/tests/observer_002.phpt b/ext/spl/tests/SplObjectStorage/observer_002.phpt similarity index 96% rename from ext/spl/tests/observer_002.phpt rename to ext/spl/tests/SplObjectStorage/observer_002.phpt index 74bf3d4b930..227122b637d 100644 --- a/ext/spl/tests/observer_002.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_002.phpt @@ -70,13 +70,13 @@ class SubjectImpl implements SplSubject function attach(SplObserver $observer): void { echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $this->observers->attach($observer); + $this->observers->offsetSet($observer); } function detach(SplObserver $observer): void { echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $this->observers->detach($observer); + $this->observers->offsetUnset($observer); } function count(): int @@ -100,7 +100,7 @@ class SubjectImpl implements SplSubject function contains($obj) { - return $this->observers->contains($obj); + return $this->observers->offsetExists($obj); } } diff --git a/ext/spl/tests/observer_003.phpt b/ext/spl/tests/SplObjectStorage/observer_003.phpt similarity index 93% rename from ext/spl/tests/observer_003.phpt rename to ext/spl/tests/SplObjectStorage/observer_003.phpt index 36ead923365..7708c526f94 100644 --- a/ext/spl/tests/observer_003.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_003.phpt @@ -17,7 +17,7 @@ $storage = new SplObjectStorage(); foreach(array(1,"2","foo",true) as $value) { - $storage->attach(new TestClass($value)); + $storage->offsetSet(new TestClass($value)); } var_dump(count($storage)); diff --git a/ext/spl/tests/observer_004.phpt b/ext/spl/tests/SplObjectStorage/observer_004.phpt similarity index 97% rename from ext/spl/tests/observer_004.phpt rename to ext/spl/tests/SplObjectStorage/observer_004.phpt index b0b25ec117a..96d2e5b9999 100644 --- a/ext/spl/tests/observer_004.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_004.phpt @@ -27,7 +27,7 @@ $storage = new MyStorage(); foreach(array(1,2) as $value) { - $storage->attach(new TestClass($value)); + $storage->offsetSet(new TestClass($value)); } var_dump(count($storage)); diff --git a/ext/spl/tests/observer_005.phpt b/ext/spl/tests/SplObjectStorage/observer_005.phpt similarity index 97% rename from ext/spl/tests/observer_005.phpt rename to ext/spl/tests/SplObjectStorage/observer_005.phpt index 833b978d725..b5b3669b870 100644 --- a/ext/spl/tests/observer_005.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_005.phpt @@ -45,7 +45,7 @@ $storage = new MyStorage(1,2,3); foreach(array(array(4,5,6),array(7,8,9)) as $value) { - $storage->attach(new TestClass($value[0], $value[1], $value[2])); + $storage->offsetSet(new TestClass($value[0], $value[1], $value[2])); } var_dump(count($storage)); diff --git a/ext/spl/tests/observer_006.phpt b/ext/spl/tests/SplObjectStorage/observer_006.phpt similarity index 95% rename from ext/spl/tests/observer_006.phpt rename to ext/spl/tests/SplObjectStorage/observer_006.phpt index d1e53522797..afd40e9b122 100644 --- a/ext/spl/tests/observer_006.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_006.phpt @@ -27,7 +27,7 @@ $storage = new MyStorage(); foreach(array(1=>"foo",2=>42) as $key => $value) { - $storage->attach(new TestClass($key), $value); + $storage->offsetSet(new TestClass($key), $value); } var_dump(count($storage)); @@ -52,8 +52,8 @@ foreach($storage2 as $object) } var_dump($storage2); -$storage->attach(new TestClass(3), new stdClass); -$storage->attach(new TestClass(4), new TestClass(5)); +$storage->offsetSet(new TestClass(3), new stdClass); +$storage->offsetSet(new TestClass(4), new TestClass(5)); echo "===UNSERIALIZE2===\n"; var_dump(unserialize(serialize($storage))); $storage->rewind(); @@ -70,7 +70,7 @@ $storage->next(); $storage->next(); var_dump($storage->key()); var_dump($storage->current()); -$storage->attach($storage->current(), "replaced"); +$storage->offsetSet($storage->current(), "replaced"); echo "===UNSERIALIZE4===\n"; var_dump(unserialize(serialize($storage))); diff --git a/ext/spl/tests/observer_007.phpt b/ext/spl/tests/SplObjectStorage/observer_007.phpt similarity index 100% rename from ext/spl/tests/observer_007.phpt rename to ext/spl/tests/SplObjectStorage/observer_007.phpt diff --git a/ext/spl/tests/observer_008.phpt b/ext/spl/tests/SplObjectStorage/observer_008.phpt similarity index 71% rename from ext/spl/tests/observer_008.phpt rename to ext/spl/tests/SplObjectStorage/observer_008.phpt index 0f6f0d263b9..36769c57d52 100644 --- a/ext/spl/tests/observer_008.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_008.phpt @@ -9,24 +9,24 @@ $o2 = new StdClass; $o3 = new StdClass; $a = new A; -$a->attach($o1); -$a->attach($o2); +$a->offsetSet($o1); +$a->offsetSet($o2); $b = new SplObjectStorage(); -$b->attach($o2); -$b->attach($o3); +$b->offsetSet($o2); +$b->offsetSet($o3); -$a->addAll($b); +$a->offsetUnset($b); var_dump($a->count()); -$a->detach($o3); +$a->offsetUnset($o3); var_dump($a->count()); $a->removeAll($b); var_dump($a->count()); ?> --EXPECT-- -int(3) +int(2) int(2) int(1) diff --git a/ext/spl/tests/observer_009.phpt b/ext/spl/tests/SplObjectStorage/observer_009.phpt similarity index 87% rename from ext/spl/tests/observer_009.phpt rename to ext/spl/tests/SplObjectStorage/observer_009.phpt index 58f49980846..0b402c1d31e 100644 --- a/ext/spl/tests/observer_009.phpt +++ b/ext/spl/tests/SplObjectStorage/observer_009.phpt @@ -5,8 +5,8 @@ SPL: SplObjectStorage addAll/removeAll class Foo {} $storageA = new \SplObjectStorage(); -$storageA->attach(new \Foo); -$storageA->attach(new \Foo); +$storageA->offsetSet(new \Foo); +$storageA->offsetSet(new \Foo); echo ("Count storage A: " . count($storageA)); foreach ($storageA as $object) { diff --git a/ext/spl/tests/observer_010.phpt b/ext/spl/tests/SplObjectStorage/observer_010.phpt similarity index 100% rename from ext/spl/tests/observer_010.phpt rename to ext/spl/tests/SplObjectStorage/observer_010.phpt