diff --git a/Session/Session.php b/Session/Session.php index 6c1d3a23b..4e17e7efc 100644 --- a/Session/Session.php +++ b/Session/Session.php @@ -43,7 +43,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, callable $usageReporter = null) { $this->storage = $storage ?? new NativeSessionStorage(); - $this->usageReporter = $usageReporter instanceof \Closure || !\is_callable($usageReporter) ? $usageReporter : \Closure::fromCallable($usageReporter); + $this->usageReporter = null === $usageReporter ? null : $usageReporter(...); $attributes ??= new AttributeBag(); $this->attributeName = $attributes->getName(); diff --git a/Session/SessionBagProxy.php b/Session/SessionBagProxy.php index a5bdc92c9..76dfed724 100644 --- a/Session/SessionBagProxy.php +++ b/Session/SessionBagProxy.php @@ -28,7 +28,7 @@ public function __construct(SessionBagInterface $bag, array &$data, ?int &$usage $this->bag = $bag; $this->data = &$data; $this->usageIndex = &$usageIndex; - $this->usageReporter = $usageReporter instanceof \Closure || !\is_callable($usageReporter) ? $usageReporter : \Closure::fromCallable($usageReporter); + $this->usageReporter = null === $usageReporter ? null : $usageReporter(...); } public function getBag(): SessionBagInterface diff --git a/Session/SessionFactory.php b/Session/SessionFactory.php index 098bc1ce0..cdb6af51e 100644 --- a/Session/SessionFactory.php +++ b/Session/SessionFactory.php @@ -30,7 +30,7 @@ public function __construct(RequestStack $requestStack, SessionStorageFactoryInt { $this->requestStack = $requestStack; $this->storageFactory = $storageFactory; - $this->usageReporter = $usageReporter instanceof \Closure || !\is_callable($usageReporter) ? $usageReporter : \Closure::fromCallable($usageReporter); + $this->usageReporter = null === $usageReporter ? null : $usageReporter(...); } public function createSession(): SessionInterface diff --git a/Tests/BinaryFileResponseTest.php b/Tests/BinaryFileResponseTest.php index 45d5afad8..a9999c988 100644 --- a/Tests/BinaryFileResponseTest.php +++ b/Tests/BinaryFileResponseTest.php @@ -310,7 +310,6 @@ public function testXAccelMapping($realpath, $mapping, $virtual) $response = new BinaryFileResponse($file, 200, ['Content-Type' => 'application/octet-stream']); $reflection = new \ReflectionObject($response); $property = $reflection->getProperty('file'); - $property->setAccessible(true); $property->setValue($response, $file); $response->prepare($request); diff --git a/Tests/RequestTest.php b/Tests/RequestTest.php index 6151377ac..32e19ee52 100644 --- a/Tests/RequestTest.php +++ b/Tests/RequestTest.php @@ -1838,7 +1838,6 @@ public function testUrlencodedStringPrefix($string, $prefix, $expect) $request = new Request(); $me = new \ReflectionMethod($request, 'getUrlencodedPrefix'); - $me->setAccessible(true); $this->assertSame($expect, $me->invoke($request, $string, $prefix)); } @@ -1861,7 +1860,6 @@ private function disableHttpMethodParameterOverride() { $class = new \ReflectionClass(Request::class); $property = $class->getProperty('httpMethodParameterOverride'); - $property->setAccessible(true); $property->setValue(false); } diff --git a/Tests/ResponseTest.php b/Tests/ResponseTest.php index dc4a395c1..8822dd261 100644 --- a/Tests/ResponseTest.php +++ b/Tests/ResponseTest.php @@ -832,7 +832,6 @@ public function testSetStatusCode($code, $text, $expectedText) $response->setStatusCode($code, $text); $statusText = new \ReflectionProperty($response, 'statusText'); - $statusText->setAccessible(true); $this->assertEquals($expectedText, $statusText->getValue($response)); } diff --git a/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index d404b74c6..d535989e6 100644 --- a/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -142,7 +142,6 @@ public function getOptionFixtures() public function testGetConnection() { $method = new \ReflectionMethod($this->storage, 'getMemcached'); - $method->setAccessible(true); $this->assertInstanceOf(\Memcached::class, $method->invoke($this->storage)); } diff --git a/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index a96fcc42a..2aa3e4007 100644 --- a/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -198,7 +198,6 @@ public function testGc() public function testGetConnection() { $method = new \ReflectionMethod($this->storage, 'getMongo'); - $method->setAccessible(true); $this->assertInstanceOf(Client::class, $method->invoke($this->storage)); } diff --git a/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index d067bf862..f9b42c7cc 100644 --- a/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -296,7 +296,6 @@ public function testGetConnection() $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); $this->assertInstanceOf(\PDO::class, $method->invoke($storage)); } @@ -306,7 +305,6 @@ public function testGetConnectionConnectsIfNeeded() $storage = new PdoSessionHandler('sqlite::memory:'); $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); $this->assertInstanceOf(\PDO::class, $method->invoke($storage)); } @@ -324,7 +322,6 @@ public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPa continue; } $property = $reflection->getProperty($property); - $property->setAccessible(true); $this->assertSame($expectedValue, $property->getValue($storage)); } } diff --git a/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php b/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php index 8ec2be4b1..74f7ebb8d 100644 --- a/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php +++ b/Tests/Session/Storage/Handler/SessionHandlerFactoryTest.php @@ -67,11 +67,9 @@ public function testCreateRedisHandlerFromDsn() $reflection = new \ReflectionObject($handler); $prefixProperty = $reflection->getProperty('prefix'); - $prefixProperty->setAccessible(true); $this->assertSame('foo', $prefixProperty->getValue($handler)); $ttlProperty = $reflection->getProperty('ttl'); - $ttlProperty->setAccessible(true); $this->assertSame(3600, $ttlProperty->getValue($handler)); } } diff --git a/composer.json b/composer.json index 9f5cccc65..8df36aa4d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.1" },