Skip to content

Commit e36a2c2

Browse files
style: update some of the QA tools configurations and enforce more modern code style (e.g. use of native annotations in fixtures) (#283)
1 parent 6bb84e7 commit e36a2c2

32 files changed

+147
-79
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#Call to deprecated method getName\(\) of class MartinGeorgiev\\Doctrine\\DBAL\\Types\\BaseType#'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#Access to undefined constant Doctrine\\ORM\\Query\\Lexer::T_[A-Z_]+#'
4+
- '#Access to constant [A-Z_]+ on an unknown class Doctrine\\ORM\\Query\\TokenType#'
5+
- '#Fetching deprecated class constant T_IDENTIFIER of class Doctrine\\ORM\\Query\\Lexer#'
6+
- '#Fetching deprecated class constant T_OPEN_PARENTHESIS of class Doctrine\\ORM\\Query\\Lexer#'
7+
- '#Fetching deprecated class constant T_CLOSE_PARENTHESIS of class Doctrine\\ORM\\Query\\Lexer#'
8+
- '#Fetching deprecated class constant T_COMMA of class Doctrine\\ORM\\Query\\Lexer#'
9+
- '#Fetching deprecated class constant T_ORDER of class Doctrine\\ORM\\Query\\Lexer#'
10+
- '#Fetching deprecated class constant T_AS of class Doctrine\\ORM\\Query\\Lexer#'
11+
- '#Fetching deprecated class constant T_DISTINCT of class Doctrine\\ORM\\Query\\Lexer#'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
ignoreErrors:
3+
- identifier: missingType.iterableValue
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#Parameter \#1 \$phpArray of method MartinGeorgiev\\Doctrine\\DBAL\\Types\\BaseArray::convertToDatabaseValue\(\) expects array\|null, string given.#'
4+
- '#Parameter \#1 \$postgresArray of method MartinGeorgiev\\Doctrine\\DBAL\\Types\\BaseArray::convertToPHPValue\(\) expects string\|null, int given.#'
5+
- '#Property MartinGeorgiev\\Doctrine\\ORM\\Query\\AST\\Functions\\Cast::\$sourceType \(Doctrine\\ORM\\Query\\AST\\Node\) does not accept Doctrine\\ORM\\Query\\AST\\Node\|string#'

ci/phpstan/config.neon

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
includes:
22
- ../../vendor/ekino/phpstan-banned-code/extension.neon
3+
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon
4+
- ../../vendor/phpstan/phpstan-doctrine/extension.neon
35
- ../../vendor/phpstan/phpstan-phpunit/extension.neon
6+
- ./baselines/deprecated-methods.neon
7+
- ./baselines/lexer-constants.neon
8+
- ./baselines/phpstan-identifiers.neon
9+
- ./baselines/type-mismatches.neon
410

511
parameters:
612
level: max
@@ -9,13 +15,10 @@ parameters:
915
- ../../src
1016
- ../../tests
1117

12-
reportUnmatchedIgnoredErrors: false
18+
tmpDir: ../../var/cache/phpstan
19+
20+
parallel:
21+
maximumNumberOfProcesses: 4
1322

14-
ignoreErrors:
15-
- identifier: missingType.iterableValue
16-
17-
- '#Parameter \#1 \$phpArray of method MartinGeorgiev\\Doctrine\\DBAL\\Types\\BaseArray::convertToDatabaseValue\(\) expects array\|null, string given.#'
18-
- '#Parameter \#1 \$postgresArray of method MartinGeorgiev\\Doctrine\\DBAL\\Types\\BaseArray::convertToPHPValue\(\) expects string\|null, int given.#'
19-
- '#Property MartinGeorgiev\\Doctrine\\ORM\\Query\\AST\\Functions\\Cast::\$sourceType \(Doctrine\\ORM\\Query\\AST\\Node\) does not accept Doctrine\\ORM\\Query\\AST\\Node\|string#'
20-
- '#Access to undefined constant Doctrine\\ORM\\Query\\Lexer::T_[A-Z_]+#'
21-
- '#Access to constant [A-Z_]+ on an unknown class Doctrine\\ORM\\Query\\TokenType#'
23+
errorFormat: table
24+
reportUnmatchedIgnoredErrors: false

ci/phpunit/config.xml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" stopOnFailure="false" bootstrap="../../vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
3-
<testsuites>
4-
<testsuite name="PostgreSQL-for-Doctrine Test Suite">
5-
<directory>../../tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
<source>
9-
<include>
10-
<directory suffix=".php">../../src</directory>
11-
</include>
12-
</source>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
colors="true"
4+
stopOnFailure="false"
5+
bootstrap="../../vendor/autoload.php"
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
7+
cacheDirectory="../../var/cache/phpunit/"
8+
executionOrder="random"
9+
failOnRisky="true"
10+
failOnWarning="true"
11+
beStrictAboutOutputDuringTests="true"
12+
beStrictAboutTodoAnnotatedTests="true">
13+
<testsuites>
14+
<testsuite name="PostgreSQL-for-Doctrine Test Suite">
15+
<directory>../../tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
<coverage>
19+
<report>
20+
<html outputDirectory="../../var/coverage/html"/>
21+
<clover outputFile="../../var/coverage/clover.xml"/>
22+
</report>
23+
</coverage>
24+
<source>
25+
<include>
26+
<directory suffix=".php">../../src</directory>
27+
</include>
28+
</source>
1329
</phpunit>

ci/rector/config.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,36 @@
1212
$basePath = __DIR__.'/../../';
1313
$paths = [
1414
$basePath.'ci',
15+
$basePath.'fixtures',
1516
$basePath.'src',
1617
$basePath.'tests',
1718
];
1819
$rectorConfig->paths($paths);
1920

21+
$rectorConfig->cacheDirectory($basePath.'var/cache/rector/');
22+
2023
$rectorConfig->parallel();
2124
$rectorConfig->phpstanConfig($basePath.'ci/phpstan/config.neon');
25+
26+
$rectorConfig->sets([
27+
SetList::CODE_QUALITY,
28+
SetList::DEAD_CODE,
29+
SetList::EARLY_RETURN,
30+
SetList::NAMING,
31+
SetList::PHP_80,
32+
SetList::PHP_81,
33+
SetList::TYPE_DECLARATION,
34+
SetList::PRIVATIZATION,
35+
SetList::CODING_STYLE,
36+
DoctrineSetList::DOCTRINE_ORM_25,
37+
DoctrineSetList::DOCTRINE_CODE_QUALITY,
38+
LevelSetList::UP_TO_PHP_81,
39+
]);
40+
2241
$rectorConfig->skip([
2342
RenamePropertyToMatchTypeRector::class,
2443
]);
25-
$rectorConfig->importShortClasses(false);
26-
$rectorConfig->importNames(false, false); // @todo Enable once Rector introduces better support for function imports.
27-
28-
$rectorConfig->import(SetList::CODE_QUALITY);
29-
$rectorConfig->import(SetList::DEAD_CODE);
30-
$rectorConfig->import(SetList::EARLY_RETURN);
31-
$rectorConfig->import(SetList::NAMING);
32-
$rectorConfig->import(SetList::PHP_80);
33-
$rectorConfig->import(SetList::PHP_81);
34-
$rectorConfig->import(SetList::TYPE_DECLARATION);
3544

36-
$rectorConfig->import(DoctrineSetList::DOCTRINE_ORM_25);
37-
$rectorConfig->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);
38-
39-
$rectorConfig->import(LevelSetList::UP_TO_PHP_81);
45+
$rectorConfig->importShortClasses(false);
46+
$rectorConfig->importNames(false, false);
4047
};

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@
4848
"ekino/phpstan-banned-code": "^1.0",
4949
"friendsofphp/php-cs-fixer": "^3.72.0",
5050
"phpstan/phpstan": "^1.12.21",
51+
"phpstan/phpstan-deprecation-rules": "^1.2",
52+
"phpstan/phpstan-doctrine": "^1.5",
5153
"phpstan/phpstan-phpunit": "^1.4.2",
5254
"phpunit/phpunit": "^10.5.45",
53-
"rector/rector": "^1.2.10",
55+
"rector/rector": "^1.2",
5456
"symfony/cache": "^6.4||^7.0"
5557
},
5658
"suggest": {

fixtures/MartinGeorgiev/Doctrine/Entity/ContainsArrays.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
namespace Fixtures\MartinGeorgiev\Doctrine\Entity;
66

7+
use Doctrine\DBAL\Types\Types;
78
use Doctrine\ORM\Mapping as ORM;
89

910
#[ORM\Entity()]
1011
class ContainsArrays extends Entity
1112
{
12-
#[ORM\Column(type: 'json')]
13+
#[ORM\Column(type: Types::JSON)]
1314
public array $array1;
1415

15-
#[ORM\Column(type: 'json')]
16+
#[ORM\Column(type: Types::JSON)]
1617
public array $array2;
1718
}

fixtures/MartinGeorgiev/Doctrine/Entity/ContainsDates.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@
44

55
namespace Fixtures\MartinGeorgiev\Doctrine\Entity;
66

7+
use Doctrine\DBAL\Types\Types;
78
use Doctrine\ORM\Mapping as ORM;
89

910
#[ORM\Entity()]
1011
class ContainsDates extends Entity
1112
{
12-
#[ORM\Column(type: 'date_immutable')]
13+
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
1314
public \DateTimeImmutable $date1;
1415

15-
#[ORM\Column(type: 'date_immutable')]
16+
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
1617
public \DateTimeImmutable $date2;
1718

18-
#[ORM\Column(type: 'datetime_immutable')]
19+
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
1920
public \DateTimeImmutable $datetime1;
2021

21-
#[ORM\Column(type: 'datetime_immutable')]
22+
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
2223
public \DateTimeImmutable $datetime2;
2324

24-
#[ORM\Column(type: 'datetimetz_immutable')]
25+
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
2526
public \DateTimeImmutable $datetimetz1;
2627

27-
#[ORM\Column(type: 'datetimetz_immutable')]
28+
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE)]
2829
public \DateTimeImmutable $datetimetz2;
2930
}

0 commit comments

Comments
 (0)