Skip to content

Commit

Permalink
Upgrade doctrine/coding-standard (#8321)
Browse files Browse the repository at this point in the history
* Use a classname that exists

Doctrine\ORM\Mapping\TableGenerator does not exist, only
Doctrine\ORM\Id\TableGenerator does.

* Upgrade doctrine/coding-standard

That library has a dependency on another library that requires composer
plugin API v1. Updating both libs allow to use Composer v2.

* Account for doctrine/reflection deprecation
greg0ire authored Oct 28, 2020

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill
1 parent ca27cc3 commit b13b2e8
Showing 6 changed files with 863 additions and 304 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
"php": "^7.1",
"ext-pdo": "*",
"composer/package-versions-deprecated": "^1.8",
"doctrine/annotations": "^1.8",
"doctrine/annotations": "^1.11.1",
"doctrine/cache": "^1.9.1",
"doctrine/collections": "^1.5",
"doctrine/common": "^2.11 || ^3.0",
@@ -35,7 +35,7 @@
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
"doctrine/coding-standard": "^5.0",
"doctrine/coding-standard": "^6.0",
"phpstan/phpstan": "^0.12.18",
"phpunit/phpunit": "^7.5",
"symfony/yaml": "^3.4|^4.0|^5.0",
1,143 changes: 849 additions & 294 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
@@ -342,7 +342,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
'initialValue' => $seqGeneratorAnnot->initialValue
]
);
} else if ($this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) {
} elseif ($this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Id\TableGenerator')) {
throw MappingException::tableIdGeneratorNotImplemented($className);
} else if ($customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, Mapping\CustomIdGenerator::class)) {
$metadata->setCustomGeneratorDefinition(
4 changes: 0 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -41,10 +41,6 @@
<exclude-pattern>lib/Doctrine/ORM/Annotation/*</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedNotEqualOperator">
<exclude-pattern>lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php</exclude-pattern>
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>lib/Doctrine/ORM/Query/Parser.php</exclude-pattern>
</rule>
12 changes: 10 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Reflection\RuntimePublicReflectionProperty;

use Doctrine\Common\Reflection\RuntimePublicReflectionProperty as LegacyRuntimePublicReflectionProperty;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\Mapping\ReflectionEmbeddedProperty;
use Doctrine\ORM\Query\QueryException;
use Doctrine\Persistence\Reflection\RuntimePublicReflectionProperty;
use Doctrine\Tests\OrmFunctionalTestCase;
use function class_exists;

/**
* @group DDC-93
@@ -35,7 +38,12 @@ public function testMetadataHasReflectionEmbeddablesAccessible()
{
$classMetadata = $this->_em->getClassMetadata(DDC93Person::class);

$this->assertInstanceOf(RuntimePublicReflectionProperty::class, $classMetadata->getReflectionProperty('address'));
$this->assertInstanceOf(
class_exists(RuntimePublicReflectionProperty::class) ?
RuntimePublicReflectionProperty::class :
LegacyRuntimePublicReflectionProperty::class,
$classMetadata->getReflectionProperty('address')
);
$this->assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street'));
}

2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php
Original file line number Diff line number Diff line change
@@ -238,7 +238,7 @@ public function testInvalidFetchOptionThrowsException()
$factory->setEntityManager($em);

$this->expectException(AnnotationException::class);
$this->expectExceptionMessage('[Enum Error] Attribute "fetch" of @Doctrine\ORM\Mapping\OneToMany declared on property Doctrine\Tests\ORM\Mapping\InvalidFetchOption::$collection accept only [LAZY, EAGER, EXTRA_LAZY], but got eager.');
$this->expectExceptionMessage('[Enum Error] Attribute "fetch" of @Doctrine\ORM\Mapping\OneToMany declared on property Doctrine\Tests\ORM\Mapping\InvalidFetchOption::$collection accepts only [LAZY, EAGER, EXTRA_LAZY], but got eager.');

$factory->getMetadataFor(InvalidFetchOption::class);
}

0 comments on commit b13b2e8

Please sign in to comment.