Skip to content

Commit 539c669

Browse files
Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
1 parent 9ca1108 commit 539c669

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [4.0.6] - 2025-08-10
6+
7+
### Changed
8+
9+
* Do not use `SplObjectStorage` methods that will be deprecated in PHP 8.5
10+
511
## [4.0.5] - 2023-02-03
612

713
### Fixed
@@ -33,6 +39,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
3339

3440
* Tests etc. are now ignored for archive exports
3541

42+
[4.0.6]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.5...4.0.6
3643
[4.0.5]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.4...4.0.5
3744
[4.0.4]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.3...4.0.4
3845
[4.0.3]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.2...4.0.3

src/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ private function addArray(array &$array)
158158
*/
159159
private function addObject($object): string
160160
{
161-
if (!$this->objects->contains($object)) {
162-
$this->objects->attach($object);
161+
if (!$this->objects->offsetExists($object)) {
162+
$this->objects->offsetSet($object);
163163
}
164164

165165
return spl_object_hash($object);
@@ -182,7 +182,7 @@ private function containsArray(array &$array)
182182
*/
183183
private function containsObject($value)
184184
{
185-
if ($this->objects->contains($value)) {
185+
if ($this->objects->offsetExists($value)) {
186186
return spl_object_hash($value);
187187
}
188188

tests/ContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function valuesProvider(): array
6868
$obj->self = $obj;
6969

7070
$storage = new SplObjectStorage;
71-
$storage->attach($obj2);
71+
$storage->offsetSet($obj2);
7272

7373
return [
7474
[$obj, spl_object_hash($obj)],

0 commit comments

Comments
 (0)