Skip to content

Commit

Permalink
Remove Reflection's setAccessible() method
Browse files Browse the repository at this point in the history
This method is no-op since PHP 8.1.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 21, 2023
1 parent f2bdca0 commit cb67fa3
Show file tree
Hide file tree
Showing 38 changed files with 0 additions and 321 deletions.
205 changes: 0 additions & 205 deletions psalm-baseline.xml

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions test/classes/AbstractNetworkTestCase.php
Expand Up @@ -87,7 +87,6 @@ public function mockResponse(...$param): MockObject
}

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

return $mockResponse;
Expand All @@ -100,8 +99,6 @@ protected function tearDown(): void
{
parent::tearDown();
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
$response->setAccessible(true);
$response->setValue(null);
$response->setAccessible(false);
}
}
1 change: 0 additions & 1 deletion test/classes/AbstractTestCase.php
Expand Up @@ -226,7 +226,6 @@ protected function callFunction($object, string $className, string $methodName,
{
$class = new ReflectionClass($className);
$method = $class->getMethod($methodName);
$method->setAccessible(true);

return $method->invokeArgs($object, $params);
}
Expand Down
16 changes: 0 additions & 16 deletions test/classes/Config/FormDisplayTest.php
Expand Up @@ -55,7 +55,6 @@ public function testRegisterForm(): void
$reflection = new ReflectionClass(FormDisplay::class);

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

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

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

$this->assertEquals(
[
Expand All @@ -82,7 +80,6 @@ public function testRegisterForm(): void
);

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

$this->assertEquals(
[
Expand Down Expand Up @@ -110,7 +107,6 @@ public function testProcess(): void
->getMock();

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

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

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

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

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

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

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

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

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

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

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

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

$arr = ['foo' => 'var'];
$value = 'foo';
Expand Down Expand Up @@ -286,7 +275,6 @@ public function testValidateSelect(): void
public function testHasErrors(): void
{
$attrErrors = new ReflectionProperty(FormDisplay::class, 'errors');
$attrErrors->setAccessible(true);

$this->assertFalse(
$this->object->hasErrors()
Expand Down Expand Up @@ -333,7 +321,6 @@ public function testGetDocLink(): void
public function testGetOptName(): void
{
$method = new ReflectionMethod(FormDisplay::class, 'getOptName');
$method->setAccessible(true);

$this->assertEquals(
'Servers_',
Expand All @@ -352,11 +339,9 @@ public function testGetOptName(): void
public function testLoadUserprefsInfo(): void
{
$method = new ReflectionMethod(FormDisplay::class, 'loadUserprefsInfo');
$method->setAccessible(true);

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

$attrUserprefs->setAccessible(true);
$method->invoke($this->object, null);
$this->assertEquals(
[],
Expand All @@ -370,7 +355,6 @@ public function testLoadUserprefsInfo(): void
public function testSetComments(): void
{
$method = new ReflectionMethod(FormDisplay::class, 'setComments');
$method->setAccessible(true);

// recoding
$opts = ['values' => []];
Expand Down
5 changes: 0 additions & 5 deletions test/classes/Config/FormTest.php
Expand Up @@ -68,7 +68,6 @@ public function testContructor(): void
public function testGetOptionType(): void
{
$attrFieldsTypes = new ReflectionProperty(Form::class, 'fieldsTypes');
$attrFieldsTypes->setAccessible(true);
$attrFieldsTypes->setValue(
$this->object,
['7' => 'Seven']
Expand Down Expand Up @@ -124,7 +123,6 @@ public function testReadFormPathsCallBack(): void
{
$reflection = new ReflectionClass(Form::class);
$method = $reflection->getMethod('readFormPathsCallback');
$method->setAccessible(true);

$array = [
'foo' => [
Expand Down Expand Up @@ -160,7 +158,6 @@ public function testReadFormPaths(): void
{
$reflection = new ReflectionClass(Form::class);
$method = $reflection->getMethod('readFormPaths');
$method->setAccessible(true);

$array = [
'foo' => [
Expand Down Expand Up @@ -200,7 +197,6 @@ public function testReadTypes(): void
{
$reflection = new ReflectionClass(Form::class);
$method = $reflection->getMethod('readTypes');
$method->setAccessible(true);

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

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

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

Expand Down
1 change: 0 additions & 1 deletion test/classes/Config/ServerConfigChecksTest.php
Expand Up @@ -39,7 +39,6 @@ protected function setUp(): void
$GLOBALS['ConfigFile'] = $cf;

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

unset($_SESSION['messages']);
Expand Down
Expand Up @@ -51,7 +51,6 @@ public function testSynchronizeFavoriteTables(): void

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

$controller = new FavoriteTableController(
new ResponseStub(),
Expand Down
11 changes: 0 additions & 11 deletions test/classes/Controllers/Database/StructureControllerTest.php
Expand Up @@ -77,7 +77,6 @@ public function testGetValuesForInnodbTable(): void
{
$class = new ReflectionClass(StructureController::class);
$method = $class->getMethod('getValuesForInnodbTable');
$method->setAccessible(true);
$controller = new StructureController(
$this->response,
$this->template,
Expand All @@ -87,7 +86,6 @@ public function testGetValuesForInnodbTable(): void
);
// Showing statistics
$property = $class->getProperty('isShowStats');
$property->setAccessible(true);
$property->setValue($controller, true);

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

$controller = new StructureController(
$this->response,
Expand All @@ -159,10 +156,8 @@ public function testGetValuesForAriaTable(): void
);
// Showing statistics
$property = $class->getProperty('isShowStats');
$property->setAccessible(true);
$property->setValue($controller, true);
$property = $class->getProperty('dbIsSystemSchema');
$property->setAccessible(true);
$property->setValue($controller, true);

$currentTable = [
Expand Down Expand Up @@ -252,7 +247,6 @@ public function testHasTable(): void
{
$class = new ReflectionClass(StructureController::class);
$method = $class->getMethod('hasTable');
$method->setAccessible(true);

$controller = new StructureController(
$this->response,
Expand Down Expand Up @@ -287,7 +281,6 @@ public function testCheckFavoriteTable(): void
{
$class = new ReflectionClass(StructureController::class);
$method = $class->getMethod('checkFavoriteTable');
$method->setAccessible(true);

$controller = new StructureController(
$this->response,
Expand Down Expand Up @@ -320,7 +313,6 @@ public function testDisplayTableList(): void
{
$class = new ReflectionClass(StructureController::class);
$method = $class->getMethod('displayTableList');
$method->setAccessible(true);

$controller = new StructureController(
$this->response,
Expand All @@ -332,14 +324,11 @@ public function testDisplayTableList(): void
// Showing statistics
$class = new ReflectionClass(StructureController::class);
$showStatsProperty = $class->getProperty('isShowStats');
$showStatsProperty->setAccessible(true);
$showStatsProperty->setValue($controller, true);

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

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

//no tables
Expand Down
3 changes: 0 additions & 3 deletions test/classes/Controllers/Server/VariablesControllerTest.php
Expand Up @@ -154,7 +154,6 @@ public function testFormatVariable(): void
->willReturnOnConsecutiveCalls('byte', 'string');

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

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

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

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

$controller = new VariablesController(ResponseRenderer::getInstance(), new Template(), $GLOBALS['dbi']);
Expand Down
1 change: 0 additions & 1 deletion test/classes/Controllers/Table/IndexesControllerTest.php
Expand Up @@ -102,7 +102,6 @@ public function testDisplayFormAction(): void
$template = new Template();

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

$ctrl = new IndexesController(
$response,
Expand Down
Expand Up @@ -48,7 +48,6 @@ public function testChangeController(): void

$class = new ReflectionClass(ChangeController::class);
$method = $class->getMethod('displayHtmlForColumnChange');
$method->setAccessible(true);

$ctrl = new ChangeController(
$response,
Expand Down
Expand Up @@ -112,7 +112,6 @@ public function testAdjustColumnPrivileges(): void

$class = new ReflectionClass(SaveController::class);
$method = $class->getMethod('adjustColumnPrivileges');
$method->setAccessible(true);

$ctrl = new SaveController(
new ResponseRenderer(),
Expand Down
1 change: 0 additions & 1 deletion test/classes/Database/DesignerTest.php
Expand Up @@ -106,7 +106,6 @@ public function testGetPageIdsAndNames(): void
$this->designer = new Designer($GLOBALS['dbi'], new Relation($GLOBALS['dbi']), new Template());

$method = new ReflectionMethod(Designer::class, 'getPageIdsAndNames');
$method->setAccessible(true);
$result = $method->invokeArgs($this->designer, [$db]);

$this->assertEquals(
Expand Down
1 change: 0 additions & 1 deletion test/classes/Gis/GisGeomTestCase.php
Expand Up @@ -102,7 +102,6 @@ protected static function createEmptyPdf(string $id): TCPDF
{
$pdf = new TCPDF();
$prop = new ReflectionProperty($pdf, 'file_id');
$prop->setAccessible(true);
$prop->setValue($pdf, md5($id));
$pdf->setDocCreationTimestamp(1600000000);
$pdf->setDocModificationTimestamp(1600000000);
Expand Down
1 change: 0 additions & 1 deletion test/classes/HeaderTest.php
Expand Up @@ -121,7 +121,6 @@ public function testGetMessage(): void
public function testDisableWarnings(): void
{
$reflection = new ReflectionProperty(Header::class, 'warningsEnabled');
$reflection->setAccessible(true);

$header = new Header();
$header->disableWarnings();
Expand Down
4 changes: 0 additions & 4 deletions test/classes/InsertEditTest.php
Expand Up @@ -112,9 +112,7 @@ protected function tearDown(): void
{
parent::tearDown();
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
$response->setAccessible(true);
$response->setValue(null);
$response->setAccessible(false);
}

/**
Expand Down Expand Up @@ -360,7 +358,6 @@ public function testShowEmptyResultMessageOrSetUniqueCondition(): void

$restoreInstance = ResponseRenderer::getInstance();
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
$response->setAccessible(true);
$response->setValue($responseMock);

$result = $this->callFunction(
Expand Down Expand Up @@ -2971,7 +2968,6 @@ public function testDetermineInsertOrEdit(): void

$restoreInstance = ResponseRenderer::getInstance();
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
$response->setAccessible(true);
$response->setValue($responseMock);

$this->insertEdit = new InsertEdit(
Expand Down
1 change: 0 additions & 1 deletion test/classes/Navigation/Nodes/NodeTest.php
Expand Up @@ -244,7 +244,6 @@ public function testHasSiblingsForNodesAtLevelThree(): void
public function testGetWhereClause(): void
{
$method = new ReflectionMethod(Node::class, 'getWhereClause');
$method->setAccessible(true);

// Vanilla case
$node = new Node('default');
Expand Down

0 comments on commit cb67fa3

Please sign in to comment.