diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index cc3ec50..be830dd 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -11,7 +11,7 @@ on: jobs: test: name: "PHP ${{ matrix.php-version }} ${{ matrix.dependencies }} ${{ matrix.dev-dependencies && 'dev' }}" - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false @@ -22,7 +22,8 @@ jobs: - php-version: '8.1' - php-version: '8.2' - php-version: '8.3' - - php-version: '8.3' + - php-version: '8.4' + - php-version: '8.5' steps: - name: Checkout project diff --git a/composer.json b/composer.json index 843324f..9889173 100644 --- a/composer.json +++ b/composer.json @@ -33,8 +33,8 @@ }, "require-dev": { "ramsey/uuid": "^3.5", - "phpunit/phpunit": "^7.5 || ^8.0 || ^9.0", - "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^9.0", + "phpstan/phpstan": "^2.1", "friendsofphp/php-cs-fixer": "^3.40" }, "suggest": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6fc9436..4fdac27 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,8 +9,3 @@ parameters: message: "#^Empty array passed to foreach\\.$#" count: 5 path: src/PHPCR/Util/Console/Helper/PhpcrHelper.php - # only formulated in phpdoc that the return value must be countable - - - message: "#expects array|Countable, Iterator given\\.$#" - count: 1 - path: src/PHPCR/Util/Console/Command/NodesUpdateCommand.php diff --git a/phpstan.tests.neon.dist b/phpstan.tests.neon.dist index d7889e1..0c5d8e1 100644 --- a/phpstan.tests.neon.dist +++ b/phpstan.tests.neon.dist @@ -6,15 +6,3 @@ parameters: excludePaths: analyse: - tests/*/Fixtures/* - - ignoreErrors: - # too pedantic for tests - - - message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge expects array, array\\\\|false given\\.$#" - count: 1 - path: tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php - - - - message: "#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_merge expects array, array\\\\|false given\\.$#" - count: 1 - path: tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php diff --git a/src/PHPCR/Util/CND/Parser/AbstractParser.php b/src/PHPCR/Util/CND/Parser/AbstractParser.php index 638013f..2f91bb4 100644 --- a/src/PHPCR/Util/CND/Parser/AbstractParser.php +++ b/src/PHPCR/Util/CND/Parser/AbstractParser.php @@ -44,7 +44,7 @@ protected function checkToken(int $type, ?string $data = null, bool $ignoreCase } if ($data && $token->getData() !== $data) { - if ($ignoreCase && is_string($data) && is_string($token->getData())) { + if ($ignoreCase) { return 0 !== strcasecmp($data, $token->getData()); } diff --git a/src/PHPCR/Util/CND/Parser/CndParser.php b/src/PHPCR/Util/CND/Parser/CndParser.php index 33dd38d..fc661fb 100644 --- a/src/PHPCR/Util/CND/Parser/CndParser.php +++ b/src/PHPCR/Util/CND/Parser/CndParser.php @@ -595,7 +595,7 @@ private function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void */ private function parseChildNodeAttributes( NodeTypeTemplateInterface $parentType, - NodeDefinitionTemplateInterface $childType + NodeDefinitionTemplateInterface $childType, ): void { while (true) { if ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->PRIMARY)) { diff --git a/src/PHPCR/Util/CND/Scanner/Token.php b/src/PHPCR/Util/CND/Scanner/Token.php index 1081328..6e4d146 100644 --- a/src/PHPCR/Util/CND/Scanner/Token.php +++ b/src/PHPCR/Util/CND/Scanner/Token.php @@ -22,7 +22,7 @@ public function __construct( */ private string $data = '', private int $line = 0, - private int $row = 0 + private int $row = 0, ) { } diff --git a/src/PHPCR/Util/CND/Writer/CndWriter.php b/src/PHPCR/Util/CND/Writer/CndWriter.php index 796f399..b585a8c 100644 --- a/src/PHPCR/Util/CND/Writer/CndWriter.php +++ b/src/PHPCR/Util/CND/Writer/CndWriter.php @@ -33,7 +33,7 @@ class CndWriter private array $namespaces = []; public function __construct( - private NamespaceRegistryInterface $ns + private NamespaceRegistryInterface $ns, ) { } diff --git a/src/PHPCR/Util/Console/Helper/TreeDumper/ConsoleDumperItemVisitor.php b/src/PHPCR/Util/Console/Helper/TreeDumper/ConsoleDumperItemVisitor.php index ecdd293..11aabc9 100644 --- a/src/PHPCR/Util/Console/Helper/TreeDumper/ConsoleDumperItemVisitor.php +++ b/src/PHPCR/Util/Console/Helper/TreeDumper/ConsoleDumperItemVisitor.php @@ -20,7 +20,7 @@ abstract class ConsoleDumperItemVisitor implements ItemVisitorInterface protected int $level = 0; public function __construct( - protected OutputInterface $output + protected OutputInterface $output, ) { } diff --git a/src/PHPCR/Util/QOM/QueryBuilder.php b/src/PHPCR/Util/QOM/QueryBuilder.php index 046bc87..5138b8a 100644 --- a/src/PHPCR/Util/QOM/QueryBuilder.php +++ b/src/PHPCR/Util/QOM/QueryBuilder.php @@ -68,7 +68,7 @@ class QueryBuilder private array $params = []; public function __construct( - private QueryObjectModelFactoryInterface $qomFactory + private QueryObjectModelFactoryInterface $qomFactory, ) { } diff --git a/src/PHPCR/Util/QOM/Sql2Generator.php b/src/PHPCR/Util/QOM/Sql2Generator.php index 7c042f1..6ed211a 100644 --- a/src/PHPCR/Util/QOM/Sql2Generator.php +++ b/src/PHPCR/Util/QOM/Sql2Generator.php @@ -270,7 +270,7 @@ public function evalColumns(iterable $columns): string public function evalColumn(string $selectorName, ?string $propertyName = null, ?string $colname = null): string { $sql2 = ''; - if (null !== $selectorName && null === $propertyName && null === $colname) { + if (null === $propertyName && null === $colname) { $sql2 .= $this->addBracketsIfNeeded($selectorName).'.*'; } else { $sql2 .= $this->evalPropertyValue($propertyName, $selectorName); diff --git a/tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php b/tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php index 1e49cbb..ac8d2fb 100644 --- a/tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php +++ b/tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php @@ -9,32 +9,21 @@ class FileReaderTest extends TestCase { - /** - * @var string - */ - private $filepath; - - /** - * @var FileReader - */ - private $reader; + private string $filepath; - /** - * @var string[] - */ - private $lines; + private FileReader $reader; /** * @var string[] */ - private $chars; + private array $chars; public function setUp(): void { $this->filepath = __DIR__.'/../Fixtures/files/TestFile.txt'; $this->reader = new FileReader($this->filepath); - $this->lines = [ + $lines = [ 'This is a test file...', '', '...containing dummy content.', @@ -42,9 +31,11 @@ public function setUp(): void ]; $this->chars = array_merge( - preg_split('//', $this->lines[0], -1, PREG_SPLIT_NO_EMPTY), + /* @phpstan-ignore argument.type */ // our fixtures are expected to be without error, no need to check if split worked + preg_split('//', $lines[0], -1, PREG_SPLIT_NO_EMPTY), ["\n", "\n"], - preg_split('//', $this->lines[2], -1, PREG_SPLIT_NO_EMPTY), + /* @phpstan-ignore argument.type */ + preg_split('//', $lines[2], -1, PREG_SPLIT_NO_EMPTY), ["\n", "\n"] ); } diff --git a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php index 1868ed0..95ea9f2 100644 --- a/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php +++ b/tests/PHPCR/Tests/Util/Console/Command/WorkspaceExportCommandTest.php @@ -35,21 +35,12 @@ public function testNodeTypeList(): void $this->session->expects($this->once()) ->method('exportSystemView'); - if (method_exists($this, 'assertFileDoesNotExist')) { - $this->assertFileDoesNotExist('test', 'test export file must not exist, it will be overwritten'); - } else { - // support phpunit 8 and older, can be removed when we only support php 9 or newer - $this->assertFileNotExists('test', 'test export file must not exist, it will be overwritten'); - } + $this->assertFileDoesNotExist('test', 'test export file must not exist, it will be overwritten'); $ct = $this->executeCommand('phpcr:workspace:export', [ 'filename' => 'test', ]); - if (method_exists($ct, 'getStatusCode')) { - // Only available since symfony 2.4 - $this->assertEquals(0, $ct->getStatusCode()); - } - $this->assertFileExists('test'); + $this->assertEquals(0, $ct->getStatusCode()); } } diff --git a/tests/PHPCR/Tests/Util/QOM/QueryBuilderTest.php b/tests/PHPCR/Tests/Util/QOM/QueryBuilderTest.php index b89f7e2..5771144 100644 --- a/tests/PHPCR/Tests/Util/QOM/QueryBuilderTest.php +++ b/tests/PHPCR/Tests/Util/QOM/QueryBuilderTest.php @@ -26,8 +26,6 @@ class QueryBuilderTest extends TestCase public function setUp(): void { $this->qf = $this->getMockBuilder(QueryObjectModelFactoryInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) ->getMock(); } @@ -45,18 +43,10 @@ public function testSetMaxResults(): void $this->assertEquals(15, $qb->getMaxResults()); } - /** - * @return DynamicOperandInterface - */ - private function createDynamicOperandMock() + private function createDynamicOperandMock(): DynamicOperandInterface { - /** @var DynamicOperandInterface $dynamicOperand */ - $dynamicOperand = $this->getMockBuilder(DynamicOperandInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) + return $this->getMockBuilder(DynamicOperandInterface::class) ->getMock(); - - return $dynamicOperand; } public function testAddOrderBy(): void @@ -137,18 +127,10 @@ public function testOrderAscendingIsDefault(): void $qb->addOrderBy($dynamicOperand); } - /** - * @return ConstraintInterface - */ - private function createConstraintMock() + private function createConstraintMock(): ConstraintInterface { - /** @var ConstraintInterface $constraint */ - $constraint = $this->getMockBuilder(ConstraintInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) + return $this->getMockBuilder(ConstraintInterface::class) ->getMock(); - - return $constraint; } public function testWhere(): void @@ -206,18 +188,10 @@ public function testAddSelect(): void $this->assertCount(2, $qb->getColumns()); } - /** - * @return SourceInterface - */ - private function createSourceMock() + private function createSourceMock(): SourceInterface { - /** @var SourceInterface $source */ - $source = $this->getMockBuilder(SourceInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) + return $this->getMockBuilder(SourceInterface::class) ->getMock(); - - return $source; } public function testFrom(): void @@ -229,18 +203,10 @@ public function testFrom(): void $this->assertEquals($source, $qb->getSource()); } - /** - * @return SameNodeJoinConditionInterface - */ - private function createSameNodeJoinConditionMock() + private function createSameNodeJoinConditionMock(): SameNodeJoinConditionInterface { - /** @var SameNodeJoinConditionInterface $joinCondition */ - $joinCondition = $this->getMockBuilder(SameNodeJoinConditionInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) + return $this->getMockBuilder(SameNodeJoinConditionInterface::class) ->getMock(); - - return $joinCondition; } public function testInvalidJoin(): void @@ -335,12 +301,8 @@ public function testGetQuery(): void */ private function createQueryMock() { - $query = $this->getMockBuilder(QueryObjectModelInterface::class) - ->setMethods([]) - ->setConstructorArgs([]) + return $this->getMockBuilder(QueryObjectModelInterface::class) ->getMock(); - - return $query; } public function testGetQueryWithOffsetAndLimit(): void diff --git a/tests/PHPCR/Tests/Util/ValueConverterTest.php b/tests/PHPCR/Tests/Util/ValueConverterTest.php index 28f0b87..af3d542 100644 --- a/tests/PHPCR/Tests/Util/ValueConverterTest.php +++ b/tests/PHPCR/Tests/Util/ValueConverterTest.php @@ -26,7 +26,7 @@ public function setUp(): void } /** - * @return array + * @return array */ public function dataConversionMatrix(): array { @@ -284,7 +284,7 @@ public function testConvertType(mixed $value, int $srcType, mixed $expected, int $this->fail('Expected that this conversion would throw an exception'); } catch (ValueFormatException $e) { // expected - $this->assertTrue(true); // make it assert something + $this->addToAssertionCount(1); } } else { if ($expected instanceof \DateTime) {