Skip to content

Commit 641ef4a

Browse files
bug #61402 Remove calls to deprecated methods of SplObjectStorage (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- Remove calls to deprecated methods of SplObjectStorage | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Commits ------- a038d69 Remove deprecated calls to deprecated methods of SplObjectStorage
2 parents e5772a9 + a038d69 commit 641ef4a

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed

src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private function sendToElasticsearch(array $records): void
144144
],
145145
]);
146146

147-
$this->responses->attach($response);
147+
$this->responses[$response] = null;
148148

149149
$this->wait(false);
150150
}
@@ -178,10 +178,10 @@ private function wait(bool $blocking): void
178178
continue;
179179
}
180180
if ($chunk->isLast()) {
181-
$this->responses->detach($response);
181+
unset($this->responses[$response]);
182182
}
183183
} catch (ExceptionInterface $e) {
184-
$this->responses->detach($response);
184+
unset($this->responses[$response]);
185185
error_log(\sprintf("Could not push logs to Elasticsearch:\n%s", (string) $e));
186186
}
187187
}

src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function setUp(): void
3636
];
3737

3838
$transitionsMetadata = new \SplObjectStorage();
39-
$transitionsMetadata->attach($this->t1, ['title' => 't1 title']);
39+
$transitionsMetadata[$this->t1] = ['title' => 't1 title'];
4040
$metadataStore = new InMemoryMetadataStore(
4141
['title' => 'workflow title'],
4242
['orderer' => ['title' => 'ordered title']],

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ private function addServiceConfigurator(Definition $definition, string $variable
814814

815815
if (\is_array($callable)) {
816816
if ($callable[0] instanceof Reference
817-
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
817+
|| ($callable[0] instanceof Definition && $this->definitionVariables->offsetExists($callable[0]))
818818
) {
819819
return \sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
820820
}
@@ -1205,15 +1205,15 @@ private function addNewInstance(Definition $definition, string $return = '', ?st
12051205

12061206
if (['...'] === $arguments && ('Closure' !== ($class = $definition->getClass() ?: 'Closure') || $definition->isLazy() && (
12071207
$callable[0] instanceof Reference
1208-
|| ($callable[0] instanceof Definition && !$this->definitionVariables->contains($callable[0]))
1208+
|| ($callable[0] instanceof Definition && !$this->definitionVariables->offsetExists($callable[0]))
12091209
))) {
12101210
$initializer = 'fn () => '.$this->dumpValue($callable[0]);
12111211

12121212
return $return.LazyClosure::getCode($initializer, $callable, $class, $this->container, $id).$tail;
12131213
}
12141214

12151215
if ($callable[0] instanceof Reference
1216-
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
1216+
|| ($callable[0] instanceof Definition && $this->definitionVariables->offsetExists($callable[0]))
12171217
) {
12181218
return $return.\sprintf('%s->%s(%s)', $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '').$tail;
12191219
}
@@ -1920,7 +1920,7 @@ private function dumpValue(mixed $value, bool $interpolate = true): string
19201920
if ($value->hasErrors() && $e = $value->getErrors()) {
19211921
return \sprintf('throw new RuntimeException(%s)', $this->export(reset($e)));
19221922
}
1923-
if ($this->definitionVariables?->contains($value)) {
1923+
if ($this->definitionVariables?->offsetExists($value)) {
19241924
return $this->dumpValue($this->definitionVariables[$value], $interpolate);
19251925
}
19261926
if ($value->getMethodCalls()) {

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private function preProcess(string $eventName): void
279279
$this->wrappedListeners[$eventName][] = $wrappedListener;
280280
$this->dispatcher->removeListener($eventName, $listener);
281281
$this->dispatcher->addListener($eventName, $wrappedListener, $priority);
282-
$this->callStack->attach($wrappedListener, [$eventName, $this->currentRequestHash]);
282+
$this->callStack[$wrappedListener] = [$eventName, $this->currentRequestHash];
283283
}
284284
}
285285

@@ -303,7 +303,7 @@ private function postProcess(string $eventName): void
303303
if ($listener->wasCalled()) {
304304
$this->logger?->debug('Notified event "{event}" to listener "{listener}".', $context);
305305
} else {
306-
$this->callStack->detach($listener);
306+
unset($this->callStack[$listener]);
307307
}
308308

309309
if (null !== $this->logger && $skipped) {

src/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
4040
$this->data['redirect'] = true;
4141
$this->data['url'] = $response->getTargetUrl();
4242

43-
if ($this->controllers->contains($request)) {
43+
if ($this->controllers->offsetExists($request)) {
4444
$this->data['route'] = $this->guessRoute($request, $this->controllers[$request]);
4545
}
4646
}

src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function getNextTransport(): ?TransportInterface
8686
}
8787

8888
if ((microtime(true) - $this->deadTransports[$transport]) > $this->retryPeriod) {
89-
$this->deadTransports->detach($transport);
89+
unset($this->deadTransports[$transport]);
9090

9191
break;
9292
}
@@ -103,7 +103,7 @@ protected function getNextTransport(): ?TransportInterface
103103

104104
protected function isTransportDead(TransportInterface $transport): bool
105105
{
106-
return $this->deadTransports->contains($transport);
106+
return $this->deadTransports->offsetExists($transport);
107107
}
108108

109109
protected function getInitialCursor(): int

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ public function dispatch(object $message, array $stamps = []): Envelope
619619
$unacks = $unacksProperty->getValue($worker);
620620
$dummyHandler = new DummyBatchHandler();
621621
$envelopeWithNoAutoAck = $envelope->with(new NoAutoAckStamp(new HandlerDescriptor($dummyHandler)));
622-
$unacks->attach($dummyHandler, [$envelopeWithNoAutoAck, 'transport']);
622+
$unacks[$dummyHandler] = [$envelopeWithNoAutoAck, 'transport'];
623623

624624
$worker->run();
625625

src/Symfony/Component/Notifier/Transport/RoundRobinTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function getNextTransport(MessageInterface $message): ?TransportInterf
103103
}
104104

105105
if ((microtime(true) - $this->deadTransports[$transport]) > $this->retryPeriod) {
106-
$this->deadTransports->detach($transport);
106+
unset($this->deadTransports[$transport]);
107107

108108
break;
109109
}
@@ -120,7 +120,7 @@ protected function getNextTransport(MessageInterface $message): ?TransportInterf
120120

121121
protected function isTransportDead(TransportInterface $transport): bool
122122
{
123-
return $this->deadTransports->contains($transport);
123+
return $this->deadTransports->offsetExists($transport);
124124
}
125125

126126
protected function getInitialCursor(): int

src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static function provideCastSplDoublyLinkedList()
148148
public function testCastObjectStorageIsntModified()
149149
{
150150
$var = new \SplObjectStorage();
151-
$var->attach(new \stdClass());
151+
$var[new \stdClass()] = null;
152152
$var->rewind();
153153
$current = $var->current();
154154

@@ -159,7 +159,7 @@ public function testCastObjectStorageIsntModified()
159159
public function testCastObjectStorageDumpsInfo()
160160
{
161161
$var = new \SplObjectStorage();
162-
$var->attach(new \stdClass(), new \DateTimeImmutable());
162+
$var[new \stdClass()] = new \DateTimeImmutable();
163163

164164
$this->assertDumpMatchesFormat('%ADateTimeImmutable%A', $var);
165165
}

src/Symfony/Component/VarExporter/Internal/Hydrator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function getHydrator($class)
8686
if ("\0" === $name) {
8787
foreach ($values as $i => $v) {
8888
for ($j = 0; $j < \count($v); ++$j) {
89-
$objects[$i]->attach($v[$j], $v[++$j]);
89+
$objects[$i][$v[$j]] = $v[++$j];
9090
}
9191
}
9292
continue;
@@ -194,7 +194,7 @@ public static function getSimpleHydrator($class)
194194
continue;
195195
}
196196
for ($i = 0; $i < \count($value); ++$i) {
197-
$object->attach($value[$i], $value[++$i]);
197+
$object[$value[$i]] = $value[++$i];
198198
}
199199
}
200200
};

0 commit comments

Comments
 (0)