From b113703983d22916dc5cc8f372f38a84342e06a8 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 18:22:09 +0100 Subject: [PATCH 1/9] Upgrade Psalm and PHPStan Signed-off-by: Kamil Tekiela --- composer.lock | 102 +++++++++++++++++++++--------------------- phpstan-baseline.neon | 4 +- psalm-baseline.xml | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/composer.lock b/composer.lock index 92485ad030..b64600891c 100644 --- a/composer.lock +++ b/composer.lock @@ -8,28 +8,28 @@ "packages": [ { "name": "composer/ca-bundle", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "3ce240142f6d59b808dd65c1f52f7a1c252e6cfd" + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/3ce240142f6d59b808dd65c1f52f7a1c252e6cfd", - "reference": "3ce240142f6d59b808dd65c1f52f7a1c252e6cfd", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", "shasum": "" }, "require": { "ext-openssl": "*", "ext-pcre": "*", - "php": "^5.3.2 || ^7.0 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan": "^1.10", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { @@ -64,7 +64,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.4.1" + "source": "https://github.com/composer/ca-bundle/tree/1.5.0" }, "funding": [ { @@ -80,7 +80,7 @@ "type": "tidelift" } ], - "time": "2024-02-23T10:16:52+00:00" + "time": "2024-03-15T14:00:32+00:00" }, { "name": "fig/http-message-util", @@ -4044,21 +4044,21 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v4.19.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -4094,9 +4094,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-03-17T08:10:35+00:00" }, { "name": "nyholm/psr7", @@ -4731,16 +4731,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.60", + "version": "1.10.63", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe" + "reference": "ad12836d9ca227301f5fb9960979574ed8628339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/95dcea7d6c628a3f2f56d091d8a0219485a86bbe", - "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ad12836d9ca227301f5fb9960979574ed8628339", + "reference": "ad12836d9ca227301f5fb9960979574ed8628339", "shasum": "" }, "require": { @@ -4789,7 +4789,7 @@ "type": "tidelift" } ], - "time": "2024-03-07T13:30:19+00:00" + "time": "2024-03-18T16:53:53+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -4945,16 +4945,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.13", + "version": "10.1.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "d51c3aec14896d5e80b354fad58e998d1980f8f8" + "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d51c3aec14896d5e80b354fad58e998d1980f8f8", - "reference": "d51c3aec14896d5e80b354fad58e998d1980f8f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", + "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", "shasum": "" }, "require": { @@ -5011,7 +5011,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.13" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.14" }, "funding": [ { @@ -5019,7 +5019,7 @@ "type": "github" } ], - "time": "2024-03-09T16:54:15+00:00" + "time": "2024-03-12T15:33:41+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5266,16 +5266,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.12", + "version": "10.5.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "41a9886b85ac7bf3929853baf96b95361cd69d2b" + "reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/41a9886b85ac7bf3929853baf96b95361cd69d2b", - "reference": "41a9886b85ac7bf3929853baf96b95361cd69d2b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/20a63fc1c6db29b15da3bd02d4b6cf59900088a7", + "reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7", "shasum": "" }, "require": { @@ -5347,7 +5347,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.12" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.13" }, "funding": [ { @@ -5363,7 +5363,7 @@ "type": "tidelift" } ], - "time": "2024-03-09T12:04:07+00:00" + "time": "2024-03-12T15:37:41+00:00" }, { "name": "pragmarx/google2fa", @@ -5783,12 +5783,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "83b3589bb774f27084c7f358c13f465d94afa036" + "reference": "eedc674d89085b0199bd96bfad410404fb2f5dbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/83b3589bb774f27084c7f358c13f465d94afa036", - "reference": "83b3589bb774f27084c7f358c13f465d94afa036", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/eedc674d89085b0199bd96bfad410404fb2f5dbf", + "reference": "eedc674d89085b0199bd96bfad410404fb2f5dbf", "shasum": "" }, "conflict": { @@ -5940,7 +5940,7 @@ "ezsystems/ezplatform-solr-search-engine": ">=1.7,<1.7.12|>=2,<2.0.2|>=3.3,<3.3.15", "ezsystems/ezplatform-user": ">=1,<1.0.1", "ezsystems/ezpublish-kernel": "<6.13.8.2-dev|>=7,<7.5.31", - "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.06,<=2019.03.5.1", + "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.6,<=2019.03.5.1", "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", "ezsystems/repository-forms": ">=2.3,<2.3.2.1-dev|>=2.5,<2.5.15", "ezyang/htmlpurifier": "<4.1.1", @@ -6232,7 +6232,7 @@ "react/http": ">=0.7,<1.9", "really-simple-plugins/complianz-gdpr": "<6.4.2", "redaxo/source": "<=5.15.1", - "remdex/livehelperchat": "<3.99", + "remdex/livehelperchat": "<4.29", "reportico-web/reportico": "<=7.1.21", "rhukster/dom-sanitizer": "<1.0.7", "rmccue/requests": ">=1.6,<1.8", @@ -6515,7 +6515,7 @@ "type": "tidelift" } ], - "time": "2024-03-08T12:05:25+00:00" + "time": "2024-03-13T21:04:41+00:00" }, { "name": "sebastian/cli-parser", @@ -8189,20 +8189,20 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.6.5", + "version": "6.7.2", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "5fce932fcee4371865314ab7f6c0d85423c5c7ce" + "reference": "1ae5c4721cecb6be1fa1c0bebb506ed454a3e02d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/5fce932fcee4371865314ab7f6c0d85423c5c7ce", - "reference": "5fce932fcee4371865314ab7f6c0d85423c5c7ce", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/1ae5c4721cecb6be1fa1c0bebb506ed454a3e02d", + "reference": "1ae5c4721cecb6be1fa1c0bebb506ed454a3e02d", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.5.0" }, "type": "library", "autoload": { @@ -8249,7 +8249,7 @@ ], "support": { "issues": "https://github.com/tecnickcom/TCPDF/issues", - "source": "https://github.com/tecnickcom/TCPDF/tree/6.6.5" + "source": "https://github.com/tecnickcom/TCPDF/tree/6.7.2" }, "funding": [ { @@ -8257,7 +8257,7 @@ "type": "custom" } ], - "time": "2023-09-06T15:09:26+00:00" + "time": "2024-03-18T17:08:30+00:00" }, { "name": "thecodingmachine/safe", @@ -8450,16 +8450,16 @@ }, { "name": "vimeo/psalm", - "version": "5.23.0", + "version": "5.23.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "005e3184fb6de4350a873b9b8c4dc3cede9db762" + "reference": "8471a896ccea3526b26d082f4461eeea467f10a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/005e3184fb6de4350a873b9b8c4dc3cede9db762", - "reference": "005e3184fb6de4350a873b9b8c4dc3cede9db762", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/8471a896ccea3526b26d082f4461eeea467f10a4", + "reference": "8471a896ccea3526b26d082f4461eeea467f10a4", "shasum": "" }, "require": { @@ -8556,7 +8556,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-03-09T19:39:11+00:00" + "time": "2024-03-11T20:33:46+00:00" }, { "name": "web-auth/cose-lib", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8b0025c873..e6e496478f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -14136,7 +14136,7 @@ parameters: path: src/Table/Table.php - - message: "#^Method PhpMyAdmin\\\\Table\\\\Table\\:\\:getNameAndTypeOfTheColumns\\(\\) should return array\\ but returns array\\\\.$#" + message: "#^Method PhpMyAdmin\\\\Table\\\\Table\\:\\:getNameAndTypeOfTheColumns\\(\\) should return array\\ but returns array\\.$#" count: 1 path: src/Table/Table.php @@ -15361,7 +15361,7 @@ parameters: path: tests/unit/Config/DescriptionTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ''\\|'; Compressed export…'\\|'Compressed export…'\\|'Compressed import…'\\|'Compressed import…'\\|'Compressed import…' and null will always evaluate to false\\.$#" + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ''\\|'; Compressed export…'\\|'Compressed export…'\\|'Compressed import…' and null will always evaluate to false\\.$#" count: 1 path: tests/unit/Config/FormDisplayTest.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a6a668696f..a4148b65a3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + From 46035d2d6a91eec774b313710abf2a97d7b86a4c Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 18:44:52 +0100 Subject: [PATCH 2/9] Minor changes Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 9 ++------- tests/unit/Config/FormDisplayTest.php | 6 +----- tests/unit/Engines/PbxtTest.php | 2 +- tests/unit/Table/TableTest.php | 24 ++++++++++++------------ 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e6e496478f..5398501c6e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15361,12 +15361,12 @@ parameters: path: tests/unit/Config/DescriptionTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ''\\|'; Compressed export…'\\|'Compressed export…'\\|'Compressed import…' and null will always evaluate to false\\.$#" + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsString\\(\\) with '' will always evaluate to true\\.$#" count: 1 path: tests/unit/Config/FormDisplayTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with 'string' and 'string' will always evaluate to true\\.$#" + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ''\\|'; Compressed export…'\\|'Compressed export…'\\|'Compressed import…' and null will always evaluate to false\\.$#" count: 1 path: tests/unit/Config/FormDisplayTest.php @@ -16660,11 +16660,6 @@ parameters: count: 1 path: tests/unit/Table/TableTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\ and array\\{'aNonValidExampleToR…'\\} will always evaluate to false\\.$#" - count: 1 - path: tests/unit/Table/TableTest.php - - message: "#^Cannot access offset 'SCHEMA_TABLES' on mixed\\.$#" count: 1 diff --git a/tests/unit/Config/FormDisplayTest.php b/tests/unit/Config/FormDisplayTest.php index 0060b6266b..114ce2f24e 100644 --- a/tests/unit/Config/FormDisplayTest.php +++ b/tests/unit/Config/FormDisplayTest.php @@ -17,7 +17,6 @@ use ReflectionMethod; use ReflectionProperty; use function function_exists; -use function gettype; #[CoversClass(FormDisplay::class)] class FormDisplayTest extends AbstractTestCase @@ -204,10 +203,7 @@ class FormDisplayTest extends AbstractTestCase [&$value, $arr], ), ); - self::assertSame( - 'string', - gettype($value), - ); + self::assertIsString($value); $arr = [0 => 'foobar']; $value = 0; diff --git a/tests/unit/Engines/PbxtTest.php b/tests/unit/Engines/PbxtTest.php index c62972a45e..a731d050f1 100644 --- a/tests/unit/Engines/PbxtTest.php +++ b/tests/unit/Engines/PbxtTest.php @@ -216,7 +216,7 @@ class PbxtTest extends AbstractTestCase self::assertEquals( $this->object->getPage('NonExistMethod'), - false, + '', ); } } diff --git a/tests/unit/Table/TableTest.php b/tests/unit/Table/TableTest.php index 25bd6dd066..f701089350 100644 --- a/tests/unit/Table/TableTest.php +++ b/tests/unit/Table/TableTest.php @@ -14,6 +14,7 @@ use PhpMyAdmin\Query\Cache; use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\Table\Table; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Tests\FieldHelper; use PhpMyAdmin\Tests\Stubs\DbiDummy; use PhpMyAdmin\Tests\Stubs\DummyResult; use PHPUnit\Framework\Attributes\CoversClass; @@ -21,6 +22,8 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; +use const MYSQLI_TYPE_STRING; + #[CoversClass(Table::class)] class TableTest extends AbstractTestCase { @@ -1124,10 +1127,12 @@ class TableTest extends AbstractTestCase ->with('SELECT * FROM `db`.`table` LIMIT 1') ->willReturn($resultStub); + $dummyFieldMetadata = FieldHelper::fromArray(['type' => MYSQLI_TYPE_STRING]); + $dbi->expects(self::once()) ->method('getFieldsMeta') ->with($resultStub) - ->willReturn(['aNonValidExampleToRefactor']); + ->willReturn([$dummyFieldMetadata]); DatabaseInterface::$instance = $dbi; @@ -1135,7 +1140,7 @@ class TableTest extends AbstractTestCase self::assertSame( $tableObj->getColumnsMeta(), - ['aNonValidExampleToRefactor'], + [$dummyFieldMetadata], ); } @@ -1238,18 +1243,15 @@ class TableTest extends AbstractTestCase // Case 1 : Check if table is non-empty $return = $tableObj->checkIfMinRecordsExist(); - $expect = true; - self::assertSame($expect, $return); + self::assertTrue($return); // Case 2 : Check if table contains at least 100 $return = $tableObj->checkIfMinRecordsExist(100); - $expect = false; - self::assertSame($expect, $return); + self::assertFalse($return); // Case 3 : Check if table contains at least 100 $return = $tableObj->checkIfMinRecordsExist(100); - $expect = true; - self::assertSame($expect, $return); + self::assertTrue($return); DatabaseInterface::$instance = $oldDbi; } @@ -1332,8 +1334,7 @@ class TableTest extends AbstractTestCase $return = Table::moveCopy($sourceDb, $sourceTable, $targetDb, $targetTable, $what, $move, $mode, true); //successfully - $expect = true; - self::assertSame($expect, $return); + self::assertTrue($return); $sqlQuery = 'INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)' . ' SELECT `COLUMN_NAME1` FROM ' . '`PMA`.`PMA_BookMark`'; @@ -1344,8 +1345,7 @@ class TableTest extends AbstractTestCase $return = Table::moveCopy($sourceDb, $sourceTable, $targetDb, $targetTable, $what, false, $mode, true); //successfully - $expect = true; - self::assertSame($expect, $return); + self::assertTrue($return); $sqlQuery = 'INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)' . ' SELECT `COLUMN_NAME1` FROM ' . '`PMA`.`PMA_BookMark`'; From 7464263253b2126aae980574456bab54aef7fe6b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 18:45:23 +0100 Subject: [PATCH 3/9] Remove useless test Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- tests/unit/Table/TableTest.php | 9 --------- 2 files changed, 14 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5398501c6e..2eb699536a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -16655,11 +16655,6 @@ parameters: count: 1 path: tests/unit/Table/TableTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Table\\\\\\\\Table' and PhpMyAdmin\\\\Table\\\\Table will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Table/TableTest.php - - message: "#^Cannot access offset 'SCHEMA_TABLES' on mixed\\.$#" count: 1 diff --git a/tests/unit/Table/TableTest.php b/tests/unit/Table/TableTest.php index f701089350..22c689e28d 100644 --- a/tests/unit/Table/TableTest.php +++ b/tests/unit/Table/TableTest.php @@ -284,15 +284,6 @@ class TableTest extends AbstractTestCase DatabaseInterface::$instance = null; } - /** - * Test object creating - */ - public function testCreate(): void - { - $table = new Table('table1', 'pma_test', $this->mockedDbi); - self::assertInstanceOf(Table::class, $table); - } - /** * Test for constructor */ From e27370d05c95e5e786fcd3d8a9cc0771a978abed Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 19:43:27 +0100 Subject: [PATCH 4/9] Remove testGetGroup Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- .../unit/Properties/Options/OptionsPropertyGroupTest.php | 8 -------- 2 files changed, 13 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2eb699536a..c2a8cbc280 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -16475,11 +16475,6 @@ parameters: count: 1 path: tests/unit/PluginsTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Properties\\\\\\\\Options\\\\\\\\OptionsPropertyGroup' and PhpMyAdmin\\\\Properties\\\\Options\\\\OptionsPropertyGroup&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Properties/Options/OptionsPropertyGroupTest.php - - message: "#^Property PhpMyAdmin\\\\Config\\:\\:\\$settings \\(array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\) does not accept array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\.$#" count: 1 diff --git a/tests/unit/Properties/Options/OptionsPropertyGroupTest.php b/tests/unit/Properties/Options/OptionsPropertyGroupTest.php index 5aacc0553f..d64cec60df 100644 --- a/tests/unit/Properties/Options/OptionsPropertyGroupTest.php +++ b/tests/unit/Properties/Options/OptionsPropertyGroupTest.php @@ -67,14 +67,6 @@ class OptionsPropertyGroupTest extends AbstractTestCase ); } - public function testGetGroup(): void - { - self::assertInstanceOf( - OptionsPropertyGroup::class, - $this->stub->getGroup(), - ); - } - public function testGetProperties(): void { $propertyItem = new BoolPropertyItem(); From 7ed4a092be8ce2d9a2b5b4b5f84a92682a19e3af Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 19:11:58 +0100 Subject: [PATCH 5/9] Remove more unnecessary asserts Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 80 --------------------------- psalm-baseline.xml | 18 ------ tests/unit/DatabaseInterfaceTest.php | 5 +- tests/unit/Error/ErrorHandlerTest.php | 2 - tests/unit/OpenDocumentTest.php | 1 - tests/unit/ParseAnalyzeTest.php | 2 - tests/unit/PluginsTest.php | 3 - tests/unit/Server/PluginTest.php | 1 - tests/unit/Server/PluginsTest.php | 6 -- tests/unit/Server/PrivilegesTest.php | 6 -- tests/unit/Theme/ThemeManagerTest.php | 1 - tests/unit/Theme/ThemeTest.php | 1 - tests/unit/UserPreferencesTest.php | 2 - 13 files changed, 1 insertion(+), 127 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c2a8cbc280..973255745f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15780,11 +15780,6 @@ parameters: count: 1 path: tests/unit/Database/DesignerTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Dbal\\\\\\\\ResultInterface' and PhpMyAdmin\\\\Dbal\\\\ResultInterface will always evaluate to true\\.$#" - count: 1 - path: tests/unit/DatabaseInterfaceTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\SystemDatabase' and PhpMyAdmin\\\\SystemDatabase will always evaluate to true\\.$#" count: 1 @@ -15895,11 +15890,6 @@ parameters: count: 3 path: tests/unit/Display/ResultsTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Error\\\\\\\\Error' and PhpMyAdmin\\\\Error\\\\Error will always evaluate to true\\.$#" - count: 2 - path: tests/unit/Error/ErrorHandlerTest.php - - message: "#^Property PhpMyAdmin\\\\Config\\:\\:\\$settings \\(array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\) does not accept array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\.$#" count: 1 @@ -16245,16 +16235,6 @@ parameters: count: 2 path: tests/unit/NormalizationTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotFalse\\(\\) with string will always evaluate to true\\.$#" - count: 1 - path: tests/unit/OpenDocumentTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertCount\\(\\) with 3 and array\\{PhpMyAdmin\\\\SqlParser\\\\Utils\\\\StatementInfo, string, string\\} will always evaluate to true\\.$#" - count: 2 - path: tests/unit/ParseAnalyzeTest.php - - message: "#^Method PhpMyAdmin\\\\Tests\\\\Partitioning\\\\TablePartitionDefinitionTest\\:\\:testGetDetails\\(\\) has parameter \\$partitions with no value type specified in iterable type array\\.$#" count: 1 @@ -16455,21 +16435,6 @@ parameters: count: 1 path: tests/unit/Plugins/Transformations/TransformationPluginsTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: tests/unit/PluginsTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: tests/unit/PluginsTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: tests/unit/PluginsTest.php - - message: "#^Property PhpMyAdmin\\\\Config\\:\\:\\$settings \\(array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\) does not accept array\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\.$#" count: 1 @@ -16490,41 +16455,11 @@ parameters: count: 1 path: tests/unit/Routing/RoutingTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Server\\\\\\\\Plugin' and PhpMyAdmin\\\\Server\\\\Plugin will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Server/PluginTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Server\\\\\\\\Plugin' and PhpMyAdmin\\\\Server\\\\Plugin will always evaluate to true\\.$#" - count: 2 - path: tests/unit/Server/PluginsTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 2 - path: tests/unit/Server/PluginsTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Server/PluginsTest.php - - message: "#^Class PhpMyAdmin\\\\Tests\\\\Server\\\\PluginsTest has an uninitialized property \\$plugins\\. Give it default value or assign it in the constructor\\.$#" count: 1 path: tests/unit/Server/PluginsTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 0 and array\\{string, PhpMyAdmin\\\\Message\\} will always evaluate to true\\.$#" - count: 3 - path: tests/unit/Server/PrivilegesTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 1 and array\\{string, PhpMyAdmin\\\\Message\\} will always evaluate to true\\.$#" - count: 3 - path: tests/unit/Server/PrivilegesTest.php - - message: "#^Cannot call method getMessage\\(\\) on mixed\\.$#" count: 2 @@ -16670,21 +16605,11 @@ parameters: count: 1 path: tests/unit/Table/TableTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Theme/ThemeManagerTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#" count: 1 path: tests/unit/Theme/ThemeManagerTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Theme\\\\\\\\Theme' and PhpMyAdmin\\\\Theme\\\\Theme will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Theme/ThemeTest.php - - message: "#^Casting to int something that's already int\\.$#" count: 1 @@ -16735,11 +16660,6 @@ parameters: count: 1 path: tests/unit/UserPasswordTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertCount\\(\\) with 3 and array\\{config_data\\: array, mtime\\: int, type\\: 'db'\\|'session'\\} will always evaluate to true\\.$#" - count: 1 - path: tests/unit/UserPreferencesTest.php - - message: "#^Cannot access offset 'db' on mixed\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a4148b65a3..94170999f5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -13958,11 +13958,6 @@ settings]]> - - - - - @@ -14391,11 +14386,6 @@ settings]]> - - - - - @@ -14446,11 +14436,6 @@ - - - - - @@ -14648,9 +14633,6 @@ - - - diff --git a/tests/unit/DatabaseInterfaceTest.php b/tests/unit/DatabaseInterfaceTest.php index 7833cda269..feb6104516 100644 --- a/tests/unit/DatabaseInterfaceTest.php +++ b/tests/unit/DatabaseInterfaceTest.php @@ -574,10 +574,7 @@ class DatabaseInterfaceTest extends AbstractTestCase $dummyDbi->addResult($sql, true); $dummyDbi->addResult('Invalid query', false); - self::assertInstanceOf( - ResultInterface::class, - $dbi->queryAsControlUser($sql), - ); + $dbi->queryAsControlUser($sql); self::assertInstanceOf( ResultInterface::class, $dbi->tryQueryAsControlUser($sql), diff --git a/tests/unit/Error/ErrorHandlerTest.php b/tests/unit/Error/ErrorHandlerTest.php index c8cd1c1146..412a508187 100644 --- a/tests/unit/Error/ErrorHandlerTest.php +++ b/tests/unit/Error/ErrorHandlerTest.php @@ -279,7 +279,6 @@ class ErrorHandlerTest extends AbstractTestCase $errors = $errorHandler->getCurrentErrors(); self::assertCount(1, $errors); $error = array_pop($errors); - self::assertInstanceOf(Error::class, $error); self::assertSame('Exception: Exception message.', $error->getOnlyMessage()); self::assertStringContainsString($error->getDisplay(), $output); self::assertStringContainsString('Internal error', $output); @@ -303,7 +302,6 @@ class ErrorHandlerTest extends AbstractTestCase $errors = $errorHandler->getCurrentErrors(); self::assertCount(1, $errors); $error = array_pop($errors); - self::assertInstanceOf(Error::class, $error); self::assertSame('Exception: Exception message.', $error->getOnlyMessage()); self::assertStringContainsString($error->getDisplay(), $output); self::assertStringContainsString('Exception: Exception message.', $output); diff --git a/tests/unit/OpenDocumentTest.php b/tests/unit/OpenDocumentTest.php index 2c3952ecd4..af7077e20b 100644 --- a/tests/unit/OpenDocumentTest.php +++ b/tests/unit/OpenDocumentTest.php @@ -22,7 +22,6 @@ class OpenDocumentTest extends AbstractTestCase public function testCreateDocument(): void { $document = OpenDocument::create('application/vnd.oasis.opendocument.text', ''); - self::assertNotFalse($document); $tmpFile = tempnam('./', 'open-document-test'); self::assertNotFalse($tmpFile); diff --git a/tests/unit/ParseAnalyzeTest.php b/tests/unit/ParseAnalyzeTest.php index 2a44a6cdc8..0de673be2d 100644 --- a/tests/unit/ParseAnalyzeTest.php +++ b/tests/unit/ParseAnalyzeTest.php @@ -30,7 +30,6 @@ class ParseAnalyzeTest extends AbstractTestCase /** @psalm-suppress TypeDoesNotContainType */ self::assertSame('SELECT * FROM `sakila`.`actor`', $GLOBALS['unparsed_sql']); - self::assertCount(3, $actual); self::assertSame('sakila', $actual[1]); self::assertSame('actor', $actual[2]); self::assertTrue($actual[0]->flags->reload); @@ -51,7 +50,6 @@ class ParseAnalyzeTest extends AbstractTestCase /** @psalm-suppress TypeDoesNotContainType */ self::assertSame('SELECT `first_name`, `title` FROM `actor`, `film`', $GLOBALS['unparsed_sql']); - self::assertCount(3, $actual); self::assertSame('sakila', $actual[1]); self::assertSame('', $actual[2]); self::assertFalse($actual[0]->flags->reload); diff --git a/tests/unit/PluginsTest.php b/tests/unit/PluginsTest.php index 4672d73546..444632afd4 100644 --- a/tests/unit/PluginsTest.php +++ b/tests/unit/PluginsTest.php @@ -28,7 +28,6 @@ class PluginsTest extends AbstractTestCase { $plugins = Plugins::getExport('database', false); self::assertSame(['export_type' => 'database', 'single_table' => false], $GLOBALS['plugin_param']); - self::assertIsArray($plugins); self::assertCount(14, $plugins); self::assertContainsOnlyInstancesOf(Plugins\ExportPlugin::class, $plugins); } @@ -37,7 +36,6 @@ class PluginsTest extends AbstractTestCase { ImportSettings::$importType = 'database'; $plugins = Plugins::getImport(); - self::assertIsArray($plugins); self::assertCount(6, $plugins); self::assertContainsOnlyInstancesOf(Plugins\ImportPlugin::class, $plugins); } @@ -45,7 +43,6 @@ class PluginsTest extends AbstractTestCase public function testGetSchema(): void { $plugins = Plugins::getSchema(); - self::assertIsArray($plugins); self::assertCount(4, $plugins); self::assertContainsOnlyInstancesOf(Plugins\SchemaPlugin::class, $plugins); } diff --git a/tests/unit/Server/PluginTest.php b/tests/unit/Server/PluginTest.php index a8dcb78c0f..8e733bf990 100644 --- a/tests/unit/Server/PluginTest.php +++ b/tests/unit/Server/PluginTest.php @@ -30,7 +30,6 @@ class PluginTest extends AbstractTestCase 'authVersion' => '1.0', ]); - self::assertInstanceOf(Plugin::class, $plugin); self::assertSame('BLACKHOLE', $plugin->getName()); self::assertSame('1.0', $plugin->getVersion()); self::assertSame('ACTIVE', $plugin->getStatus()); diff --git a/tests/unit/Server/PluginsTest.php b/tests/unit/Server/PluginsTest.php index 539bf8657c..c8441faf16 100644 --- a/tests/unit/Server/PluginsTest.php +++ b/tests/unit/Server/PluginsTest.php @@ -6,7 +6,6 @@ namespace PhpMyAdmin\Tests\Server; use PhpMyAdmin\Config; use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Server\Plugin; use PhpMyAdmin\Server\Plugins; use PhpMyAdmin\Tests\AbstractTestCase; use PHPUnit\Framework\Attributes\CoversClass; @@ -35,12 +34,10 @@ class PluginsTest extends AbstractTestCase $plugins = $this->plugins->getAll(); - self::assertIsArray($plugins); self::assertNotEmpty($plugins); $plugin = $plugins[0]; - self::assertInstanceOf(Plugin::class, $plugin); self::assertSame([ 'name' => 'BLACKHOLE', 'version' => '1.0', @@ -68,12 +65,10 @@ class PluginsTest extends AbstractTestCase $plugins = $this->plugins->getAll(); - self::assertIsArray($plugins); self::assertNotEmpty($plugins); $plugin = $plugins[0]; - self::assertInstanceOf(Plugin::class, $plugin); self::assertSame([ 'name' => 'partition', 'version' => null, @@ -95,7 +90,6 @@ class PluginsTest extends AbstractTestCase { $this->plugins = new Plugins(DatabaseInterface::getInstance()); $plugins = $this->plugins->getAuthentication(); - self::assertIsArray($plugins); self::assertNotEmpty($plugins); self::assertSame( [ diff --git a/tests/unit/Server/PrivilegesTest.php b/tests/unit/Server/PrivilegesTest.php index 2c61ad0c3b..ec535f4bc6 100644 --- a/tests/unit/Server/PrivilegesTest.php +++ b/tests/unit/Server/PrivilegesTest.php @@ -1790,8 +1790,6 @@ class PrivilegesTest extends AbstractTestCase // Test case 1 : empty queries $queries = []; $actual = $serverPrivileges->deleteUser($queries); - self::assertArrayHasKey(0, $actual); - self::assertArrayHasKey(1, $actual); self::assertSame('', $actual[0]); self::assertSame( 'No users selected for deleting!', @@ -1802,8 +1800,6 @@ class PrivilegesTest extends AbstractTestCase $_POST['mode'] = 3; $queries = ['foo']; $actual = $serverPrivileges->deleteUser($queries); - self::assertArrayHasKey(0, $actual); - self::assertArrayHasKey(1, $actual); self::assertSame("foo\n# Reloading the privileges …\nFLUSH PRIVILEGES;", $actual[0]); self::assertSame( 'The selected users have been deleted successfully.', @@ -1814,8 +1810,6 @@ class PrivilegesTest extends AbstractTestCase $_POST['mode'] = 1; $queries = ['bar']; $actual = $serverPrivileges->deleteUser($queries); - self::assertArrayHasKey(0, $actual); - self::assertArrayHasKey(1, $actual); self::assertSame('bar', $actual[0]); self::assertSame( 'Some error occurred!' . "\n", diff --git a/tests/unit/Theme/ThemeManagerTest.php b/tests/unit/Theme/ThemeManagerTest.php index 9391ab3349..adcee29f61 100644 --- a/tests/unit/Theme/ThemeManagerTest.php +++ b/tests/unit/Theme/ThemeManagerTest.php @@ -53,7 +53,6 @@ class ThemeManagerTest extends AbstractTestCase $tm = new ThemeManager(); $tm->initializeTheme(); $themes = $tm->getThemesArray(); - self::assertIsArray($themes); self::assertArrayHasKey(0, $themes); self::assertIsArray($themes[0]); self::assertArrayHasKey('id', $themes[0]); diff --git a/tests/unit/Theme/ThemeTest.php b/tests/unit/Theme/ThemeTest.php index e8810b8e72..2ed256cf06 100644 --- a/tests/unit/Theme/ThemeTest.php +++ b/tests/unit/Theme/ThemeTest.php @@ -100,7 +100,6 @@ class ThemeTest extends AbstractTestCase 'original', ); self::assertNotNull($newTheme); - self::assertInstanceOf(Theme::class, $newTheme); } /** diff --git a/tests/unit/UserPreferencesTest.php b/tests/unit/UserPreferencesTest.php index 1f94cc7bdc..6fbb5d25c2 100644 --- a/tests/unit/UserPreferencesTest.php +++ b/tests/unit/UserPreferencesTest.php @@ -74,8 +74,6 @@ class UserPreferencesTest extends AbstractTestCase $userPreferences = new UserPreferences($dbi1, new Relation($dbi1), new Template()); $result = $userPreferences->load(); - self::assertCount(3, $result); - self::assertSame( [], $result['config_data'], From 7affa5e3abb1b1db9ce119e50feb06c9ea6ddcb2 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 20:15:31 +0100 Subject: [PATCH 6/9] Remove getSystemDatabase() method Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Controllers/View/CreateController.php | 3 ++- src/DatabaseInterface.php | 8 -------- src/Dbal/DbalInterface.php | 6 ------ tests/unit/DatabaseInterfaceTest.php | 11 ----------- 5 files changed, 2 insertions(+), 31 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 973255745f..3021039873 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15780,11 +15780,6 @@ parameters: count: 1 path: tests/unit/Database/DesignerTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\SystemDatabase' and PhpMyAdmin\\\\SystemDatabase will always evaluate to true\\.$#" - count: 1 - path: tests/unit/DatabaseInterfaceTest.php - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\ and array\\\\> will always evaluate to false\\.$#" count: 1 diff --git a/src/Controllers/View/CreateController.php b/src/Controllers/View/CreateController.php index 03efa99b78..843320b895 100644 --- a/src/Controllers/View/CreateController.php +++ b/src/Controllers/View/CreateController.php @@ -20,6 +20,7 @@ use PhpMyAdmin\ResponseRenderer; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statements\CreateStatement; use PhpMyAdmin\SqlParser\TokensList; +use PhpMyAdmin\SystemDatabase; use PhpMyAdmin\Template; use PhpMyAdmin\Url; use PhpMyAdmin\Util; @@ -210,7 +211,7 @@ class CreateController extends AbstractController $viewColumns = explode(',', $view['column_names']); } - $systemDb = $this->dbi->getSystemDatabase(); + $systemDb = new SystemDatabase($this->dbi); $pmaTransformationData = $systemDb->getExistingTransformationData(Current::$database); if ($pmaTransformationData !== false) { diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index 8fea9bec39..de0746509b 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -1921,14 +1921,6 @@ class DatabaseInterface implements DbalInterface return 'KILL ' . $process . ';'; } - /** - * Get the phpmyadmin database manager - */ - public function getSystemDatabase(): SystemDatabase - { - return new SystemDatabase($this); - } - /** * Get a table with database name and table name * diff --git a/src/Dbal/DbalInterface.php b/src/Dbal/DbalInterface.php index a25ecaa7be..374dbb26b7 100644 --- a/src/Dbal/DbalInterface.php +++ b/src/Dbal/DbalInterface.php @@ -10,7 +10,6 @@ use PhpMyAdmin\Config\Settings\Server; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\FieldMetadata; use PhpMyAdmin\Identifiers\DatabaseName; -use PhpMyAdmin\SystemDatabase; use PhpMyAdmin\Table\Table; /** @@ -542,11 +541,6 @@ interface DbalInterface */ public function getKillQuery(int $process): string; - /** - * Get the phpmyadmin database manager - */ - public function getSystemDatabase(): SystemDatabase; - /** * Get a table with database name and table name * diff --git a/tests/unit/DatabaseInterfaceTest.php b/tests/unit/DatabaseInterfaceTest.php index feb6104516..f811ef80ad 100644 --- a/tests/unit/DatabaseInterfaceTest.php +++ b/tests/unit/DatabaseInterfaceTest.php @@ -18,7 +18,6 @@ use PhpMyAdmin\Index; use PhpMyAdmin\LanguageManager; use PhpMyAdmin\Query\Utilities; use PhpMyAdmin\SqlParser\Context; -use PhpMyAdmin\SystemDatabase; use PhpMyAdmin\Utils\SessionCache; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -170,16 +169,6 @@ class DatabaseInterfaceTest extends AbstractTestCase ]; } - /** - * Tests for DBI::getSystemDatabase() method. - */ - public function testGetSystemDatabase(): void - { - $dbi = $this->createDatabaseInterface(); - $sd = $dbi->getSystemDatabase(); - self::assertInstanceOf(SystemDatabase::class, $sd); - } - /** * Tests for DBI::postConnect() method. * should not call setVersion method if cannot fetch version From ae0c06d49401d45f18882974a45940147276d6f2 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 20:24:17 +0100 Subject: [PATCH 7/9] Fix incorrect type hint Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 17 +---------------- psalm-baseline.xml | 10 +--------- src/DatabaseInterface.php | 2 +- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3021039873..4dfa53ca7e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6681,12 +6681,7 @@ parameters: path: src/DatabaseInterface.php - - message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getCurrentRoles\\(\\) should return array\\\\> but returns array\\\\.$#" - count: 1 - path: src/DatabaseInterface.php - - - - message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getCurrentRoles\\(\\) should return array\\\\> but returns mixed\\.$#" + message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getCurrentRoles\\(\\) should return array\\ but returns mixed\\.$#" count: 1 path: src/DatabaseInterface.php @@ -6730,11 +6725,6 @@ parameters: count: 1 path: src/DatabaseInterface.php - - - message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(array\\\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: non\\-empty\\-array\\ given\\.$#" - count: 1 - path: src/DatabaseInterface.php - - message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: non\\-empty\\-string given\\.$#" count: 1 @@ -15780,11 +15770,6 @@ parameters: count: 1 path: tests/unit/Database/DesignerTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\ and array\\\\> will always evaluate to false\\.$#" - count: 1 - path: tests/unit/DatabaseInterfaceTest.php - - message: "#^Parameter \\#2 \\$result of method PhpMyAdmin\\\\Tests\\\\Stubs\\\\DbiDummy\\:\\:addResult\\(\\) expects array\\\\>\\|bool, array\\\\>\\|false given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 94170999f5..c8cccc93b7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -4887,11 +4887,6 @@ - - - @@ -4900,9 +4895,6 @@ - - - @@ -4935,7 +4927,7 @@ versionString]]> - >]]> + ]]> diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index de0746509b..9c94c7d89d 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -1442,7 +1442,7 @@ class DatabaseInterface implements DbalInterface * @see https://mariadb.com/kb/en/mariadb-1005-release-notes/#newly-implemented-features * @see https://mariadb.com/kb/en/roles_overview/ * - * @return array> the current roles i.e. array of role@host + * @return list the current roles i.e. array of role@host */ public function getCurrentRoles(): array { From 6b4a77b073377d998853833f2cd0ac701f4b2d56 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 20:25:19 +0100 Subject: [PATCH 8/9] Remove more unnecessary asserts Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 20 -------------------- psalm-baseline.xml | 3 --- tests/end-to-end/Database/OperationsTest.php | 7 +------ tests/unit/Charsets/CharsetTest.php | 1 - tests/unit/Charsets/CollationTest.php | 1 - tests/unit/ConfigTest.php | 3 +-- tests/unit/Database/CentralColumnsTest.php | 1 - 7 files changed, 2 insertions(+), 34 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4dfa53ca7e..703ccbc7b0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15100,11 +15100,6 @@ parameters: count: 1 path: tests/config.e2e.inc.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement will always evaluate to true\\.$#" - count: 1 - path: tests/end-to-end/Database/OperationsTest.php - - message: "#^Call to function is_string\\(\\) with non\\-falsy\\-string will always evaluate to true\\.$#" count: 2 @@ -15285,16 +15280,6 @@ parameters: count: 1 path: tests/unit/CacheTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Charsets\\\\\\\\Charset' and PhpMyAdmin\\\\Charsets\\\\Charset will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Charsets/CharsetTest.php - - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Charsets\\\\\\\\Collation' and PhpMyAdmin\\\\Charsets\\\\Collation will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Charsets/CollationTest.php - - message: "#^Class PhpMyAdmin\\\\Tests\\\\Command\\\\SetVersionCommandTest has an uninitialized property \\$command\\. Give it default value or assign it in the constructor\\.$#" count: 1 @@ -15745,11 +15730,6 @@ parameters: count: 1 path: tests/unit/Crypto/CryptoTest.php - - - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: tests/unit/Database/CentralColumnsTest.php - - message: "#^Parameter \\#1 \\$needle of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c8cccc93b7..2ee22407df 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -13146,9 +13146,6 @@ [$this->modifiedColumnData[0], 0], )]]> - - - diff --git a/tests/end-to-end/Database/OperationsTest.php b/tests/end-to-end/Database/OperationsTest.php index 242eb0c65c..7b2c9fa250 100644 --- a/tests/end-to-end/Database/OperationsTest.php +++ b/tests/end-to-end/Database/OperationsTest.php @@ -43,12 +43,7 @@ class OperationsTest extends TestBase $this->byName('comment')->sendKeys('comment_foobar'); $this->byCssSelector("form#formDatabaseComment input[type='submit']")->click(); - self::assertNotNull( - $this->waitForElement( - 'xpath', - "//span[@class='breadcrumb-comment' and contains(., 'comment_foobar')]", - ), - ); + $this->waitForElement('xpath', "//span[@class='breadcrumb-comment' and contains(., 'comment_foobar')]"); } /** diff --git a/tests/unit/Charsets/CharsetTest.php b/tests/unit/Charsets/CharsetTest.php index fbe59d8c3a..7eeca9ad70 100644 --- a/tests/unit/Charsets/CharsetTest.php +++ b/tests/unit/Charsets/CharsetTest.php @@ -22,7 +22,6 @@ class CharsetTest extends AbstractTestCase $charset = Charset::fromServer($serverCharset); - self::assertInstanceOf(Charset::class, $charset); self::assertSame('utf8', $charset->getName()); self::assertSame('utf8_general_ci', $charset->getDefaultCollation()); self::assertSame('UTF-8 Unicode', $charset->getDescription()); diff --git a/tests/unit/Charsets/CollationTest.php b/tests/unit/Charsets/CollationTest.php index 668ab5c332..cc585412d2 100644 --- a/tests/unit/Charsets/CollationTest.php +++ b/tests/unit/Charsets/CollationTest.php @@ -26,7 +26,6 @@ class CollationTest extends AbstractTestCase $collation = Collation::fromServer($serverCollation); - self::assertInstanceOf(Collation::class, $collation); self::assertSame('utf8_general_ci', $collation->getName()); self::assertSame('Unicode, case-insensitive', $collation->getDescription()); self::assertSame('utf8', $collation->getCharset()); diff --git a/tests/unit/ConfigTest.php b/tests/unit/ConfigTest.php index a5afdc762b..eeef70b095 100644 --- a/tests/unit/ConfigTest.php +++ b/tests/unit/ConfigTest.php @@ -17,7 +17,6 @@ use ReflectionProperty; use function define; use function defined; -use function file_exists; use function file_put_contents; use function fileperms; use function function_exists; @@ -123,7 +122,7 @@ PHP; // Teardown unlink($tmpConfig); - self::assertFalse(file_exists($tmpConfig)); + self::assertFileDoesNotExist($tmpConfig); } /** diff --git a/tests/unit/Database/CentralColumnsTest.php b/tests/unit/Database/CentralColumnsTest.php index 2003971881..e499d79d49 100644 --- a/tests/unit/Database/CentralColumnsTest.php +++ b/tests/unit/Database/CentralColumnsTest.php @@ -405,7 +405,6 @@ class CentralColumnsTest extends AbstractTestCase public function testGetColumnsNotInCentralList(): void { $columns = $this->centralColumns->getColumnsNotInCentralList('PMA_db', 'PMA_table'); - self::assertIsArray($columns); self::assertSame(['id', 'col1', 'col2'], $columns); } } From 49e827a6b535726efed4b1bec49d00893244f07e Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 18 Mar 2024 20:58:56 +0100 Subject: [PATCH 9/9] Data provider should be static Signed-off-by: Kamil Tekiela --- tests/end-to-end/ExportTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end-to-end/ExportTest.php b/tests/end-to-end/ExportTest.php index bc945ea15b..28d47b8ce3 100644 --- a/tests/end-to-end/ExportTest.php +++ b/tests/end-to-end/ExportTest.php @@ -92,7 +92,7 @@ class ExportTest extends TestBase * @return array>> * @psalm-return array */ - public function exportDataProvider(): array + public static function exportDataProvider(): array { return [ ['CSV', ['"1","2"']],