diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ea011733d8..4073ca8689 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3948,18 +3948,6 @@ parameters: count: 1 path: src/Controllers/Server/Status/VariablesController.php - - - message: '#^Parameter \#1 \$haystack of function str_contains expects string, \(int\|string\) given\.$#' - identifier: argument.type - count: 1 - path: src/Controllers/Server/Status/VariablesController.php - - - - message: '#^Parameter \#1 \$name of static method PhpMyAdmin\\Html\\Generator\:\:linkToVarDocumentation\(\) expects string, \(int\|string\) given\.$#' - identifier: argument.type - count: 1 - path: src/Controllers/Server/Status/VariablesController.php - - message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#' identifier: ternary.shortNotAllowed @@ -16296,6 +16284,12 @@ parameters: count: 1 path: src/Server/Status/Data.php + - + message: '#^Property PhpMyAdmin\\Server\\Status\\Data\:\:\$status \(array\\) does not accept array\\.$#' + identifier: assign.propertyType + count: 1 + path: src/Server/Status/Data.php + - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -20490,12 +20484,6 @@ parameters: count: 1 path: tests/unit/Controllers/Server/Status/ProcessesControllerTest.php - - - message: '#^@readonly property PhpMyAdmin\\Server\\Status\\Data\:\:\$status is assigned outside of its declaring class\.$#' - identifier: property.readOnlyByPhpDocAssignOutOfClass - count: 1 - path: tests/unit/Controllers/Server/Status/QueriesControllerTest.php - - message: '#^@readonly property PhpMyAdmin\\Server\\Status\\Data\:\:\$usedQueries is assigned outside of its declaring class\.$#' identifier: property.readOnlyByPhpDocAssignOutOfClass @@ -20532,12 +20520,6 @@ parameters: count: 1 path: tests/unit/Controllers/Server/Status/QueriesControllerTest.php - - - message: '#^@readonly property PhpMyAdmin\\Server\\Status\\Data\:\:\$status is assigned outside of its declaring class\.$#' - identifier: property.readOnlyByPhpDocAssignOutOfClass - count: 6 - path: tests/unit/Controllers/Server/Status/StatusControllerTest.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: @@ -20553,7 +20535,7 @@ parameters: Use dependency injection instead\.$# ''' identifier: staticMethod.deprecated - count: 3 + count: 2 path: tests/unit/Controllers/Server/Status/StatusControllerTest.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 85ee57d7d0..71be13cf82 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2410,10 +2410,6 @@ - - - - @@ -9530,6 +9526,9 @@ + + + @@ -11979,7 +11978,6 @@ - data->status]]> data->usedQueries]]> @@ -12001,16 +11999,7 @@ - - - status]]> - status]]> - status]]> - status]]> - status]]> - status]]> - diff --git a/src/Server/Status/Data.php b/src/Server/Status/Data.php index a6df004902..4b657d9ada 100644 --- a/src/Server/Status/Data.php +++ b/src/Server/Status/Data.php @@ -69,11 +69,8 @@ final class Data 'Opened_files' => 'files', ]; - /** - * @var mixed[] - * @readonly - * */ - public array $status; + /** @var array */ + public readonly array $status; /** @var array */ public readonly array $sections; diff --git a/tests/unit/Controllers/Server/Status/QueriesControllerTest.php b/tests/unit/Controllers/Server/Status/QueriesControllerTest.php index 96251ba4ed..2a6962fd28 100644 --- a/tests/unit/Controllers/Server/Status/QueriesControllerTest.php +++ b/tests/unit/Controllers/Server/Status/QueriesControllerTest.php @@ -46,8 +46,18 @@ class QueriesControllerTest extends AbstractTestCase $config->selectedServer['DisableIS'] = false; $config->selectedServer['host'] = 'localhost'; - $this->data = new Data($this->dbi, $config); - $this->data->status['Uptime'] = 36000; + $dummyDbi = $this->createDbiDummy(); + $dbi = $this->createDatabaseInterface($dummyDbi); + $dummyDbi->addResult('SHOW GLOBAL STATUS', [ + ['Uptime' , '36000'], + ['Aborted_connects' , '0'], + ['Aborted_clients', '0'], + ['Com_delete_multi', '0'], + ['Com_create_function', '0'], + ['Com_empty_query', '0'], + ], ['Variable_name', 'Value']); + + $this->data = new Data($dbi, $config); $this->data->usedQueries = [ 'Com_change_db' => '15', 'Com_select' => '12', diff --git a/tests/unit/Controllers/Server/Status/StatusControllerTest.php b/tests/unit/Controllers/Server/Status/StatusControllerTest.php index f05e9b7eca..79ba64ce54 100644 --- a/tests/unit/Controllers/Server/Status/StatusControllerTest.php +++ b/tests/unit/Controllers/Server/Status/StatusControllerTest.php @@ -44,19 +44,28 @@ class StatusControllerTest extends AbstractTestCase public function testIndex(): void { - $data = new Data(DatabaseInterface::getInstance(), Config::getInstance()); - $bytesReceived = 100; $bytesSent = 200; $maxUsedConnections = 500; $abortedConnections = 200; $connections = 1000; - $data->status['Uptime'] = 36000; - $data->status['Bytes_received'] = $bytesReceived; - $data->status['Bytes_sent'] = $bytesSent; - $data->status['Max_used_connections'] = $maxUsedConnections; - $data->status['Aborted_connects'] = $abortedConnections; - $data->status['Connections'] = $connections; + + $dummyDbi = $this->createDbiDummy(); + $dbi = $this->createDatabaseInterface($dummyDbi); + $dummyDbi->addResult('SHOW GLOBAL STATUS', [ + ['Uptime' , '36000'], + ['Bytes_received' , $bytesReceived], + ['Bytes_sent' , $bytesSent], + ['Max_used_connections' ,$maxUsedConnections], + ['Aborted_connects' , $abortedConnections], + ['Connections' , $connections], + ['Aborted_clients', '0'], + ['Com_delete_multi', '0'], + ['Com_create_function', '0'], + ['Com_empty_query', '0'], + ], ['Variable_name', 'Value']); + + $data = new Data($dbi, Config::getInstance()); $response = new ResponseRenderer(); $template = new Template();