Skip to content

Commit f3bb629

Browse files
committed
replace deprecated methods in 8.5
alternatives have been around since 5.3 Signed-off-by: Kent Rasmussen <kent@gplusmedia.com>
1 parent c4b556b commit f3bb629

5 files changed

Lines changed: 29 additions & 12 deletions

File tree

rector.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/benchmark',
10+
__DIR__ . '/src',
11+
__DIR__ . '/test',
12+
])
13+
// uncomment to reach your current PHP version
14+
->withPhpSets(php85: true)
15+
->withTypeCoverageLevel(0)
16+
->withDeadCodeLevel(0)
17+
->withCodeQualityLevel(0);

src/Storage/Adapter/AbstractAdapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ protected function triggerException($eventName, ArrayObject $args, mixed &$resul
259259
public function hasPlugin(Plugin\PluginInterface $plugin)
260260
{
261261
$registry = $this->getPluginRegistry();
262-
return $registry->contains($plugin);
262+
return $registry->offsetExists($plugin);
263263
}
264264

265265
/**
@@ -268,15 +268,15 @@ public function hasPlugin(Plugin\PluginInterface $plugin)
268268
public function addPlugin(Plugin\PluginInterface $plugin, $priority = 1)
269269
{
270270
$registry = $this->getPluginRegistry();
271-
if ($registry->contains($plugin)) {
271+
if ($registry->offsetExists($plugin)) {
272272
throw new Exception\LogicException(sprintf(
273273
'Plugin of type "%s" already registered',
274274
$plugin::class
275275
));
276276
}
277277

278278
$plugin->attach($this->getEventManager(), $priority);
279-
$registry->attach($plugin);
279+
$registry->offsetSet($plugin);
280280

281281
return $this;
282282
}
@@ -287,9 +287,9 @@ public function addPlugin(Plugin\PluginInterface $plugin, $priority = 1)
287287
public function removePlugin(Plugin\PluginInterface $plugin)
288288
{
289289
$registry = $this->getPluginRegistry();
290-
if ($registry->contains($plugin)) {
290+
if ($registry->offsetExists($plugin)) {
291291
$plugin->detach($this->getEventManager());
292-
$registry->detach($plugin);
292+
$registry->offsetUnset($plugin);
293293
}
294294
return $this;
295295
}

test/Pattern/CallbackCacheTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getCommonPatternNamesProvider(): array
5151
public function testCallEnabledCacheOutputByDefault(): void
5252
{
5353
$this->executeCallbackAndMakeAssertions(
54-
[TestCallbackCache::class, 'bar'],
54+
TestCallbackCache::bar(...),
5555
['testCallEnabledCacheOutputByDefault', 'arg2']
5656
);
5757
}
@@ -61,7 +61,7 @@ public function testCallDisabledCacheOutput(): void
6161
$options = $this->pattern->getOptions();
6262
$options->setCacheOutput(false);
6363
$this->executeCallbackAndMakeAssertions(
64-
[TestCallbackCache::class, 'bar'],
64+
TestCallbackCache::bar(...),
6565
['testCallDisabledCacheOutput', 'arg2']
6666
);
6767
}
@@ -76,7 +76,7 @@ public function testMagicFunctionCall(): void
7676

7777
public function testGenerateKey(): void
7878
{
79-
$callback = [TestCallbackCache::class, 'emptyMethod'];
79+
$callback = TestCallbackCache::emptyMethod(...);
8080
$args = ['arg1', 2, 3.33, null];
8181

8282
$generatedKey = $this->pattern->generateKey($callback, $args);

test/Pattern/TestAsset/FailableCallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
final class FailableCallback
1010
{
11-
public function __invoke()
11+
public function __invoke(): never
1212
{
1313
throw new Exception('This callback should either fail or never be invoked');
1414
}

test/Storage/Adapter/AbstractAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function testEventHandlingSimple(
423423
$storage
424424
->expects($this->once())
425425
->method($internalMethodName)
426-
->with(...array_map([$this, 'equalTo'], $methodArgs))
426+
->with(...array_map($this->equalTo(...), $methodArgs))
427427
->willReturn($retVal);
428428

429429
call_user_func_array([$storage, $methodName], $methodArgs);
@@ -463,7 +463,7 @@ public function testEventHandlingCatchException(
463463
$storage
464464
->expects($this->once())
465465
->method($internalMethodName)
466-
->with(...array_map([$this, 'equalTo'], $methodArgs))
466+
->with(...array_map($this->equalTo(...), $methodArgs))
467467
->willThrowException(new \Exception('test'));
468468

469469
call_user_func_array([$storage, $methodName], $methodArgs);
@@ -1100,7 +1100,7 @@ protected function checkPreEventCanChangeArguments(string $method, array $args,
11001100
foreach ($expectedArgs as $v) {
11011101
$equals[] = $this->equalTo($v);
11021102
}
1103-
call_user_func_array([$tmp, 'with'], $equals);
1103+
call_user_func_array($tmp->with(...), $equals);
11041104

11051105
// run
11061106
call_user_func_array([$storage, $method], $args);

0 commit comments

Comments
 (0)