Skip to content

Commit 943818e

Browse files
committed
Modernize codebase for PHP 7.4
1 parent 4d16277 commit 943818e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+220
-299
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ jobs:
2525
strategy:
2626
matrix:
2727
php-version:
28-
- "7.2"
29-
- "7.3"
3028
- "7.4"
3129
- "8.0"
3230
- "8.1"
31+
- "8.2"
3332
dependencies:
3433
- "highest"
3534
include:
36-
- php-version: "7.2"
35+
- php-version: "7.4"
3736
dependencies: "lowest"
3837

3938
steps:

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^7.2 || ^8.0",
17+
"php": "^7.4 || ^8.0",
1818
"doctrine/persistence": "^2.0|^3.0"
1919
},
2020
"conflict": {
2121
"doctrine/dbal": "<2.13",
22-
"doctrine/orm": "<2.12",
22+
"doctrine/orm": "<2.13",
2323
"doctrine/phpcr-odm": "<1.3.0"
2424
},
2525
"require-dev": {
2626
"ext-sqlite3": "*",
27-
"doctrine/coding-standard": "^11.0",
27+
"doctrine/coding-standard": "^11.1",
2828
"doctrine/dbal": "^2.13 || ^3.0",
2929
"doctrine/deprecations": "^1.0",
3030
"doctrine/mongodb-odm": "^1.3.0 || ^2.0.0",
31-
"doctrine/orm": "^2.12",
32-
"phpstan/phpstan": "^1.5",
33-
"phpunit/phpunit": "^8.5 || ^9.5 || ^10.0",
34-
"symfony/cache": "^5.0 || ^6.0",
35-
"vimeo/psalm": "^4.10 || ^5.9"
31+
"doctrine/orm": "^2.13",
32+
"phpstan/phpstan": "^1.10",
33+
"phpunit/phpunit": "^9.6.6 || ^10.0",
34+
"symfony/cache": "^5.4 || ^6.2",
35+
"vimeo/psalm": "^5.9"
3636
},
3737
"suggest": {
3838
"alcaeus/mongo-php-adapter": "For using MongoDB ODM 1.3 with PHP 7 (deprecated)",

phpcs.xml.dist

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<arg name="cache" value=".phpcs-cache"/>
77
<arg name="colors" />
88

9-
<config name="php_version" value="70200"/>
9+
<config name="php_version" value="70400"/>
1010

1111
<!-- Ignore warnings and show progress of the run -->
1212
<arg value="nps"/>
@@ -19,10 +19,6 @@
1919
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
2020
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
2121
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
22-
23-
<!-- Will cause BC breaks to method signatures - disabled for now -->
24-
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
25-
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
2622
</rule>
2723

2824
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
@@ -47,6 +43,24 @@
4743
<exclude-pattern>src/SharedFixtureInterface.php</exclude-pattern>
4844
</rule>
4945

46+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
47+
<!-- Adding parameter types is a BC break in most cases because of strict types. -->
48+
<exclude-pattern>src/*</exclude-pattern>
49+
50+
<!-- Don't add parameter types to overridden methods -->
51+
<exclude-pattern>tests/Common/DataFixtures/TestTypes/UuidType.php</exclude-pattern>
52+
</rule>
53+
54+
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint">
55+
<!-- Adding property types is a BC break in most cases. -->
56+
<exclude-pattern>src/*</exclude-pattern>
57+
</rule>
58+
59+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
60+
<!-- Adding return types is a BC break in most cases. -->
61+
<exclude-pattern>src/*</exclude-pattern>
62+
</rule>
63+
5064
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
5165
<exclude-pattern>tests/*</exclude-pattern>
5266
</rule>

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ parameters:
102102

103103
-
104104
message: "#^Method Doctrine\\\\Tests\\\\Common\\\\DataFixtures\\\\Executor\\\\PHPCRExecutorTest\\:\\:getDocumentManager\\(\\) has invalid return type Doctrine\\\\ODM\\\\PHPCR\\\\DocumentManager\\.$#"
105-
count: 1
105+
count: 2
106106
path: tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php
107107

108108
-

psalm-baseline.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
2+
<files psalm-version="5.9.0@8b9ad1eb9e8b7d3101f949291da2b9f7767cd163">
33
<file src="src/Executor/PHPCRExecutor.php">
4-
<UndefinedClass occurrences="1">
4+
<UndefinedClass>
55
<code>DocumentManagerInterface</code>
6-
</UndefinedClass>
7-
<UndefinedDocblockClass occurrences="2">
86
<code>DocumentManagerInterface</code>
7+
</UndefinedClass>
8+
<UndefinedDocblockClass>
99
<code>DocumentManagerInterface</code>
1010
</UndefinedDocblockClass>
1111
</file>
1212
<file src="src/Purger/PHPCRPurger.php">
13-
<UndefinedClass occurrences="3">
13+
<UndefinedClass>
14+
<code><![CDATA[$this->dm]]></code>
15+
<code>?DocumentManagerInterface</code>
1416
<code>?DocumentManagerInterface</code>
1517
<code>DocumentManager</code>
1618
<code>NodeHelper</code>
1719
</UndefinedClass>
18-
<UndefinedDocblockClass occurrences="3">
19-
<code>$this-&gt;dm</code>
20-
<code>DocumentManagerInterface|null</code>
20+
<UndefinedDocblockClass>
2121
<code>DocumentManagerInterface|null</code>
2222
</UndefinedDocblockClass>
2323
</file>
2424
<file src="src/ReferenceRepository.php">
25-
<UndefinedClass occurrences="2">
25+
<UndefinedClass>
2626
<code>PhpcrDocumentManager</code>
2727
<code>PhpcrDocumentManager</code>
2828
</UndefinedClass>

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
phpVersion="7.4"
3+
phpVersion="8.2"
44
errorLevel="7"
55
findUnusedBaselineEntry="true"
66
findUnusedCode="false"

src/AbstractFixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function getReference($name, ?string $class = null)
9696
'doctrine/data-fixtures',
9797
'https://github.com/doctrine/data-fixtures/pull/409',
9898
'Argument $class of %s() will be mandatory in 2.0.',
99-
__METHOD__
99+
__METHOD__,
100100
);
101101
}
102102

@@ -121,7 +121,7 @@ public function hasReference($name, ?string $class = null)
121121
'doctrine/data-fixtures',
122122
'https://github.com/doctrine/data-fixtures/pull/409',
123123
'Argument $class of %s() will be mandatory in 2.0.',
124-
__METHOD__
124+
__METHOD__,
125125
);
126126
}
127127

src/Event/Listener/MongoDBReferenceListener.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717
final class MongoDBReferenceListener implements EventSubscriber
1818
{
19-
/** @var ReferenceRepository */
20-
private $referenceRepository;
19+
private ReferenceRepository $referenceRepository;
2120

2221
public function __construct(ReferenceRepository $referenceRepository)
2322
{
@@ -27,17 +26,15 @@ public function __construct(ReferenceRepository $referenceRepository)
2726
/**
2827
* {@inheritdoc}
2928
*/
30-
public function getSubscribedEvents()
29+
public function getSubscribedEvents(): array
3130
{
3231
return ['postPersist'];
3332
}
3433

3534
/**
3635
* Populates identities for stored references
37-
*
38-
* @return void
3936
*/
40-
public function postPersist(LifecycleEventArgs $args)
37+
public function postPersist(LifecycleEventArgs $args): void
4138
{
4239
$object = $args->getDocument();
4340

src/Event/Listener/ORMReferenceListener.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717
final class ORMReferenceListener implements EventSubscriber
1818
{
19-
/** @var ReferenceRepository */
20-
private $referenceRepository;
19+
private ReferenceRepository $referenceRepository;
2120

2221
public function __construct(ReferenceRepository $referenceRepository)
2322
{
@@ -27,18 +26,16 @@ public function __construct(ReferenceRepository $referenceRepository)
2726
/**
2827
* {@inheritdoc}
2928
*/
30-
public function getSubscribedEvents()
29+
public function getSubscribedEvents(): array
3130
{
3231
// would be better to use onClear, but it is supported only in 2.1
3332
return ['postPersist'];
3433
}
3534

3635
/**
3736
* Populates identities for stored references
38-
*
39-
* @return void
4037
*/
41-
public function postPersist(LifecycleEventArgs $args)
38+
public function postPersist(LifecycleEventArgs $args): void
4239
{
4340
$object = $args->getEntity();
4441

src/Executor/AbstractExecutor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function purge()
135135
if ($this->purger === null) {
136136
throw new Exception(
137137
PurgerInterface::class .
138-
' instance is required if you want to purge the database before loading your data fixtures.'
138+
' instance is required if you want to purge the database before loading your data fixtures.',
139139
);
140140
}
141141

@@ -154,5 +154,5 @@ public function purge()
154154
*
155155
* @return void
156156
*/
157-
abstract public function execute(array $fixtures, $append = false);
157+
abstract public function execute(array $fixtures, bool $append = false);
158158
}

0 commit comments

Comments
 (0)