Skip to content

Commit cb67fa3

Browse files
committed
Remove Reflection's setAccessible() method
This method is no-op since PHP 8.1. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent f2bdca0 commit cb67fa3

38 files changed

Lines changed: 0 additions & 321 deletions

psalm-baseline.xml

Lines changed: 0 additions & 205 deletions
Large diffs are not rendered by default.

test/classes/AbstractNetworkTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public function mockResponse(...$param): MockObject
8787
}
8888

8989
$attrInstance = new ReflectionProperty(ResponseRenderer::class, 'instance');
90-
$attrInstance->setAccessible(true);
9190
$attrInstance->setValue($mockResponse);
9291

9392
return $mockResponse;
@@ -100,8 +99,6 @@ protected function tearDown(): void
10099
{
101100
parent::tearDown();
102101
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
103-
$response->setAccessible(true);
104102
$response->setValue(null);
105-
$response->setAccessible(false);
106103
}
107104
}

test/classes/AbstractTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ protected function callFunction($object, string $className, string $methodName,
226226
{
227227
$class = new ReflectionClass($className);
228228
$method = $class->getMethod($methodName);
229-
$method->setAccessible(true);
230229

231230
return $method->invokeArgs($object, $params);
232231
}

test/classes/Config/FormDisplayTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public function testRegisterForm(): void
5555
$reflection = new ReflectionClass(FormDisplay::class);
5656

5757
$attrForms = $reflection->getProperty('forms');
58-
$attrForms->setAccessible(true);
5958

6059
$array = [
6160
'Servers' => [
@@ -71,7 +70,6 @@ public function testRegisterForm(): void
7170
$this->assertInstanceOf(Form::class, $_forms['pma_testform']);
7271

7372
$attrSystemPaths = $reflection->getProperty('systemPaths');
74-
$attrSystemPaths->setAccessible(true);
7573

7674
$this->assertEquals(
7775
[
@@ -82,7 +80,6 @@ public function testRegisterForm(): void
8280
);
8381

8482
$attrTranslatedPaths = $reflection->getProperty('translatedPaths');
85-
$attrTranslatedPaths->setAccessible(true);
8683

8784
$this->assertEquals(
8885
[
@@ -110,7 +107,6 @@ public function testProcess(): void
110107
->getMock();
111108

112109
$attrForms = new ReflectionProperty(FormDisplay::class, 'forms');
113-
$attrForms->setAccessible(true);
114110
$attrForms->setValue($this->object, [1, 2, 3]);
115111

116112
$this->object->expects($this->once())
@@ -137,11 +133,9 @@ public function testDisplayErrors(): void
137133
$reflection = new ReflectionClass(FormDisplay::class);
138134

139135
$attrIsValidated = $reflection->getProperty('isValidated');
140-
$attrIsValidated->setAccessible(true);
141136
$attrIsValidated->setValue($this->object, true);
142137

143138
$attrIsValidated = $reflection->getProperty('errors');
144-
$attrIsValidated->setAccessible(true);
145139
$attrIsValidated->setValue($this->object, []);
146140

147141
$result = $this->object->displayErrors();
@@ -159,7 +153,6 @@ public function testDisplayErrors(): void
159153
$sysArr = ['Servers/1/test' => 'Servers/1/test2'];
160154

161155
$attrSystemPaths = $reflection->getProperty('systemPaths');
162-
$attrSystemPaths->setAccessible(true);
163156
$attrSystemPaths->setValue($this->object, $sysArr);
164157

165158
$attrIsValidated->setValue($this->object, $arr);
@@ -181,11 +174,9 @@ public function testFixErrors(): void
181174
$reflection = new ReflectionClass(FormDisplay::class);
182175

183176
$attrIsValidated = $reflection->getProperty('isValidated');
184-
$attrIsValidated->setAccessible(true);
185177
$attrIsValidated->setValue($this->object, true);
186178

187179
$attrIsValidated = $reflection->getProperty('errors');
188-
$attrIsValidated->setAccessible(true);
189180
$attrIsValidated->setValue($this->object, []);
190181

191182
$this->object->fixErrors();
@@ -202,7 +193,6 @@ public function testFixErrors(): void
202193
$sysArr = ['Servers/1/test' => 'Servers/1/host'];
203194

204195
$attrSystemPaths = $reflection->getProperty('systemPaths');
205-
$attrSystemPaths->setAccessible(true);
206196
$attrSystemPaths->setValue($this->object, $sysArr);
207197

208198
$attrIsValidated->setValue($this->object, $arr);
@@ -225,7 +215,6 @@ public function testFixErrors(): void
225215
public function testValidateSelect(): void
226216
{
227217
$attrValidateSelect = new ReflectionMethod(FormDisplay::class, 'validateSelect');
228-
$attrValidateSelect->setAccessible(true);
229218

230219
$arr = ['foo' => 'var'];
231220
$value = 'foo';
@@ -286,7 +275,6 @@ public function testValidateSelect(): void
286275
public function testHasErrors(): void
287276
{
288277
$attrErrors = new ReflectionProperty(FormDisplay::class, 'errors');
289-
$attrErrors->setAccessible(true);
290278

291279
$this->assertFalse(
292280
$this->object->hasErrors()
@@ -333,7 +321,6 @@ public function testGetDocLink(): void
333321
public function testGetOptName(): void
334322
{
335323
$method = new ReflectionMethod(FormDisplay::class, 'getOptName');
336-
$method->setAccessible(true);
337324

338325
$this->assertEquals(
339326
'Servers_',
@@ -352,11 +339,9 @@ public function testGetOptName(): void
352339
public function testLoadUserprefsInfo(): void
353340
{
354341
$method = new ReflectionMethod(FormDisplay::class, 'loadUserprefsInfo');
355-
$method->setAccessible(true);
356342

357343
$attrUserprefs = new ReflectionProperty(FormDisplay::class, 'userprefsDisallow');
358344

359-
$attrUserprefs->setAccessible(true);
360345
$method->invoke($this->object, null);
361346
$this->assertEquals(
362347
[],
@@ -370,7 +355,6 @@ public function testLoadUserprefsInfo(): void
370355
public function testSetComments(): void
371356
{
372357
$method = new ReflectionMethod(FormDisplay::class, 'setComments');
373-
$method->setAccessible(true);
374358

375359
// recoding
376360
$opts = ['values' => []];

test/classes/Config/FormTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function testContructor(): void
6868
public function testGetOptionType(): void
6969
{
7070
$attrFieldsTypes = new ReflectionProperty(Form::class, 'fieldsTypes');
71-
$attrFieldsTypes->setAccessible(true);
7271
$attrFieldsTypes->setValue(
7372
$this->object,
7473
['7' => 'Seven']
@@ -124,7 +123,6 @@ public function testReadFormPathsCallBack(): void
124123
{
125124
$reflection = new ReflectionClass(Form::class);
126125
$method = $reflection->getMethod('readFormPathsCallback');
127-
$method->setAccessible(true);
128126

129127
$array = [
130128
'foo' => [
@@ -160,7 +158,6 @@ public function testReadFormPaths(): void
160158
{
161159
$reflection = new ReflectionClass(Form::class);
162160
$method = $reflection->getMethod('readFormPaths');
163-
$method->setAccessible(true);
164161

165162
$array = [
166163
'foo' => [
@@ -200,7 +197,6 @@ public function testReadTypes(): void
200197
{
201198
$reflection = new ReflectionClass(Form::class);
202199
$method = $reflection->getMethod('readTypes');
203-
$method->setAccessible(true);
204200

205201
$this->object->fields = [
206202
'pma_form1' => 'Servers/1/port',
@@ -210,7 +206,6 @@ public function testReadTypes(): void
210206
];
211207

212208
$attrFieldsTypes = $reflection->getProperty('fieldsTypes');
213-
$attrFieldsTypes->setAccessible(true);
214209

215210
$method->invoke($this->object, null);
216211

test/classes/Config/ServerConfigChecksTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ protected function setUp(): void
3939
$GLOBALS['ConfigFile'] = $cf;
4040

4141
$reflection = new ReflectionProperty(ConfigFile::class, 'id');
42-
$reflection->setAccessible(true);
4342
$this->sessionID = $reflection->getValue($cf);
4443

4544
unset($_SESSION['messages']);

test/classes/Controllers/Database/Structure/FavoriteTableControllerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function testSynchronizeFavoriteTables(): void
5151

5252
$class = new ReflectionClass(FavoriteTableController::class);
5353
$method = $class->getMethod('synchronizeFavoriteTables');
54-
$method->setAccessible(true);
5554

5655
$controller = new FavoriteTableController(
5756
new ResponseStub(),

test/classes/Controllers/Database/StructureControllerTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function testGetValuesForInnodbTable(): void
7777
{
7878
$class = new ReflectionClass(StructureController::class);
7979
$method = $class->getMethod('getValuesForInnodbTable');
80-
$method->setAccessible(true);
8180
$controller = new StructureController(
8281
$this->response,
8382
$this->template,
@@ -87,7 +86,6 @@ public function testGetValuesForInnodbTable(): void
8786
);
8887
// Showing statistics
8988
$property = $class->getProperty('isShowStats');
90-
$property->setAccessible(true);
9189
$property->setValue($controller, true);
9290

9391
$GLOBALS['cfg']['MaxExactCount'] = 10;
@@ -148,7 +146,6 @@ public function testGetValuesForAriaTable(): void
148146
{
149147
$class = new ReflectionClass(StructureController::class);
150148
$method = $class->getMethod('getValuesForAriaTable');
151-
$method->setAccessible(true);
152149

153150
$controller = new StructureController(
154151
$this->response,
@@ -159,10 +156,8 @@ public function testGetValuesForAriaTable(): void
159156
);
160157
// Showing statistics
161158
$property = $class->getProperty('isShowStats');
162-
$property->setAccessible(true);
163159
$property->setValue($controller, true);
164160
$property = $class->getProperty('dbIsSystemSchema');
165-
$property->setAccessible(true);
166161
$property->setValue($controller, true);
167162

168163
$currentTable = [
@@ -252,7 +247,6 @@ public function testHasTable(): void
252247
{
253248
$class = new ReflectionClass(StructureController::class);
254249
$method = $class->getMethod('hasTable');
255-
$method->setAccessible(true);
256250

257251
$controller = new StructureController(
258252
$this->response,
@@ -287,7 +281,6 @@ public function testCheckFavoriteTable(): void
287281
{
288282
$class = new ReflectionClass(StructureController::class);
289283
$method = $class->getMethod('checkFavoriteTable');
290-
$method->setAccessible(true);
291284

292285
$controller = new StructureController(
293286
$this->response,
@@ -320,7 +313,6 @@ public function testDisplayTableList(): void
320313
{
321314
$class = new ReflectionClass(StructureController::class);
322315
$method = $class->getMethod('displayTableList');
323-
$method->setAccessible(true);
324316

325317
$controller = new StructureController(
326318
$this->response,
@@ -332,14 +324,11 @@ public function testDisplayTableList(): void
332324
// Showing statistics
333325
$class = new ReflectionClass(StructureController::class);
334326
$showStatsProperty = $class->getProperty('isShowStats');
335-
$showStatsProperty->setAccessible(true);
336327
$showStatsProperty->setValue($controller, true);
337328

338329
$tablesProperty = $class->getProperty('tables');
339-
$tablesProperty->setAccessible(true);
340330

341331
$numTables = $class->getProperty('numTables');
342-
$numTables->setAccessible(true);
343332
$numTables->setValue($controller, 1);
344333

345334
//no tables

test/classes/Controllers/Server/VariablesControllerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public function testFormatVariable(): void
154154
->willReturnOnConsecutiveCalls('byte', 'string');
155155

156156
$response = new ReflectionProperty(ServerVariablesProvider::class, 'instance');
157-
$response->setAccessible(true);
158157
$response->setValue($voidProviderMock);
159158

160159
[$formattedValue, $isHtmlFormatted] = $this->callFunction(
@@ -206,7 +205,6 @@ public function testFormatVariableMariaDbMySqlKbs(): void
206205
}
207206

208207
$response = new ReflectionProperty(ServerVariablesProvider::class, 'instance');
209-
$response->setAccessible(true);
210208
$response->setValue(null);
211209

212210
$controller = new VariablesController(ResponseRenderer::getInstance(), new Template(), $GLOBALS['dbi']);
@@ -265,7 +263,6 @@ public function testFormatVariableMariaDbMySqlKbs(): void
265263
public function testFormatVariableVoidProvider(): void
266264
{
267265
$response = new ReflectionProperty(ServerVariablesProvider::class, 'instance');
268-
$response->setAccessible(true);
269266
$response->setValue(new ServerVariablesVoidProvider());
270267

271268
$controller = new VariablesController(ResponseRenderer::getInstance(), new Template(), $GLOBALS['dbi']);

test/classes/Controllers/Table/IndexesControllerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public function testDisplayFormAction(): void
102102
$template = new Template();
103103

104104
$method = new ReflectionMethod(IndexesController::class, 'displayForm');
105-
$method->setAccessible(true);
106105

107106
$ctrl = new IndexesController(
108107
$response,

0 commit comments

Comments
 (0)