Skip to content

Commit

Permalink
Merge branch '2.12.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.12.x:
  Indicate support for doctrine/persistence 3 (doctrine#9656)
  Fix tests for enum ID hydration (doctrine#9658)
  Revert "Use charset/collation from column or table default when creating relations (doctrine#9636)"
  Fix test file/class names (doctrine#9649)
  • Loading branch information
derrabus committed Apr 15, 2022
2 parents 29a3495 + 7029965 commit 046683a
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 190 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,6 @@ env:
fail-fast: true

jobs:
phpunit-unstable:
name: "PHPUnit with unstable dependencies"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "8.1"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "pdo, pdo_sqlite"
coverage: "pcov"
ini-values: "zend.assertions=1"

- name: "Require specific doctrine/persistence version"
run: "composer require doctrine/persistence '3.0.x-dev as 2.4.0' --no-update"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage-no-cache.xml"
env:
ENABLE_SECOND_LEVEL_CACHE: 0

- name: "Run PHPUnit with Second Level Cache"
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml"
env:
ENABLE_SECOND_LEVEL_CACHE: 1

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-sqlite-${{ matrix.php-version }}-unstable-coverage"
path: "coverage*.xml"

phpunit-smoke-check:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
include:
- php-version: "8.1"
dbal-version: "default"
persistence-version: "'3.0.x-dev as 2.4.0'"
persistence-version: "2.5"

steps:
- name: "Checkout code"
Expand All @@ -43,7 +43,7 @@ jobs:
if: "${{ matrix.dbal-version != 'default' }}"

- name: "Require specific persistence version"
run: "composer require doctrine/persistence ${{ matrix.persistence-version }} --no-update"
run: "composer require doctrine/persistence ^${{ matrix.persistence-version }} --no-update"
if: "${{ matrix.persistence-version != 'default' }}"

- name: "Install dependencies with Composer"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"doctrine/inflector": "^1.4 || ^2.0",
"doctrine/instantiator": "^1.3",
"doctrine/lexer": "^1.2.3",
"doctrine/persistence": "^2.4",
"doctrine/persistence": "^2.4 || ^3",
"psr/cache": "^1 || ^2 || ^3",
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0"
},
Expand Down
6 changes: 4 additions & 2 deletions lib/Doctrine/ORM/Exception/NotSupported.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public static function createForDbal3(string $context): self
Context: %s
Problem: Feature was deprecated in doctrine/dbal 2.x and is not supported by installed doctrine/dbal:3.x
Solution: See the doctrine/deprecations logs for new alternative approaches.
EXCEPTION,
EXCEPTION
,
$context
));
}
Expand All @@ -34,7 +35,8 @@ public static function createForPersistence3(string $context): self
Context: %s
Problem: Feature was deprecated in doctrine/persistence 2.x and is not supported by installed doctrine/persistence:3.x
Solution: See the doctrine/deprecations logs for new alternative approaches.
EXCEPTION,
EXCEPTION
,
$context
));
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio
}

/**
* {@inheritDoc}
* @deprecated This method will be removed in ORM 3.0.
*/
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName): string
{
throw new BadMethodCallException(__METHOD__ . ' is no longer supported by ' . self::class);
}
Expand Down
22 changes: 0 additions & 22 deletions lib/Doctrine/ORM/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use function in_array;
use function is_array;
use function is_numeric;
use function method_exists;
use function strtolower;

/**
Expand Down Expand Up @@ -724,27 +723,6 @@ private function gatherRelationJoinColumns(
$columnOptions['precision'] = $fieldMapping['precision'];
}

// Only do this for DBAL v3 or higher.
if (! method_exists(AbstractPlatform::class, 'getGuidExpression')) {
$theJoinTableCharset = $theJoinTable->hasOption('charset') ? $theJoinTable->getOption('charset') : null;
if (
! isset($columnOptions['customSchemaOptions']['charset'])
&& isset($class->table['options']['charset'])
&& $theJoinTableCharset !== $class->table['options']['charset']
) {
$columnOptions['customSchemaOptions']['charset'] = $class->table['options']['charset'];
}

$theJoinTableCollation = $theJoinTable->hasOption('collation') ? $theJoinTable->getOption('collation') : null;
if (
! isset($columnOptions['customSchemaOptions']['collation'])
&& isset($class->table['options']['collation'])
&& $theJoinTableCollation !== $class->table['options']['collation']
) {
$columnOptions['customSchemaOptions']['collation'] = $class->table['options']['collation'];
}
}

$theJoinTable->addColumn($quotedColumnName, $fieldMapping['type'], $columnOptions);
}

Expand Down
12 changes: 6 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,12 @@
</RedundantCastGivenDocblockType>
</file>
<file src="lib/Doctrine/ORM/EntityManager.php">
<ArgumentTypeCoercion occurrences="1">
<ArgumentTypeCoercion occurrences="5">
<code>$className</code>
<code>$connection</code>
<code>ltrim($className, '\\')</code>
<code>ltrim($entityName, '\\')</code>
<code>ltrim($entityName, '\\')</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="4">
<code>is_object($entity)</code>
Expand Down Expand Up @@ -1129,9 +1133,6 @@
<code>$metadata-&gt;isEmbeddedClass</code>
<code>$metadata-&gt;isMappedSuperclass</code>
</NoInterfaceProperties>
<PossiblyNullArgument occurrences="1">
<code>$property-&gt;name</code>
</PossiblyNullArgument>
<PossiblyNullPropertyFetch occurrences="1">
<code>$property-&gt;name</code>
</PossiblyNullPropertyFetch>
Expand Down Expand Up @@ -1851,8 +1852,7 @@
<code>string</code>
<code>string</code>
</InvalidReturnType>
<InvalidScalarArgument occurrences="14">
<code>$field</code>
<InvalidScalarArgument occurrences="13">
<code>$field</code>
<code>$field</code>
<code>$functionName</code>
Expand Down
14 changes: 14 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
<file name="lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php"/>
</errorLevel>
</MissingDependency>
<MissingParamType>
<errorLevel type="suppress">
<!-- Persistence 2 compatibility -->
<file name="lib/Doctrine/ORM/EntityManager.php"/>
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php"/>
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php"/>
</errorLevel>
</MissingParamType>
<RedundantCastGivenDocblockType>
<errorLevel type="suppress">
<!-- Can be removed once the "getMaxResults" methods of those classes have native parameter types -->
Expand All @@ -77,6 +85,9 @@
<errorLevel type="suppress">
<!-- Symfony cache supports passing a key prefix to the clear method. -->
<referencedFunction name="Psr\Cache\CacheItemPoolInterface::clear"/>

<!-- Persistence 2 compatibility -->
<referencedFunction name="Doctrine\Persistence\ObjectManager::clear"/>
</errorLevel>
</TooManyArguments>
<TypeDoesNotContainType>
Expand All @@ -94,6 +105,9 @@
<!-- DBAL 3.2 forward compatibility -->
<referencedClass name="Doctrine\DBAL\Platforms\PostgreSQLPlatform"/>
<referencedClass name="Doctrine\DBAL\Platforms\SQLServerPlatform"/>

<!-- Persistence 2 compatibility -->
<referencedClass name="Doctrine\Persistence\ObjectManagerAware"/>
</errorLevel>
</UndefinedClass>
</issueHandlers>
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\Tests\OrmFunctionalTestCase;

class DDC1258Test extends OrmFunctionalTestCase
class DDC1458Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
Expand Down
105 changes: 0 additions & 105 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Github issue: 7684
*/
class GH7684 extends DatabaseDriverTestCase
class GH7684Test extends DatabaseDriverTestCase
{
public function testIssue(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Doctrine\ORM\Mapping\Table;
use Doctrine\Tests\OrmFunctionalTestCase;

class Ticket4646MultipleInstanceOfWithMultipleParametersTest extends OrmFunctionalTestCase
class Ticket4646InstanceOfWithMultipleParametersTest extends OrmFunctionalTestCase
{
protected function setUp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public function testFlattenIdentifierWithEnumId(): void

$this->_em->persist($typedCardEnumIdEntity);
$this->_em->flush();
$this->_em->clear();

$findTypedCardEnumIdEntityNotFound = $this->_em->getRepository(TypedCardEnumId::class)->find(Suit::Diamonds);

self::assertNull($findTypedCardEnumIdEntityNotFound, 'Search by non-cached Enum ID does not work');
self::assertNull($findTypedCardEnumIdEntityNotFound, 'Search by non-persisted Enum ID does not work');

$findTypedCardEnumIdEntity = $this->_em->getRepository(TypedCardEnumId::class)->find(Suit::Clubs);

Expand All @@ -73,10 +74,11 @@ public function testFlattenIdentifierWithCompositeEnumId(): void

$this->_em->persist($typedCardEnumCompositeIdEntity);
$this->_em->flush();
$this->_em->clear();

$findTypedCardEnumCompositeIdEntityNotFound = $this->_em->getRepository(TypedCardEnumCompositeId::class)->find(['suit' => Suit::Diamonds, 'unit' => Unit::Gram]);

self::assertNull($findTypedCardEnumCompositeIdEntityNotFound, 'Search by non-cached composite Enum ID does not work');
self::assertNull($findTypedCardEnumCompositeIdEntityNotFound, 'Search by non-persisted composite Enum ID does not work');

$findTypedCardEnumCompositeIdEntity = $this->_em->getRepository(TypedCardEnumCompositeId::class)->find(['suit' => Suit::Clubs, 'unit' => Unit::Gram]);

Expand Down

0 comments on commit 046683a

Please sign in to comment.