Skip to content

Commit

Permalink
Indicate support for doctrine/persistence 3 (doctrine#9656)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Apr 15, 2022
1 parent 7e49c70 commit 7029965
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 75 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
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
persistence-version: "default"
- 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 @@ -46,7 +46,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 All @@ -63,7 +63,7 @@ jobs:
if: "${{ matrix.dbal-version == '2.13' }}"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse -c phpstan-persistence3.neon"
run: "vendor/bin/phpstan analyse -c phpstan-persistence2.neon"
if: "${{ matrix.dbal-version == 'default' && matrix.persistence-version != 'default'}}"

static-analysis-psalm:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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",
"symfony/polyfill-php72": "^1.23",
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 @@ -20,7 +20,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 @@ -32,7 +33,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: 3 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio
}

/**
* {@inheritDoc}
* @deprecated This method will be removed in ORM 3.0.
*
* @return class-string
*/
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
{
Expand Down
11 changes: 11 additions & 0 deletions phpstan-dbal2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ parameters:

# Symfony cache supports passing a key prefix to the clear method.
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'

# Persistence 2 support
-
message: '/clear.*invoked with 1 parameter/'
path: lib/Doctrine/ORM/EntityRepository.php
-
message: '#^Class Doctrine\\Persistence\\ObjectManagerAware not found\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
-
message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
43 changes: 43 additions & 0 deletions phpstan-persistence2.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
includes:
- phpstan-baseline.neon
- phpstan-params.neon

parameters:
ignoreErrors:
# deprecations from doctrine/dbal:3.x
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/'

# Fallback logic for DBAL 2
-
message: '/HelperSet constructor expects/'
path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
-
message: '/Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command/'
path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php

- '/^Class Doctrine\\DBAL\\Platforms\\(PostgreSQL|SQLServer|SQLAnywhere)Platform not found\.$/'

-
message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/'
path: lib/Doctrine/ORM/Internal/SQLResultCasing.php
-
message: '/^Parameter \$stmt of method .* has invalid type Doctrine\\DBAL\\Driver\\ResultStatement\.$/'
path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
-
message: '/^Class Doctrine\\DBAL\\Driver\\ResultStatement not found\.$/'
path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
-
message: '/^Call to static method ensure\(\) on an unknown class Doctrine\\DBAL\\ForwardCompatibility\\Result\.$/'
path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php

# False positive
-
message: '/^Variable \$offset in isset\(\) always exists and is not nullable\.$/'
path: lib/Doctrine/ORM/PersistentCollection.php
-
message: '/^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/'
count: 1
path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php

# Symfony cache supports passing a key prefix to the clear method.
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'
14 changes: 0 additions & 14 deletions phpstan-persistence3.neon

This file was deleted.

11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ parameters:

# Symfony cache supports passing a key prefix to the clear method.
- '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/'

# Persistence 2 support
-
message: '/clear.*invoked with 1 parameter/'
path: lib/Doctrine/ORM/EntityRepository.php
-
message: '#^Class Doctrine\\Persistence\\ObjectManagerAware not found\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
-
message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php
20 changes: 11 additions & 9 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,22 @@
<MissingReturnType occurrences="1">
<code>wrapInTransaction</code>
</MissingReturnType>
<MoreSpecificImplementedParamType occurrences="1">
<code>$className</code>
</MoreSpecificImplementedParamType>
<TooManyArguments occurrences="2">
<code>find</code>
<code>flush</code>
</TooManyArguments>
</file>
<file src="lib/Doctrine/ORM/EntityManager.php">
<ArgumentTypeCoercion occurrences="1">
<ArgumentTypeCoercion occurrences="6">
<code>$className</code>
<code>$connection</code>
<code>$entityName</code>
<code>ltrim($className, '\\')</code>
<code>ltrim($entityName, '\\')</code>
<code>ltrim($entityName, '\\')</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="2">
<code>getMetadataCacheImpl</code>
Expand Down Expand Up @@ -299,14 +307,12 @@
<MissingReturnType occurrences="1">
<code>wrapInTransaction</code>
</MissingReturnType>
<ParamNameMismatch occurrences="8">
<ParamNameMismatch occurrences="6">
<code>$entity</code>
<code>$entity</code>
<code>$entity</code>
<code>$entity</code>
<code>$entity</code>
<code>$entity</code>
<code>$entityName</code>
<code>$entityName</code>
</ParamNameMismatch>
<PossiblyNullArgument occurrences="2">
Expand Down Expand Up @@ -1428,9 +1434,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 @@ -2169,8 +2172,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 @@ -109,6 +109,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 @@ -126,6 +134,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 @@ -148,6 +159,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>
<UndefinedDocblockClass>
Expand Down

0 comments on commit 7029965

Please sign in to comment.