Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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<mixed, PHPCR\\Query\\RowInterface> given\\.$#"
count: 1
path: src/PHPCR/Util/Console/Command/NodesUpdateCommand.php
12 changes: 0 additions & 12 deletions phpstan.tests.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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\\<int, string\\>\\|false given\\.$#"
count: 1
path: tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Parser/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Parser/CndParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Scanner/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
*/
private string $data = '',
private int $line = 0,
private int $row = 0
private int $row = 0,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Writer/CndWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CndWriter
private array $namespaces = [];

public function __construct(
private NamespaceRegistryInterface $ns
private NamespaceRegistryInterface $ns,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class ConsoleDumperItemVisitor implements ItemVisitorInterface
protected int $level = 0;

public function __construct(
protected OutputInterface $output
protected OutputInterface $output,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/QOM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class QueryBuilder
private array $params = [];

public function __construct(
private QueryObjectModelFactoryInterface $qomFactory
private QueryObjectModelFactoryInterface $qomFactory,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/QOM/Sql2Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 8 additions & 17 deletions tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,33 @@

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.',
'',
];

$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"]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
56 changes: 9 additions & 47 deletions tests/PHPCR/Tests/Util/QOM/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class QueryBuilderTest extends TestCase
public function setUp(): void
{
$this->qf = $this->getMockBuilder(QueryObjectModelFactoryInterface::class)
->setMethods([])
->setConstructorArgs([])
->getMock();
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPCR/Tests/Util/ValueConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function setUp(): void
}

/**
* @return array<array{0: string, 1: int, 2: mixed, 3: mixed}>
* @return array<array{0: mixed, 1: int, 2: mixed, 3: mixed}>
*/
public function dataConversionMatrix(): array
{
Expand Down Expand Up @@ -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) {
Expand Down