diff --git a/.doctrine-project.json b/.doctrine-project.json
index f68f2fd0bc3..ff81ef1e9f0 100644
--- a/.doctrine-project.json
+++ b/.doctrine-project.json
@@ -7,7 +7,7 @@
"versions": [
{
"name": "3.0",
- "branchName": "develop",
+ "branchName": "3.0.x",
"slug": "latest",
"upcoming": true
},
diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml
index 4e660b208bd..4d42ad000e5 100644
--- a/.github/workflows/coding-standards.yml
+++ b/.github/workflows/coding-standards.yml
@@ -1,6 +1,14 @@
name: "Coding Standards"
-on: ["pull_request", "push"]
+on:
+ pull_request:
+ branches:
+ - "*.x"
+ - "master"
+ push:
+ branches:
+ - "*.x"
+ - "master"
jobs:
coding-standards:
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 1b38ac3651c..56725b50e3b 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -1,31 +1,49 @@
name: "Continuous Integration"
-on: ["pull_request", "push"]
+on:
+ pull_request:
+ branches:
+ - "*.x"
+ - "master"
+ push:
+ branches:
+ - "*.x"
+ - "master"
+ schedule:
+ - cron: "42 3 * * *"
jobs:
- static-analysis-phpstan:
- name: "Static Analysis with PHPStan"
- runs-on: "ubuntu-latest"
+ phpunit-smoke-check:
+ name: "PHPUnit with SQLite"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
php-version:
+ - "7.3"
- "7.4"
+ deps:
+ - "fixed"
+ include:
+ - deps: "low"
+ php-version: "7.3"
steps:
- - name: "Checkout code"
+ - name: "Checkout"
uses: "actions/checkout@v2"
+ with:
+ fetch-depth: 2
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
- coverage: "none"
php-version: "${{ matrix.php-version }}"
- tools: "cs2pr"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1"
- name: "Cache dependencies installed with composer"
- uses: "actions/cache@v1"
+ uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -33,31 +51,53 @@ jobs:
- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"
+ if: "${{ matrix.deps == 'fixed' }}"
- - name: "Run a static analysis with phpstan/phpstan"
- run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
+ - name: "Install lowest possible dependencies with composer"
+ run: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-lowest"
+ if: "${{ matrix.deps == 'low' }}"
- static-analysis-psalm:
- name: "Static Analysis with Psalm"
- runs-on: "ubuntu-latest"
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "phpunit-sqlite-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
+
+ phpunit-oci8:
+ name: "PHPUnit on OCI8"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
strategy:
matrix:
php-version:
- "7.4"
+ services:
+ oracle:
+ image: "wnameless/oracle-xe-11g-r2"
+ ports:
+ - "1521:1521"
+
steps:
- - name: "Checkout code"
+ - name: "Checkout"
uses: "actions/checkout@v2"
+ with:
+ fetch-depth: 2
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
- coverage: "none"
php-version: "${{ matrix.php-version }}"
+ extensions: "oci8"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1"
- name: "Cache dependencies installed with composer"
- uses: "actions/cache@v1"
+ uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -66,12 +106,19 @@ jobs:
- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"
- - name: "Run a static analysis with vimeo/psalm"
- run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=4"
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/oci8.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
- phpunit-oci8:
- name: "PHPUnit on OCI8"
- runs-on: "ubuntu-latest"
+ phpunit-pdo-oci:
+ name: "PHPUnit on PDO_OCI"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
strategy:
matrix:
@@ -94,11 +141,12 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
- extensions: "oci8"
+ extensions: "pdo_oci"
coverage: "pcov"
+ ini-values: "zend.assertions=1"
- name: "Cache dependencies installed with composer"
- uses: "actions/cache@v1"
+ uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -108,25 +156,110 @@ jobs:
run: "composer install --no-interaction --no-progress --no-suggest"
- name: "Run PHPUnit"
- run: "vendor/bin/phpunit -c ci/github/phpunit.oci8.xml --coverage-clover=coverage.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_oci.xml --coverage-clover=coverage.xml"
- - name: "Upload Code Coverage"
- uses: "codecov/codecov-action@v1"
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
- phpunit-pdo-oci:
- name: "PHPUnit on PDO_OCI"
- runs-on: "ubuntu-latest"
+ phpunit-postgres:
+ name: "PHPUnit with PostgreSQL"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
strategy:
matrix:
php-version:
- "7.4"
+ postgres-version:
+ - "9.2"
+ - "9.3"
+ - "9.4"
+ - "9.5"
+ - "9.6"
+ - "10"
+ - "11"
+ - "12"
+ - "13"
services:
- oracle:
- image: "wnameless/oracle-xe-11g-r2"
+ postgres:
+ image: "postgres:${{ matrix.postgres-version }}"
+ env:
+ POSTGRES_PASSWORD: "postgres"
+
+ options: >-
+ --health-cmd "pg_isready || psql -U postgres -c 'SELECT 1'"
+
ports:
- - "1521:1521"
+ - "5432:5432"
+
+ 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 }}"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Install dependencies with composer"
+ run: "composer install --no-interaction --no-progress --no-suggest"
+
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_pgsql.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
+
+ phpunit-mariadb:
+ name: "PHPUnit with MariaDB"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.4"
+ mariadb-version:
+ - "10.0"
+ - "10.1"
+ - "10.2"
+ - "10.3"
+ - "10.4"
+ - "10.5"
+ extension:
+ - "mysqli"
+ - "pdo_mysql"
+
+ services:
+ mariadb:
+ image: "mariadb:${{ matrix.mariadb-version }}"
+ env:
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
+ MYSQL_DATABASE: "doctrine_tests"
+
+ options: >-
+ --health-cmd "mysqladmin ping --silent"
+
+ ports:
+ - "3306:3306"
steps:
- name: "Checkout"
@@ -138,11 +271,12 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
- extensions: "pdo_oci"
coverage: "pcov"
+ ini-values: "zend.assertions=1"
+ extensions: "${{ matrix.extension }}"
- name: "Cache dependencies installed with composer"
- uses: "actions/cache@v1"
+ uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -152,7 +286,303 @@ jobs:
run: "composer install --no-interaction --no-progress --no-suggest"
- name: "Run PHPUnit"
- run: "vendor/bin/phpunit -c ci/github/phpunit.pdo-oci.xml --coverage-clover=coverage.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.mariadb-version }}-${{ matrix.extension }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
+
+
+ phpunit-mysql:
+ name: "PHPUnit with MySQL"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.4"
+ mysql-version:
+ - "5.7"
+ - "8.0"
+ extension:
+ - "mysqli"
+ - "pdo_mysql"
+ config-file-suffix:
+ - ""
+ include:
+ - php-version: "7.3"
+ mysql-version: "8.0"
+ extension: "mysqli"
+ custom-entrypoint: >-
+ --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
+ - php-version: "7.3"
+ mysql-version: "8.0"
+ extension: "pdo_mysql"
+ custom-entrypoint: >-
+ --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
+ - mysql-version: "5.7"
+ - mysql-version: "8.0"
+ # https://stackoverflow.com/questions/60902904/how-to-pass-mysql-native-password-to-mysql-service-in-github-actions
+ custom-entrypoint: >-
+ --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
+ - config-file-suffix: "-tls"
+ php-version: "7.4"
+ mysql-version: "8.0"
+ extension: "mysqli"
+
+ services:
+ mysql:
+ image: "mysql:${{ matrix.mysql-version }}"
+
+ options: >-
+ --health-cmd "mysqladmin ping --silent"
+ -e MYSQL_ALLOW_EMPTY_PASSWORD=yes
+ -e MYSQL_DATABASE=doctrine_tests
+ ${{ matrix.custom-entrypoint }}
+
+ ports:
+ - "3306:3306"
+
+ 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 }}"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1"
+ extensions: "${{ matrix.extension }}"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Install dependencies with composer"
+ run: "composer install --no-interaction --no-progress --no-suggest"
+
+ - name: "Copy TLS-related files"
+ run: 'docker cp "${{ job.services.mysql.id }}:/var/lib/mysql/ca.pem" . && docker cp "${{ job.services.mysql.id }}:/var/lib/mysql/client-cert.pem" . && docker cp "${{ job.services.mysql.id }}:/var/lib/mysql/client-key.pem" .'
+ if: "${{ endsWith(matrix.config-file-suffix, 'tls') }}"
+
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}${{ matrix.config-file-suffix }}.xml --coverage-clover=coverage.xml"
- - name: "Upload Code Coverage"
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.config-file-suffix }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
+
+ phpunit-mssql:
+ name: "PHPUnit with SQL Server"
+ runs-on: "ubuntu-20.04"
+ needs: "phpunit-smoke-check"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.3"
+ - "7.4"
+ extension:
+ - "sqlsrv"
+ - "pdo_sqlsrv"
+ collation:
+ - "Latin1_General_100_CI_AS"
+ include:
+ - collation: "Latin1_General_100_CS_AS"
+ php-version: "7.4"
+ extension: "sqlsrv"
+ - collation: "Latin1_General_100_CS_AS"
+ php-version: "7.4"
+ extension: "pdo_sqlsrv"
+
+ services:
+ mssql:
+ image: "microsoft/mssql-server-linux:2017-latest"
+ env:
+ ACCEPT_EULA: "Y"
+ SA_PASSWORD: "Doctrine2018"
+ MSSQL_COLLATION: "${{ matrix.collation }}"
+
+ options: >-
+ --health-cmd "echo quit | /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -l 1 -U sa -P Doctrine2018"
+
+ ports:
+ - "1433:1433"
+
+ 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 }}"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1"
+ tools: "pecl"
+ extensions: "${{ matrix.extension }}-5.7.0preview"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Install dependencies with composer"
+ run: "composer install --no-interaction --no-progress --no-suggest"
+
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.collation }}.coverage"
+ path: "coverage.xml"
+
+ phpunit-ibm-db2:
+ name: "PHPUnit with IBM DB2"
+ runs-on: "ubuntu-18.04"
+ needs: "phpunit-smoke-check"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.3"
+ - "7.4"
+
+ services:
+ ibm_db2:
+ image: "ibmcom/db2:11.5.0.0"
+ env:
+ DB2INST1_PASSWORD: "Doctrine2018"
+ LICENSE: "accept"
+ DBNAME: "doctrine"
+
+ options: "--privileged=true"
+
+ ports:
+ - "50000:50000"
+
+ steps:
+ - name: "Perform healthcheck from the outside"
+ run: "docker logs -f ${{ job.services.ibm_db2.id }} | sed '/(*) Setup has completed./ q'"
+
+ - name: "Create temporary tablespace"
+ run: "docker exec ${{ job.services.ibm_db2.id }} su - db2inst1 -c 'db2 CONNECT TO doctrine && db2 CREATE USER TEMPORARY TABLESPACE doctrine_tbsp PAGESIZE 4 K'"
+
+ - name: "Checkout"
+ uses: "actions/checkout@v2"
+ with:
+ fetch-depth: 2
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "${{ matrix.php-version }}"
+ coverage: "pcov"
+ ini-values: "zend.assertions=1,extension=ibm_db2.so, ibm_db2.instance_name=db2inst1"
+
+ - name: "Install ibm_db2 extension"
+ run: "ci/github/ext/install-ibm_db2.sh ${{ matrix.php-version }}"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Install dependencies with composer"
+ run: "composer install --no-interaction --no-progress --no-suggest"
+
+ - name: "Run PHPUnit"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/ibm_db2.xml --coverage-clover=coverage.xml"
+
+ - name: "Upload coverage file"
+ uses: "actions/upload-artifact@v2"
+ with:
+ name: "${{ github.job }}-${{ matrix.php-version }}.coverage"
+ path: "coverage.xml"
+
+
+ development-deps:
+ name: "PHPUnit with SQLite and development dependencies"
+ runs-on: "ubuntu-20.04"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.4"
+
+ steps:
+ - name: "Checkout"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "${{ matrix.php-version }}"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Lower minimum stability"
+ run: "composer config minimum-stability dev"
+
+ - name: "Install development dependencies with composer"
+ run: "composer update --no-interaction --no-progress --no-suggest --prefer-dist"
+
+ - 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"
+ needs:
+ - "phpunit-smoke-check"
+ - "phpunit-oci8"
+ - "phpunit-pdo-oci"
+ - "phpunit-postgres"
+ - "phpunit-mariadb"
+ - "phpunit-mysql"
+ - "phpunit-mssql"
+ - "phpunit-ibm-db2"
+
+ steps:
+ - name: "Checkout"
+ uses: "actions/checkout@v2"
+ with:
+ fetch-depth: 2
+
+ - name: "Download coverage files"
+ uses: "actions/download-artifact@v2"
+ with:
+ path: "reports"
+
+ - name: "Display structure of downloaded files"
+ run: ls -R
+ working-directory: reports
+
+ - name: "Upload to Codecov"
uses: "codecov/codecov-action@v1"
+ with:
+ directory: reports
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
new file mode 100644
index 00000000000..fd8e302709f
--- /dev/null
+++ b/.github/workflows/static-analysis.yml
@@ -0,0 +1,62 @@
+
+name: "Static Analysis"
+
+on:
+ pull_request:
+ branches:
+ - "*.x"
+ - "master"
+ push:
+ branches:
+ - "*.x"
+ - "master"
+
+jobs:
+ static-analysis-phpstan:
+ name: "Static Analysis with PHPStan"
+ runs-on: "ubuntu-20.04"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.4"
+
+ steps:
+ - name: "Checkout code"
+ uses: "actions/checkout@v2"
+
+ - name: "Install PHP"
+ uses: "shivammathur/setup-php@v2"
+ with:
+ coverage: "none"
+ php-version: "${{ matrix.php-version }}"
+ tools: "cs2pr"
+
+ - name: "Cache dependencies installed with composer"
+ uses: "actions/cache@v2"
+ with:
+ path: "~/.composer/cache"
+ key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
+ restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
+
+ - name: "Install dependencies with composer"
+ run: "composer install --no-interaction --no-progress --no-suggest"
+
+ - name: "Run a static analysis with phpstan/phpstan"
+ run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
+
+ static-analysis-psalm:
+ name: "Static Analysis with Psalm"
+ runs-on: "ubuntu-20.04"
+
+ strategy:
+ matrix:
+ php-version:
+ - "7.4"
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Psalm
+ uses: docker://vimeo/psalm-github-actions:3.17.2
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 4621a9afa96..00000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,191 +0,0 @@
-language: php
-dist: xenial
-
-cache:
- directories:
- - vendor
- - $HOME/.composer/cache
-
-before_install:
- - phpenv config-rm xdebug.ini || true
- - pecl install pcov
-
-before_script:
- - |
- if [[ -n "$IMAGE" ]]
- then
- bash ./tests/travis/docker-run-mysql-or-mariadb.sh
- fi
-
-install:
- - travis_retry composer -n install --prefer-dist
-
-script:
- - ./vendor/bin/phpunit --configuration tests/travis/$DB.travis.xml --coverage-clover clover.xml
-
-after_success:
- - bash <(curl -s https://codecov.io/bash)
-
-jobs:
- include:
-
- - stage: Smoke Testing
- php: 7.3
- env: DB=sqlite
-
- - stage: Test
- php: 7.3
- env: DB=mysql.docker IMAGE=mysql:5.7
- - stage: Test
- php: 7.3
- env: DB=mysql.docker IMAGE=mysql:8.0
- - stage: Test
- php: 7.3
- env: DB=mysqli.docker IMAGE=mysql:5.7
- - stage: Test
- php: 7.3
- env: DB=mysqli.docker IMAGE=mysql:8.0
- - stage: Test
- php: 7.3
- env: DB=mariadb.docker IMAGE=mariadb:10.0
- - stage: Test
- php: 7.3
- env: DB=mariadb.docker IMAGE=mariadb:10.1
- - stage: Test
- php: 7.3
- env: DB=mariadb.docker IMAGE=mariadb:10.2
- - stage: Test
- php: 7.3
- env: DB=mariadb.docker IMAGE=mariadb:10.3
- - stage: Test
- php: 7.3
- env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.0
- - stage: Test
- php: 7.3
- env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.1
- - stage: Test
- php: 7.3
- env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.2
- - stage: Test
- php: 7.3
- env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
- - stage: Test
- dist: trusty
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=9.2
- services:
- - postgresql
- addons:
- postgresql: "9.2"
- - stage: Test
- dist: trusty
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=9.3
- services:
- - postgresql
- addons:
- postgresql: "9.3"
- - stage: Test
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=9.4
- addons:
- postgresql: "9.4"
- - stage: Test
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=9.5
- addons:
- postgresql: "9.5"
- - stage: Test
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=9.6
- addons:
- postgresql: "9.6"
- - stage: Test
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=10.0
- sudo: required
- addons:
- postgresql: "10"
- before_script:
- - bash ./tests/travis/install-postgres-10.sh
- - stage: Test
- php: 7.3
- env: DB=pgsql POSTGRESQL_VERSION=11.0
- sudo: required
- before_script:
- - bash ./tests/travis/install-postgres-11.sh
- - stage: Test
- php: 7.3
- env: DB=sqlsrv
- sudo: required
- before_script:
- - bash ./tests/travis/install-sqlsrv-dependencies.sh
- - bash ./tests/travis/install-mssql-sqlsrv.sh
- - bash ./tests/travis/install-mssql.sh
- - stage: Test
- php: 7.3
- env: DB=pdo_sqlsrv
- sudo: required
- before_script:
- - bash ./tests/travis/install-sqlsrv-dependencies.sh
- - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
- - bash ./tests/travis/install-mssql.sh
- - stage: Test
- php: 7.3
- env: DB=ibm_db2
- sudo: required
- before_script:
- - bash ./tests/travis/install-db2.sh
- - bash ./tests/travis/install-db2-ibm_db2.sh
- - stage: Test
- php: 7.3
- env: DB=sqlite DEPENDENCIES=low
- install:
- - travis_retry composer update --prefer-dist --prefer-lowest
- - stage: Test
- php: 7.4
- env: DB=mysql.docker IMAGE=mysql:8.0
- - stage: Test
- php: 7.4
- env: DB=mysqli-tls.docker IMAGE=mysql:8.0 TLS=yes
- - stage: Test
- php: 7.4
- env: DB=mariadb.docker IMAGE=mariadb:10.3
- - stage: Test
- php: 7.4
- env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
- - stage: Test
- php: 7.4
- env: DB=pgsql POSTGRESQL_VERSION=11.0
- sudo: required
- before_script:
- - bash ./tests/travis/install-postgres-11.sh
- - stage: Test
- php: 7.4
- env: DB=sqlite
- - stage: Test
- php: 7.4
- env: DB=sqlsrv MSSQL_COLLATION=Latin1_General_100_CS_AS
- sudo: required
- before_script:
- - bash ./tests/travis/install-sqlsrv-dependencies.sh
- - bash ./tests/travis/install-mssql-sqlsrv.sh
- - bash ./tests/travis/install-mssql.sh
- - stage: Test
- php: 7.4
- env: DB=pdo_sqlsrv MSSQL_COLLATION=Latin1_General_100_CS_AS
- sudo: required
- before_script:
- - bash ./tests/travis/install-sqlsrv-dependencies.sh
- - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh
- - bash ./tests/travis/install-mssql.sh
- - stage: Test
- if: type = cron
- php: 7.2
- env: DB=sqlite DEPENDENCIES=dev
- install:
- - composer config minimum-stability dev
- - travis_retry composer update --prefer-dist
-
- allow_failures:
- - env: DEPENDENCIES=dev
diff --git a/tests/travis/install-db2-ibm_db2.sh b/ci/github/ext/install-ibm_db2.sh
old mode 100644
new mode 100755
similarity index 67%
rename from tests/travis/install-db2-ibm_db2.sh
rename to ci/github/ext/install-ibm_db2.sh
index b59bb6396fd..fa0abc12df7
--- a/tests/travis/install-db2-ibm_db2.sh
+++ b/ci/github/ext/install-ibm_db2.sh
@@ -5,8 +5,8 @@ set -ex
echo "Installing extension"
(
# updating APT packages as per support recommendation
- sudo apt -y -q update
- sudo apt install ksh
+ sudo apt-get -y -q update
+ sudo apt-get install ksh php-pear
cd /tmp
@@ -21,7 +21,6 @@ echo "Installing extension"
cd ibm_db2-*
phpize
./configure --with-IBM_DB2=/tmp/dsdriver
- make -j `nproc`
- make install
- echo -e 'extension=ibm_db2.so\nibm_db2.instance_name=db2inst1' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/ibm_db2.ini
+ make -j "$(nproc)"
+ sudo make install
)
diff --git a/tests/travis/ibm_db2.travis.xml b/ci/github/phpunit/ibm_db2.xml
similarity index 80%
rename from tests/travis/ibm_db2.travis.xml
rename to ci/github/phpunit/ibm_db2.xml
index 3089c56c47a..eabf83d108d 100644
--- a/tests/travis/ibm_db2.travis.xml
+++ b/ci/github/phpunit/ibm_db2.xml
@@ -1,6 +1,6 @@
-
-
@@ -19,13 +17,13 @@
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/mysqli-tls.docker.travis.xml b/ci/github/phpunit/mysqli-tls.xml
similarity index 86%
rename from tests/travis/mysqli-tls.docker.travis.xml
rename to ci/github/phpunit/mysqli-tls.xml
index f6f653c42bf..3a05258a188 100644
--- a/tests/travis/mysqli-tls.docker.travis.xml
+++ b/ci/github/phpunit/mysqli-tls.xml
@@ -1,6 +1,6 @@
-
+
@@ -25,13 +25,13 @@
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/mysqli.docker.travis.xml b/ci/github/phpunit/mysqli.xml
similarity index 75%
rename from tests/travis/mysqli.docker.travis.xml
rename to ci/github/phpunit/mysqli.xml
index d93ca5ceda5..1660b7f4493 100644
--- a/tests/travis/mysqli.docker.travis.xml
+++ b/ci/github/phpunit/mysqli.xml
@@ -1,6 +1,6 @@
-
-
-
+
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/ci/github/phpunit.oci8.xml b/ci/github/phpunit/oci8.xml
similarity index 89%
rename from ci/github/phpunit.oci8.xml
rename to ci/github/phpunit/oci8.xml
index f4454b2f9c4..fef723fec5e 100644
--- a/ci/github/phpunit.oci8.xml
+++ b/ci/github/phpunit/oci8.xml
@@ -1,6 +1,6 @@
- ../../tests
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/mysql.docker.travis.xml b/ci/github/phpunit/pdo_mysql.xml
similarity index 75%
rename from tests/travis/mysql.docker.travis.xml
rename to ci/github/phpunit/pdo_mysql.xml
index 67f63b2fde4..99612ab3271 100644
--- a/tests/travis/mysql.docker.travis.xml
+++ b/ci/github/phpunit/pdo_mysql.xml
@@ -1,6 +1,6 @@
-
-
-
+
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/ci/github/phpunit.pdo-oci.xml b/ci/github/phpunit/pdo_oci.xml
similarity index 89%
rename from ci/github/phpunit.pdo-oci.xml
rename to ci/github/phpunit/pdo_oci.xml
index 900e5ce10b8..610b56cd72e 100644
--- a/ci/github/phpunit.pdo-oci.xml
+++ b/ci/github/phpunit/pdo_oci.xml
@@ -1,6 +1,6 @@
- ../../tests
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/pgsql.travis.xml b/ci/github/phpunit/pdo_pgsql.xml
similarity index 79%
rename from tests/travis/pgsql.travis.xml
rename to ci/github/phpunit/pdo_pgsql.xml
index 0a1a5c1bebb..8f6b760781e 100644
--- a/tests/travis/pgsql.travis.xml
+++ b/ci/github/phpunit/pdo_pgsql.xml
@@ -1,6 +1,6 @@
-
-
+
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/pdo_sqlsrv.travis.xml b/ci/github/phpunit/pdo_sqlsrv.xml
similarity index 80%
rename from tests/travis/pdo_sqlsrv.travis.xml
rename to ci/github/phpunit/pdo_sqlsrv.xml
index 38802c599e9..0f1e1b2edda 100644
--- a/tests/travis/pdo_sqlsrv.travis.xml
+++ b/ci/github/phpunit/pdo_sqlsrv.xml
@@ -1,6 +1,6 @@
-
-
@@ -19,13 +17,13 @@
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/sqlite.travis.xml b/ci/github/phpunit/sqlite.xml
similarity index 70%
rename from tests/travis/sqlite.travis.xml
rename to ci/github/phpunit/sqlite.xml
index ce3c1d0f914..3e911bd0afc 100644
--- a/tests/travis/sqlite.travis.xml
+++ b/ci/github/phpunit/sqlite.xml
@@ -1,25 +1,21 @@
-
-
-
-
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/tests/travis/sqlsrv.travis.xml b/ci/github/phpunit/sqlsrv.xml
similarity index 80%
rename from tests/travis/sqlsrv.travis.xml
rename to ci/github/phpunit/sqlsrv.xml
index de56350ce9d..02dfcbd4b51 100644
--- a/tests/travis/sqlsrv.travis.xml
+++ b/ci/github/phpunit/sqlsrv.xml
@@ -1,6 +1,6 @@
-
-
@@ -19,13 +17,13 @@
- ../Doctrine/Tests/DBAL
+ ../../../tests
- ../../lib/Doctrine
+ ../../../lib/Doctrine
diff --git a/composer.json b/composer.json
index e3c26687995..de722c523a5 100644
--- a/composer.json
+++ b/composer.json
@@ -40,12 +40,11 @@
"require-dev": {
"doctrine/coding-standard": "^8.1",
"jetbrains/phpstorm-stubs": "^2019.1",
- "nikic/php-parser": "^4.4",
"phpstan/phpstan": "^0.12.40",
- "phpunit/phpunit": "^9.3",
+ "phpunit/phpunit": "^9.4",
"psalm/plugin-phpunit": "^0.10.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
- "vimeo/psalm": "^3.14.2"
+ "vimeo/psalm": "^3.17.2"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
diff --git a/composer.lock b/composer.lock
index c0e3434b50c..55d6b6e3b18 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "2a7bb91be55d10f401c5f03dd7f235bc",
+ "content-hash": "b9b5b86a282f25dc5f24bc422885e9c0",
"packages": [
{
"name": "doctrine/cache",
@@ -326,16 +326,16 @@
},
{
"name": "composer/package-versions-deprecated",
- "version": "1.10.99.1",
+ "version": "1.11.99",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
- "reference": "68c9b502036e820c33445ff4d174327f6bb87486"
+ "reference": "c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/68c9b502036e820c33445ff4d174327f6bb87486",
- "reference": "68c9b502036e820c33445ff4d174327f6bb87486",
+ "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855",
+ "reference": "c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855",
"shasum": ""
},
"require": {
@@ -343,7 +343,7 @@
"php": "^7 || ^8"
},
"replace": {
- "ocramius/package-versions": "1.10.99"
+ "ocramius/package-versions": "1.11.99"
},
"require-dev": {
"composer/composer": "^1.9.3 || ^2.0@dev",
@@ -379,7 +379,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
- "source": "https://github.com/composer/package-versions-deprecated/tree/1.10.99.1"
+ "source": "https://github.com/composer/package-versions-deprecated/tree/master"
},
"funding": [
{
@@ -395,20 +395,20 @@
"type": "tidelift"
}
],
- "time": "2020-08-13T12:55:41+00:00"
+ "time": "2020-08-25T05:50:16+00:00"
},
{
"name": "composer/semver",
- "version": "1.5.1",
+ "version": "1.7.1",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
- "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de"
+ "reference": "38276325bd896f90dfcfe30029aa5db40df387a7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de",
- "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de",
+ "url": "https://api.github.com/repos/composer/semver/zipball/38276325bd896f90dfcfe30029aa5db40df387a7",
+ "reference": "38276325bd896f90dfcfe30029aa5db40df387a7",
"shasum": ""
},
"require": {
@@ -459,9 +459,23 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
- "source": "https://github.com/composer/semver/tree/1.5.1"
+ "source": "https://github.com/composer/semver/tree/1.7.1"
},
- "time": "2020-01-13T12:06:48+00:00"
+ "funding": [
+ {
+ "url": "https://packagist.com",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/composer",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-09-27T13:13:07+00:00"
},
{
"name": "composer/xdebug-handler",
@@ -596,6 +610,43 @@
},
"time": "2020-06-25T14:57:39+00:00"
},
+ {
+ "name": "dnoegel/php-xdg-base-dir",
+ "version": "v0.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dnoegel/php-xdg-base-dir.git",
+ "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd",
+ "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "XdgBaseDir\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "implementation of xdg base directory specification for php",
+ "support": {
+ "issues": "https://github.com/dnoegel/php-xdg-base-dir/issues",
+ "source": "https://github.com/dnoegel/php-xdg-base-dir/tree/v0.1.1"
+ },
+ "time": "2019-12-04T15:06:13+00:00"
+ },
{
"name": "doctrine/coding-standard",
"version": "8.1.0",
@@ -984,16 +1035,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v4.9.0",
+ "version": "v4.10.2",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "aaee038b912e567780949787d5fe1977be11a778"
+ "reference": "658f1be311a230e0907f5dfe0213742aff0596de"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/aaee038b912e567780949787d5fe1977be11a778",
- "reference": "aaee038b912e567780949787d5fe1977be11a778",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/658f1be311a230e0907f5dfe0213742aff0596de",
+ "reference": "658f1be311a230e0907f5dfe0213742aff0596de",
"shasum": ""
},
"require": {
@@ -1034,9 +1085,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/master"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.2"
},
- "time": "2020-08-18T19:48:01+00:00"
+ "time": "2020-09-26T10:30:38+00:00"
},
{
"name": "openlss/lib-array2xml",
@@ -1257,16 +1308,16 @@
},
{
"name": "phpdocumentor/reflection-docblock",
- "version": "5.2.1",
+ "version": "5.2.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44"
+ "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d870572532cd70bc3fab58f2e23ad423c8404c44",
- "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
+ "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
"shasum": ""
},
"require": {
@@ -1309,20 +1360,20 @@
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
},
- "time": "2020-08-15T11:14:08+00:00"
+ "time": "2020-09-03T19:13:55+00:00"
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.3.0",
+ "version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "e878a14a65245fbe78f8080eba03b47c3b705651"
+ "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651",
- "reference": "e878a14a65245fbe78f8080eba03b47c3b705651",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
+ "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
"shasum": ""
},
"require": {
@@ -1356,34 +1407,34 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x"
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
},
- "time": "2020-06-27T10:12:23+00:00"
+ "time": "2020-09-17T18:55:26+00:00"
},
{
"name": "phpspec/prophecy",
- "version": "1.11.1",
+ "version": "1.12.1",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160"
+ "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160",
- "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/8ce87516be71aae9b956f81906aaf0338e0d8a2d",
+ "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.2",
- "php": "^7.2",
- "phpdocumentor/reflection-docblock": "^5.0",
+ "php": "^7.2 || ~8.0, <8.1",
+ "phpdocumentor/reflection-docblock": "^5.2",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
"phpspec/phpspec": "^6.0",
- "phpunit/phpunit": "^8.0"
+ "phpunit/phpunit": "^8.0 || ^9.0 <9.3"
},
"type": "library",
"extra": {
@@ -1423,9 +1474,9 @@
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
- "source": "https://github.com/phpspec/prophecy/tree/master"
+ "source": "https://github.com/phpspec/prophecy/tree/1.12.1"
},
- "time": "2020-07-08T12:44:21+00:00"
+ "time": "2020-09-29T09:10:42+00:00"
},
{
"name": "phpstan/phpdoc-parser",
@@ -1542,24 +1593,24 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.0.0",
+ "version": "9.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "ee24e82baca11d7d6fb3513e127d6000f541cf90"
+ "reference": "53a4b737e83be724efd2bc4e7b929b9a30c48972"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ee24e82baca11d7d6fb3513e127d6000f541cf90",
- "reference": "ee24e82baca11d7d6fb3513e127d6000f541cf90",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53a4b737e83be724efd2bc4e7b929b9a30c48972",
+ "reference": "53a4b737e83be724efd2bc4e7b929b9a30c48972",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^4.7",
- "php": "^7.3 || ^8.0",
+ "nikic/php-parser": "^4.8",
+ "php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
"sebastian/code-unit-reverse-lookup": "^2.0.2",
@@ -1579,7 +1630,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "9.0-dev"
+ "dev-master": "9.2-dev"
}
},
"autoload": {
@@ -1607,7 +1658,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.0.0"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.0"
},
"funding": [
{
@@ -1615,27 +1666,27 @@
"type": "github"
}
],
- "time": "2020-08-07T04:12:30+00:00"
+ "time": "2020-10-02T03:37:32+00:00"
},
{
"name": "phpunit/php-file-iterator",
- "version": "3.0.4",
+ "version": "3.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e"
+ "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/25fefc5b19835ca653877fe081644a3f8c1d915e",
- "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
+ "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -1667,7 +1718,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
- "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.4"
+ "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
},
"funding": [
{
@@ -1675,28 +1726,28 @@
"type": "github"
}
],
- "time": "2020-07-11T05:18:21+00:00"
+ "time": "2020-09-28T05:57:25+00:00"
},
{
"name": "phpunit/php-invoker",
- "version": "3.1.0",
+ "version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-invoker.git",
- "reference": "7a85b66acc48cacffdf87dadd3694e7123674298"
+ "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/7a85b66acc48cacffdf87dadd3694e7123674298",
- "reference": "7a85b66acc48cacffdf87dadd3694e7123674298",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
+ "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
"ext-pcntl": "*",
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-pcntl": "*"
@@ -1730,7 +1781,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
- "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.0"
+ "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
},
"funding": [
{
@@ -1738,27 +1789,27 @@
"type": "github"
}
],
- "time": "2020-08-06T07:04:15+00:00"
+ "time": "2020-09-28T05:58:55+00:00"
},
{
"name": "phpunit/php-text-template",
- "version": "2.0.2",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324"
+ "reference": "18c887016e60e52477e54534956d7b47bc52cd84"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/6ff9c8ea4d3212b88fcf74e25e516e2c51c99324",
- "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/18c887016e60e52477e54534956d7b47bc52cd84",
+ "reference": "18c887016e60e52477e54534956d7b47bc52cd84",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -1789,7 +1840,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
- "source": "https://github.com/sebastianbergmann/php-text-template/tree/master"
+ "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.3"
},
"funding": [
{
@@ -1797,27 +1848,27 @@
"type": "github"
}
],
- "time": "2020-06-26T11:55:37+00:00"
+ "time": "2020-09-28T06:03:05+00:00"
},
{
"name": "phpunit/php-timer",
- "version": "5.0.1",
+ "version": "5.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7"
+ "reference": "c9ff14f493699e2f6adee9fd06a0245b276643b7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/cc49734779cbb302bf51a44297dab8c4bbf941e7",
- "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/c9ff14f493699e2f6adee9fd06a0245b276643b7",
+ "reference": "c9ff14f493699e2f6adee9fd06a0245b276643b7",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.2"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -1848,7 +1899,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
- "source": "https://github.com/sebastianbergmann/php-timer/tree/master"
+ "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.2"
},
"funding": [
{
@@ -1856,20 +1907,20 @@
"type": "github"
}
],
- "time": "2020-06-26T11:58:13+00:00"
+ "time": "2020-09-28T06:00:25+00:00"
},
{
"name": "phpunit/phpunit",
- "version": "9.3.2",
+ "version": "9.4.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "eacb57f3857cb6706550bd39ea500f9b1097b0bf"
+ "reference": "ef533467a7974c4b6c354f3eff42a115910bd4e5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/eacb57f3857cb6706550bd39ea500f9b1097b0bf",
- "reference": "eacb57f3857cb6706550bd39ea500f9b1097b0bf",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ef533467a7974c4b6c354f3eff42a115910bd4e5",
+ "reference": "ef533467a7974c4b6c354f3eff42a115910bd4e5",
"shasum": ""
},
"require": {
@@ -1883,13 +1934,14 @@
"myclabs/deep-copy": "^1.10.1",
"phar-io/manifest": "^2.0.1",
"phar-io/version": "^3.0.2",
- "php": "^7.3 || ^8.0",
+ "php": ">=7.3",
"phpspec/prophecy": "^1.11.1",
- "phpunit/php-code-coverage": "^9.0",
+ "phpunit/php-code-coverage": "^9.2",
"phpunit/php-file-iterator": "^3.0.4",
"phpunit/php-invoker": "^3.1",
"phpunit/php-text-template": "^2.0.2",
"phpunit/php-timer": "^5.0.1",
+ "sebastian/cli-parser": "^1.0",
"sebastian/code-unit": "^1.0.5",
"sebastian/comparator": "^4.0.3",
"sebastian/diff": "^4.0.2",
@@ -1915,7 +1967,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "9.3-dev"
+ "dev-master": "9.4-dev"
}
},
"autoload": {
@@ -1946,7 +1998,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.3.2"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.4.0"
},
"funding": [
{
@@ -1958,7 +2010,7 @@
"type": "github"
}
],
- "time": "2020-08-07T09:12:30+00:00"
+ "time": "2020-10-02T03:54:37+00:00"
},
{
"name": "psalm/plugin-phpunit",
@@ -2118,25 +2170,81 @@
},
"time": "2020-03-23T09:12:05+00:00"
},
+ {
+ "name": "sebastian/cli-parser",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/cli-parser.git",
+ "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2",
+ "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Library for parsing CLI options",
+ "homepage": "https://github.com/sebastianbergmann/cli-parser",
+ "support": {
+ "issues": "https://github.com/sebastianbergmann/cli-parser/issues",
+ "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/sebastianbergmann",
+ "type": "github"
+ }
+ ],
+ "time": "2020-09-28T06:08:49+00:00"
+ },
{
"name": "sebastian/code-unit",
- "version": "1.0.5",
+ "version": "1.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit.git",
- "reference": "c1e2df332c905079980b119c4db103117e5e5c90"
+ "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/c1e2df332c905079980b119c4db103117e5e5c90",
- "reference": "c1e2df332c905079980b119c4db103117e5e5c90",
+ "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/59236be62b1bb9919e6d7f60b0b832dc05cef9ab",
+ "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2164,7 +2272,7 @@
"homepage": "https://github.com/sebastianbergmann/code-unit",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
- "source": "https://github.com/sebastianbergmann/code-unit/tree/master"
+ "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.7"
},
"funding": [
{
@@ -2172,27 +2280,27 @@
"type": "github"
}
],
- "time": "2020-06-26T12:50:45+00:00"
+ "time": "2020-10-02T14:47:54+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
- "version": "2.0.2",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
- "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819"
+ "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ee51f9bb0c6d8a43337055db3120829fa14da819",
- "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819",
+ "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
+ "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2219,7 +2327,7 @@
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
- "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/master"
+ "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
},
"funding": [
{
@@ -2227,29 +2335,29 @@
"type": "github"
}
],
- "time": "2020-06-26T12:04:00+00:00"
+ "time": "2020-09-28T05:30:19+00:00"
},
{
"name": "sebastian/comparator",
- "version": "4.0.3",
+ "version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f"
+ "reference": "7a8ff306445707539c1a6397372a982a1ec55120"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f",
- "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/7a8ff306445707539c1a6397372a982a1ec55120",
+ "reference": "7a8ff306445707539c1a6397372a982a1ec55120",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0",
+ "php": ">=7.3",
"sebastian/diff": "^4.0",
"sebastian/exporter": "^4.0"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2293,7 +2401,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
- "source": "https://github.com/sebastianbergmann/comparator/tree/master"
+ "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.5"
},
"funding": [
{
@@ -2301,28 +2409,28 @@
"type": "github"
}
],
- "time": "2020-06-26T12:05:46+00:00"
+ "time": "2020-09-30T06:47:25+00:00"
},
{
"name": "sebastian/complexity",
- "version": "2.0.0",
+ "version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git",
- "reference": "33fcd6a26656c6546f70871244ecba4b4dced097"
+ "reference": "ba8cc2da0c0bfbc813d03b56406734030c7f1eff"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/33fcd6a26656c6546f70871244ecba4b4dced097",
- "reference": "33fcd6a26656c6546f70871244ecba4b4dced097",
+ "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/ba8cc2da0c0bfbc813d03b56406734030c7f1eff",
+ "reference": "ba8cc2da0c0bfbc813d03b56406734030c7f1eff",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.7",
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.2"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2350,7 +2458,7 @@
"homepage": "https://github.com/sebastianbergmann/complexity",
"support": {
"issues": "https://github.com/sebastianbergmann/complexity/issues",
- "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.0"
+ "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.1"
},
"funding": [
{
@@ -2358,27 +2466,27 @@
"type": "github"
}
],
- "time": "2020-07-25T14:01:34+00:00"
+ "time": "2020-09-28T06:05:03+00:00"
},
{
"name": "sebastian/diff",
- "version": "4.0.2",
+ "version": "4.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113"
+ "reference": "ffc949a1a2aae270ea064453d7535b82e4c32092"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113",
- "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ffc949a1a2aae270ea064453d7535b82e4c32092",
+ "reference": "ffc949a1a2aae270ea064453d7535b82e4c32092",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0",
+ "phpunit/phpunit": "^9.3",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
@@ -2416,7 +2524,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
- "source": "https://github.com/sebastianbergmann/diff/tree/master"
+ "source": "https://github.com/sebastianbergmann/diff/tree/4.0.3"
},
"funding": [
{
@@ -2424,27 +2532,27 @@
"type": "github"
}
],
- "time": "2020-06-30T04:46:02+00:00"
+ "time": "2020-09-28T05:32:55+00:00"
},
{
"name": "sebastian/environment",
- "version": "5.1.2",
+ "version": "5.1.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2"
+ "reference": "388b6ced16caa751030f6a69e588299fa09200ac"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2",
- "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac",
+ "reference": "388b6ced16caa751030f6a69e588299fa09200ac",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-posix": "*"
@@ -2452,7 +2560,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "5.0-dev"
+ "dev-master": "5.1-dev"
}
},
"autoload": {
@@ -2479,7 +2587,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
- "source": "https://github.com/sebastianbergmann/environment/tree/master"
+ "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
},
"funding": [
{
@@ -2487,29 +2595,29 @@
"type": "github"
}
],
- "time": "2020-06-26T12:07:24+00:00"
+ "time": "2020-09-28T05:52:38+00:00"
},
{
"name": "sebastian/exporter",
- "version": "4.0.2",
+ "version": "4.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "571d721db4aec847a0e59690b954af33ebf9f023"
+ "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/571d721db4aec847a0e59690b954af33ebf9f023",
- "reference": "571d721db4aec847a0e59690b954af33ebf9f023",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
+ "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0",
+ "php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"ext-mbstring": "*",
- "phpunit/phpunit": "^9.2"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2556,7 +2664,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
- "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.2"
+ "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
},
"funding": [
{
@@ -2564,24 +2672,24 @@
"type": "github"
}
],
- "time": "2020-06-26T12:08:55+00:00"
+ "time": "2020-09-28T05:24:23+00:00"
},
{
"name": "sebastian/global-state",
- "version": "5.0.0",
+ "version": "5.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "22ae663c951bdc39da96603edc3239ed3a299097"
+ "reference": "ea779cb749a478b22a2564ac41cd7bda79c78dc7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/22ae663c951bdc39da96603edc3239ed3a299097",
- "reference": "22ae663c951bdc39da96603edc3239ed3a299097",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/ea779cb749a478b22a2564ac41cd7bda79c78dc7",
+ "reference": "ea779cb749a478b22a2564ac41cd7bda79c78dc7",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0",
+ "php": ">=7.3",
"sebastian/object-reflector": "^2.0",
"sebastian/recursion-context": "^4.0"
},
@@ -2620,7 +2728,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
- "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.0"
+ "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.1"
},
"funding": [
{
@@ -2628,28 +2736,28 @@
"type": "github"
}
],
- "time": "2020-08-07T04:09:03+00:00"
+ "time": "2020-09-28T05:54:06+00:00"
},
{
"name": "sebastian/lines-of-code",
- "version": "1.0.0",
+ "version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
- "reference": "e02bf626f404b5daec382a7b8a6a4456e49017e5"
+ "reference": "6514b8f21906b8b46f520d1fbd17a4523fa59a54"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e02bf626f404b5daec382a7b8a6a4456e49017e5",
- "reference": "e02bf626f404b5daec382a7b8a6a4456e49017e5",
+ "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/6514b8f21906b8b46f520d1fbd17a4523fa59a54",
+ "reference": "6514b8f21906b8b46f520d1fbd17a4523fa59a54",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.6",
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.2"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2677,7 +2785,7 @@
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
"support": {
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
- "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.0"
+ "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.1"
},
"funding": [
{
@@ -2685,29 +2793,29 @@
"type": "github"
}
],
- "time": "2020-07-22T18:33:42+00:00"
+ "time": "2020-09-28T06:07:27+00:00"
},
{
"name": "sebastian/object-enumerator",
- "version": "4.0.2",
+ "version": "4.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
- "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8"
+ "reference": "f6f5957013d84725427d361507e13513702888a4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/074fed2d0a6d08e1677dd8ce9d32aecb384917b8",
- "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8",
+ "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f6f5957013d84725427d361507e13513702888a4",
+ "reference": "f6f5957013d84725427d361507e13513702888a4",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0",
+ "php": ">=7.3",
"sebastian/object-reflector": "^2.0",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2734,7 +2842,7 @@
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
- "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master"
+ "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.3"
},
"funding": [
{
@@ -2742,27 +2850,27 @@
"type": "github"
}
],
- "time": "2020-06-26T12:11:32+00:00"
+ "time": "2020-09-28T05:55:06+00:00"
},
{
"name": "sebastian/object-reflector",
- "version": "2.0.2",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
- "reference": "127a46f6b057441b201253526f81d5406d6c7840"
+ "reference": "d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/127a46f6b057441b201253526f81d5406d6c7840",
- "reference": "127a46f6b057441b201253526f81d5406d6c7840",
+ "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5",
+ "reference": "d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2789,7 +2897,7 @@
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
- "source": "https://github.com/sebastianbergmann/object-reflector/tree/master"
+ "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.3"
},
"funding": [
{
@@ -2797,27 +2905,27 @@
"type": "github"
}
],
- "time": "2020-06-26T12:12:55+00:00"
+ "time": "2020-09-28T05:56:16+00:00"
},
{
"name": "sebastian/recursion-context",
- "version": "4.0.2",
+ "version": "4.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63"
+ "reference": "ed8c9cd355089134bc9cba421b5cfdd58f0eaef7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/062231bf61d2b9448c4fa5a7643b5e1829c11d63",
- "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63",
+ "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/ed8c9cd355089134bc9cba421b5cfdd58f0eaef7",
+ "reference": "ed8c9cd355089134bc9cba421b5cfdd58f0eaef7",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.0"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2852,7 +2960,7 @@
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
- "source": "https://github.com/sebastianbergmann/recursion-context/tree/master"
+ "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.3"
},
"funding": [
{
@@ -2860,24 +2968,24 @@
"type": "github"
}
],
- "time": "2020-06-26T12:14:17+00:00"
+ "time": "2020-09-28T05:17:32+00:00"
},
{
"name": "sebastian/resource-operations",
- "version": "3.0.2",
+ "version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
- "reference": "0653718a5a629b065e91f774595267f8dc32e213"
+ "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0653718a5a629b065e91f774595267f8dc32e213",
- "reference": "0653718a5a629b065e91f774595267f8dc32e213",
+ "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
+ "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
@@ -2907,7 +3015,7 @@
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
- "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.2"
+ "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
},
"funding": [
{
@@ -2915,27 +3023,27 @@
"type": "github"
}
],
- "time": "2020-06-26T12:16:22+00:00"
+ "time": "2020-09-28T06:45:17+00:00"
},
{
"name": "sebastian/type",
- "version": "2.2.1",
+ "version": "2.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a"
+ "reference": "e494dcaeb89d1458c9ccd8c819745245a1669aea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/86991e2b33446cd96e648c18bcdb1e95afb2c05a",
- "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/e494dcaeb89d1458c9ccd8c819745245a1669aea",
+ "reference": "e494dcaeb89d1458c9ccd8c819745245a1669aea",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"require-dev": {
- "phpunit/phpunit": "^9.2"
+ "phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
@@ -2963,7 +3071,7 @@
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
- "source": "https://github.com/sebastianbergmann/type/tree/2.2.1"
+ "source": "https://github.com/sebastianbergmann/type/tree/2.2.2"
},
"funding": [
{
@@ -2971,24 +3079,24 @@
"type": "github"
}
],
- "time": "2020-07-05T08:31:53+00:00"
+ "time": "2020-09-28T06:01:38+00:00"
},
{
"name": "sebastian/version",
- "version": "3.0.1",
+ "version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
- "reference": "626586115d0ed31cb71483be55beb759b5af5a3c"
+ "reference": "c6c1022351a901512170118436c764e473f6de8c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/626586115d0ed31cb71483be55beb759b5af5a3c",
- "reference": "626586115d0ed31cb71483be55beb759b5af5a3c",
+ "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c",
+ "reference": "c6c1022351a901512170118436c764e473f6de8c",
"shasum": ""
},
"require": {
- "php": "^7.3 || ^8.0"
+ "php": ">=7.3"
},
"type": "library",
"extra": {
@@ -3016,7 +3124,7 @@
"homepage": "https://github.com/sebastianbergmann/version",
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
- "source": "https://github.com/sebastianbergmann/version/tree/3.0.1"
+ "source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
},
"funding": [
{
@@ -3024,7 +3132,7 @@
"type": "github"
}
],
- "time": "2020-06-26T12:18:43+00:00"
+ "time": "2020-09-28T06:39:44+00:00"
},
{
"name": "slevomat/coding-standard",
@@ -3236,65 +3344,6 @@
],
"time": "2020-03-30T11:41:10+00:00"
},
- {
- "name": "symfony/debug",
- "version": "v4.0.6",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/debug.git",
- "reference": "1721e4e7effb23480966690cdcdc7d2a4152d489"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/debug/zipball/1721e4e7effb23480966690cdcdc7d2a4152d489",
- "reference": "1721e4e7effb23480966690cdcdc7d2a4152d489",
- "shasum": ""
- },
- "require": {
- "php": "^7.1.3",
- "psr/log": "~1.0"
- },
- "conflict": {
- "symfony/http-kernel": "<3.4"
- },
- "require-dev": {
- "symfony/http-kernel": "~3.4|~4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Debug\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony Debug Component",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/debug/tree/4.0"
- },
- "time": "2018-02-28T21:50:02+00:00"
- },
{
"name": "symfony/polyfill-ctype",
"version": "v1.18.1",
@@ -3610,16 +3659,16 @@
},
{
"name": "vimeo/psalm",
- "version": "3.14.2",
+ "version": "3.17.2",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
- "reference": "3538fe1955d47f6ee926c0769d71af6db08aa488"
+ "reference": "9e526d9cb569fe4631e6a737bbb7948d05596e3f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vimeo/psalm/zipball/3538fe1955d47f6ee926c0769d71af6db08aa488",
- "reference": "3538fe1955d47f6ee926c0769d71af6db08aa488",
+ "url": "https://api.github.com/repos/vimeo/psalm/zipball/9e526d9cb569fe4631e6a737bbb7948d05596e3f",
+ "reference": "9e526d9cb569fe4631e6a737bbb7948d05596e3f",
"shasum": ""
},
"require": {
@@ -3628,9 +3677,11 @@
"composer/package-versions-deprecated": "^1.8.0",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^1.1",
+ "dnoegel/php-xdg-base-dir": "^0.1.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
+ "ext-mbstring": "*",
"ext-simplexml": "*",
"ext-tokenizer": "*",
"felixfbecker/advanced-json-rpc": "^3.0.3",
@@ -3656,10 +3707,11 @@
"phpmyadmin/sql-parser": "5.1.0",
"phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^7.5.16 || ^8.5 || ^9.0",
- "psalm/plugin-phpunit": "^0.10",
+ "psalm/plugin-phpunit": "^0.11",
"slevomat/coding-standard": "^5.0",
"squizlabs/php_codesniffer": "^3.5",
- "symfony/process": "^4.3"
+ "symfony/process": "^4.3",
+ "weirdan/prophecy-shim": "^1.0 || ^2.0"
},
"suggest": {
"ext-igbinary": "^2.0.5"
@@ -3705,9 +3757,9 @@
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
- "source": "https://github.com/vimeo/psalm/tree/3.14.2"
+ "source": "https://github.com/vimeo/psalm/tree/3.17.2"
},
- "time": "2020-08-22T14:01:26+00:00"
+ "time": "2020-10-15T00:23:17+00:00"
},
{
"name": "webmozart/assert",
diff --git a/docs/en/reference/data-retrieval-and-manipulation.rst b/docs/en/reference/data-retrieval-and-manipulation.rst
index 8a88deb6a64..7e85e3c3a82 100644
--- a/docs/en/reference/data-retrieval-and-manipulation.rst
+++ b/docs/en/reference/data-retrieval-and-manipulation.rst
@@ -379,6 +379,45 @@ Execute the query and fetch all results into an array:
)
*/
+fetchAllKeyValue()
+~~~~~~~~~~~~~~~~~~
+
+Execute the query and fetch the first two columns into an associative array as keys and values respectively:
+
+.. code-block:: php
+
+ fetchAllKeyValue('SELECT username, password FROM user');
+
+ /*
+ array(
+ 'jwage' => 'changeme',
+ )
+ */
+
+.. note::
+ All additional columns will be ignored and are only allowed to be selected by DBAL for its internal purposes.
+
+fetchAllAssociativeIndexed()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Execute the query and fetch the data as an associative array where the key represents the first column and the value is
+an associative array of the rest of the columns and their values:
+
+.. code-block:: php
+
+ fetchAllAssociativeIndexed('SELECT id, username, password FROM user');
+
+ /*
+ array(
+ 1 => array(
+ 'username' => 'jwage',
+ 'password' => 'changeme',
+ )
+ )
+ */
+
fetchNumeric()
~~~~~~~~~~~~~~
@@ -425,6 +464,34 @@ Retrieve associative array of the first result row.
There are also convenience methods for data manipulation queries:
+iterateKeyValue()
+~~~~~~~~~~~~~~~~~
+
+Execute the query and iterate over the first two columns as keys and values respectively:
+
+.. code-block:: php
+
+ iterateKeyValue('SELECT username, password FROM user') as $username => $password) {
+ // ...
+ }
+
+.. note::
+ All additional columns will be ignored and are only allowed to be selected by DBAL for its internal purposes.
+
+iterateAssociativeIndexed()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Execute the query and iterate over the result with the key representing the first column and the value being
+an associative array of the rest of the columns and their values:
+
+.. code-block:: php
+
+ iterateAssociativeIndexed('SELECT id, username, password FROM user') as $id => $data) {
+ // ...
+ }
+
delete()
~~~~~~~~~
diff --git a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
index b1270846512..3a57358faad 100644
--- a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
+++ b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Cache;
use Doctrine\Common\Cache\Cache;
+use Doctrine\DBAL\Types\Type;
use function hash;
use function serialize;
@@ -68,10 +69,10 @@ public function getCacheKey()
/**
* Generates the real cache key from query, params, types and connection parameters.
*
- * @param string $sql
- * @param mixed[] $params
- * @param int[]|string[] $types
- * @param mixed[] $connectionParams
+ * @param string $sql
+ * @param array|array $params
+ * @param array|array $types
+ * @param array $connectionParams
*
* @return string[]
*/
diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
index 34381e23b1c..07a6c220611 100644
--- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
@@ -244,7 +244,7 @@ public function fetchAllNumeric(): array
$this->store($data);
- return array_map('array_values', $this->data);
+ return array_map('array_values', $data);
}
/**
diff --git a/lib/Doctrine/DBAL/Configuration.php b/lib/Doctrine/DBAL/Configuration.php
index 6d2497b632d..545b0ffb0b4 100644
--- a/lib/Doctrine/DBAL/Configuration.php
+++ b/lib/Doctrine/DBAL/Configuration.php
@@ -73,7 +73,7 @@ public function setResultCacheImpl(Cache $cacheImpl)
*
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
*
- * @param string $filterExpression
+ * @param string|null $filterExpression
*
* @return void
*/
diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php
index af803e5db26..2d5d4402bb8 100644
--- a/lib/Doctrine/DBAL/Connection.php
+++ b/lib/Doctrine/DBAL/Connection.php
@@ -15,6 +15,7 @@
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception\ConnectionLost;
use Doctrine\DBAL\Exception\InvalidArgumentException;
+use Doctrine\DBAL\Exception\NoKeyValue;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use Doctrine\DBAL\Query\QueryBuilder;
@@ -24,6 +25,7 @@
use Traversable;
use function array_key_exists;
+use function array_shift;
use function assert;
use function func_get_args;
use function implode;
@@ -543,11 +545,11 @@ public function setFetchMode($fetchMode)
*
* @deprecated Use fetchAssociative()
*
- * @param string $sql The query SQL
- * @param mixed[] $params The query parameters
- * @param int[]|string[] $types The query parameter types
+ * @param string $sql SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
- * @return mixed[]|false False is returned if no rows are found.
+ * @return array|false False is returned if no rows are found.
*
* @throws Exception
*/
@@ -562,11 +564,11 @@ public function fetchAssoc($sql, array $params = [], array $types = [])
*
* @deprecated Use fetchNumeric()
*
- * @param string $sql The query SQL
- * @param mixed[] $params The query parameters
- * @param int[]|string[] $types The query parameter types
+ * @param string $sql SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
- * @return mixed[]|false False is returned if no rows are found.
+ * @return array|false False is returned if no rows are found.
*/
public function fetchArray($sql, array $params = [], array $types = [])
{
@@ -579,10 +581,10 @@ public function fetchArray($sql, array $params = [], array $types = [])
*
* @deprecated Use fetchOne() instead.
*
- * @param string $sql The query SQL
- * @param mixed[] $params The query parameters
- * @param int $column The 0-indexed column number to retrieve
- * @param int[]|string[] $types The query parameter types
+ * @param string $sql SQL query
+ * @param array|array $params Query parameters
+ * @param int $column 0-indexed column number
+ * @param array|array $types Parameter types
*
* @return mixed|false False is returned if no rows are found.
*
@@ -597,9 +599,9 @@ public function fetchColumn($sql, array $params = [], $column = 0, array $types
* Prepares and executes an SQL query and returns the first row of the result
* as an associative array.
*
- * @param string $query The SQL query.
- * @param array|array $params The prepared statement params.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return array|false False is returned if no rows are found.
*
@@ -624,9 +626,9 @@ public function fetchAssociative(string $query, array $params = [], array $types
* Prepares and executes an SQL query and returns the first row of the result
* as a numerically indexed array.
*
- * @param string $query The SQL query to be executed.
- * @param array|array $params The prepared statement params.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return array|false False is returned if no rows are found.
*
@@ -651,9 +653,9 @@ public function fetchNumeric(string $query, array $params = [], array $types = [
* Prepares and executes an SQL query and returns the value of a single column
* of the first row of the result.
*
- * @param string $query The SQL query to be executed.
- * @param array|array $params The prepared statement params.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return mixed|false False is returned if no rows are found.
*
@@ -695,24 +697,24 @@ public function isTransactionActive()
}
/**
- * Adds identifier condition to the query components
+ * Adds condition based on the criteria to the query components
*
- * @param mixed[] $identifier Map of key columns to their values
+ * @param mixed[] $criteria Map of key columns to their values
* @param string[] $columns Column names
* @param mixed[] $values Column values
* @param string[] $conditions Key conditions
*
* @throws Exception
*/
- private function addIdentifierCondition(
- array $identifier,
+ private function addCriteriaCondition(
+ array $criteria,
array &$columns,
array &$values,
array &$conditions
): void {
$platform = $this->getDatabasePlatform();
- foreach ($identifier as $columnName => $value) {
+ foreach ($criteria as $columnName => $value) {
if ($value === null) {
$conditions[] = $platform->getIsNullExpression($columnName);
continue;
@@ -729,23 +731,23 @@ private function addIdentifierCondition(
*
* Table expression and columns are not escaped and are not safe for user-input.
*
- * @param string $table The expression of the table on which to delete.
- * @param mixed[] $identifier The deletion criteria. An associative array containing column-value pairs.
- * @param int[]|string[] $types The types of identifiers.
+ * @param string $table Table name
+ * @param array $criteria Deletion criteria
+ * @param array|array $types Parameter types
*
* @return int The number of affected rows.
*
* @throws Exception
*/
- public function delete($table, array $identifier, array $types = [])
+ public function delete($table, array $criteria, array $types = [])
{
- if (empty($identifier)) {
+ if (empty($criteria)) {
throw InvalidArgumentException::fromEmptyCriteria();
}
$columns = $values = $conditions = [];
- $this->addIdentifierCondition($identifier, $columns, $values, $conditions);
+ $this->addCriteriaCondition($criteria, $columns, $values, $conditions);
return $this->executeStatement(
'DELETE FROM ' . $table . ' WHERE ' . implode(' AND ', $conditions),
@@ -797,16 +799,16 @@ public function getTransactionIsolation()
*
* Table expression and columns are not escaped and are not safe for user-input.
*
- * @param string $table The expression of the table to update quoted or unquoted.
- * @param mixed[] $data An associative array containing column-value pairs.
- * @param mixed[] $identifier The update criteria. An associative array containing column-value pairs.
- * @param int[]|string[] $types Types of the merged $data and $identifier arrays in that order.
+ * @param string $table Table name
+ * @param array $data Column-value pairs
+ * @param array $criteria Update criteria
+ * @param array|array $types Parameter types
*
* @return int The number of affected rows.
*
* @throws Exception
*/
- public function update($table, array $data, array $identifier, array $types = [])
+ public function update($table, array $data, array $criteria, array $types = [])
{
$columns = $values = $conditions = $set = [];
@@ -816,7 +818,7 @@ public function update($table, array $data, array $identifier, array $types = []
$set[] = $columnName . ' = ?';
}
- $this->addIdentifierCondition($identifier, $columns, $values, $conditions);
+ $this->addCriteriaCondition($criteria, $columns, $values, $conditions);
if (is_string(key($types))) {
$types = $this->extractTypeValues($columns, $types);
@@ -833,9 +835,9 @@ public function update($table, array $data, array $identifier, array $types = []
*
* Table expression and columns are not escaped and are not safe for user-input.
*
- * @param string $table The expression of the table to insert data into, quoted or unquoted.
- * @param mixed[] $data An associative array containing column-value pairs.
- * @param int[]|string[] $types Types of the inserted data.
+ * @param string $table Table name
+ * @param array $data Column-value pairs
+ * @param array|array $types Parameter types
*
* @return int The number of affected rows.
*
@@ -868,10 +870,10 @@ public function insert($table, array $data, array $types = [])
/**
* Extract ordered type list from an ordered column list and type map.
*
- * @param int[]|string[] $columnList
- * @param int[]|string[] $types
+ * @param array $columnList
+ * @param array|array $types
*
- * @return int[]|string[]
+ * @return array|array
*/
private function extractTypeValues(array $columnList, array $types)
{
@@ -905,6 +907,8 @@ public function quoteIdentifier($str)
/**
* {@inheritDoc}
+ *
+ * @param int|string|Type|null $type
*/
public function quote($value, $type = ParameterType::STRING)
{
@@ -934,9 +938,9 @@ public function fetchAll($sql, array $params = [], $types = [])
/**
* Prepares and executes an SQL query and returns the result as an array of numeric arrays.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return array>
*
@@ -960,9 +964,9 @@ public function fetchAllNumeric(string $query, array $params = [], array $types
/**
* Prepares and executes an SQL query and returns the result as an array of associative arrays.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return array>
*
@@ -983,12 +987,65 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty
}
}
+ /**
+ * Prepares and executes an SQL query and returns the result as an associative array with the keys
+ * mapped to the first column and the values mapped to the second column.
+ *
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
+ *
+ * @return array
+ *
+ * @throws Exception
+ */
+ public function fetchAllKeyValue(string $query, array $params = [], array $types = []): array
+ {
+ $stmt = $this->executeQuery($query, $params, $types);
+
+ $this->ensureHasKeyValue($stmt);
+
+ $data = [];
+
+ foreach ($stmt->fetchAll(FetchMode::NUMERIC) as [$key, $value]) {
+ $data[$key] = $value;
+ }
+
+ return $data;
+ }
+
+ /**
+ * Prepares and executes an SQL query and returns the result as an associative array with the keys mapped
+ * to the first column and the values being an associative array representing the rest of the columns
+ * and their values.
+ *
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
+ *
+ * @return array>
+ *
+ * @throws Exception
+ */
+ public function fetchAllAssociativeIndexed(string $query, array $params = [], array $types = []): array
+ {
+ $stmt = $this->executeQuery($query, $params, $types);
+
+ $data = [];
+
+ foreach ($stmt->fetchAll(FetchMode::ASSOCIATIVE) as $row) {
+ $data[array_shift($row)] = $row;
+ }
+
+ return $data;
+ }
+
/**
* Prepares and executes an SQL query and returns the result as an array of the first column values.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return array
*
@@ -1012,9 +1069,9 @@ public function fetchFirstColumn(string $query, array $params = [], array $types
/**
* Prepares and executes an SQL query and returns the result as an iterator over rows represented as numeric arrays.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return Traversable>
*
@@ -1041,9 +1098,9 @@ public function iterateNumeric(string $query, array $params = [], array $types =
* Prepares and executes an SQL query and returns the result as an iterator over rows represented
* as associative arrays.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return Traversable>
*
@@ -1066,12 +1123,57 @@ public function iterateAssociative(string $query, array $params = [], array $typ
}
}
+ /**
+ * Prepares and executes an SQL query and returns the result as an iterator with the keys
+ * mapped to the first column and the values mapped to the second column.
+ *
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
+ *
+ * @return Traversable
+ *
+ * @throws Exception
+ */
+ public function iterateKeyValue(string $query, array $params = [], array $types = []): Traversable
+ {
+ $stmt = $this->executeQuery($query, $params, $types);
+
+ $this->ensureHasKeyValue($stmt);
+
+ while (($row = $stmt->fetch(FetchMode::NUMERIC)) !== false) {
+ yield $row[0] => $row[1];
+ }
+ }
+
+ /**
+ * Prepares and executes an SQL query and returns the result as an iterator with the keys mapped
+ * to the first column and the values being an associative array representing the rest of the columns
+ * and their values.
+ *
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
+ *
+ * @return Traversable>
+ *
+ * @throws Exception
+ */
+ public function iterateAssociativeIndexed(string $query, array $params = [], array $types = []): Traversable
+ {
+ $stmt = $this->executeQuery($query, $params, $types);
+
+ while (($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) !== false) {
+ yield array_shift($row) => $row;
+ }
+ }
+
/**
* Prepares and executes an SQL query and returns the result as an iterator over the first column values.
*
- * @param string $query The SQL query.
- * @param array|array $params The query parameters.
- * @param array|array $types The query parameter types.
+ * @param string $query SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return Traversable
*
@@ -1122,10 +1224,9 @@ public function prepare($sql)
* If the query is parametrized, a prepared statement is used.
* If an SQLLogger is configured, the execution is logged.
*
- * @param string $sql The SQL query to execute.
- * @param mixed[] $params The parameters to bind to the query, if any.
- * @param int[]|string[] $types The types the previous parameters are in.
- * @param QueryCacheProfile|null $qcp The query cache profile, optional.
+ * @param string $sql SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return ResultStatement The executed statement.
*
@@ -1179,10 +1280,9 @@ public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheP
/**
* Executes a caching query.
*
- * @param string $sql The SQL query to execute.
- * @param mixed[] $params The parameters to bind to the query, if any.
- * @param int[]|string[] $types The types the previous parameters are in.
- * @param QueryCacheProfile $qcp The query cache profile.
+ * @param string $sql SQL query
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
* @return ResultStatement
*
@@ -1299,9 +1399,9 @@ public function query()
*
* @deprecated Use {@link executeStatement()} instead.
*
- * @param string $sql The SQL query.
- * @param array $params The query parameters.
- * @param array $types The parameter types.
+ * @param string $sql SQL statement
+ * @param array|array $params Statement parameters
+ * @param array|array $types Parameter types
*
* @return int The number of affected rows.
*
@@ -1324,9 +1424,9 @@ public function executeUpdate($sql, array $params = [], array $types = [])
*
* This method supports PDO binding types as well as DBAL mapping types.
*
- * @param string $sql The statement SQL
- * @param array $params The query parameters
- * @param array $types The parameter types
+ * @param string $sql SQL statement
+ * @param array|array $params Statement parameters
+ * @param array|array $types Parameter types
*
* @return int The number of affected rows.
*
@@ -1840,9 +1940,9 @@ public function convertToPHPValue($value, $type)
* @internal Duck-typing used on the $stmt parameter to support driver statements as well as
* raw PDOStatement instances.
*
- * @param \Doctrine\DBAL\Driver\Statement $stmt The statement to bind the values to.
- * @param mixed[] $params The map/list of named/positional parameters.
- * @param int[]|string[] $types The parameter types (PDO binding types or DBAL mapping types).
+ * @param \Doctrine\DBAL\Driver\Statement $stmt Prepared statement
+ * @param array|array $params Statement parameters
+ * @param array|array $types Parameter types
*
* @return void
*/
@@ -1882,8 +1982,8 @@ private function _bindTypedValues($stmt, array $params, array $types)
/**
* Gets the binding type of a given type. The given type can be a PDO or DBAL mapping type.
*
- * @param mixed $value The value to bind.
- * @param int|string|null $type The type to bind (PDO or DBAL).
+ * @param mixed $value The value to bind.
+ * @param int|string|Type|null $type The type to bind (PDO or DBAL).
*
* @return mixed[] [0] => the (escaped) value, [1] => the binding type.
*/
@@ -1909,10 +2009,10 @@ private function getBindingInfo($value, $type)
* @internal This is a purely internal method. If you rely on this method, you are advised to
* copy/paste the code as this method may change, or be removed without prior notice.
*
- * @param mixed[] $params
- * @param int[]|string[] $types
+ * @param array|array $params Query parameters
+ * @param array|array $types Parameter types
*
- * @return mixed[]
+ * @return array|array
*/
public function resolveParams(array $params, array $types)
{
@@ -2004,8 +2104,8 @@ public function ping()
/**
* @internal
*
- * @param array|array $params
- * @param array|array $types
+ * @param array|array $params
+ * @param array|array $types
*
* @throws Exception
*
@@ -2055,4 +2155,13 @@ private function throw(Exception $e): void
throw $e;
}
+
+ private function ensureHasKeyValue(ResultStatement $stmt): void
+ {
+ $columnCount = $stmt->columnCount();
+
+ if ($columnCount < 2) {
+ throw NoKeyValue::fromColumnCount($columnCount);
+ }
+ }
}
diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
index 0e97267643b..984736fd633 100644
--- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
+++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
@@ -38,21 +38,18 @@ public function __construct(
$this->deprecated('Params key "master"', '"primary"');
$params['primary'] = $params['master'];
- unset($params['master']);
}
if (isset($params['slaves'])) {
$this->deprecated('Params key "slaves"', '"replica"');
$params['replica'] = $params['slaves'];
- unset($params['slaves']);
}
if (isset($params['keepSlave'])) {
$this->deprecated('Params key "keepSlave"', '"keepReplica"');
$params['keepReplica'] = $params['keepSlave'];
- unset($params['keepSlave']);
}
parent::__construct($params, $driver, $config, $eventManager);
diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php
index 78cb755d805..81f4accfd22 100644
--- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php
+++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php
@@ -317,11 +317,11 @@ public function rollBack()
/**
* {@inheritDoc}
*/
- public function delete($table, array $identifier, array $types = [])
+ public function delete($table, array $criteria, array $types = [])
{
$this->ensureConnectedToPrimary();
- return parent::delete($table, $identifier, $types);
+ return parent::delete($table, $criteria, $types);
}
/**
@@ -340,11 +340,11 @@ public function close()
/**
* {@inheritDoc}
*/
- public function update($table, array $data, array $identifier, array $types = [])
+ public function update($table, array $data, array $criteria, array $types = [])
{
$this->ensureConnectedToPrimary();
- return parent::update($table, $data, $identifier, $types);
+ return parent::update($table, $data, $criteria, $types);
}
/**
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
index dc2701e344a..bdc52551f52 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
@@ -37,7 +37,7 @@
class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection
{
/** @var resource */
- private $conn = null;
+ private $conn;
/**
* @internal The connection can be only instantiated by its driver.
@@ -93,7 +93,7 @@ public function prepare($sql)
$stmt = @db2_prepare($this->conn, $sql);
if ($stmt === false) {
- throw PrepareFailed::new(error_get_last()['message']);
+ throw PrepareFailed::new(error_get_last());
}
return new Statement($stmt);
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
index 02cc6526907..c758a253d0a 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
@@ -455,9 +455,9 @@ public function free(): void
/**
* Casts a stdClass object to the given class name mapping its' properties.
*
- * @param stdClass $sourceObject Object to cast from.
- * @param string|object $destinationClass Name of the class or class instance to cast to.
- * @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
+ * @param stdClass $sourceObject Object to cast from.
+ * @param class-string|object $destinationClass Name of the class or class instance to cast to.
+ * @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
* @return object
*
@@ -527,7 +527,7 @@ private function createTemporaryFile()
$handle = @tmpfile();
if ($handle === false) {
- throw CannotCreateTemporaryFile::new(error_get_last()['message']);
+ throw CannotCreateTemporaryFile::new(error_get_last());
}
return $handle;
@@ -542,7 +542,7 @@ private function createTemporaryFile()
private function copyStreamToStream($source, $target): void
{
if (@stream_copy_to_stream($source, $target) === false) {
- throw CannotCopyStreamToStream::new(error_get_last()['message']);
+ throw CannotCopyStreamToStream::new(error_get_last());
}
}
@@ -554,7 +554,7 @@ private function copyStreamToStream($source, $target): void
private function writeStringToStream(string $string, $target): void
{
if (@fwrite($target, $string) === false) {
- throw CannotWriteToTemporaryFile::new(error_get_last()['message']);
+ throw CannotWriteToTemporaryFile::new(error_get_last());
}
}
}
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
index 8223a92d660..61244c1cc61 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
@@ -13,8 +13,17 @@
*/
final class CannotCopyStreamToStream extends DB2Exception
{
- public static function new(string $message): self
+ /**
+ * @psalm-param array{message: string}|null $error
+ */
+ public static function new(?array $error): self
{
- return new self('Could not copy source stream to temporary file: ' . $message);
+ $message = 'Could not copy source stream to temporary file';
+
+ if ($error !== null) {
+ $message .= ': ' . $error['message'];
+ }
+
+ return new self($message);
}
}
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
index 48b28dd33d3..d5481ed9e31 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
@@ -13,8 +13,17 @@
*/
final class CannotCreateTemporaryFile extends DB2Exception
{
- public static function new(string $message): self
+ /**
+ * @psalm-param array{message: string}|null $error
+ */
+ public static function new(?array $error): self
{
- return new self('Could not create temporary file: ' . $message);
+ $message = 'Could not create temporary file';
+
+ if ($error !== null) {
+ $message .= ': ' . $error['message'];
+ }
+
+ return new self($message);
}
}
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php
index 8acc269a4ad..33d0b86cc4f 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php
@@ -13,8 +13,17 @@
*/
final class CannotWriteToTemporaryFile extends DB2Exception
{
- public static function new(string $message): self
+ /**
+ * @psalm-param array{message: string}|null $error
+ */
+ public static function new(?array $error): self
{
- return new self('Could not write string to temporary file: ' . $message);
+ $message = 'Could not write string to temporary file';
+
+ if ($error !== null) {
+ $message .= ': ' . $error['message'];
+ }
+
+ return new self($message);
}
}
diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php
index f566df8d50d..035fd67f9c2 100644
--- a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php
+++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php
@@ -13,8 +13,15 @@
*/
final class PrepareFailed extends AbstractException
{
- public static function new(string $message): self
+ /**
+ * @psalm-param array{message: string}|null $error
+ */
+ public static function new(?array $error): self
{
- return new self($message);
+ if ($error === null) {
+ return new self('Unknown error');
+ }
+
+ return new self($error['message']);
}
}
diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
index 3c34a8767c3..cbb8a851b27 100644
--- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
@@ -181,7 +181,7 @@ public static function convertPositionalToNamedPlaceholders($statement)
* Finds next placeholder or opening quote.
*
* @param string $statement The SQL statement to parse
- * @param string $tokenOffset The offset to start searching from
+ * @param int $tokenOffset The offset to start searching from
* @param int $fragmentOffset The offset to build the next fragment from
* @param string[] $fragments Fragments of the original statement
* not containing placeholders
@@ -228,7 +228,7 @@ private static function findPlaceholderOrOpeningQuote(
* Finds closing quote
*
* @param string $statement The SQL statement to parse
- * @param string $tokenOffset The offset to start searching from
+ * @param int $tokenOffset The offset to start searching from
* @param string $currentLiteralDelimiter The delimiter of the current string literal
*
* @return bool Whether the token was found
@@ -299,8 +299,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le
if ($type === ParameterType::LARGE_OBJECT) {
$lob = oci_new_descriptor($this->_dbh, OCI_D_LOB);
- $class = 'OCI-Lob';
- assert($lob instanceof $class);
+ assert($lob !== false);
$lob->writeTemporary($variable, OCI_TEMP_BLOB);
diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php
index f31f960f5e0..5373ee39907 100644
--- a/lib/Doctrine/DBAL/Driver/ResultStatement.php
+++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php
@@ -75,22 +75,22 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX
*
* @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.
*
- * @param int|null $fetchMode Controls how the next row will be returned to the caller.
- * The value must be one of the {@link FetchMode} constants,
- * defaulting to {@link FetchMode::MIXED}.
- * @param int|null $fetchArgument This argument has a different meaning depending on the value
- * of the $fetchMode parameter:
- * * {@link FetchMode::COLUMN}:
- * Returns the indicated 0-indexed column.
- * * {@link FetchMode::CUSTOM_OBJECT}:
- * Returns instances of the specified class, mapping the columns of each row
- * to named properties in the class.
- * * {@link PDO::FETCH_FUNC}: Returns the results of calling
- * the specified function, using each row's
- * columns as parameters in the call.
- * @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller.
- * The value must be one of the {@link FetchMode} constants,
- * defaulting to {@link FetchMode::MIXED}.
+ * @param int|null $fetchMode Controls how the next row will be returned to the caller.
+ * The value must be one of the {@link FetchMode} constants,
+ * defaulting to {@link FetchMode::MIXED}.
+ * @param int|string|null $fetchArgument This argument has a different meaning depending on the value
+ * of the $fetchMode parameter:
+ * * {@link FetchMode::COLUMN}:
+ * Returns the indicated 0-indexed column.
+ * * {@link FetchMode::CUSTOM_OBJECT}:
+ * Returns instances of the specified class, mapping the columns of each row
+ * to named properties in the class.
+ * * {@link PDO::FETCH_FUNC}: Returns the results of calling
+ * the specified function, using each row's
+ * columns as parameters in the call.
+ * @param mixed[]|null $ctorArgs Controls how the next row will be returned to the caller.
+ * The value must be one of the {@link FetchMode} constants,
+ * defaulting to {@link FetchMode::MIXED}.
*
* @return mixed[]
*/
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
index 95b59274e9e..81d88232dca 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
@@ -52,15 +52,15 @@ public function getName()
/**
* Build the connection string for given connection parameters and driver options.
*
- * @param string $host Host address to connect to.
- * @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
- * @param string $server Database server name on the host to connect to.
- * SQL Anywhere allows multiple database server instances on the same host,
- * therefore specifying the server instance name to use is mandatory.
- * @param string $dbname Name of the database on the server instance to connect to.
- * @param string $username User name to use for connection authentication.
- * @param string $password Password to use for connection authentication.
- * @param mixed[] $driverOptions Additional parameters to use for the connection.
+ * @param string|null $host Host address to connect to.
+ * @param int|null $port Port to use for the connection (default to SQL Anywhere standard port 2638).
+ * @param string|null $server Database server name on the host to connect to.
+ * SQL Anywhere allows multiple database server instances on the same host,
+ * therefore specifying the server instance name to use is mandatory.
+ * @param string|null $dbname Name of the database on the server instance to connect to.
+ * @param string $username User name to use for connection authentication.
+ * @param string $password Password to use for connection authentication.
+ * @param mixed[] $driverOptions Additional parameters to use for the connection.
*
* @return string
*/
diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
index 1542276dba2..513e4a508ef 100644
--- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
@@ -419,9 +419,9 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
/**
* Casts a stdClass object to the given class name mapping its' properties.
*
- * @param stdClass $sourceObject Object to cast from.
- * @param string|object $destinationClass Name of the class or class instance to cast to.
- * @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
+ * @param stdClass $sourceObject Object to cast from.
+ * @param class-string|object $destinationClass Name of the class or class instance to cast to.
+ * @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
*
* @return object
*
diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php
index 6c21d806580..17ba8584da2 100644
--- a/lib/Doctrine/DBAL/DriverManager.php
+++ b/lib/Doctrine/DBAL/DriverManager.php
@@ -12,7 +12,6 @@
use Doctrine\DBAL\Driver\SQLSrv;
use function array_keys;
-use function array_map;
use function array_merge;
use function assert;
use function class_implements;
@@ -22,6 +21,7 @@
use function parse_str;
use function parse_url;
use function preg_replace;
+use function rawurldecode;
use function str_replace;
use function strpos;
use function substr;
@@ -113,7 +113,7 @@ private function __construct()
* driverClass:
* The driver class to use.
*
- * @param array{wrapperClass?: class-string} $params
+ * @param array{wrapperClass?: class-string} $params
* @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use.
*
@@ -195,6 +195,7 @@ public static function getConnection(
throw Exception::invalidWrapperClass($params['wrapperClass']);
}
+ /** @var class-string $wrapperClass */
$wrapperClass = $params['wrapperClass'];
}
@@ -280,13 +281,19 @@ private static function parseDatabaseUrl(array $params): array
throw new Exception('Malformed parameter "url".');
}
- $url = array_map('rawurldecode', $url);
+ foreach ($url as $param => $value) {
+ if (! is_string($value)) {
+ continue;
+ }
+
+ $url[$param] = rawurldecode($value);
+ }
// If we have a connection URL, we have to unset the default PDO instance connection parameter (if any)
// as we cannot merge connection details from the URL into the PDO instance (URL takes precedence).
unset($params['pdo']);
- $params = self::parseDatabaseUrlScheme($url, $params);
+ $params = self::parseDatabaseUrlScheme($url['scheme'] ?? null, $params);
if (isset($url['host'])) {
$params['host'] = $url['host'];
@@ -412,23 +419,22 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params): a
/**
* Parses the scheme part from given connection URL and resolves the given connection parameters.
*
- * @param mixed[] $url The connection URL parts to evaluate.
- * @param mixed[] $params The connection parameters to resolve.
+ * @param string|null $scheme The connection URL scheme, if available
+ * @param mixed[] $params The connection parameters to resolve.
*
* @return mixed[] The resolved connection parameters.
*
* @throws Exception If parsing failed or resolution is not possible.
*/
- private static function parseDatabaseUrlScheme(array $url, array $params): array
+ private static function parseDatabaseUrlScheme($scheme, array $params): array
{
- if (isset($url['scheme'])) {
+ if ($scheme !== null) {
// The requested driver from the URL scheme takes precedence
// over the default custom driver from the connection parameters (if any).
unset($params['driverClass']);
// URL schemes must not contain underscores, but dashes are ok
- $driver = str_replace('-', '_', $url['scheme']);
- assert(is_string($driver));
+ $driver = str_replace('-', '_', $scheme);
// The requested driver from the URL scheme takes precedence over the
// default driver from the connection parameters. If the driver is
diff --git a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
index 2be445e38af..7c962a928f4 100644
--- a/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaColumnDefinitionEventArgs.php
@@ -12,7 +12,7 @@
class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
{
/** @var Column|null */
- private $column = null;
+ private $column;
/**
* Raw column data as fetched from the database.
diff --git a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
index 1236de401ab..072e1efb909 100644
--- a/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaDropTableEventArgs.php
@@ -18,7 +18,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
private $platform;
/** @var string|null */
- private $sql = null;
+ private $sql;
/**
* @param string|Table $table
diff --git a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
index ca6bbf81f7e..055a19a7c27 100644
--- a/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
+++ b/lib/Doctrine/DBAL/Event/SchemaIndexDefinitionEventArgs.php
@@ -12,7 +12,7 @@
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
{
/** @var Index|null */
- private $index = null;
+ private $index;
/**
* Raw index data as fetched from the database.
diff --git a/lib/Doctrine/DBAL/Exception/NoKeyValue.php b/lib/Doctrine/DBAL/Exception/NoKeyValue.php
new file mode 100644
index 00000000000..34093704aa1
--- /dev/null
+++ b/lib/Doctrine/DBAL/Exception/NoKeyValue.php
@@ -0,0 +1,25 @@
+ $types The SQL parameter types.
+ * @param string $sql SQL statement
+ * @param array|array|null $params Statement parameters
+ * @param array|array|null $types Parameter types
*
* @return void
*/
diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
index ba551574651..911daa8cb8b 100644
--- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -132,7 +132,7 @@ abstract class AbstractPlatform
public const TRIM_BOTH = TrimMode::BOTH;
/** @var string[]|null */
- protected $doctrineTypeMapping = null;
+ protected $doctrineTypeMapping;
/**
* Contains a list of all columns that should generate parseable column comments for type-detection
@@ -140,7 +140,7 @@ abstract class AbstractPlatform
*
* @var string[]|null
*/
- protected $doctrineTypeComments = null;
+ protected $doctrineTypeComments;
/** @var EventManager */
protected $_eventManager;
@@ -1602,8 +1602,10 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
}
}
+ $name = $column->getQuotedName($this);
+
$columnData = array_merge($column->toArray(), [
- 'name' => $column->getQuotedName($this),
+ 'name' => $name,
'version' => $column->hasPlatformOption('version') ? $column->getPlatformOption('version') : false,
'comment' => $this->getColumnComment($column),
]);
@@ -1616,7 +1618,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE
$columnData['primary'] = true;
}
- $columns[$columnData['name']] = $columnData;
+ $columns[$name] = $columnData;
}
if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) {
@@ -1742,7 +1744,7 @@ protected function _getCreateTableSQL($name, array $columns, array $options = []
$query .= ')';
- $sql[] = $query;
+ $sql = [$query];
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $definition) {
diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php b/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
index 860d9f21099..852a58aba2b 100644
--- a/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
+++ b/lib/Doctrine/DBAL/Platforms/Keywords/KeywordList.php
@@ -12,7 +12,7 @@
abstract class KeywordList
{
/** @var string[]|null */
- private $keywords = null;
+ private $keywords;
/**
* Checks if the given word is a keyword of this dialect/vendor platform.
diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
index c1da7ab8e83..b41f33bef46 100644
--- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
@@ -532,7 +532,7 @@ public function getAlterTableSQL(TableDiff $diff)
);
} elseif ($hasFromComment && ! $hasComment) {
$commentsSql[] = $this->getDropColumnCommentSQL($diff->name, $column->getQuotedName($this));
- } elseif ($hasComment) {
+ } elseif (! $hasFromComment && $hasComment) {
$commentsSql[] = $this->getCreateColumnCommentSQL(
$diff->name,
$column->getQuotedName($this),
@@ -1199,10 +1199,10 @@ public function getAsciiStringTypeDeclarationSQL(array $column): string
$length = $column['length'] ?? null;
if (! isset($column['fixed'])) {
- return sprintf('VARCHAR(%d)', $length);
+ return sprintf('VARCHAR(%d)', $length ?? 255);
}
- return sprintf('CHAR(%d)', $length);
+ return sprintf('CHAR(%d)', $length ?? 255);
}
/**
diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
index c33970fc142..e42a6bd89ec 100644
--- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
@@ -719,7 +719,9 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
*/
protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
{
- if (! $diff->fromTable instanceof Table) {
+ $fromTable = $diff->fromTable;
+
+ if (! $fromTable instanceof Table) {
throw new Exception(
'Sqlite platform requires for alter table the table diff with reference to original table schema'
);
@@ -732,7 +734,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
$tableName = $diff->getName($this);
}
- foreach ($this->getIndexesInAlteredTable($diff) as $index) {
+ foreach ($this->getIndexesInAlteredTable($diff, $fromTable) as $index) {
if ($index->isPrimary()) {
continue;
}
@@ -952,8 +954,8 @@ public function getAlterTableSQL(TableDiff $diff)
$newTable = new Table(
$table->getQuotedName($this),
$columns,
- $this->getPrimaryIndexInAlteredTable($diff),
- $this->getForeignKeysInAlteredTable($diff),
+ $this->getPrimaryIndexInAlteredTable($diff, $fromTable),
+ $this->getForeignKeysInAlteredTable($diff, $fromTable),
0,
$table->getOptions()
);
@@ -1092,11 +1094,11 @@ private function getSimpleAlterTableSQL(TableDiff $diff)
/**
* @return string[]
*/
- private function getColumnNamesInAlteredTable(TableDiff $diff)
+ private function getColumnNamesInAlteredTable(TableDiff $diff, Table $fromTable)
{
$columns = [];
- foreach ($diff->fromTable->getColumns() as $columnName => $column) {
+ foreach ($fromTable->getColumns() as $columnName => $column) {
$columns[strtolower($columnName)] = $column->getName();
}
@@ -1132,10 +1134,10 @@ private function getColumnNamesInAlteredTable(TableDiff $diff)
/**
* @return Index[]
*/
- private function getIndexesInAlteredTable(TableDiff $diff)
+ private function getIndexesInAlteredTable(TableDiff $diff, Table $fromTable)
{
- $indexes = $diff->fromTable->getIndexes();
- $columnNames = $this->getColumnNamesInAlteredTable($diff);
+ $indexes = $fromTable->getIndexes();
+ $columnNames = $this->getColumnNamesInAlteredTable($diff, $fromTable);
foreach ($indexes as $key => $index) {
foreach ($diff->renamedIndexes as $oldIndexName => $renamedIndex) {
@@ -1200,10 +1202,10 @@ private function getIndexesInAlteredTable(TableDiff $diff)
/**
* @return ForeignKeyConstraint[]
*/
- private function getForeignKeysInAlteredTable(TableDiff $diff)
+ private function getForeignKeysInAlteredTable(TableDiff $diff, Table $fromTable)
{
- $foreignKeys = $diff->fromTable->getForeignKeys();
- $columnNames = $this->getColumnNamesInAlteredTable($diff);
+ $foreignKeys = $fromTable->getForeignKeys();
+ $columnNames = $this->getColumnNamesInAlteredTable($diff, $fromTable);
foreach ($foreignKeys as $key => $constraint) {
$changed = false;
@@ -1264,11 +1266,11 @@ private function getForeignKeysInAlteredTable(TableDiff $diff)
/**
* @return Index[]
*/
- private function getPrimaryIndexInAlteredTable(TableDiff $diff)
+ private function getPrimaryIndexInAlteredTable(TableDiff $diff, Table $fromTable)
{
$primaryIndex = [];
- foreach ($this->getIndexesInAlteredTable($diff) as $index) {
+ foreach ($this->getIndexesInAlteredTable($diff, $fromTable) as $index) {
if (! $index->isPrimary()) {
continue;
}
diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php
index a1306754836..492a06951bb 100644
--- a/lib/Doctrine/DBAL/Query/QueryBuilder.php
+++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php
@@ -7,11 +7,13 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
+use Doctrine\DBAL\Types\Type;
use function array_filter;
use function array_key_exists;
use function array_keys;
use function array_unshift;
+use function count;
use function func_get_args;
use function func_num_args;
use function implode;
@@ -87,14 +89,14 @@ class QueryBuilder
/**
* The query parameters.
*
- * @var mixed[]
+ * @var array|array
*/
private $params = [];
/**
* The parameter type map of this query.
*
- * @var int[]|string[]
+ * @var array|array
*/
private $paramTypes = [];
@@ -117,14 +119,14 @@ class QueryBuilder
*
* @var int
*/
- private $firstResult = null;
+ private $firstResult;
/**
* The maximum number of results to retrieve or NULL to retrieve all results.
*
* @var int|null
*/
- private $maxResults = null;
+ private $maxResults;
/**
* The counter of bound parameters used with {@see bindValue).
@@ -262,9 +264,9 @@ public function getSQL()
* ->setParameter(':user_id', 1);
*
*
- * @param string|int $key The parameter position or name.
- * @param mixed $value The parameter value.
- * @param string|int|null $type One of the {@link ParameterType} constants.
+ * @param int|string $key Parameter position or name
+ * @param mixed $value Parameter value
+ * @param int|string|Type|null $type One of the {@link ParameterType} constants or DBAL type
*
* @return $this This QueryBuilder instance.
*/
@@ -293,8 +295,8 @@ public function setParameter($key, $value, $type = null)
* ));
*
*
- * @param mixed[] $params The query parameters to set.
- * @param int[]|string[] $types The query parameters types to set.
+ * @param array|array $params Parameters to set
+ * @param array|array $types Parameter types
*
* @return $this This QueryBuilder instance.
*/
@@ -309,7 +311,7 @@ public function setParameters(array $params, array $types = [])
/**
* Gets all defined query parameters for the query being constructed indexed by parameter index or name.
*
- * @return mixed[] The currently defined query parameters indexed by parameter index or name.
+ * @return array|array The currently defined query parameters
*/
public function getParameters()
{
@@ -331,7 +333,8 @@ public function getParameter($key)
/**
* Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
*
- * @return int[]|string[] The currently defined query parameter types indexed by parameter index or name.
+ * @return array|array The currently defined
+ * query parameter types
*/
public function getParameterTypes()
{
@@ -341,9 +344,9 @@ public function getParameterTypes()
/**
* Gets a (previously set) query parameter type of the query being constructed.
*
- * @param mixed $key The key (index or name) of the bound parameter type.
+ * @param int|string $key The key of the bound parameter type
*
- * @return mixed The value of the bound parameter type.
+ * @return int|string|Type|null The value of the bound parameter type
*/
public function getParameterType($key)
{
@@ -834,7 +837,9 @@ public function andWhere($where)
$where = $this->getQueryPart('where');
if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_AND) {
- $where = $where->with(...$args);
+ if (count($args) > 0) {
+ $where = $where->with(...$args);
+ }
} else {
array_unshift($args, $where);
$where = CompositeExpression::and(...$args);
@@ -868,7 +873,9 @@ public function orWhere($where)
$where = $this->getQueryPart('where');
if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_OR) {
- $where = $where->with(...$args);
+ if (count($args) > 0) {
+ $where = $where->with(...$args);
+ }
} else {
array_unshift($args, $where);
$where = CompositeExpression::or(...$args);
@@ -1191,7 +1198,7 @@ private function getFromClauses()
}
/**
- * @param string[] $knownAliases
+ * @param array $knownAliases
*
* @throws QueryException
*/
@@ -1286,9 +1293,9 @@ public function __toString()
*
* @link http://www.zetacomponents.org
*
- * @param mixed $value
- * @param mixed $type
- * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
+ * @param mixed $value
+ * @param int|string|Type|null $type
+ * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
*
* @return string the placeholder name used.
*/
@@ -1321,8 +1328,8 @@ public function createNamedParameter($value, $type = ParameterType::STRING, $pla
* ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', ParameterType::STRING))
*
*
- * @param mixed $value
- * @param int $type
+ * @param mixed $value
+ * @param int|string|Type|null $type
*
* @return string
*/
@@ -1335,8 +1342,8 @@ public function createPositionalParameter($value, $type = ParameterType::STRING)
}
/**
- * @param string $fromAlias
- * @param string[] $knownAliases
+ * @param string $fromAlias
+ * @param array $knownAliases
*
* @return string
*
diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php
index b469741ca0e..5b558f01343 100644
--- a/lib/Doctrine/DBAL/SQLParserUtils.php
+++ b/lib/Doctrine/DBAL/SQLParserUtils.php
@@ -2,6 +2,8 @@
namespace Doctrine\DBAL;
+use Doctrine\DBAL\Types\Type;
+
use function array_fill;
use function array_fill_keys;
use function array_key_exists;
@@ -64,7 +66,7 @@ public static function getPlaceholderPositions($statement, $isPositional = true)
/**
* Returns a zero-indexed list of placeholder position.
*
- * @return int[]
+ * @return list
*/
private static function getPositionalPlaceholderPositions(string $statement): array
{
@@ -81,7 +83,7 @@ static function (string $_, int $placeholderPosition, int $fragmentPosition, arr
/**
* Returns a map of placeholder positions to their parameter names.
*
- * @return string[]
+ * @return array
*/
private static function getNamedPlaceholderPositions(string $statement): array
{
@@ -128,9 +130,9 @@ private static function collectPlaceholders(
/**
* For a positional query this method can rewrite the sql statement with regard to array parameters.
*
- * @param string $query The SQL query to execute.
- * @param mixed[] $params The parameters to bind to the query.
- * @param array $types The types the previous parameters are in.
+ * @param string $query SQL query
+ * @param mixed[] $params Query parameters
+ * @param array|array $types Parameter types
*
* @return mixed[]
*
diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php
index 3424b17c544..02111832e26 100644
--- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php
+++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php
@@ -31,7 +31,7 @@ abstract class AbstractAsset
*
* @var string|null
*/
- protected $_namespace = null;
+ protected $_namespace;
/** @var bool */
protected $_quoted = false;
diff --git a/lib/Doctrine/DBAL/Schema/Column.php b/lib/Doctrine/DBAL/Schema/Column.php
index e33f285108b..f63bcc9226b 100644
--- a/lib/Doctrine/DBAL/Schema/Column.php
+++ b/lib/Doctrine/DBAL/Schema/Column.php
@@ -21,7 +21,7 @@ class Column extends AbstractAsset
protected $_type;
/** @var int|null */
- protected $_length = null;
+ protected $_length;
/** @var int */
protected $_precision = 10;
@@ -39,7 +39,7 @@ class Column extends AbstractAsset
protected $_notnull = true;
/** @var string|null */
- protected $_default = null;
+ protected $_default;
/** @var bool */
protected $_autoincrement = false;
@@ -48,10 +48,10 @@ class Column extends AbstractAsset
protected $_platformOptions = [];
/** @var string|null */
- protected $_columnDefinition = null;
+ protected $_columnDefinition;
/** @var string|null */
- protected $_comment = null;
+ protected $_comment;
/** @var mixed[] */
protected $_customSchemaOptions = [];
diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php
index 20f5ea7b1a9..7e24b3e8c01 100644
--- a/lib/Doctrine/DBAL/Schema/Comparator.php
+++ b/lib/Doctrine/DBAL/Schema/Comparator.php
@@ -188,24 +188,24 @@ public function diffSequence(Sequence $sequence1, Sequence $sequence2)
}
/**
- * Returns the difference between the tables $table1 and $table2.
+ * Returns the difference between the tables $fromTable and $toTable.
*
* If there are no differences this method returns the boolean false.
*
* @return TableDiff|false
*/
- public function diffTable(Table $table1, Table $table2)
+ public function diffTable(Table $fromTable, Table $toTable)
{
$changes = 0;
- $tableDifferences = new TableDiff($table1->getName());
- $tableDifferences->fromTable = $table1;
+ $tableDifferences = new TableDiff($fromTable->getName());
+ $tableDifferences->fromTable = $fromTable;
- $table1Columns = $table1->getColumns();
- $table2Columns = $table2->getColumns();
+ $fromTableColumns = $fromTable->getColumns();
+ $toTableColumns = $toTable->getColumns();
- /* See if all the columns in table 1 exist in table 2 */
- foreach ($table2Columns as $columnName => $column) {
- if ($table1->hasColumn($columnName)) {
+ /* See if all the columns in "from" table exist in "to" table */
+ foreach ($toTableColumns as $columnName => $column) {
+ if ($fromTable->hasColumn($columnName)) {
continue;
}
@@ -213,23 +213,23 @@ public function diffTable(Table $table1, Table $table2)
$changes++;
}
- /* See if there are any removed columns in table 2 */
- foreach ($table1Columns as $columnName => $column) {
- // See if column is removed in table 2.
- if (! $table2->hasColumn($columnName)) {
+ /* See if there are any removed columns in "to" table */
+ foreach ($fromTableColumns as $columnName => $column) {
+ // See if column is removed in "to" table.
+ if (! $toTable->hasColumn($columnName)) {
$tableDifferences->removedColumns[$columnName] = $column;
$changes++;
continue;
}
- // See if column has changed properties in table 2.
- $changedProperties = $this->diffColumn($column, $table2->getColumn($columnName));
+ // See if column has changed properties in "to" table.
+ $changedProperties = $this->diffColumn($column, $toTable->getColumn($columnName));
if (empty($changedProperties)) {
continue;
}
- $columnDiff = new ColumnDiff($column->getName(), $table2->getColumn($columnName), $changedProperties);
+ $columnDiff = new ColumnDiff($column->getName(), $toTable->getColumn($columnName), $changedProperties);
$columnDiff->fromColumn = $column;
$tableDifferences->changedColumns[$column->getName()] = $columnDiff;
@@ -238,12 +238,12 @@ public function diffTable(Table $table1, Table $table2)
$this->detectColumnRenamings($tableDifferences);
- $table1Indexes = $table1->getIndexes();
- $table2Indexes = $table2->getIndexes();
+ $fromTableIndexes = $fromTable->getIndexes();
+ $toTableIndexes = $toTable->getIndexes();
- /* See if all the indexes in table 1 exist in table 2 */
- foreach ($table2Indexes as $indexName => $index) {
- if (($index->isPrimary() && $table1->hasPrimaryKey()) || $table1->hasIndex($indexName)) {
+ /* See if all the indexes in "from" table exist in "to" table */
+ foreach ($toTableIndexes as $indexName => $index) {
+ if (($index->isPrimary() && $fromTable->hasPrimaryKey()) || $fromTable->hasIndex($indexName)) {
continue;
}
@@ -251,56 +251,56 @@ public function diffTable(Table $table1, Table $table2)
$changes++;
}
- /* See if there are any removed indexes in table 2 */
- foreach ($table1Indexes as $indexName => $index) {
- // See if index is removed in table 2.
+ /* See if there are any removed indexes in "to" table */
+ foreach ($fromTableIndexes as $indexName => $index) {
+ // See if index is removed in "to" table.
if (
- ($index->isPrimary() && ! $table2->hasPrimaryKey()) ||
- ! $index->isPrimary() && ! $table2->hasIndex($indexName)
+ ($index->isPrimary() && ! $toTable->hasPrimaryKey()) ||
+ ! $index->isPrimary() && ! $toTable->hasIndex($indexName)
) {
$tableDifferences->removedIndexes[$indexName] = $index;
$changes++;
continue;
}
- // See if index has changed in table 2.
- $table2Index = $index->isPrimary() ? $table2->getPrimaryKey() : $table2->getIndex($indexName);
- assert($table2Index instanceof Index);
+ // See if index has changed in "to" table.
+ $toTableIndex = $index->isPrimary() ? $toTable->getPrimaryKey() : $toTable->getIndex($indexName);
+ assert($toTableIndex instanceof Index);
- if (! $this->diffIndex($index, $table2Index)) {
+ if (! $this->diffIndex($index, $toTableIndex)) {
continue;
}
- $tableDifferences->changedIndexes[$indexName] = $table2Index;
+ $tableDifferences->changedIndexes[$indexName] = $toTableIndex;
$changes++;
}
$this->detectIndexRenamings($tableDifferences);
- $fromFkeys = $table1->getForeignKeys();
- $toFkeys = $table2->getForeignKeys();
+ $fromForeignKeys = $fromTable->getForeignKeys();
+ $toForeignKeys = $toTable->getForeignKeys();
- foreach ($fromFkeys as $key1 => $constraint1) {
- foreach ($toFkeys as $key2 => $constraint2) {
- if ($this->diffForeignKey($constraint1, $constraint2) === false) {
- unset($fromFkeys[$key1], $toFkeys[$key2]);
+ foreach ($fromForeignKeys as $fromKey => $fromConstraint) {
+ foreach ($toForeignKeys as $toKey => $toConstraint) {
+ if ($this->diffForeignKey($fromConstraint, $toConstraint) === false) {
+ unset($fromForeignKeys[$fromKey], $toForeignKeys[$toKey]);
} else {
- if (strtolower($constraint1->getName()) === strtolower($constraint2->getName())) {
- $tableDifferences->changedForeignKeys[] = $constraint2;
+ if (strtolower($fromConstraint->getName()) === strtolower($toConstraint->getName())) {
+ $tableDifferences->changedForeignKeys[] = $toConstraint;
$changes++;
- unset($fromFkeys[$key1], $toFkeys[$key2]);
+ unset($fromForeignKeys[$fromKey], $toForeignKeys[$toKey]);
}
}
}
}
- foreach ($fromFkeys as $constraint1) {
- $tableDifferences->removedForeignKeys[] = $constraint1;
+ foreach ($fromForeignKeys as $fromConstraint) {
+ $tableDifferences->removedForeignKeys[] = $fromConstraint;
$changes++;
}
- foreach ($toFkeys as $constraint2) {
- $tableDifferences->addedForeignKeys[] = $constraint2;
+ foreach ($toForeignKeys as $toConstraint) {
+ $tableDifferences->addedForeignKeys[] = $toConstraint;
$changes++;
}
diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
index 25f0282c536..fcc196ae519 100644
--- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
@@ -7,7 +7,6 @@
use function array_change_key_case;
use function assert;
-use function is_resource;
use function preg_match;
use function str_replace;
use function strpos;
@@ -207,13 +206,12 @@ protected function _getPortableForeignKeyRuleDef($def)
protected function _getPortableViewDefinition($view)
{
$view = array_change_key_case($view, CASE_LOWER);
- // sadly this still segfaults on PDO_IBM, see http://pecl.php.net/bugs/bug.php?id=17199
- //$view['text'] = (is_resource($view['text']) ? stream_get_contents($view['text']) : $view['text']);
- if (! is_resource($view['text'])) {
- $pos = strpos($view['text'], ' AS ');
+
+ $sql = '';
+ $pos = strpos($view['text'], ' AS ');
+
+ if ($pos !== false) {
$sql = substr($view['text'], $pos + 4);
- } else {
- $sql = '';
}
return new View($view['name'], $sql);
diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
index d9fabec1660..e64a9c81735 100644
--- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
@@ -60,7 +60,11 @@ public function getSchemaNames()
public function getSchemaSearchPaths()
{
$params = $this->_conn->getParams();
- $schema = explode(',', $this->_conn->fetchColumn('SHOW search_path'));
+
+ $searchPaths = $this->_conn->fetchColumn('SHOW search_path');
+ assert($searchPaths !== false);
+
+ $schema = explode(',', $searchPaths);
if (isset($params['user'])) {
$schema = str_replace('"$user"', $params['user'], $schema);
@@ -150,13 +154,17 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
$onDelete = $match[1];
}
- if (preg_match('/FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)/', $tableForeignKey['condef'], $values)) {
- // PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
- // the idea to trim them here.
- $localColumns = array_map('trim', explode(',', $values[1]));
- $foreignColumns = array_map('trim', explode(',', $values[3]));
- $foreignTable = $values[2];
- }
+ assert(preg_match(
+ '/FOREIGN KEY \((.+)\) REFERENCES (.+)\((.+)\)/',
+ $tableForeignKey['condef'],
+ $values
+ ) !== 0);
+
+ // PostgreSQL returns identifiers that are keywords with quotes, we need them later, don't get
+ // the idea to trim them here.
+ $localColumns = array_map('trim', explode(',', $values[1]));
+ $foreignColumns = array_map('trim', explode(',', $values[3]));
+ $foreignTable = $values[2];
return new ForeignKeyConstraint(
$localColumns,
diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php
index 6ea5fd0c8c0..24fc47b599b 100644
--- a/lib/Doctrine/DBAL/Schema/Schema.php
+++ b/lib/Doctrine/DBAL/Schema/Schema.php
@@ -52,7 +52,7 @@ class Schema extends AbstractAsset
protected $_sequences = [];
/** @var SchemaConfig */
- protected $_schemaConfig = false;
+ protected $_schemaConfig;
/**
* @param Table[] $tables
diff --git a/lib/Doctrine/DBAL/Schema/Sequence.php b/lib/Doctrine/DBAL/Schema/Sequence.php
index 19dec9cd57a..1cba86c086c 100644
--- a/lib/Doctrine/DBAL/Schema/Sequence.php
+++ b/lib/Doctrine/DBAL/Schema/Sequence.php
@@ -19,7 +19,7 @@ class Sequence extends AbstractAsset
protected $initialValue = 1;
/** @var int|null */
- protected $cache = null;
+ protected $cache;
/**
* @param string $name
diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php
index bd0462151a4..d69dc45f189 100644
--- a/lib/Doctrine/DBAL/Schema/Table.php
+++ b/lib/Doctrine/DBAL/Schema/Table.php
@@ -29,7 +29,7 @@ class Table extends AbstractAsset
/** @var Index[] */
protected $_indexes = [];
- /** @var string */
+ /** @var string|false */
protected $_primaryKeyName = false;
/** @var ForeignKeyConstraint[] */
@@ -41,7 +41,7 @@ class Table extends AbstractAsset
];
/** @var SchemaConfig|null */
- protected $_schemaConfig = null;
+ protected $_schemaConfig;
/**
* @param string $name
@@ -150,6 +150,10 @@ public function addIndex(array $columnNames, $indexName = null, array $flags = [
*/
public function dropPrimaryKey()
{
+ if ($this->_primaryKeyName === false) {
+ return;
+ }
+
$this->dropIndex($this->_primaryKeyName);
$this->_primaryKeyName = false;
}
@@ -717,11 +721,11 @@ public function getColumn($name)
*/
public function getPrimaryKey()
{
- if (! $this->hasPrimaryKey()) {
- return null;
+ if ($this->_primaryKeyName !== false) {
+ return $this->getIndex($this->_primaryKeyName);
}
- return $this->getIndex($this->_primaryKeyName);
+ return null;
}
/**
diff --git a/lib/Doctrine/DBAL/Schema/TableDiff.php b/lib/Doctrine/DBAL/Schema/TableDiff.php
index dcaeb200a6a..82c912f71b1 100644
--- a/lib/Doctrine/DBAL/Schema/TableDiff.php
+++ b/lib/Doctrine/DBAL/Schema/TableDiff.php
@@ -10,7 +10,7 @@
class TableDiff
{
/** @var string */
- public $name = null;
+ public $name;
/** @var string|false */
public $newName = false;
diff --git a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
index b2fab3ae4af..c08fb6fecd8 100644
--- a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
+++ b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -24,7 +24,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
private $createFkConstraintQueries = [];
/** @var AbstractPlatform */
- private $platform = null;
+ private $platform;
public function __construct(AbstractPlatform $platform)
{
diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
index 7ea9ce1fad3..5fa2aa782eb 100644
--- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
+++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php
@@ -125,6 +125,8 @@ public function getDropAllSchema()
$this->shardManager->selectGlobal();
$globalSql = $this->synchronizer->getDropAllSchema();
+ $sql = [];
+
if ($globalSql) {
$sql[] = "-- Work on Root Federation\nUSE FEDERATION ROOT WITH RESET;";
$sql = array_merge($sql, $globalSql);
diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php
index 294866921ec..ad5d29b9a5d 100644
--- a/lib/Doctrine/DBAL/Statement.php
+++ b/lib/Doctrine/DBAL/Statement.php
@@ -5,6 +5,7 @@
use Doctrine\DBAL\Abstraction\Result;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
+use Doctrine\DBAL\Exception\NoKeyValue;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use IteratorAggregate;
@@ -12,6 +13,7 @@
use Throwable;
use Traversable;
+use function array_shift;
use function is_array;
use function is_string;
@@ -375,6 +377,47 @@ public function fetchAllAssociative(): array
}
}
+ /**
+ * Returns an associative array with the keys mapped to the first column and the values mapped to the second column.
+ *
+ * The result must contain at least two columns.
+ *
+ * @return array
+ *
+ * @throws Exception
+ */
+ public function fetchAllKeyValue(): array
+ {
+ $this->ensureHasKeyValue();
+
+ $data = [];
+
+ foreach ($this->fetchAllNumeric() as [$key, $value]) {
+ $data[$key] = $value;
+ }
+
+ return $data;
+ }
+
+ /**
+ * Returns an associative array with the keys mapped to the first column and the values being
+ * an associative array representing the rest of the columns and their values.
+ *
+ * @return array>
+ *
+ * @throws Exception
+ */
+ public function fetchAllAssociativeIndexed(): array
+ {
+ $data = [];
+
+ foreach ($this->fetchAll(FetchMode::ASSOCIATIVE) as $row) {
+ $data[array_shift($row)] = $row;
+ }
+
+ return $data;
+ }
+
/**
* {@inheritdoc}
*
@@ -441,6 +484,40 @@ public function iterateAssociative(): Traversable
}
}
+ /**
+ * Returns an iterator over the result set with the keys mapped to the first column
+ * and the values mapped to the second column.
+ *
+ * The result must contain at least two columns.
+ *
+ * @return Traversable
+ *
+ * @throws Exception
+ */
+ public function iterateKeyValue(): Traversable
+ {
+ $this->ensureHasKeyValue();
+
+ foreach ($this->iterateNumeric() as [$key, $value]) {
+ yield $key => $value;
+ }
+ }
+
+ /**
+ * Returns an iterator over the result set with the keys mapped to the first column and the values being
+ * an associative array representing the rest of the columns and their values.
+ *
+ * @return Traversable>
+ *
+ * @throws Exception
+ */
+ public function iterateAssociativeIndexed(): Traversable
+ {
+ while (($row = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) !== false) {
+ yield array_shift($row) => $row;
+ }
+ }
+
/**
* {@inheritDoc}
*
@@ -495,4 +572,13 @@ public function getWrappedStatement()
{
return $this->stmt;
}
+
+ private function ensureHasKeyValue(): void
+ {
+ $columnCount = $this->columnCount();
+
+ if ($columnCount < 2) {
+ throw NoKeyValue::fromColumnCount($columnCount);
+ }
+ }
}
diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
index 3d53f342968..26456bde0ce 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
@@ -85,9 +85,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
$sql = @file_get_contents($filePath);
if ($sql === false) {
- throw new RuntimeException(
- sprintf("Unable to read SQL file '%s': %s", $filePath, error_get_last()['message'])
- );
+ $message = sprintf("Unable to read SQL file '%s'", $filePath);
+ $error = error_get_last();
+
+ if ($error !== null) {
+ $message .= ': ' . $error['message'];
+ }
+
+ throw new RuntimeException($message);
}
if ($conn instanceof PDOConnection) {
diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
index 50e6a59343a..bd819af0e6a 100644
--- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
+++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
@@ -4,6 +4,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\Keywords\DB2Keywords;
+use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords;
use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
@@ -33,6 +34,7 @@
use function assert;
use function count;
use function implode;
+use function is_array;
use function is_string;
use function trigger_error;
@@ -40,7 +42,7 @@
class ReservedWordsCommand extends Command
{
- /** @var string[] */
+ /** @var array> */
private $keywordListClasses = [
'mysql' => MySQLKeywords::class,
'mysql57' => MySQL57Keywords::class,
@@ -81,8 +83,8 @@ public function __construct(?ConnectionProvider $connectionProvider = null)
/**
* If you want to add or replace a keywords list use this command.
*
- * @param string $name
- * @param string $class
+ * @param string $name
+ * @param class-string $class
*
* @return void
*/
@@ -149,7 +151,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$conn = $this->getConnection($input);
- $keywordLists = (array) $input->getOption('list');
+ $keywordLists = $input->getOption('list');
+
+ if (is_string($keywordLists)) {
+ $keywordLists = [$keywordLists];
+ } elseif (! is_array($keywordLists)) {
+ $keywordLists = [];
+ }
+
if (! $keywordLists) {
$keywordLists = [
'mysql',
diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php
index 5ff51c4c9bb..f8be9131bcd 100644
--- a/lib/Doctrine/DBAL/Types/Type.php
+++ b/lib/Doctrine/DBAL/Types/Type.php
@@ -236,8 +236,8 @@ public static function getType($name)
/**
* Adds a custom type to the type map.
*
- * @param string $name The name of the type. This should correspond to what getName() returns.
- * @param string $className The class name of the custom type.
+ * @param string $name The name of the type. This should correspond to what getName() returns.
+ * @param class-string $className The class name of the custom type.
*
* @return void
*
@@ -263,8 +263,8 @@ public static function hasType($name)
/**
* Overrides an already defined type to use a different implementation.
*
- * @param string $name
- * @param string $className
+ * @param string $name
+ * @param class-string $className
*
* @return void
*
diff --git a/lib/Doctrine/DBAL/Version.php b/lib/Doctrine/DBAL/Version.php
index 044b85e54aa..e48445ed1cf 100644
--- a/lib/Doctrine/DBAL/Version.php
+++ b/lib/Doctrine/DBAL/Version.php
@@ -17,7 +17,7 @@ class Version
/**
* Current Doctrine Version.
*/
- public const VERSION = '2.11.1';
+ public const VERSION = '2.11.2';
/**
* Compares a Doctrine version with the current one.
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 38c7bdace8c..93597bd6f52 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -21,6 +21,9 @@ parameters:
- '~^Property Doctrine\\DBAL\\Schema\\Schema::\$_schemaConfig \(Doctrine\\DBAL\\Schema\\SchemaConfig\) does not accept default value of type false\.\z~'
- '~^Return type \(int\|false\) of method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~'
+ # https://github.com/phpstan/phpstan/issues/2857
+ - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array, array given\.\z~'
+
# legacy variadic-like signature
# TODO: remove in 3.0.0
- '~^Method Doctrine\\DBAL(\\.*)?Connection::query\(\) invoked with \d+ parameters?, 0 required\.\z~'
@@ -111,3 +114,9 @@ parameters:
message: '~Return type \(Doctrine\\DBAL\\Portability\\Statement\) of method Doctrine\\DBAL\\Portability\\Connection::prepare\(\) should be compatible with return type \(Doctrine\\DBAL\\Statement\) of method Doctrine\\DBAL\\Connection::prepare\(\)~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Portability/Connection.php
+
+ # Unlike Psalm, PHPStan doesn't understand the shape of the parse_str() return value
+ -
+ message: '~^Parameter #1 \$scheme of static method Doctrine\\DBAL\\DriverManager::parseDatabaseUrlScheme\(\) expects string\|null, int\|string\|null given\.$~'
+ paths:
+ - %currentWorkingDirectory%/lib/Doctrine/DBAL/DriverManager.php
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 6d693d9c924..f79efc83e40 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -12,7 +12,7 @@
Example: phpunit -c mysqlconf.xml
-->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -95,6 +166,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
index 9a969bc1d5c..b1d36c66d36 100644
--- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
+++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
@@ -38,9 +38,5 @@ public function testSetsDefaultConnectionAutoCommitMode(): void
$this->config->setAutoCommit(false);
self::assertFalse($this->config->getAutoCommit());
-
- $this->config->setAutoCommit(0);
-
- self::assertFalse($this->config->getAutoCommit());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php
index 8bcf1b817fe..675881ac207 100644
--- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php
@@ -51,7 +51,7 @@ protected function setUp(): void
}
/**
- * @return Connection|MockObject
+ * @return Connection&MockObject
*/
private function getExecuteStatementMockConnection()
{
@@ -241,8 +241,6 @@ public function testSetAutoCommit(): void
{
$this->connection->setAutoCommit(false);
self::assertFalse($this->connection->isAutoCommit());
- $this->connection->setAutoCommit(0);
- self::assertFalse($this->connection->isAutoCommit());
}
public function testConnectStartsTransactionInNoAutoCommitMode(): void
@@ -650,22 +648,18 @@ public function testFetchAll(): void
public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO(): void
{
- $params['pdo'] = new stdClass();
-
$driverMock = $this->createMock(Driver::class);
- $conn = new Connection($params, $driverMock);
+ $conn = new Connection(['pdo' => new stdClass()], $driverMock);
self::assertArrayNotHasKey('pdo', $conn->getParams());
}
public function testPassingExternalPDOMeansConnectionIsConnected(): void
{
- $params['pdo'] = new stdClass();
-
$driverMock = $this->createMock(Driver::class);
- $conn = new Connection($params, $driverMock);
+ $conn = new Connection(['pdo' => new stdClass()], $driverMock);
self::assertTrue($conn->isConnected(), 'Connection is not connected after passing external PDO');
}
diff --git a/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php
new file mode 100644
index 00000000000..c29b8b05a40
--- /dev/null
+++ b/tests/Doctrine/Tests/DBAL/Connections/MasterSlaveConnectionTest.php
@@ -0,0 +1,39 @@
+ 'pdo_mysql',
+ 'keepSlave' => true,
+ 'master' => [
+ 'host' => 'master.host',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'port' => '1234',
+ ],
+ 'slaves' => [
+ [
+ 'host' => 'slave1.host',
+ 'user' => 'root',
+ 'password' => 'password',
+ 'port' => '1234',
+ ],
+ ],
+ ];
+
+ $connection = new MasterSlaveConnection($constructionParams, $this->createStub(Driver::class));
+
+ $connectionParams = $connection->getParams();
+ foreach ($constructionParams as $key => $value) {
+ self::assertSame($value, $connectionParams[$key]);
+ }
+ }
+}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
index 078875a4086..c08b33fb898 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
@@ -70,7 +70,8 @@ protected function setUp(): void
}
/**
- * @param int|string $errorCode
+ * @param int|string $errorCode
+ * @param class-string $expectedClass
*
* @dataProvider exceptionConversionProvider
*/
diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
index e8b08f745e5..1d7d88ec342 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
@@ -14,7 +14,7 @@ class DB2ConnectionTest extends DbalTestCase
/**
* The ibm_db2 driver connection mock under test.
*
- * @var DB2Connection|MockObject
+ * @var DB2Connection&MockObject
*/
private $connectionMock;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
index 9611da063cd..c0953ea532b 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
@@ -19,7 +19,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
/**
* The mysqli driver connection mock under test.
*
- * @var MysqliConnection|MockObject
+ * @var MysqliConnection&MockObject
*/
private $connectionMock;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
index 12cd8ef7af4..5185f4abc10 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
@@ -14,7 +14,7 @@ class OCI8ConnectionTest extends DbalTestCase
/**
* The oci8 driver connection mock under test.
*
- * @var OCI8Connection|MockObject
+ * @var OCI8Connection&MockObject
*/
private $connectionMock;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php
index 4ba493ab2ee..f9323041038 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php
@@ -5,7 +5,6 @@
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\Tests\DbalTestCase;
use PDOException;
-use PHPUnit\Framework\MockObject\MockObject;
/**
* @requires extension pdo
@@ -28,7 +27,7 @@ class ExceptionTest extends DbalTestCase
/**
* The wrapped PDO exception mock.
*
- * @var PDOException|MockObject
+ * @var PDOException
*/
private $wrappedException;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
index 4a7044594f3..bfef87d5de4 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
@@ -84,11 +84,15 @@ private function connect(array $driverOptions): Connection
{
$params = TestUtil::getConnectionParams();
- return $this->createDriver()->connect(
+ $connection = $this->createDriver()->connect(
$params,
$params['user'] ?? '',
$params['password'] ?? '',
$driverOptions
);
+
+ self::assertInstanceOf(Connection::class, $connection);
+
+ return $connection;
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
index b2d1ddef6fc..54cedfce3cd 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
@@ -14,7 +14,7 @@ class SQLAnywhereConnectionTest extends DbalTestCase
/**
* The sqlanywhere driver connection mock under test.
*
- * @var SQLAnywhereConnection|MockObject
+ * @var SQLAnywhereConnection&MockObject
*/
private $connectionMock;
diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
index 8d424ee21b6..75781443962 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
@@ -11,7 +11,7 @@ class SQLSrvConnectionTest extends DbalTestCase
/**
* The sqlsrv driver connection mock under test.
*
- * @var SQLSrvConnection|MockObject
+ * @var SQLSrvConnection&MockObject
*/
private $connectionMock;
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php
index d33fc1708e9..e5f4d2472dd 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Functional\Connection;
+use Doctrine\DBAL\Exception\NoKeyValue;
+use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\Tests\DbalFunctionalTestCase;
use Doctrine\Tests\TestUtil;
@@ -77,6 +79,74 @@ public function testFetchAllAssociative(): void
], $this->connection->fetchAllAssociative($this->query));
}
+ public function testFetchAllKeyValue(): void
+ {
+ self::assertEquals([
+ 'foo' => 1,
+ 'bar' => 2,
+ 'baz' => 3,
+ ], $this->connection->fetchAllKeyValue($this->query));
+ }
+
+ public function testStatementFetchAllKeyValue(): void
+ {
+ $stmt = $this->connection->prepare($this->query);
+ $stmt->execute();
+
+ self::assertEquals([
+ 'foo' => 1,
+ 'bar' => 2,
+ 'baz' => 3,
+ ], $stmt->fetchAllKeyValue());
+ }
+
+ /**
+ * This test covers the requirement for the statement result to have at least two columns,
+ * not exactly two as PDO requires.
+ */
+ public function testFetchAllKeyValueWithLimit(): void
+ {
+ $platform = $this->connection->getDatabasePlatform();
+
+ if ($platform instanceof SQLServer2012Platform) {
+ self::markTestSkipped('See https://github.com/doctrine/dbal/issues/2374');
+ }
+
+ $query = $platform->modifyLimitQuery($this->query, 1, 1);
+
+ self::assertEquals(['bar' => 2], $this->connection->fetchAllKeyValue($query));
+ }
+
+ public function testFetchAllKeyValueOneColumn(): void
+ {
+ $sql = $this->connection->getDatabasePlatform()
+ ->getDummySelectSQL();
+
+ $this->expectException(NoKeyValue::class);
+ $this->connection->fetchAllKeyValue($sql);
+ }
+
+ public function testFetchAllAssociativeIndexed(): void
+ {
+ self::assertEquals([
+ 'foo' => ['b' => 1],
+ 'bar' => ['b' => 2],
+ 'baz' => ['b' => 3],
+ ], $this->connection->fetchAllAssociativeIndexed($this->query));
+ }
+
+ public function testStatementFetchAllAssociativeIndexed(): void
+ {
+ $stmt = $this->connection->prepare($this->query);
+ $stmt->execute();
+
+ self::assertEquals([
+ 'foo' => ['b' => 1],
+ 'bar' => ['b' => 2],
+ 'baz' => ['b' => 3],
+ ], $stmt->fetchAllAssociativeIndexed());
+ }
+
public function testFetchFirstColumn(): void
{
self::assertEquals([
@@ -113,6 +183,57 @@ public function testIterateAssociative(): void
], iterator_to_array($this->connection->iterateAssociative($this->query)));
}
+ public function testIterateKeyValue(): void
+ {
+ self::assertEquals([
+ 'foo' => 1,
+ 'bar' => 2,
+ 'baz' => 3,
+ ], iterator_to_array($this->connection->iterateKeyValue($this->query)));
+ }
+
+ public function testStatementIterateKeyValue(): void
+ {
+ $stmt = $this->connection->prepare($this->query);
+ $stmt->execute();
+
+ self::assertEquals([
+ 'foo' => 1,
+ 'bar' => 2,
+ 'baz' => 3,
+ ], iterator_to_array($stmt->iterateKeyValue()));
+ }
+
+ public function testIterateKeyValueOneColumn(): void
+ {
+ $sql = $this->connection->getDatabasePlatform()
+ ->getDummySelectSQL();
+
+ $this->expectException(NoKeyValue::class);
+ iterator_to_array($this->connection->iterateKeyValue($sql));
+ }
+
+ public function testIterateAssociativeIndexed(): void
+ {
+ self::assertEquals([
+ 'foo' => ['b' => 1],
+ 'bar' => ['b' => 2],
+ 'baz' => ['b' => 3],
+ ], iterator_to_array($this->connection->iterateAssociativeIndexed($this->query)));
+ }
+
+ public function testStatementIterateAssociativeIndexed(): void
+ {
+ $stmt = $this->connection->prepare($this->query);
+ $stmt->execute();
+
+ self::assertEquals([
+ 'foo' => ['b' => 1],
+ 'bar' => ['b' => 2],
+ 'baz' => ['b' => 3],
+ ], iterator_to_array($stmt->iterateAssociativeIndexed()));
+ }
+
public function testIterateColumn(): void
{
self::assertEquals([
diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
index ef68b5be62f..58322e9d90e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
@@ -20,13 +20,13 @@
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
+use stdClass;
use function array_change_key_case;
use function array_filter;
use function array_keys;
use function count;
use function date;
-use function implode;
use function is_numeric;
use function json_encode;
use function property_exists;
@@ -34,7 +34,6 @@
use function strtotime;
use const CASE_LOWER;
-use const PHP_EOL;
class DataAccessTest extends DbalFunctionalTestCase
{
@@ -361,6 +360,7 @@ public function testFetchArray(): void
{
$sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
$row = $this->connection->fetchArray($sql, [1, 'foo']);
+ self::assertNotFalse($row);
self::assertEquals(1, $row[0]);
self::assertEquals('foo', $row[1]);
@@ -505,6 +505,8 @@ public function testTrimExpression(string $value, int $position, $char, string $
'FROM fetch_table';
$row = $this->connection->fetchAssoc($sql);
+ self::assertNotFalse($row);
+
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals($expectedResult, $row['trimmed']);
@@ -578,6 +580,8 @@ public function testDateArithmetics(): void
$sql .= 'FROM fetch_table';
$row = $this->connection->fetchAssoc($sql);
+ self::assertNotFalse($row);
+
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])));
@@ -642,6 +646,8 @@ public function testLocateExpression(): void
$sql .= 'FROM fetch_table';
$row = $this->connection->fetchAssoc($sql);
+ self::assertNotFalse($row);
+
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(2, $row['locate1']);
@@ -681,14 +687,20 @@ public function testBitComparisonExpressionSupport(): void
]);
}
- $sql[] = 'SELECT ';
- $sql[] = 'test_int, ';
- $sql[] = 'test_string, ';
- $sql[] = $platform->getBitOrComparisonExpression('test_int', 2) . ' AS bit_or, ';
- $sql[] = $platform->getBitAndComparisonExpression('test_int', 2) . ' AS bit_and ';
- $sql[] = 'FROM fetch_table';
+ $sql = sprintf(
+ <<<'SQL'
+SELECT test_int,
+ test_string,
+ %s AS bit_or,
+ %s AS bit_and
+FROM fetch_table
+SQL
+ ,
+ $platform->getBitOrComparisonExpression('test_int', 2),
+ $platform->getBitAndComparisonExpression('test_int', 2)
+ );
- $stmt = $this->connection->executeQuery(implode(PHP_EOL, $sql));
+ $stmt = $this->connection->executeQuery($sql);
$data = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
self::assertCount(4, $data);
@@ -734,7 +746,7 @@ public function testFetchAllStyleObject(): void
$results = $stmt->fetchAll(FetchMode::STANDARD_OBJECT);
self::assertCount(1, $results);
- self::assertInstanceOf('stdClass', $results[0]);
+ self::assertInstanceOf(stdClass::class, $results[0]);
self::assertEquals(
1,
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
index a7cb0686ebf..08a356704ee 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
@@ -32,8 +32,8 @@ public function testDriverOptions(): void
{
$driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1];
- $connection = $this->getConnection($driverOptions);
- self::assertInstanceOf(Connection::class, $connection);
+ $this->getConnection($driverOptions);
+ $this->expectNotToPerformAssertions();
}
public function testUnsupportedDriverOption(): void
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php
index f4947212ec0..909528eb06e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php
@@ -2,7 +2,6 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
-use Doctrine\DBAL\Driver\OCI8\Connection;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
@@ -12,18 +11,15 @@
*/
class ConnectionTest extends DbalFunctionalTestCase
{
- /** @var Connection */
- protected $driverConnection;
-
protected function setUp(): void
{
parent::setUp();
- if (! $this->connection->getDriver() instanceof Driver) {
- $this->markTestSkipped('oci8 only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
- $this->driverConnection = $this->connection->getWrappedConnection();
+ $this->markTestSkipped('oci8 only test.');
}
public function testLastInsertIdAcceptsFqn(): void
@@ -42,6 +38,6 @@ public function testLastInsertIdAcceptsFqn(): void
$schema = $this->connection->getDatabase();
$sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
- self::assertSame(1, $this->driverConnection->lastInsertId($sequence));
+ self::assertSame(1, $this->connection->lastInsertId($sequence));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
index c9f748fbce6..143cbf6c687 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
@@ -31,13 +31,13 @@ protected function setUp(): void
{
parent::setUp();
- $this->driverConnection = $this->connection->getWrappedConnection();
+ $driverConnection = $this->connection->getWrappedConnection();
- if ($this->driverConnection instanceof Connection) {
- return;
+ if (! $driverConnection instanceof Connection) {
+ $this->markTestSkipped('PDO connection only test.');
}
- $this->markTestSkipped('PDO connection only test.');
+ $this->driverConnection = $driverConnection;
}
protected function tearDown(): void
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
index d829a013ea7..f8974ef7b14 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
@@ -48,12 +48,16 @@ private function getConnection(array $driverOptions): Connection
$driverOptions = array_merge($params['driverOptions'], $driverOptions);
}
- return $this->connection->getDriver()->connect(
+ $connection = $this->connection->getDriver()->connect(
$params,
$params['user'] ?? '',
$params['password'] ?? '',
$driverOptions
);
+
+ self::assertInstanceOf(Connection::class, $connection);
+
+ return $connection;
}
public function testConnectionOptions(): void
diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
index 13aaea3c6a9..5e75f6fd29d 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
@@ -11,9 +11,6 @@
use function array_change_key_case;
use function sprintf;
-use function strlen;
-use function strtolower;
-use function substr;
use const CASE_LOWER;
@@ -46,7 +43,11 @@ protected function setUp(): void
private function createMasterSlaveConnection(bool $keepSlave = false): MasterSlaveConnection
{
- return DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave));
+ $connection = DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave));
+
+ self::assertInstanceOf(MasterSlaveConnection::class, $connection);
+
+ return $connection;
}
/**
@@ -88,12 +89,9 @@ public function testInheritCharsetFromMaster(): void
self::assertFalse($conn->isConnectedToMaster());
- $clientCharset = $conn->fetchColumn('select @@character_set_client as c');
+ $clientCharset = $conn->fetchColumn('select @@character_set_client');
- self::assertSame(
- $charset,
- substr(strtolower($clientCharset), 0, strlen($charset))
- );
+ self::assertSame($charset, $clientCharset);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php
index 7dd14c355ee..e371cf2cfeb 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php
@@ -11,9 +11,6 @@
use function array_change_key_case;
use function sprintf;
-use function strlen;
-use function strtolower;
-use function substr;
use const CASE_LOWER;
@@ -49,7 +46,11 @@ protected function setUp(): void
private function createPrimaryReadReplicaConnection(bool $keepReplica = false): PrimaryReadReplicaConnection
{
- return DriverManager::getConnection($this->createPrimaryReadReplicaConnectionParams($keepReplica));
+ $connection = DriverManager::getConnection($this->createPrimaryReadReplicaConnectionParams($keepReplica));
+
+ self::assertInstanceOf(PrimaryReadReplicaConnection::class, $connection);
+
+ return $connection;
}
/**
@@ -93,10 +94,7 @@ public function testInheritCharsetFromPrimary(): void
$clientCharset = $conn->fetchColumn('select @@character_set_client as c');
- self::assertSame(
- $charset,
- substr(strtolower($clientCharset), 0, strlen($charset))
- );
+ self::assertSame($charset, $clientCharset);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
index b1a88e8a26c..05d3ff70cd2 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
@@ -232,7 +232,7 @@ public function testFetchAllColumn(): void
$query = $this->connection->getDatabasePlatform()
->getDummySelectSQL('1');
- $qcp = new QueryCacheProfile(0, 0, new ArrayCache());
+ $qcp = new QueryCacheProfile(0, null, new ArrayCache());
$stmt = $this->connection->executeCacheQuery($query, [], [], $qcp);
$stmt->fetchAll(FetchMode::COLUMN);
@@ -243,7 +243,7 @@ public function testFetchAllColumn(): void
}
/**
- * @param array>|list $expectedResult
+ * @param list $expectedResult
*/
private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode): void
{
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
index 9bc1bd1165e..8bc11a776f8 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
@@ -2,11 +2,18 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BooleanType;
class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
{
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof DB2Platform;
+ }
+
public function testGetBooleanColumn(): void
{
$table = new Table('boolean_column_test');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
index 0943124b86b..917e42055ff 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
@@ -2,11 +2,18 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\DrizzlePlatform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BinaryType;
class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof DrizzlePlatform;
+ }
+
public function testListTableWithBinary(): void
{
$tableName = 'test_binary_table';
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
index 90a78487f19..0b1e56daebc 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
use DateTime;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
@@ -15,6 +16,11 @@
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof MySqlPlatform;
+ }
+
protected function setUp(): void
{
parent::setUp();
@@ -39,8 +45,10 @@ public function testSwitchPrimaryKeyColumns(): void
$tableNew = clone $tableFetched;
$tableNew->setPrimaryKey(['bar_id', 'foo_id']);
- $comparator = new Comparator();
- $this->schemaManager->alterTable($comparator->diffTable($tableFetched, $tableNew));
+ $diff = (new Comparator())->diffTable($tableFetched, $tableNew);
+ self::assertNotFalse($diff);
+
+ $this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('switch_primary_key_columns');
$primaryKey = $table->getPrimaryKeyColumns();
@@ -67,8 +75,7 @@ public function testDiffTableBug(): void
$this->schemaManager->createTable($table);
$tableFetched = $this->schemaManager->listTableDetails('diffbug_routing_translations');
- $comparator = new Comparator();
- $diff = $comparator->diffTable($tableFetched, $table);
+ $diff = (new Comparator())->diffTable($tableFetched, $table);
self::assertFalse($diff, 'no changes expected.');
}
@@ -129,13 +136,15 @@ public function testAlterTableAddPrimaryKey(): void
$this->schemaManager->createTable($table);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropIndex('idx_id');
$diffTable->setPrimaryKey(['id']);
- $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
+ $this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('alter_table_add_pk');
@@ -156,9 +165,10 @@ public function testDropPrimaryKeyWithAutoincrementColumn(): void
$diffTable->dropPrimaryKey();
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('drop_primary_key');
@@ -191,9 +201,10 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): vo
self::assertNull($onlineTable->getColumn('def_blob_null')->getDefault());
self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull());
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($table, $onlineTable);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($comparator->diffTable($table, $onlineTable));
+ $this->schemaManager->alterTable($diff);
$onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
@@ -234,9 +245,10 @@ public function testAlterColumnCharset(): void
$diffTable = clone $table;
$diffTable->getColumn('col_text')->setPlatformOption('charset', 'ascii');
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails($tableName);
@@ -451,6 +463,7 @@ public function testColumnDefaultsAreValid(): void
$row = $this->connection->fetchAssoc(
'SELECT *, DATEDIFF(CURRENT_TIMESTAMP(), col_datetime) as diff_seconds FROM test_column_defaults_are_valid'
);
+ self::assertNotFalse($row);
self::assertInstanceOf(DateTime::class, DateTime::createFromFormat('Y-m-d H:i:s', $row['col_datetime']));
self::assertNull($row['col_datetime_null']);
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
index 41306d4ef04..af0c6b79791 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
@@ -2,7 +2,10 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema;
+use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\Types;
@@ -15,6 +18,11 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
/** @var bool */
private static $privilegesGranted = false;
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof OraclePlatform;
+ }
+
protected function setUp(): void
{
parent::setUp();
@@ -43,7 +51,7 @@ public function testRenameTable(): void
$tables = $this->schemaManager->listTables();
- self::assertHasTable($tables, 'list_tables_test_new_name');
+ self::assertHasTable($tables);
}
public function testListTableWithBinary(): void
@@ -69,9 +77,8 @@ public function testListTableWithBinary(): void
public function testAlterTableColumnNotNull(): void
{
- $comparator = new Schema\Comparator();
- $tableName = 'list_table_column_notnull';
- $table = new Schema\Table($tableName);
+ $tableName = 'list_table_column_notnull';
+ $table = new Table($tableName);
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
@@ -90,7 +97,10 @@ public function testAlterTableColumnNotNull(): void
$diffTable->changeColumn('foo', ['notnull' => false]);
$diffTable->changeColumn('bar', ['length' => 1024]);
- $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
+ $this->schemaManager->alterTable($diff);
$columns = $this->schemaManager->listTableColumns($tableName);
@@ -115,7 +125,7 @@ public function testListDatabases(): void
public function testListTableDetailsWithDifferentIdentifierQuotingRequirements(): void
{
$primaryTableName = '"Primary_Table"';
- $offlinePrimaryTable = new Schema\Table($primaryTableName);
+ $offlinePrimaryTable = new Table($primaryTableName);
$offlinePrimaryTable->addColumn(
'"Id"',
'integer',
@@ -132,7 +142,7 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
$offlinePrimaryTable->setPrimaryKey(['"Id"']);
$foreignTableName = 'foreign';
- $offlineForeignTable = new Schema\Table($foreignTableName);
+ $offlineForeignTable = new Table($foreignTableName);
$offlineForeignTable->addColumn('id', 'integer', ['autoincrement' => true]);
$offlineForeignTable->addColumn('"Fk"', 'integer');
$offlineForeignTable->addIndex(['"Fk"'], '"Fk_index"');
@@ -162,7 +172,11 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
self::assertTrue($onlinePrimaryTable->hasColumn('"Id"'));
self::assertSame('"Id"', $onlinePrimaryTable->getColumn('"Id"')->getQuotedName($platform));
self::assertTrue($onlinePrimaryTable->hasPrimaryKey());
- self::assertSame(['"Id"'], $onlinePrimaryTable->getPrimaryKey()->getQuotedColumns($platform));
+
+ $primaryKey = $onlinePrimaryTable->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+ self::assertSame(['"Id"'], $primaryKey->getQuotedColumns($platform));
self::assertTrue($onlinePrimaryTable->hasColumn('select'));
self::assertSame('"select"', $onlinePrimaryTable->getColumn('select')->getQuotedName($platform));
@@ -196,7 +210,11 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
self::assertTrue($onlineForeignTable->hasColumn('id'));
self::assertSame('ID', $onlineForeignTable->getColumn('id')->getQuotedName($platform));
self::assertTrue($onlineForeignTable->hasPrimaryKey());
- self::assertSame(['ID'], $onlineForeignTable->getPrimaryKey()->getQuotedColumns($platform));
+
+ $primaryKey = $onlineForeignTable->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+ self::assertSame(['ID'], $primaryKey->getQuotedColumns($platform));
self::assertTrue($onlineForeignTable->hasColumn('"Fk"'));
self::assertSame('"Fk"', $onlineForeignTable->getColumn('"Fk"')->getQuotedName($platform));
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
index cdf3a51245a..949ee50d51c 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
@@ -25,6 +25,11 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/** @var PostgreSqlSchemaManager */
protected $schemaManager;
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof PostgreSQL94Platform;
+ }
+
protected function tearDown(): void
{
parent::tearDown();
@@ -94,9 +99,10 @@ public function testAlterTableAutoIncrementAdd(): void
$column = $tableTo->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $c = new Comparator();
- $diff = $c->diffTable($tableFrom, $tableTo);
- $sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
+ $diff = (new Comparator())->diffTable($tableFrom, $tableTo);
+ self::assertNotFalse($diff);
+
+ $sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
self::assertEquals([
'CREATE SEQUENCE autoinc_table_add_id_seq',
"SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))",
@@ -120,9 +126,9 @@ public function testAlterTableAutoIncrementDrop(): void
$tableTo = new Table('autoinc_table_drop');
$tableTo->addColumn('id', 'integer');
- $c = new Comparator();
- $diff = $c->diffTable($tableFrom, $tableTo);
- self::assertInstanceOf(TableDiff::class, $diff);
+ $diff = (new Comparator())->diffTable($tableFrom, $tableTo);
+ self::assertNotFalse($diff);
+
self::assertEquals(
['ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT'],
$this->connection->getDatabasePlatform()->getAlterTableSQL($diff)
@@ -156,7 +162,11 @@ public function testTableWithSchema(): void
$nestedSchemaTable = $this->schemaManager->listTableDetails('nested.schematable');
self::assertTrue($nestedSchemaTable->hasColumn('id'));
- self::assertEquals(['id'], $nestedSchemaTable->getPrimaryKey()->getColumns());
+
+ $primaryKey = $nestedSchemaTable->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+ self::assertEquals(['id'], $primaryKey->getColumns());
$relatedFks = $nestedSchemaTable->getForeignKeys();
self::assertCount(1, $relatedFks);
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
index dbce7bba895..c502a729c1e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
@@ -2,12 +2,19 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\View;
class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof SQLAnywherePlatform;
+ }
+
public function testCreateAndListViews(): void
{
$this->createTestTable('view_test_table');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
index 8b0bd707ee5..8d6b0bb56fd 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Table;
@@ -12,9 +14,9 @@
class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
- protected function getPlatformName(): string
+ protected function supportsPlatform(AbstractPlatform $platform): bool
{
- return 'mssql';
+ return $platform instanceof SQLServer2012Platform;
}
public function testDropColumnConstraints(): void
@@ -178,12 +180,13 @@ public function testColumnComments(): void
$table->addColumn('create', 'integer', ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!']);
$table->addColumn('commented_type', 'object');
$table->addColumn('commented_type_with_comment', 'array', ['comment' => 'Doctrine array type.']);
+ $table->addColumn('commented_req_change_column', 'integer', ['comment' => 'Some comment', 'notnull' => true]);
$table->setPrimaryKey(['id']);
$this->schemaManager->createTable($table);
$columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
- self::assertCount(12, $columns);
+ self::assertCount(13, $columns);
self::assertNull($columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment());
self::assertNull($columns['comment_false']->getComment());
@@ -199,6 +202,7 @@ public function testColumnComments(): void
self::assertEquals('Doctrine 0wnz comments for reserved keyword columns!', $columns['[create]']->getComment());
self::assertNull($columns['commented_type']->getComment());
self::assertEquals('Doctrine array type.', $columns['commented_type_with_comment']->getComment());
+ self::assertEquals('Some comment', $columns['commented_req_change_column']->getComment());
$tableDiff = new TableDiff('sqlsrv_column_comment');
$tableDiff->fromTable = $table;
@@ -326,13 +330,29 @@ public function testColumnComments(): void
new Column('commented_type_with_comment', Type::getType('array'), ['comment' => 'Doctrine array type.'])
);
+ // Change column requirements without changing comment.
+ $tableDiff->changedColumns['commented_req_change_column'] = new ColumnDiff(
+ 'commented_req_change_column',
+ new Column(
+ 'commented_req_change_column',
+ Type::getType('integer'),
+ ['comment' => 'Some comment', 'notnull' => true]
+ ),
+ ['notnull'],
+ new Column(
+ 'commented_req_change_column',
+ Type::getType('integer'),
+ ['comment' => 'Some comment', 'notnull' => false]
+ ),
+ );
+
$tableDiff->removedColumns['comment_integer_0']
= new Column('comment_integer_0', Type::getType('integer'), ['comment' => 0]);
$this->schemaManager->alterTable($tableDiff);
$columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
- self::assertCount(23, $columns);
+ self::assertCount(24, $columns);
self::assertEquals('primary', $columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment());
self::assertEquals('false', $columns['comment_false']->getComment());
@@ -356,6 +376,7 @@ public function testColumnComments(): void
self::assertEquals('666', $columns['[select]']->getComment());
self::assertNull($columns['added_commented_type']->getComment());
self::assertEquals('666', $columns['added_commented_type_with_comment']->getComment());
+ self::assertEquals('Some comment', $columns['commented_req_change_column']->getComment());
}
public function testPkOrdering(): void
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
index e34ef79ec1d..a635991e998 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
@@ -6,6 +6,7 @@
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Events;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
@@ -38,11 +39,9 @@
use function array_values;
use function count;
use function current;
-use function end;
-use function explode;
+use function get_class;
use function in_array;
use function sprintf;
-use function str_replace;
use function strcasecmp;
use function strlen;
use function strtolower;
@@ -53,23 +52,16 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
/** @var AbstractSchemaManager */
protected $schemaManager;
- protected function getPlatformName(): string
- {
- $class = static::class;
- $e = explode('\\', $class);
- $testClass = end($e);
-
- return strtolower(str_replace('SchemaManagerTest', '', $testClass));
- }
+ abstract protected function supportsPlatform(AbstractPlatform $platform): bool;
protected function setUp(): void
{
parent::setUp();
- $dbms = $this->getPlatformName();
+ $platform = $this->connection->getDatabasePlatform();
- if ($this->connection->getDatabasePlatform()->getName() !== $dbms) {
- $this->markTestSkipped(static::class . ' requires the use of ' . $dbms);
+ if (! $this->supportsPlatform($platform)) {
+ $this->markTestSkipped(sprintf('Skipping since connected to %s', get_class($platform)));
}
$this->schemaManager = $this->connection->getSchemaManager();
@@ -749,10 +741,10 @@ public function testUpdateSchemaWithForeignKeyRenaming(): void
$tableFKNew->addIndex(['rename_fk_id'], 'fk_idx');
$tableFKNew->addForeignKeyConstraint('test_fk_base', ['rename_fk_id'], ['id']);
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableFK, $tableFKNew);
+ $diff = (new Comparator())->diffTable($tableFK, $tableFKNew);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($tableDiff);
+ $this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('test_fk_rename');
$foreignKeys = $table->getForeignKeys();
@@ -789,9 +781,10 @@ public function testRenameIndexUsedInForeignKeyConstraint(): void
$foreignTable2 = clone $foreignTable;
$foreignTable2->renameIndex('rename_index_fk_idx', 'renamed_index_fk_idx');
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($foreignTable, $foreignTable2);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($comparator->diffTable($foreignTable, $foreignTable2));
+ $this->schemaManager->alterTable($diff);
$foreignTable = $this->schemaManager->listTableDetails('test_rename_index_foreign');
@@ -966,7 +959,7 @@ protected function createTestTable(string $name = 'test_table', array $data = []
*/
protected function getTestTable(string $name, array $options = []): Table
{
- $table = new Table($name, [], [], [], false, $options);
+ $table = new Table($name, [], [], [], 0, $options);
$table->setSchemaConfig($this->schemaManager->createSchemaConfig());
$table->addColumn('id', 'integer', ['notnull' => true]);
$table->setPrimaryKey(['id']);
@@ -978,7 +971,7 @@ protected function getTestTable(string $name, array $options = []): Table
protected function getTestCompositeTable(string $name): Table
{
- $table = new Table($name, [], [], [], false, []);
+ $table = new Table($name, [], [], [], 0, []);
$table->setSchemaConfig($this->schemaManager->createSchemaConfig());
$table->addColumn('id', 'integer', ['notnull' => true]);
$table->addColumn('other_id', 'integer', ['notnull' => true]);
@@ -1069,9 +1062,10 @@ public function testColumnDefaultLifecycle(): void
$diffTable->changeColumn('column6', ['default' => 666]);
$diffTable->changeColumn('column7', ['default' => null]);
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
- $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($diff);
$columns = $this->schemaManager->listTableColumns('col_def_lifecycle');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
index d94a8f8dabe..b7c0c606fa4 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
@@ -4,7 +4,10 @@
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Exception;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema;
+use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
@@ -14,6 +17,11 @@
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
+ protected function supportsPlatform(AbstractPlatform $platform): bool
+ {
+ return $platform instanceof SqlitePlatform;
+ }
+
/**
* SQLITE does not support databases.
*/
@@ -196,10 +204,11 @@ public function testDiffListIntegerAutoincrementTableColumns(
$this->schemaManager->dropAndCreateTable($offlineTable);
$onlineTable = $this->schemaManager->listTableDetails($tableName);
- $comparator = new Schema\Comparator();
- $diff = $comparator->diffTable($offlineTable, $onlineTable);
+
+ $diff = (new Comparator())->diffTable($offlineTable, $onlineTable);
if ($expectedComparatorDiff) {
+ self::assertNotFalse($diff);
self::assertEmpty($this->schemaManager->getDatabasePlatform()->getAlterTableSQL($diff));
} else {
self::assertFalse($diff);
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
index 35e9f0675bc..7bd3dd42333 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
@@ -23,7 +23,9 @@ protected function setUp(): void
public function testGuidShouldMatchPattern(): void
{
- $guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn();
+ $guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn();
+ self::assertNotFalse($guid);
+
$pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i';
self::assertEquals(1, preg_match($pattern, $guid), 'GUID does not match pattern');
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
index 77cd108b595..dea9f88d8f6 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
@@ -50,6 +50,7 @@ public function testBooleanConversionSqlLiteral(): void
self::assertNotEmpty($id);
$row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
+ self::assertNotFalse($row);
self::assertFalse($row['bool_col']);
}
@@ -65,6 +66,7 @@ public function testBooleanConversionBoolParamRealPrepares(): void
self::assertNotEmpty($id);
$row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
+ self::assertNotFalse($row);
self::assertFalse($row['bool_col']);
}
@@ -84,6 +86,7 @@ public function testBooleanConversionBoolParamEmulatedPrepares(): void
self::assertNotEmpty($id);
$row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
+ self::assertNotFalse($row);
self::assertFalse($row['bool_col']);
}
@@ -108,6 +111,7 @@ public function testBooleanConversionNullParamEmulatedPrepares(
self::assertNotEmpty($id);
$row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]);
+ self::assertNotFalse($row);
self::assertSame($databaseConvertedValue, $row['bool_col']);
}
@@ -136,6 +140,7 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB
self::assertNotEmpty($id);
$row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]);
+ self::assertNotFalse($row);
self::assertSame($databaseConvertedValue, $row['bool_col']);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
index 984e19ec719..6f47275a4e8 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
@@ -184,8 +184,8 @@ public function testUniquePrimaryKey(): void
$oldTable->addColumn('bar', 'integer');
$oldTable->addColumn('baz', 'string');
- $c = new Comparator();
- $diff = $c->diffTable($oldTable, $keyTable);
+ $diff = (new Comparator())->diffTable($oldTable, $keyTable);
+ self::assertNotFalse($diff);
$sql = $this->platform->getAlterTableSQL($diff);
@@ -384,15 +384,17 @@ public function testAlterTableAddPrimaryKey(): void
$table->addColumn('foo', 'integer');
$table->addIndex(['id'], 'idx_id');
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropIndex('idx_id');
$diffTable->setPrimaryKey(['id']);
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertEquals(
['DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -403,19 +405,21 @@ public function testAlterPrimaryKeyWithAutoincrementColumn(): void
$table->addColumn('foo', 'integer');
$table->setPrimaryKey(['id']);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['foo']);
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertEquals(
[
'ALTER TABLE alter_primary_key MODIFY id INT NOT NULL',
'ALTER TABLE alter_primary_key DROP PRIMARY KEY',
'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)',
],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -427,17 +431,19 @@ public function testDropPrimaryKeyWithAutoincrementColumn(): void
$table->addColumn('bar', 'integer');
$table->setPrimaryKey(['id', 'foo']);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertEquals(
[
'ALTER TABLE drop_primary_key MODIFY id INT NOT NULL',
'ALTER TABLE drop_primary_key DROP PRIMARY KEY',
],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -449,19 +455,21 @@ public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoinc
$table->addColumn('bar', 'integer');
$table->setPrimaryKey(['id', 'foo']);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['id']);
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertSame(
[
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id)',
],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -473,19 +481,21 @@ public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn
$table->addColumn('bar', 'integer');
$table->setPrimaryKey(['id']);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['id', 'foo']);
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertSame(
[
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id, foo)',
],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -499,8 +509,8 @@ public function testAddAutoIncrementPrimaryKey(): void
$oldTable = new Table('foo');
$oldTable->addColumn('baz', 'string');
- $c = new Comparator();
- $diff = $c->diffTable($oldTable, $keyTable);
+ $diff = (new Comparator())->diffTable($oldTable, $keyTable);
+ self::assertNotFalse($diff);
$sql = $this->platform->getAlterTableSQL($diff);
@@ -527,20 +537,22 @@ public function testAlterPrimaryKeyWithNewColumn(): void
$table->addColumn('col_a', 'integer');
$table->setPrimaryKey(['pkc1']);
- $comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->addColumn('pkc2', 'integer');
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['pkc1', 'pkc2']);
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
+
self::assertSame(
[
'ALTER TABLE yolo DROP PRIMARY KEY',
'ALTER TABLE yolo ADD pkc2 INT NOT NULL',
'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)',
],
- $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -757,9 +769,10 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): vo
$diffTable->changeColumn('def_blob', ['default' => null]);
$diffTable->changeColumn('def_blob_null', ['default' => null]);
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($table, $diffTable);
+ self::assertNotFalse($diff);
- self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)));
+ self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
index aa51cd1e836..658839bd8c1 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
@@ -17,6 +17,7 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Types\CommentedType;
+use InvalidArgumentException;
use function get_class;
use function implode;
@@ -84,7 +85,7 @@ public static function getReturnsForeignKeyReferentialActionSQL(): iterable
public function testGetInvalidForeignKeyReferentialActionSQL(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->platform->getForeignKeyReferentialActionSQL('unknown');
}
@@ -949,11 +950,12 @@ public function testQuotesAlterTableRenameColumn(): void
// quoted -> quoted
$toTable->addColumn('`baz`', 'integer', ['comment' => 'Quoted 3']);
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($fromTable, $toTable);
+ self::assertNotFalse($diff);
self::assertEquals(
$this->getQuotedAlterTableRenameColumnSQL(),
- $this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -986,11 +988,12 @@ public function testQuotesAlterTableChangeColumnLength(): void
$toTable->addColumn('table', 'string', ['comment' => 'Reserved keyword 2', 'length' => 255]);
$toTable->addColumn('select', 'string', ['comment' => 'Reserved keyword 3', 'length' => 255]);
- $comparator = new Comparator();
+ $diff = (new Comparator())->diffTable($fromTable, $toTable);
+ self::assertNotFalse($diff);
self::assertEquals(
$this->getQuotedAlterTableChangeColumnLengthSQL(),
- $this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
+ $this->platform->getAlterTableSQL($diff)
);
}
@@ -1158,7 +1161,7 @@ public function testGetCommentOnColumnSQL(): void
/**
* @dataProvider getGeneratesInlineColumnCommentSQL
*/
- public function testGeneratesInlineColumnCommentSQL(?string $comment, string $expectedSql): void
+ public function testGeneratesInlineColumnCommentSQL(string $comment, string $expectedSql): void
{
if (! $this->platform->supportsInlineColumnComments()) {
$this->markTestSkipped(sprintf('%s does not support inline column comments.', get_class($this->platform)));
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
index 5adf73f7aa0..184dcbb216c 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
@@ -600,10 +600,10 @@ public function testDroppingConstraintsBeforeColumns(): void
$oldTable->addColumn('parent_id', 'integer');
$oldTable->addUnnamedForeignKeyConstraint('mytable', ['parent_id'], ['id']);
- $comparator = new Comparator();
- $tableDiff = $comparator->diffTable($oldTable, $newTable);
+ $diff = (new Comparator())->diffTable($oldTable, $newTable);
+ self::assertNotFalse($diff);
- $sql = $this->platform->getAlterTableSQL($tableDiff);
+ $sql = $this->platform->getAlterTableSQL($diff);
$expectedSql = [
'ALTER TABLE mytable DROP CONSTRAINT FK_6B2BD609727ACA70',
@@ -681,7 +681,9 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): vo
// VARBINARY -> BINARY
// BINARY -> VARBINARY
// BLOB -> VARBINARY
- self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ $diff = $comparator->diffTable($table1, $table2);
+ self::assertNotFalse($diff);
+ self::assertEmpty($this->platform->getAlterTableSQL($diff));
$table2 = new Table('mytable');
$table2->addColumn('column_varbinary', 'binary', ['length' => 42]);
@@ -691,7 +693,9 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): vo
// VARBINARY -> VARBINARY with changed length
// BINARY -> BLOB
// BLOB -> BINARY
- self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ $diff = $comparator->diffTable($table1, $table2);
+ self::assertNotFalse($diff);
+ self::assertEmpty($this->platform->getAlterTableSQL($diff));
$table2 = new Table('mytable');
$table2->addColumn('column_varbinary', 'blob');
@@ -701,7 +705,9 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): vo
// VARBINARY -> BLOB
// BINARY -> BINARY with changed length
// BLOB -> BLOB
- self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ $diff = $comparator->diffTable($table1, $table2);
+ self::assertNotFalse($diff);
+ self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
/**
@@ -887,7 +893,7 @@ public function testAltersTableColumnCommentIfRequiredByType(): void
$tableDiff = $comparator->diffTable($table1, $table2);
- $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ $this->assertNotFalse($tableDiff);
$this->assertSame(
[
'ALTER TABLE "foo" ALTER "bar" TYPE TIMESTAMP(0) WITHOUT TIME ZONE',
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
index ddb7df84a00..7a63f3ffccf 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
@@ -1718,4 +1718,19 @@ private function expectCteWithMinAndMaxRowNums(
. ') AS doctrine_tbl WHERE doctrine_rownum >= %d AND doctrine_rownum <= %d ORDER BY doctrine_rownum ASC';
self::assertEquals(sprintf($pattern, $expectedSql, $expectedMin, $expectedMax), $sql);
}
+
+ public function testAlterTableWithSchemaSameColumnComments(): void
+ {
+ $tableDiff = new TableDiff('testschema.mytable');
+ $tableDiff->changedColumns['quota'] = new ColumnDiff(
+ 'quota',
+ new Column('quota', Type::getType('integer'), ['comment' => 'A comment', 'notnull' => true]),
+ ['notnull'],
+ new Column('quota', Type::getType('integer'), ['comment' => 'A comment', 'notnull' => false])
+ );
+
+ $expectedSql = ['ALTER TABLE testschema.mytable ALTER COLUMN quota INT NOT NULL'];
+
+ self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
+ }
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
index 092c073551d..11ca8e60f96 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
@@ -52,7 +52,7 @@ public function testValidIdentifiers(string $identifier): void
$platform = $this->createPlatform();
$platform->assertValidIdentifier($identifier);
- $this->addToAssertionCount(1);
+ $this->expectNotToPerformAssertions();
}
/**
@@ -582,7 +582,9 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): vo
// VARBINARY -> BINARY
// BINARY -> VARBINARY
- self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ $diff = (new Comparator())->diffTable($table1, $table2);
+ self::assertNotFalse($diff);
+ self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
public function testUsesSequenceEmulatedIdentityColumns(): void
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
index e0c4a24a21a..85ae95c4cc8 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
@@ -5,6 +5,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Schema\Index;
+use UnexpectedValueException;
class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest
{
@@ -64,7 +65,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void
public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions(): void
{
- $this->expectException('UnexpectedValueException');
+ $this->expectException(UnexpectedValueException::class);
$this->platform->getCreateIndexSQL(
new Index(
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
index 88f37d27ca2..2357c1a796b 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
@@ -14,11 +14,9 @@ public function createPlatform(): AbstractPlatform
}
/**
- * @param int|bool|null $lockMode
- *
* @dataProvider getLockHints
*/
- public function testAppendsLockHint($lockMode, string $lockHint): void
+ public function testAppendsLockHint(?int $lockMode, string $lockHint): void
{
$fromClause = 'FROM users';
$expectedResult = $fromClause . $lockHint;
@@ -41,8 +39,6 @@ public static function getLockHints(): iterable
{
return [
[null, ''],
- [false, ''],
- [true, ''],
[LockMode::NONE, ' WITH (NOLOCK)'],
[LockMode::OPTIMISTIC, ''],
[LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'],
diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
index f41124a8334..f83ab92e50d 100644
--- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
@@ -15,13 +15,13 @@
class StatementTest extends DbalTestCase
{
- /** @var Connection|MockObject */
+ /** @var Connection&MockObject */
protected $conn;
/** @var Statement */
protected $stmt;
- /** @var DriverStatement|MockObject */
+ /** @var DriverStatement&MockObject */
protected $wrappedStmt;
protected function setUp(): void
@@ -157,7 +157,7 @@ public function testRowCount(): void
}
/**
- * @return Connection|MockObject
+ * @return Connection&MockObject
*/
protected function createConnection()
{
diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
index 038097c8910..a83362ed588 100644
--- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
@@ -950,6 +950,19 @@ public function testJoinWithNonUniqueAliasThrowsException(): void
$qb->getSQL();
}
+ public function testWhereExpressionAndWhereEmptyString(): void
+ {
+ $qb = new QueryBuilder($this->conn);
+
+ $qb->select('id')
+ ->from('foo')
+ ->where('a = b');
+
+ $qb->andWhere('');
+
+ self::assertSame('SELECT id FROM foo WHERE a = b', $qb->getSQL());
+ }
+
public function testAndWhereEmptyStringStartingWithEmptyExpression(): void
{
$qb = new QueryBuilder($this->conn);
@@ -975,6 +988,19 @@ public function testAndWhereEmptyStringStartingWithNonEmptyExpression(): void
self::assertSame('SELECT id FROM foo WHERE (a = b) AND (c = d)', $qb->getSQL());
}
+ public function testWhereExpressionOrWhereEmptyString(): void
+ {
+ $qb = new QueryBuilder($this->conn);
+
+ $qb->select('id')
+ ->from('foo')
+ ->orWhere('a = b');
+
+ $qb->orWhere('');
+
+ self::assertSame('SELECT id FROM foo WHERE a = b', $qb->getSQL());
+ }
+
public function testOrWhereEmptyStringStartingWithEmptyExpression(): void
{
$qb = new QueryBuilder($this->conn);
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
index f2a8ec2fd15..9079fbec518 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
@@ -252,8 +252,8 @@ public function testCompareChangeColumnsMultipleNewColumnsRename(): void
$tableB->addColumn('new_datecolumn1', 'datetime');
$tableB->addColumn('new_datecolumn2', 'datetime');
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
+ $tableDiff = (new Comparator())->diffTable($tableA, $tableB);
+ self::assertNotFalse($tableDiff);
self::assertCount(1, $tableDiff->renamedColumns);
self::assertArrayHasKey('datecolumn1', $tableDiff->renamedColumns);
@@ -485,7 +485,7 @@ public function testCompareSequences(): void
$seq1 = new Sequence('foo', 1, 1);
$seq2 = new Sequence('foo', 1, 2);
$seq3 = new Sequence('foo', 2, 1);
- $seq4 = new Sequence('foo', '1', '1');
+ $seq4 = new Sequence('foo', 1, 1);
$c = new Comparator();
@@ -720,8 +720,8 @@ public function testDetectRenameColumn(): void
$tableB = new Table('foo');
$tableB->addColumn('bar', 'integer');
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
+ $tableDiff = (new Comparator())->diffTable($tableA, $tableB);
+ self::assertNotFalse($tableDiff);
self::assertCount(0, $tableDiff->addedColumns);
self::assertCount(0, $tableDiff->removedColumns);
@@ -743,8 +743,8 @@ public function testDetectRenameColumnAmbiguous(): void
$tableB = new Table('foo');
$tableB->addColumn('baz', 'integer');
- $c = new Comparator();
- $tableDiff = $c->diffTable($tableA, $tableB);
+ $tableDiff = (new Comparator())->diffTable($tableA, $tableB);
+ self::assertNotFalse($tableDiff);
self::assertCount(1, $tableDiff->addedColumns);
self::assertArrayHasKey('baz', $tableDiff->addedColumns);
@@ -765,8 +765,8 @@ public function testDetectRenameIndex(): void
$table2->addIndex(['foo'], 'idx_bar');
- $comparator = new Comparator();
- $tableDiff = $comparator->diffTable($table1, $table2);
+ $tableDiff = (new Comparator())->diffTable($table1, $table2);
+ self::assertNotFalse($tableDiff);
self::assertCount(0, $tableDiff->addedIndexes);
self::assertCount(0, $tableDiff->removedIndexes);
@@ -791,8 +791,8 @@ public function testDetectRenameIndexAmbiguous(): void
$table2->addIndex(['foo'], 'idx_baz');
- $comparator = new Comparator();
- $tableDiff = $comparator->diffTable($table1, $table2);
+ $tableDiff = (new Comparator())->diffTable($table1, $table2);
+ self::assertNotFalse($tableDiff);
self::assertCount(1, $tableDiff->addedIndexes);
self::assertArrayHasKey('idx_baz', $tableDiff->addedIndexes);
diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
index faa784a6137..36b0551d338 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
@@ -18,7 +18,7 @@
*/
final class DB2SchemaManagerTest extends TestCase
{
- /** @var Connection|MockObject */
+ /** @var Connection&MockObject */
private $conn;
/** @var DB2SchemaManager */
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
index 3802ff27a01..d134a1f2f56 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
@@ -33,7 +33,9 @@ public function testSwitchPrimaryKeyOrder(): void
$tableNew->setPrimaryKey(['bar_id', 'foo_id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
- $sql = $this->platform->getAlterTableSQL($diff);
+ self::assertNotFalse($diff);
+
+ $sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
[
@@ -74,7 +76,9 @@ public function testClobNoAlterTable(): void
$tableNew->setPrimaryKey(['id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
- $sql = $this->platform->getAlterTableSQL($diff);
+ self::assertNotFalse($diff);
+
+ $sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
['ALTER TABLE test ADD PRIMARY KEY (id)'],
diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
index 414d779438e..f5100e6c856 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
@@ -46,7 +46,7 @@ public function testSchemaDiffToSaveSql(): void
}
/**
- * @return AbstractPlatform|MockObject
+ * @return AbstractPlatform&MockObject
*/
private function createPlatform(bool $unsafe)
{
diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
index 4c0ada138d0..c1b9ede62cb 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
@@ -11,7 +11,7 @@
class TableDiffTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
public function setUp(): void
diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
index c596fecfc9c..5b6d897aa80 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
@@ -210,7 +210,7 @@ public function testConstraints(): void
public function testOptions(): void
{
- $table = new Table('foo', [], [], [], false, ['foo' => 'bar']);
+ $table = new Table('foo', [], [], [], 0, ['foo' => 'bar']);
self::assertTrue($table->hasOption('foo'));
self::assertEquals('bar', $table->getOption('foo'));
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
index c4e1aca9e85..26354adef9d 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
@@ -12,7 +12,7 @@
class CreateSchemaSqlCollectorTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platformMock;
/** @var CreateSchemaSqlCollector */
@@ -134,7 +134,7 @@ public function testResetsQueries(): void
}
/**
- * @return ForeignKeyConstraint|MockObject
+ * @return ForeignKeyConstraint&MockObject
*/
private function createForeignKeyConstraintMock()
{
@@ -144,7 +144,7 @@ private function createForeignKeyConstraintMock()
}
/**
- * @return Sequence|MockObject
+ * @return Sequence&MockObject
*/
private function createSequenceMock()
{
@@ -154,7 +154,7 @@ private function createSequenceMock()
}
/**
- * @return Table|MockObject
+ * @return Table&MockObject
*/
private function createTableMock()
{
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
index 1f0abe675f8..f1244541a50 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
@@ -6,6 +6,7 @@
use Doctrine\DBAL\Sharding\PoolingShardConnection;
use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser;
use Doctrine\DBAL\Sharding\ShardingException;
+use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use stdClass;
@@ -50,7 +51,7 @@ public function testConnect(): void
public function testNoGlobalServerException(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations.");
DriverManager::getConnection([
@@ -66,7 +67,7 @@ public function testNoGlobalServerException(): void
public function testNoShardsServersException(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations.");
DriverManager::getConnection([
@@ -79,7 +80,7 @@ public function testNoShardsServersException(): void
public function testNoShardsChoserException(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'");
DriverManager::getConnection([
@@ -95,7 +96,7 @@ public function testNoShardsChoserException(): void
public function testShardChoserWrongInstance(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"
);
@@ -114,7 +115,7 @@ public function testShardChoserWrongInstance(): void
public function testShardNonNumericId(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Shard Id has to be a non-negative number.');
DriverManager::getConnection([
@@ -130,7 +131,7 @@ public function testShardNonNumericId(): void
public function testShardMissingId(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id.");
DriverManager::getConnection([
@@ -146,7 +147,7 @@ public function testShardMissingId(): void
public function testDuplicateShardId(): void
{
- $this->expectException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Shard 1 is duplicated in the configuration.');
DriverManager::getConnection([
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
index d2ce7b7f94f..8ac09bd4e0c 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
@@ -11,7 +11,7 @@
class PoolingShardManagerTest extends TestCase
{
/**
- * @return PoolingShardConnection|MockObject
+ * @return PoolingShardConnection&MockObject
*/
private function createConnectionMock(): PoolingShardConnection
{
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
index 8ad29bfcef6..3ab0991a519 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
@@ -41,6 +41,7 @@ protected function setUp(): void
$this->conn = DriverManager::getConnection($params);
$serverEdition = $this->conn->fetchColumn("SELECT CONVERT(NVARCHAR(128), SERVERPROPERTY('Edition'))");
+ self::assertNotFalse($serverEdition);
if (strpos($serverEdition, 'SQL Azure') !== 0) {
$this->markTestSkipped('SQL Azure only test.');
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
index f12379fafee..560181996e3 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
@@ -2,7 +2,6 @@
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
-use Doctrine\DBAL\Platforms\SQLAzurePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Sharding\SQLAzure\Schema\MultiTenantVisitor;
use PHPUnit\Framework\TestCase;
@@ -11,8 +10,7 @@ class MultiTenantVisitorTest extends TestCase
{
public function testMultiTenantPrimaryKey(): void
{
- $platform = new SQLAzurePlatform();
- $visitor = new MultiTenantVisitor();
+ $visitor = new MultiTenantVisitor();
$schema = new Schema();
$foo = $schema->createTable('foo');
@@ -20,14 +18,16 @@ public function testMultiTenantPrimaryKey(): void
$foo->setPrimaryKey(['id']);
$schema->visit($visitor);
- self::assertEquals(['id', 'tenant_id'], $foo->getPrimaryKey()->getColumns());
+ $primaryKey = $foo->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+ self::assertEquals(['id', 'tenant_id'], $primaryKey->getColumns());
self::assertTrue($foo->hasColumn('tenant_id'));
}
public function testMultiTenantNonPrimaryKey(): void
{
- $platform = new SQLAzurePlatform();
- $visitor = new MultiTenantVisitor();
+ $visitor = new MultiTenantVisitor();
$schema = new Schema();
$foo = $schema->createTable('foo');
@@ -36,12 +36,20 @@ public function testMultiTenantNonPrimaryKey(): void
$foo->setPrimaryKey(['id']);
$foo->addIndex(['created'], 'idx');
- $foo->getPrimaryKey()->addFlag('nonclustered');
+ $primaryKey = $foo->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+
+ $primaryKey->addFlag('nonclustered');
$foo->getIndex('idx')->addFlag('clustered');
$schema->visit($visitor);
- self::assertEquals(['id'], $foo->getPrimaryKey()->getColumns());
+ $primaryKey = $foo->getPrimaryKey();
+
+ self::assertNotNull($primaryKey);
+
+ self::assertEquals(['id'], $primaryKey->getColumns());
self::assertTrue($foo->hasColumn('tenant_id'));
self::assertEquals(['created', 'tenant_id'], $foo->getIndex('idx')->getColumns());
}
diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
index 8a99dd366b8..5b7357b30b1 100644
--- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
+++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
@@ -24,16 +24,17 @@ class RunSqlCommandTest extends TestCase
protected function setUp(): void
{
- $application = new Application();
- $application->add(new RunSqlCommand());
+ $this->command = new RunSqlCommand();
- $this->command = $application->find('dbal:run-sql');
- $this->commandTester = new CommandTester($this->command);
+ (new Application())->add($this->command);
$this->connectionMock = $this->createMock(Connection::class);
$helperSet = ConsoleRunner::createHelperSet($this->connectionMock);
+
$this->command->setHelperSet($helperSet);
+
+ $this->commandTester = new CommandTester($this->command);
}
public function testMissingSqlArgument(): void
diff --git a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
index 53af4ae420a..5c64ae77834 100644
--- a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
+++ b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
@@ -14,10 +14,6 @@
use Doctrine\Tests\DbalTestCase;
use stdClass;
-use function print_r;
-use function strpos;
-use function substr;
-
class DumperTest extends DbalTestCase
{
public function testExportObject(): void
@@ -99,14 +95,6 @@ public function testExportArrayTraversable(): void
*/
public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected): void
{
- $print_r_class = print_r($class, true);
- $print_r_expected = print_r($expected, true);
-
- $print_r_class = substr($print_r_class, strpos($print_r_class, '('));
- $print_r_expected = substr($print_r_expected, strpos($print_r_expected, '('));
-
- self::assertSame($print_r_class, $print_r_expected);
-
$var = Dumper::export($class, 3);
$var = (array) $var;
unset($var['__CLASS__']);
diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
index df48f2f14b3..ebda9c37c2e 100644
--- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
@@ -5,7 +5,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ArrayType;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -13,7 +12,7 @@
class ArrayTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var ArrayType */
@@ -22,7 +21,7 @@ class ArrayTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('array');
+ $this->type = new ArrayType();
}
public function testArrayConvertsToDatabaseValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
index b748cdf19a2..ee111fab030 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
@@ -16,7 +16,7 @@
abstract class BaseDateTypeTestCase extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
protected $platform;
/** @var Type */
diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
index 23514f6160b..e1b14679c5b 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
@@ -6,7 +6,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -17,7 +16,7 @@
class BinaryTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
protected $platform;
/** @var BinaryType */
@@ -26,7 +25,7 @@ class BinaryTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('binary');
+ $this->type = new BinaryType();
}
public function testReturnsBindingType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
index 23486819798..340608fff44 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
@@ -4,7 +4,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BlobType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -15,7 +14,7 @@
class BlobTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
protected $platform;
/** @var BlobType */
@@ -24,7 +23,7 @@ class BlobTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('blob');
+ $this->type = new BlobType();
}
public function testBlobNullConvertsToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
index 0fe4a2d5a5e..7eefeb3f9f9 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\BooleanType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class BooleanTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var BooleanType */
@@ -19,7 +18,7 @@ class BooleanTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
- $this->type = Type::getType('boolean');
+ $this->type = new BooleanType();
}
public function testBooleanConvertsToDatabaseValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
index e06e9b02f11..46bbbd3fb39 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
@@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateImmutableType;
-use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -16,7 +15,7 @@
class DateImmutableTypeTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var DateImmutableType */
@@ -24,8 +23,8 @@ class DateImmutableTypeTest extends TestCase
protected function setUp(): void
{
- $this->type = Type::getType('date_immutable');
$this->platform = $this->createMock(AbstractPlatform::class);
+ $this->type = new DateImmutableType();
}
public function testFactoryCreatesCorrectType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
index 6c85de36510..ee81bb0e5c7 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
@@ -7,14 +7,13 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateIntervalType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use stdClass;
final class DateIntervalTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var DateIntervalType */
@@ -23,9 +22,7 @@ final class DateIntervalTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('dateinterval');
-
- self::assertInstanceOf(DateIntervalType::class, $this->type);
+ $this->type = new DateIntervalType();
}
public function testDateIntervalConvertsToDatabaseValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php
index 1d97cceaa2c..17183125e1d 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php
@@ -4,7 +4,7 @@
use DateTime;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\DateType;
use function date_default_timezone_set;
@@ -12,7 +12,7 @@ class DateTest extends BaseDateTypeTestCase
{
protected function setUp(): void
{
- $this->type = Type::getType('date');
+ $this->type = new DateType();
parent::setUp();
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
index 4c3a772d344..72a3585fe12 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
@@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeImmutableType;
-use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -16,7 +15,7 @@
class DateTimeImmutableTypeTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var DateTimeImmutableType */
@@ -24,8 +23,8 @@ class DateTimeImmutableTypeTest extends TestCase
protected function setUp(): void
{
- $this->type = Type::getType('datetime_immutable');
$this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock();
+ $this->type = new DateTimeImmutableType();
}
public function testFactoryCreatesCorrectType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
index 72868f328a8..5bf92f811e2 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
@@ -4,13 +4,13 @@
use DateTime;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\DateTimeType;
class DateTimeTest extends BaseDateTypeTestCase
{
protected function setUp(): void
{
- $this->type = Type::getType('datetime');
+ $this->type = new DateTimeType();
parent::setUp();
}
@@ -29,7 +29,7 @@ public function testDateTimeConvertsToPHPValue(): void
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform);
- self::assertInstanceOf('DateTime', $date);
+ self::assertInstanceOf(DateTime::class, $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
index eafaedcb729..7992d99b65f 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
@@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeTzImmutableType;
-use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -16,7 +15,7 @@
class DateTimeTzImmutableTypeTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var DateTimeTzImmutableType */
@@ -24,8 +23,8 @@ class DateTimeTzImmutableTypeTest extends TestCase
protected function setUp(): void
{
- $this->type = Type::getType('datetimetz_immutable');
$this->platform = $this->createMock(AbstractPlatform::class);
+ $this->type = new DateTimeTzImmutableType();
}
public function testFactoryCreatesCorrectType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
index f7367f283ec..f7696515f64 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
@@ -4,13 +4,13 @@
use DateTime;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\DateTimeTzType;
class DateTimeTzTest extends BaseDateTypeTestCase
{
protected function setUp(): void
{
- $this->type = Type::getType('datetimetz');
+ $this->type = new DateTimeTzType();
parent::setUp();
}
@@ -29,7 +29,7 @@ public function testDateTimeConvertsToPHPValue(): void
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform);
- self::assertInstanceOf('DateTime', $date);
+ self::assertInstanceOf(DateTime::class, $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
index bf05598ab32..29f88f6f54a 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DecimalType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class DecimalTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var DecimalType */
@@ -19,7 +18,7 @@ class DecimalTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('decimal');
+ $this->type = new DecimalType();
}
public function testDecimalConvertsToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
index 44623c28b90..7316252cade 100644
--- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\FloatType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class FloatTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var FloatType */
@@ -19,7 +18,7 @@ class FloatTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('float');
+ $this->type = new FloatType();
}
public function testFloatConvertsToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
index 3615b687bd9..2c15c7cbd4b 100644
--- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\GuidType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class GuidTypeTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var GuidType */
@@ -19,7 +18,7 @@ class GuidTypeTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('guid');
+ $this->type = new GuidType();
}
public function testConvertToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
index 7241a9237e1..c8f9cf952f4 100644
--- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\IntegerType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class IntegerTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var IntegerType */
@@ -19,7 +18,7 @@ class IntegerTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('integer');
+ $this->type = new IntegerType();
}
public function testIntegerConvertsToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
index 4603f3d6206..2383543b322 100644
--- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
@@ -5,7 +5,6 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\JsonArrayType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -16,7 +15,7 @@
class JsonArrayTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
protected $platform;
/** @var JsonArrayType */
@@ -25,7 +24,7 @@ class JsonArrayTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('json_array');
+ $this->type = new JsonArrayType();
}
public function testReturnsBindingType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
index 0cf41b7f867..158c7bb1a9c 100644
--- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
@@ -6,7 +6,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\JsonType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -17,7 +16,7 @@
class JsonTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
protected $platform;
/** @var JsonType */
@@ -26,7 +25,7 @@ class JsonTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('json');
+ $this->type = new JsonType();
}
public function testReturnsBindingType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
index df961faa3b9..227fcef9554 100644
--- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
@@ -5,7 +5,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\ObjectType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use stdClass;
@@ -14,7 +13,7 @@
class ObjectTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var ObjectType */
@@ -23,7 +22,7 @@ class ObjectTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('object');
+ $this->type = new ObjectType();
}
public function testObjectConvertsToDatabaseValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
index 31ed1a310dd..4c5981f4729 100644
--- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\SmallIntType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class SmallIntTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var SmallIntType */
@@ -19,7 +18,7 @@ class SmallIntTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('smallint');
+ $this->type = new SmallIntType();
}
public function testSmallIntConvertsToPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php
index 688a06ba870..5041e942e75 100644
--- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php
@@ -4,13 +4,12 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\StringType;
-use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class StringTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var StringType */
@@ -19,7 +18,7 @@ class StringTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- $this->type = Type::getType('string');
+ $this->type = new StringType();
}
public function testReturnsSqlDeclarationFromPlatformVarchar(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
index c9518fe6dbf..b2365f54a40 100644
--- a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
@@ -8,7 +8,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TimeImmutableType;
-use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -16,7 +15,7 @@
class TimeImmutableTypeTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var TimeImmutableType */
@@ -24,8 +23,8 @@ class TimeImmutableTypeTest extends TestCase
protected function setUp(): void
{
- $this->type = Type::getType('time_immutable');
$this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock();
+ $this->type = new TimeImmutableType();
}
public function testFactoryCreatesCorrectType(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
index 8bec5c2ae37..ceb1e9ee7d0 100644
--- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
@@ -2,21 +2,22 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\TimeType;
class TimeTest extends BaseDateTypeTestCase
{
protected function setUp(): void
{
- $this->type = Type::getType('time');
+ $this->type = new TimeType();
parent::setUp();
}
public function testTimeConvertsToPHPValue(): void
{
- self::assertInstanceOf('DateTime', $this->type->convertToPHPValue('5:30:55', $this->platform));
+ self::assertInstanceOf(DateTime::class, $this->type->convertToPHPValue('5:30:55', $this->platform));
}
public function testDateFieldResetInPHPValue(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
index a8652a6115b..442409ac425 100644
--- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
@@ -7,14 +7,13 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\VarDateTimeImmutableType;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class VarDateTimeImmutableTypeTest extends TestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var VarDateTimeImmutableType */
@@ -22,12 +21,8 @@ class VarDateTimeImmutableTypeTest extends TestCase
protected function setUp(): void
{
- if (! Type::hasType('vardatetime_immutable')) {
- Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class);
- }
-
- $this->type = Type::getType('vardatetime_immutable');
$this->platform = $this->getMockForAbstractClass(AbstractPlatform::class);
+ $this->type = new VarDateTimeImmutableType();
}
public function testReturnsName(): void
diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
index 586b36e89cd..206c2e094d5 100644
--- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
@@ -5,14 +5,13 @@
use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\VarDateTimeType;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
class VarDateTimeTest extends DbalTestCase
{
- /** @var AbstractPlatform|MockObject */
+ /** @var AbstractPlatform&MockObject */
private $platform;
/** @var VarDateTimeType */
@@ -21,11 +20,7 @@ class VarDateTimeTest extends DbalTestCase
protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
- if (! Type::hasType('vardatetime')) {
- Type::addType('vardatetime', VarDateTimeType::class);
- }
-
- $this->type = Type::getType('vardatetime');
+ $this->type = new VarDateTimeType();
}
public function testDateTimeConvertsToDatabaseValue(): void
@@ -42,7 +37,7 @@ public function testDateTimeConvertsToPHPValue(): void
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform);
- self::assertInstanceOf('DateTime', $date);
+ self::assertInstanceOf(DateTime::class, $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
self::assertEquals('000000', $date->format('u'));
}
@@ -56,7 +51,7 @@ public function testInvalidDateTimeFormatConversion(): void
public function testConversionWithMicroseconds(): void
{
$date = $this->type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->platform);
- self::assertInstanceOf('DateTime', $date);
+ self::assertInstanceOf(DateTime::class, $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
self::assertEquals('123456', $date->format('u'));
}
diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php
index f45ee6e232f..3a21df3910e 100644
--- a/tests/Doctrine/Tests/TestUtil.php
+++ b/tests/Doctrine/Tests/TestUtil.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests;
+use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Platforms\AbstractPlatform;
@@ -137,6 +138,8 @@ private static function addDbEventSubscribers(Connection $conn): void
}
$evm = $conn->getEventManager();
+
+ /** @psalm-var class-string $subscriberClass */
foreach (explode(',', $GLOBALS['db_event_subscribers']) as $subscriberClass) {
$subscriberInstance = new $subscriberClass();
$evm->addEventSubscriber($subscriberInstance);
diff --git a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml
index f9e1c220ec8..3b7f0d3c6bd 100644
--- a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml
+++ b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml
index 0b060018623..20a0656b4d7 100644
--- a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml
+++ b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml
index dcf655bee08..4d9a5e8f10e 100644
--- a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml
+++ b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml
index bf908ed9b5c..956cf6e527d 100644
--- a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml
+++ b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml
@@ -1,6 +1,6 @@
-
-
diff --git a/tests/travis/docker-run-mysql-or-mariadb.sh b/tests/travis/docker-run-mysql-or-mariadb.sh
deleted file mode 100644
index de0e53b9fcf..00000000000
--- a/tests/travis/docker-run-mysql-or-mariadb.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo "Starting RDBMS…">&2
-
-if [[ "$IMAGE" == "mysql:8.0" ]]
-then
- CMD_OPTIONS="--default-authentication-plugin=mysql_native_password"
-else
- CMD_OPTIONS=""
-fi
-
-docker run \
- --health-cmd='mysqladmin ping --silent' \
- --detach \
- --env MYSQL_ALLOW_EMPTY_PASSWORD=yes \
- --env MYSQL_DATABASE=doctrine_tests \
- --publish 33306:3306 \
- --name rdbms \
- "$IMAGE" $CMD_OPTIONS
-
-while true; do
- healthStatus=$(docker inspect --format "{{json .State.Health.Status }}" rdbms)
- case $healthStatus in
- '"starting"')
- echo "Waiting for RDBMS to become ready…">&2
- sleep 1
- ;;
- '"healthy"')
- echo "Container is healthy">&2
- break
- ;;
- '"unhealthy"')
- echo "Container is unhealthy">&2
- exit 1
- ;;
- *)
- echo "Unexpected health status $healthStatus">&2
- ;;
- esac
-done
-
-if [[ "$TLS" == "yes" ]]
-then
- for file in "ca.pem" "client-cert.pem" "client-key.pem"
- do
- docker cp "rdbms:/var/lib/mysql/$file" .
- done
-fi
diff --git a/tests/travis/install-db2.sh b/tests/travis/install-db2.sh
deleted file mode 100644
index 79c1be98f74..00000000000
--- a/tests/travis/install-db2.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo Setting up IBM DB2
-
-echo "su - db2inst1 -c 'db2 CONNECT TO doctrine && db2 CREATE USER TEMPORARY TABLESPACE doctrine_tbsp PAGESIZE 4 K'" > /tmp/doctrine-init.sh
-chmod +x /tmp/doctrine-init.sh
-
-sudo docker run \
- -d \
- -p 50000:50000 \
- -e DB2INST1_PASSWORD=Doctrine2018 \
- -e LICENSE=accept \
- -e DBNAME=doctrine \
- -v /tmp/doctrine-init.sh:/var/custom/doctrine-init.sh:ro \
- --name db2 \
- --privileged=true \
- ibmcom/db2:11.5.0.0
-
-sudo docker logs -f db2 | sed '/(*) Setup has completed./ q'
-
-echo DB2 started
diff --git a/tests/travis/install-mssql-pdo_sqlsrv.sh b/tests/travis/install-mssql-pdo_sqlsrv.sh
deleted file mode 100644
index 71e07aee231..00000000000
--- a/tests/travis/install-mssql-pdo_sqlsrv.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo "Installing extension"
-
-pecl install pdo_sqlsrv-5.7.0preview
diff --git a/tests/travis/install-mssql-sqlsrv.sh b/tests/travis/install-mssql-sqlsrv.sh
deleted file mode 100644
index d44841360dc..00000000000
--- a/tests/travis/install-mssql-sqlsrv.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo "Installing extension"
-
-pecl install sqlsrv-5.7.0preview
diff --git a/tests/travis/install-mssql.sh b/tests/travis/install-mssql.sh
deleted file mode 100644
index d17058e3455..00000000000
--- a/tests/travis/install-mssql.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo Setting up Microsoft SQL Server
-
-sudo docker pull microsoft/mssql-server-linux:2017-latest
-sudo docker run \
- -e 'ACCEPT_EULA=Y' \
- -e 'SA_PASSWORD=Doctrine2018' \
- -e "MSSQL_COLLATION=${MSSQL_COLLATION:-Latin1_General_100_CI_AS}" \
- -p 127.0.0.1:1433:1433 \
- --name mssql \
- -d \
- microsoft/mssql-server-linux:2017-latest
-
-sudo docker exec -i mssql bash <<< 'until echo quit | /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -l 1 -U sa -P Doctrine2018 > /dev/null 2>&1 ; do sleep 1; done'
-
-echo SQL Server started
diff --git a/tests/travis/install-postgres-10.sh b/tests/travis/install-postgres-10.sh
deleted file mode 100644
index 88041241e6e..00000000000
--- a/tests/travis/install-postgres-10.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo "Installing Postgres 10"
-sudo service postgresql stop
-sudo apt-get remove -q 'postgresql-*'
-sudo apt-get update -q
-sudo apt-get install -q postgresql-10 postgresql-client-10
-sudo cp /etc/postgresql/{9.6,10}/main/pg_hba.conf
-
-echo "Restarting Postgres 10"
-sudo service postgresql restart
diff --git a/tests/travis/install-postgres-11.sh b/tests/travis/install-postgres-11.sh
deleted file mode 100644
index 2ef1aabc4f0..00000000000
--- a/tests/travis/install-postgres-11.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo "Preparing Postgres 11"
-
-sudo service postgresql stop || true
-
-sudo docker run -d --name postgres11 -p 5432:5432 postgres:11.1
-sudo docker exec -i postgres11 bash <<< 'until pg_isready -U postgres > /dev/null 2>&1 ; do sleep 1; done'
-
-echo "Postgres 11 ready"
diff --git a/tests/travis/install-sqlsrv-dependencies.sh b/tests/travis/install-sqlsrv-dependencies.sh
deleted file mode 100644
index ff91bfdfaf0..00000000000
--- a/tests/travis/install-sqlsrv-dependencies.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-set -ex
-
-echo Installing driver dependencies
-
-curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
-curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql.list
-sudo apt-get update
-ACCEPT_EULA=Y sudo apt-get install -qy msodbcsql17 unixodbc unixodbc-dev libssl1.0.0
diff --git a/tests/travis/mariadb.docker.travis.xml b/tests/travis/mariadb.docker.travis.xml
deleted file mode 100644
index 67f63b2fde4..00000000000
--- a/tests/travis/mariadb.docker.travis.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ../Doctrine/Tests/DBAL
-
-
-
-
-
- ../../lib/Doctrine
-
-
-
diff --git a/tests/travis/mariadb.mysqli.docker.travis.xml b/tests/travis/mariadb.mysqli.docker.travis.xml
deleted file mode 100644
index d93ca5ceda5..00000000000
--- a/tests/travis/mariadb.mysqli.docker.travis.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ../Doctrine/Tests/DBAL
-
-
-
-
-
- ../../lib/Doctrine
-
-
-