diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index cd8e43ed7b5..1eed8517c85 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ee006893f4d..d2ac0fb6d66 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -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" @@ -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" @@ -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: diff --git a/composer.json b/composer.json index ff9cfe68b1e..aac8c14ec44 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/lib/Doctrine/ORM/Exception/NotSupported.php b/lib/Doctrine/ORM/Exception/NotSupported.php index c8aa0e04ff8..aa334b7e7d2 100644 --- a/lib/Doctrine/ORM/Exception/NotSupported.php +++ b/lib/Doctrine/ORM/Exception/NotSupported.php @@ -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 )); } @@ -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 )); } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 626f0fdee31..832f7c31353 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -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) { diff --git a/phpstan-dbal2.neon b/phpstan-dbal2.neon index baee22e56e8..ad779ae7ac9 100644 --- a/phpstan-dbal2.neon +++ b/phpstan-dbal2.neon @@ -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 diff --git a/phpstan-persistence2.neon b/phpstan-persistence2.neon new file mode 100644 index 00000000000..6572a340e8d --- /dev/null +++ b/phpstan-persistence2.neon @@ -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\.$/' diff --git a/phpstan-persistence3.neon b/phpstan-persistence3.neon deleted file mode 100644 index de9b301576d..00000000000 --- a/phpstan-persistence3.neon +++ /dev/null @@ -1,14 +0,0 @@ -includes: - - phpstan.neon - -parameters: - ignoreErrors: - - - 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 diff --git a/phpstan.neon b/phpstan.neon index 6572a340e8d..7eae7fdd643 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 15b341dee31..ad5b01db832 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -255,14 +255,22 @@ wrapInTransaction + + $className + find flush - + + $className $connection + $entityName + ltrim($className, '\\') + ltrim($entityName, '\\') + ltrim($entityName, '\\') getMetadataCacheImpl @@ -299,14 +307,12 @@ wrapInTransaction - + $entity $entity $entity $entity $entity - $entity - $entityName $entityName @@ -1428,9 +1434,6 @@ $metadata->isEmbeddedClass $metadata->isMappedSuperclass - - $property->name - $property->name @@ -2169,8 +2172,7 @@ string string - - $field + $field $field $functionName diff --git a/psalm.xml b/psalm.xml index e36dc9eb383..b8dfc1d5974 100644 --- a/psalm.xml +++ b/psalm.xml @@ -109,6 +109,14 @@ + + + + + + + + @@ -126,6 +134,9 @@ + + + @@ -148,6 +159,9 @@ + + +