Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 Support #8303

Merged
merged 23 commits into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
477c27f
Update doctrine/dbal to 2.12 for PHP 8 support.
beberlei Oct 24, 2020
e2e85d1
Change Query\Parser::match to Query\Parser::matchToken including DQL …
beberlei Oct 24, 2020
fe4e9ca
Fix phpunit constraint to 9.4, adjust @group usage to workaround PHPU…
beberlei Oct 24, 2020
8f69613
Fix PHPUnit API related changes.
beberlei Oct 24, 2020
d0c3497
Add PHP 8 support for EntityGenerator namespace detection.
beberlei Oct 24, 2020
b6d7797
Use new assertEqualsWithDetla for QueryDqlFunctionTest with date comp…
beberlei Oct 24, 2020
6604a32
Replace ReflectionParameter::getClass usage with non-deprecated ::get…
beberlei Oct 24, 2020
080d72c
Revert "Change Query\Parser::match to Query\Parser::matchToken includ…
beberlei Oct 24, 2020
68b23b3
More matchToken => match reverts
beberlei Oct 24, 2020
c226a44
Housekeeping: phpcs
beberlei Oct 24, 2020
c041104
Housekeeping: phpcs
beberlei Oct 24, 2020
b9af10e
Housekeeping: phpcs
beberlei Oct 24, 2020
fe6eeb2
Housekeeping: phpcs
beberlei Oct 24, 2020
9f46d7d
Add PHP 8 testrunner, update composer.json and small fix in OrmFuncti…
beberlei Nov 7, 2020
d3cf5ae
Update doctrine/coding-standard to 8.x
beberlei Nov 7, 2020
0cd43d8
Update rule names for doctrine/coding-standard v8.0
beberlei Nov 7, 2020
4c1f388
Update to Psalm 4.
beberlei Nov 7, 2020
0d9c8ab
Merge branch 'Psalm4' into Php8Support
beberlei Nov 7, 2020
0544e9b
Not failOnWarning anymore.
beberlei Nov 7, 2020
7090a95
Fix phpcs
beberlei Nov 7, 2020
f8f69a7
fix phpcs
beberlei Nov 7, 2020
0f6d18a
remove 7.2 for now until we can support in DBAL.
beberlei Nov 7, 2020
e3f80bd
Relax doctrine/dbal requirement and add 7.2 CI support again.
beberlei Nov 15, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
deps:
- "normal"
include:
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/mysqli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<var name="db_driver" value="mysqli"/>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_mysql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<var name="db_driver" value="pdo_mysql"/>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<var name="db_driver" value="pdo_pgsql"/>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/sqlite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<!-- necessary change for some CLI/console output test assertions -->
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"sort-packages": true
},
"require": {
"php": "^7.2",
"php": "^7.2|^8.0",
"ext-pdo": "*",
"composer/package-versions-deprecated": "^1.8",
"doctrine/annotations": "^1.11.1",
"doctrine/cache": "^1.9.1",
"doctrine/collections": "^1.5",
"doctrine/common": "^3.0",
"doctrine/dbal": "^2.10.0",
"doctrine/dbal": "^2.12.0",
beberlei marked this conversation as resolved.
Show resolved Hide resolved
"doctrine/event-manager": "^1.1",
"doctrine/inflector": "^1.4|^2.0",
"doctrine/instantiator": "^1.3",
Expand All @@ -32,11 +32,11 @@
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"doctrine/coding-standard": "^8.0",
"phpstan/phpstan": "^0.12.18",
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^8.5|^9.4",
"symfony/yaml": "^3.4|^4.0|^5.0",
"vimeo/psalm": "^3.11"
"vimeo/psalm": "4.1.1"
},
"suggest": {
"symfony/yaml": "If you want to use YAML Metadata Mapping Driver"
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use ReflectionClass;
use const E_USER_DEPRECATED;
use const PHP_VERSION_ID;
use function str_replace;
use function trigger_error;
use function var_export;
Expand Down Expand Up @@ -819,6 +820,8 @@ function ($type, $variable) use ($maxParamTypeLength) {
/**
* @todo this won't work if there is a namespace in brackets and a class outside of it.
*
* @psalm-suppress UndefinedConstant
*
* @param string $src
*
* @return void
Expand All @@ -842,6 +845,8 @@ protected function parseTokensInEntityFile($src)
if ($inNamespace) {
if (in_array($token[0], [T_NS_SEPARATOR, T_STRING], true)) {
$lastSeenNamespace .= $token[1];
} elseif (PHP_VERSION_ID >= 80000 && ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)) {
$lastSeenNamespace .= $token[1];
} elseif (is_string($token) && in_array($token, [';', '{'], true)) {
$inNamespace = false;
}
Expand Down
12 changes: 6 additions & 6 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<exclude-pattern>*/tests/Doctrine/Tests/Proxies/__CG__/*</exclude-pattern>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException"/>
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
Expand All @@ -37,7 +37,7 @@
<exclude-pattern>lib/Doctrine/ORM/Tools/ToolEvents.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification">
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>lib/Doctrine/ORM/Annotation/*</exclude-pattern>
</rule>

Expand Down Expand Up @@ -109,27 +109,27 @@
<exclude-pattern>lib/Doctrine/ORM/EntityManagerInterface.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingPropertyTypeHint">
<rule name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification">
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.WriteOnlyProperty">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification">
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification">
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function setUp() : void
}

/**
* @group 6759
* @group GH-6759
*/
public function testInverseSideOneToOneLoadedAfterDqlQuery(): void
{
Expand Down
6 changes: 2 additions & 4 deletions tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ public function testDateAdd(string $unit, int $amount, int $delta = 0) : void
self::assertEqualsWithDelta(
(new \DateTimeImmutable($result['now']))->modify(sprintf('+%d %s', $amount, $unit)),
new \DateTimeImmutable($result['add']),
$delta,
''
$delta
);
}

Expand Down Expand Up @@ -342,8 +341,7 @@ public function testDateSub(string $unit, int $amount, int $delta = 0) : void
self::assertEqualsWithDelta(
(new \DateTimeImmutable($result['now']))->modify(sprintf('-%d %s', $amount, $unit)),
new \DateTimeImmutable($result['sub']),
$delta,
''
$delta
);
}

Expand Down
1 change: 0 additions & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ protected function setUp() : void
$this->_em->getClassMetadata(DDC144Operand::class),
]
);

}

/**
Expand Down
7 changes: 4 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\ORM\Events;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Tests\Models\CMS\CmsUser;
use ReflectionClass;
use ReflectionObject;

/**
* @group DDC-3123
Expand Down Expand Up @@ -38,8 +38,9 @@ public function testIssue()
->expects($this->once())
->method(Events::postFlush)
->will($this->returnCallback(function () use ($uow, $test) {
$class = new ReflectionClass(UnitOfWork::class);
$property = $class->getProperty('extraUpdates');
$reflection = new ReflectionObject($uow);
$property = $reflection->getProperty('extraUpdates');

$property->setAccessible(true);
$test->assertEmpty(
$property->getValue($uow),
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ protected function setUp() : void
}

/**
* @group 4097
* @group 4277
* @group 5867
* @group GH-4097
* @group GH-4277
* @group GH-5867
*
* When using an embedded field in an inheritance, private properties should also be inherited.
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ protected function setUp() : void
/**
* @group DDC-3597
*/
public function testSaveImageEntity() {
public function testSaveImageEntity(): void
{
$imageEntity = new DDC3597Image('foobar');
$imageEntity->setFormat('JPG');
$imageEntity->setSize(123);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group 2947
* @group GH-2947
*/
class GH2947Test extends OrmFunctionalTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function setUp() : void
}

/**
* @group 5562
* @group GH-5562
*/
public function testCacheShouldBeUpdatedWhenAssociationChanges()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group 5804
* @group GH-5804
*/
final class GH5804Test extends OrmFunctionalTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group 5887
* @group GH-5887
*/
class GH5887Test extends OrmFunctionalTestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function setUp() : void
* Verifies that when wrong entity is persisted via relationship field, the error message does not correctly state
* the expected class name.
*
* @group 6029
* @group GH-6029
*/
public function testManyToManyAssociation() : void
{
Expand All @@ -55,7 +55,7 @@ public function testManyToManyAssociation() : void
* Verifies that when wrong entity is persisted via relationship field, the error message does not correctly state
* the expected class name.
*
* @group 6029
* @group GH-6029
*/
public function testOneToManyAssociation() : void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function setUp() : void
* of using objects as discriminators (which makes things a bit
* more dynamic as you can see on the mapping of `GH6141Person`)
*
* @group 6141
* @group GH-6141
*/
public function testEnumDiscriminatorsShouldBeConvertedToString()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp() : void
}

/**
* @group 6362
* @group GH-6362
*
* SELECT a as base, b, c, d
* FROM Start a
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group 6402
* @group GH-6402
*/
class GH6402Test extends OrmFunctionalTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp() : void
}

/**
* @group 6531
* @group GH-6531
*/
public function testSimpleDerivedIdentity() : void
{
Expand All @@ -41,7 +41,7 @@ public function testSimpleDerivedIdentity() : void
}

/**
* @group 6531
* @group GH-6531
*/
public function testDynamicAttributes() : void
{
Expand All @@ -58,7 +58,7 @@ public function testDynamicAttributes() : void
}

/**
* @group 6531
* @group GH-6531
*/
public function testJoinTableWithMetadata() : void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
final class GH6682Test extends OrmFunctionalTestCase
{
/**
* @group 6682
* @group GH-6682
*/
public function testIssue() : void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Doctrine\Tests\OrmFunctionalTestCase;

/**
* @group 6699
* @group GH-6699
*/
final class GH6699Test extends OrmFunctionalTestCase
{
Expand Down
Loading