Skip to content

Commit da802b6

Browse files
nicolas-grekasfabpot
authored andcommitted
Bump minimum version of PHP to 8.1
1 parent 5c32a49 commit da802b6

23 files changed

+23
-49
lines changed

Controller/ArgumentResolver/ServiceValueResolver.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
8484
}
8585

8686
$r = new \ReflectionProperty($e, 'message');
87-
$r->setAccessible(true);
8887
$r->setValue($e, $message);
8988

9089
throw $e;

EventListener/DebugHandlersListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $
5555
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
5656
restore_exception_handler();
5757

58-
$this->exceptionHandler = null === $exceptionHandler || $exceptionHandler instanceof \Closure ? $exceptionHandler : \Closure::fromCallable($exceptionHandler);
58+
$this->exceptionHandler = null === $exceptionHandler ? null : $exceptionHandler(...);
5959
$this->logger = $logger;
6060
$this->levels = $levels ?? \E_ALL;
6161
$this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null));

EventListener/ErrorListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public function onKernelException(ExceptionEvent $event)
9696
} while ($prev = $wrapper->getPrevious());
9797

9898
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
99-
$prev->setAccessible(true);
10099
$prev->setValue($wrapper, $throwable);
101100

102101
throw $e;
@@ -124,7 +123,7 @@ public function onControllerArguments(ControllerArgumentsEvent $event)
124123
return;
125124
}
126125

127-
$r = new \ReflectionFunction(\Closure::fromCallable($event->getController()));
126+
$r = new \ReflectionFunction($event->getController()(...));
128127
$r = $r->getParameters()[$k] ?? null;
129128

130129
if ($r && (!($r = $r->getType()) instanceof \ReflectionNamedType || \in_array($r->getName(), [FlattenException::class, LegacyFlattenException::class], true))) {

Exception/ControllerDoesNotReturnResponseException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function __construct(string $message, callable $controller, string $file,
2727
$this->file = $controllerDefinition['file'];
2828
$this->line = $controllerDefinition['line'];
2929
$r = new \ReflectionProperty(\Exception::class, 'trace');
30-
$r->setAccessible(true);
3130
$r->setValue($this, array_merge([
3231
[
3332
'line' => $line,

HttpCache/HttpCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct(HttpKernelInterface $kernel, StoreInterface $store,
8686
$this->surrogate = $surrogate;
8787

8888
// needed in case there is a fatal error because the backend is too slow to respond
89-
register_shutdown_function([$this->store, 'cleanup']);
89+
register_shutdown_function($this->store->cleanup(...));
9090

9191
$this->options = array_merge([
9292
'debug' => false,

Log/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(string $minLevel = null, $output = null, callable $f
6262
}
6363

6464
$this->minLevelIndex = self::LEVELS[$minLevel];
65-
$this->formatter = $formatter instanceof \Closure ? $formatter : \Closure::fromCallable($formatter ?? [$this, 'format']);
65+
$this->formatter = null !== $formatter ? $formatter(...) : $this->format(...);
6666
if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
6767
throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output));
6868
}

Tests/Controller/ArgumentResolver/BackedEnumValueResolverTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1919
use Symfony\Component\HttpKernel\Tests\Fixtures\Suit;
2020

21-
/**
22-
* @requires PHP 8.1
23-
*/
2421
class BackedEnumValueResolverTest extends TestCase
2522
{
2623
/**

Tests/Controller/ArgumentResolverTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ public function testGetArgumentWithoutArray()
186186
$request = Request::create('/');
187187
$request->attributes->set('foo', 'foo');
188188
$request->attributes->set('bar', 'foo');
189-
$controller = [$this, 'controllerWithFooAndDefaultBar'];
189+
$controller = $this->controllerWithFooAndDefaultBar(...);
190190
$resolver->getArguments($request, $controller);
191191
}
192192

193193
public function testIfExceptionIsThrownWhenMissingAnArgument()
194194
{
195195
$this->expectException(\RuntimeException::class);
196196
$request = Request::create('/');
197-
$controller = [$this, 'controllerWithFoo'];
197+
$controller = $this->controllerWithFoo(...);
198198

199199
self::$resolver->getArguments($request, $controller);
200200
}
@@ -224,7 +224,7 @@ public function testGetSessionArguments()
224224
$session = new Session(new MockArraySessionStorage());
225225
$request = Request::create('/');
226226
$request->setSession($session);
227-
$controller = [$this, 'controllerWithSession'];
227+
$controller = $this->controllerWithSession(...);
228228

229229
$this->assertEquals([$session], self::$resolver->getArguments($request, $controller));
230230
}
@@ -234,7 +234,7 @@ public function testGetSessionArgumentsWithExtendedSession()
234234
$session = new ExtendingSession(new MockArraySessionStorage());
235235
$request = Request::create('/');
236236
$request->setSession($session);
237-
$controller = [$this, 'controllerWithExtendingSession'];
237+
$controller = $this->controllerWithExtendingSession(...);
238238

239239
$this->assertEquals([$session], self::$resolver->getArguments($request, $controller));
240240
}
@@ -244,7 +244,7 @@ public function testGetSessionArgumentsWithInterface()
244244
$session = $this->createMock(SessionInterface::class);
245245
$request = Request::create('/');
246246
$request->setSession($session);
247-
$controller = [$this, 'controllerWithSessionInterface'];
247+
$controller = $this->controllerWithSessionInterface(...);
248248

249249
$this->assertEquals([$session], self::$resolver->getArguments($request, $controller));
250250
}
@@ -255,7 +255,7 @@ public function testGetSessionMissMatchWithInterface()
255255
$session = $this->createMock(SessionInterface::class);
256256
$request = Request::create('/');
257257
$request->setSession($session);
258-
$controller = [$this, 'controllerWithExtendingSession'];
258+
$controller = $this->controllerWithExtendingSession(...);
259259

260260
self::$resolver->getArguments($request, $controller);
261261
}
@@ -266,7 +266,7 @@ public function testGetSessionMissMatchWithImplementation()
266266
$session = new Session(new MockArraySessionStorage());
267267
$request = Request::create('/');
268268
$request->setSession($session);
269-
$controller = [$this, 'controllerWithExtendingSession'];
269+
$controller = $this->controllerWithExtendingSession(...);
270270

271271
self::$resolver->getArguments($request, $controller);
272272
}
@@ -275,7 +275,7 @@ public function testGetSessionMissMatchOnNull()
275275
{
276276
$this->expectException(\RuntimeException::class);
277277
$request = Request::create('/');
278-
$controller = [$this, 'controllerWithExtendingSession'];
278+
$controller = $this->controllerWithExtendingSession(...);
279279

280280
self::$resolver->getArguments($request, $controller);
281281
}

Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function testBasicTypesSignature()
109109

110110
public function testNamedClosure()
111111
{
112-
$arguments = $this->factory->createArgumentMetadata(\Closure::fromCallable([$this, 'signature1']));
112+
$arguments = $this->factory->createArgumentMetadata($this->signature1(...));
113113

114114
$this->assertEquals([
115115
new ArgumentMetadata('foo', self::class, false, false, null),

Tests/DataCollector/MemoryDataCollectorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function testBytesConversion($limit, $bytes)
3333
{
3434
$collector = new MemoryDataCollector();
3535
$method = new \ReflectionMethod($collector, 'convertToBytes');
36-
$method->setAccessible(true);
3736
$this->assertEquals($bytes, $method->invoke($collector, $limit));
3837
}
3938

0 commit comments

Comments
 (0)