Skip to content

Commit 116c19d

Browse files
Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
1 parent bd861af commit 116c19d

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

ChangeLog-8.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil
77
### Changed
88

99
* Do not use `ReflectionProperty::setAccessible()` with PHP >= 8.1
10+
* Do not use `SplObjectStorage` methods that will be deprecated in PHP 8.5
1011

1112
## [8.5.42] - 2025-05-02
1213

src/Framework/Constraint/TraversableContains.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function toString(): string
7070
protected function matches($other): bool
7171
{
7272
if ($other instanceof SplObjectStorage) {
73-
return $other->contains($this->value);
73+
return $other->offsetExists($this->value);
7474
}
7575

7676
if (is_object($this->value)) {

tests/unit/Framework/AssertTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,9 +2459,9 @@ protected function notEqualValues(): array
24592459
$object2 = new SampleClass(16, 23, 42);
24602460
$object3 = new SampleClass(4, 8, 15);
24612461
$storage1 = new SplObjectStorage;
2462-
$storage1->attach($object1);
2462+
$storage1->offsetSet($object1);
24632463
$storage2 = new SplObjectStorage;
2464-
$storage2->attach($object3); // same content, different object
2464+
$storage2->offsetSet($object3); // same content, different object
24652465

24662466
$file = TEST_FILES_PATH . 'foo.xml';
24672467

@@ -2600,9 +2600,9 @@ protected function equalValues(): array
26002600
$object1 = new SampleClass(4, 8, 15);
26012601
$object2 = new SampleClass(4, 8, 15);
26022602
$storage1 = new SplObjectStorage;
2603-
$storage1->attach($object1);
2603+
$storage1->offsetSet($object1);
26042604
$storage2 = new SplObjectStorage;
2605-
$storage2->attach($object1);
2605+
$storage2->offsetSet($object1);
26062606

26072607
return [
26082608
// arrays

tests/unit/Framework/Constraint/IsEqualTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ public function isEqualProvider(): array
105105
$d->c = $c;
106106

107107
$storage1 = new SplObjectStorage;
108-
$storage1->attach($a);
109-
$storage1->attach($b);
108+
$storage1->offsetSet($a);
109+
$storage1->offsetSet($b);
110110
$storage2 = new SplObjectStorage;
111-
$storage2->attach($b);
111+
$storage2->offsetSet($b);
112112
$storage1hash = spl_object_hash($storage1);
113113
$storage2hash = spl_object_hash($storage2);
114114

tests/unit/Framework/Constraint/TraversableContainsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testConstraintTraversableToStringMethodsWithSplObjectStorage():
153153
$storage = new SplObjectStorage;
154154
$this->assertFalse($constraint->evaluate($storage, '', true));
155155

156-
$storage->attach($object);
156+
$storage->offsetSet($object);
157157
$this->assertTrue($constraint->evaluate($storage, '', true));
158158
}
159159

0 commit comments

Comments
 (0)