Skip to content

Commit

Permalink
Support for DBAL 3
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Aug 29, 2021
1 parent d5f65ba commit c65cc91
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 119 deletions.
93 changes: 43 additions & 50 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,6 @@ env:
fail-fast: true

jobs:
phpunit-smoke-check-dbal-3:
name: "Experimental: PHPUnit with SQLite and DBAL 3"
runs-on: "ubuntu-20.04"
continue-on-error: true

strategy:
matrix:
php-version:
- "8.0"

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 DBAL 3"
run: "composer require doctrine/dbal ^3.0 --no-update"

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

- name: "Run PHPUnit"
continue-on-error: true
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"
id: "phpunit-run-slc"
continue-on-error: true
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"
if: "steps.phpunit-run-slc.outcome == 'success' && steps.phpunit-run-slc.conclusion == 'success'"
with:
name: "phpunit-sqlite-${{ matrix.php-version }}-dbal3-coverage"
path: "coverage*.xml"

phpunit-smoke-check:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
Expand All @@ -69,6 +19,11 @@ jobs:
- "7.3"
- "7.4"
- "8.0"
dbal-version:
- "default"
include:
- php-version: "8.0"
dbal-version: "2.13"

steps:
- name: "Checkout"
Expand All @@ -84,6 +39,10 @@ jobs:
coverage: "pcov"
ini-values: "zend.assertions=1"

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

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

Expand Down Expand Up @@ -113,9 +72,15 @@ jobs:
matrix:
php-version:
- "7.4"
dbal-version:
- "default"
postgres-version:
- "9.6"
- "13"
include:
- php-version: "8.0"
dbal-version: "2.13"
postgres-version: "13"

services:
postgres:
Expand All @@ -142,6 +107,10 @@ jobs:
coverage: "pcov"
ini-values: "zend.assertions=1"

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

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

Expand All @@ -164,11 +133,18 @@ jobs:
matrix:
php-version:
- "7.4"
dbal-version:
- "default"
mariadb-version:
- "10.5"
extension:
- "mysqli"
- "pdo_mysql"
include:
- php-version: "8.0"
dbal-version: "2.13"
mariadb-version: "10.5"
extension: "pdo_mysql"

services:
mariadb:
Expand All @@ -189,6 +165,10 @@ jobs:
with:
fetch-depth: 2

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

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
Expand Down Expand Up @@ -219,12 +199,19 @@ jobs:
matrix:
php-version:
- "7.4"
dbal-version:
- "default"
mysql-version:
- "5.7"
- "8.0"
extension:
- "mysqli"
- "pdo_mysql"
include:
- php-version: "8.0"
dbal-version: "2.13"
mysql-version: "8.0"
extension: "pdo_mysql"

services:
mysql:
Expand Down Expand Up @@ -252,6 +239,10 @@ jobs:
ini-values: "zend.assertions=1"
extensions: "${{ matrix.extension }}"

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

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

Expand All @@ -271,6 +262,7 @@ jobs:
name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-coverage"
path: "coverage*.xml"


phpunit-lower-php-versions:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
Expand Down Expand Up @@ -303,6 +295,7 @@ jobs:
- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml"


upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
continue-on-error: "${{ matrix.status == 'experimental' }}"

strategy:
fail-fast: false
Expand All @@ -22,12 +21,7 @@ jobs:
- "8.0"
dbal-version:
- "default"
status:
- "stable"
include:
- dbal-version: "^3.0"
php-version: "8.0"
status: "experimental"
- "2.13"

steps:
- name: "Checkout code"
Expand All @@ -39,8 +33,8 @@ jobs:
coverage: "none"
php-version: "${{ matrix.php-version }}"

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

- name: "Install dependencies with Composer"
Expand All @@ -49,19 +43,16 @@ jobs:
dependency-versions: "highest"

- name: "Run a static analysis with phpstan/phpstan"
continue-on-error: "${{ matrix.status == 'experimental' }}"
run: "vendor/bin/phpstan analyse"
if: "${{ matrix.dbal-version == 'default' }}"

- name: "Run a static analysis with phpstan/phpstan"
continue-on-error: "${{ matrix.status == 'experimental' }}"
run: "vendor/bin/phpstan analyse -c phpstan-dbal3.neon"
if: "${{ matrix.dbal-version != 'default' }}"
run: "vendor/bin/phpstan analyse -c phpstan-dbal2.neon"
if: "${{ matrix.dbal-version == '2.13' }}"

static-analysis-psalm:
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"
continue-on-error: "${{ matrix.status == 'experimental' }}"

strategy:
fail-fast: false
Expand All @@ -70,12 +61,7 @@ jobs:
- "8.0"
dbal-version:
- "default"
status:
- "stable"
include:
- dbal-version: "^3.0"
php-version: "8.0"
status: "experimental"
- "2.13"

steps:
- name: "Checkout code"
Expand All @@ -87,8 +73,8 @@ jobs:
coverage: "none"
php-version: "${{ matrix.php-version }}"

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

- name: "Install dependencies with Composer"
Expand All @@ -97,5 +83,4 @@ jobs:
dependency-versions: "highest"

- name: "Run a static analysis with vimeo/psalm"
continue-on-error: "${{ matrix.status == 'experimental' }}"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"doctrine/cache": "^1.12.1 || ^2.1.1",
"doctrine/collections": "^1.5",
"doctrine/common": "^3.0.3",
"doctrine/dbal": "^2.13.1",
"doctrine/dbal": "^2.13.1 || ^3.1.1",
"doctrine/deprecations": "^0.5.3",
"doctrine/event-manager": "^1.1",
"doctrine/inflector": "^1.4 || ^2.0",
Expand Down
12 changes: 12 additions & 0 deletions phpstan-dbal2.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- phpstan-baseline.neon
- phpstan-params.neon

parameters:
ignoreErrors:
# https://github.com/doctrine/collections/pull/282
- '/Variable \$offset in isset\(\) always exists and is not nullable\./'
# PHPStan doesn't understand our method_exists() safeguards.
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
# Class name will change in DBAL 3.
- '/Class Doctrine\\DBAL\\Platforms\\PostgreSqlPlatform referenced with incorrect case: Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform\./'
18 changes: 0 additions & 18 deletions phpstan-dbal3.neon

This file was deleted.

36 changes: 30 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,33 @@ includes:

parameters:
ignoreErrors:
# https://github.com/doctrine/collections/pull/282
- '/Variable \$offset in isset\(\) always exists and is not nullable\./'
# PHPStan doesn't understand our method_exists() safeguards.
- '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./'
# Class name will change in DBAL 3.
- '/Class Doctrine\\DBAL\\Platforms\\PostgreSqlPlatform referenced with incorrect case: Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform\./'
# 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 typehint 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
16 changes: 0 additions & 16 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@
<code>getTableHiLoUpdateNextValSql</code>
</UndefinedMethod>
</file>
<file src="lib/Doctrine/ORM/Id/UuidGenerator.php">
<DeprecatedMethod occurrences="1">
<code>getGuidExpression</code>
</DeprecatedMethod>
</file>
<file src="lib/Doctrine/ORM/Internal/CommitOrderCalculator.php">
<RedundantCondition occurrences="2">
<code>$vertex-&gt;state !== self::VISITED</code>
Expand Down Expand Up @@ -733,11 +728,6 @@
<code>$class</code>
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Internal/SQLResultCasing.php">
<MissingDependency occurrences="1">
<code>PostgreSQL94Platform</code>
</MissingDependency>
</file>
<file src="lib/Doctrine/ORM/LazyCriteriaCollection.php">
<MoreSpecificImplementedParamType occurrences="1">
<code>$element</code>
Expand Down Expand Up @@ -874,9 +864,6 @@
<code>$driver</code>
<code>$evm</code>
</MissingConstructor>
<MissingDependency occurrences="1">
<code>Platforms\PostgreSQL94Platform</code>
</MissingDependency>
<NoInterfaceProperties occurrences="31">
<code>$class-&gt;cache</code>
<code>$class-&gt;changeTrackingPolicy</code>
Expand Down Expand Up @@ -3781,9 +3768,6 @@
</ImplementedReturnTypeMismatch>
</file>
<file src="lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php">
<MissingDependency occurrences="1">
<code>PostgreSQL94Platform</code>
</MissingDependency>
<MoreSpecificImplementedParamType occurrences="1">
<code>$query</code>
</MoreSpecificImplementedParamType>
Expand Down
Loading

0 comments on commit c65cc91

Please sign in to comment.