Skip to content

Commit 912fc74

Browse files
committed
Reflection method setAccessible is useless
As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default. https://www.php.net/manual/en/reflectionproperty.setaccessible.php
1 parent 355779b commit 912fc74

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

tests/GridFS/BucketFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,6 @@ public function testResolveStreamContextForRead(): void
951951
fclose($stream);
952952

953953
$method = new ReflectionMethod($this->bucket, 'resolveStreamContext');
954-
$method->setAccessible(true);
955-
956954
$context = $method->invokeArgs($this->bucket, ['gridfs://bucket/filename', 'rb', []]);
957955

958956
$this->assertIsArray($context);
@@ -967,8 +965,6 @@ public function testResolveStreamContextForRead(): void
967965
public function testResolveStreamContextForWrite(): void
968966
{
969967
$method = new ReflectionMethod($this->bucket, 'resolveStreamContext');
970-
$method->setAccessible(true);
971-
972968
$context = $method->invokeArgs($this->bucket, ['gridfs://bucket/filename', 'wb', []]);
973969

974970
$this->assertIsArray($context);

tests/Operation/WatchFunctionalTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,7 @@ public function testInitialCursorIsNotClosed(): void
724724
$this->assertNotEquals('0', (string) $changeStream->getCursorId(true));
725725

726726
$rc = new ReflectionClass(ChangeStream::class);
727-
$rp = $rc->getProperty('iterator');
728-
$rp->setAccessible(true);
729-
730-
$iterator = $rp->getValue($changeStream);
727+
$iterator = $rc->getProperty('iterator')->getValue($changeStream);
731728

732729
$this->assertInstanceOf('IteratorIterator', $iterator);
733730

@@ -1225,7 +1222,6 @@ public function testSessionFreed(): void
12251222

12261223
$rc = new ReflectionClass($changeStream);
12271224
$rp = $rc->getProperty('resumeCallable');
1228-
$rp->setAccessible(true);
12291225

12301226
$this->assertIsCallable($rp->getValue($changeStream));
12311227

0 commit comments

Comments
 (0)