diff --git a/.build/.gitignore b/.build/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/.build/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/.editorconfig b/.editorconfig
index f02a64bf..558bf795 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -11,10 +11,8 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
-[*.yml]
-indent_style = space
+[*.{yml,yaml}]
indent_size = 2
-[*.json]
-indent_style = space
-indent_size = 4
+[Makefile]
+indent_style = tab
diff --git a/.env.example b/.env.example
new file mode 100644
index 00000000..5473cafc
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,21 @@
+# https://docs.docker.com/compose/reference/envvars/#compose_project_name
+# With custom namespace provided, it will be used to prefix all services
+# in Docker network for current project
+COMPOSE_PROJECT_NAME=cycle-database
+APP_ENV=production
+
+DB_CONNECTION=pgsql
+DB_HOST=pgsql
+DB_PORT=5432
+
+DB_DATABASE=default
+DB_USERNAME=root
+DB_PASSWORD=Strong(!)Password
+
+DB_SQLSERVER_FORWARD_PORT=11433
+DB_MYSQL_FORWARD_PORT=13306
+DB_PGSQL_FORWARD_PORT=15432
+
+XDEBUG_MODE=coverage
+
+GITHUB_TOKEN=ghp_
diff --git a/.gitattributes b/.gitattributes
index 3f6e40b1..97087181 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,21 @@
-/.github export-ignore
-/.editorconfig export-ignore
-/.gitattributes export-ignore
-/.gitignore export-ignore
-/tests export-ignore
+/.build export-ignore
+/.github export-ignore
+/.phive/ export-ignore
+/tests export-ignore
+.editorconfig export-ignore
+.env.example export-ignore
+.gitattributes export-ignore
+.gitignore export-ignore
+.php-cs-fixer.dist.php export-ignore
+.pre-commit-config.yaml export-ignore
+.scrutinizer.yml export-ignore
+.styleci.yml export-ignore
+.yamllint.yaml export-ignore
+composer.lock export-ignore
+composer-require-checker.json export-ignore
+docker-compose.yaml export-ignore
+infection.json.dist export-ignore
+Makefile export-ignore
+phpunit.xml export-ignore
+psalm.xml export-ignore
+psalm-baseline.xml export-ignore
diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json
new file mode 100644
index 00000000..19b22198
--- /dev/null
+++ b/.github/.release-please-config.json
@@ -0,0 +1,72 @@
+{
+ "release-type": "node",
+ "packages": {
+ ".": {
+ "package-name": "database",
+ "changelog-path": "/CHANGELOG.md"
+ }
+ },
+ "include-component-in-tag": false,
+ "changelog-sections": [
+ {
+ "type": "feat",
+ "section": "Features",
+ "hidden": false
+ },
+ {
+ "type": "fix",
+ "section": "Bug Fixes",
+ "hidden": false
+ },
+ {
+ "type": "perf",
+ "section": "Performance Improvements",
+ "hidden": false
+ },
+ {
+ "type": "docs",
+ "section": "Documentation",
+ "hidden": false
+ },
+ {
+ "type": "chore",
+ "section": "Miscellaneous",
+ "hidden": false
+ },
+ {
+ "type": "style",
+ "section": "Styles",
+ "hidden": true
+ },
+ {
+ "type": "revert",
+ "section": "Reverts",
+ "hidden": true
+ },
+ {
+ "type": "deps",
+ "section": "Dependencies",
+ "hidden": false
+ },
+ {
+ "type": "refactor",
+ "section": "Code Refactoring",
+ "hidden": false
+ },
+ {
+ "type": "test",
+ "section": "Tests",
+ "hidden": true
+ },
+ {
+ "type": "build",
+ "section": "Build System",
+ "hidden": true
+ },
+ {
+ "type": "ci",
+ "section": "Continuous Integration",
+ "hidden": true
+ }
+ ]
+}
diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json
new file mode 100644
index 00000000..bc7a84b6
--- /dev/null
+++ b/.github/.release-please-manifest.json
@@ -0,0 +1,3 @@
+{
+ ".": "3.0.0"
+}
diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
similarity index 100%
rename from CODE_OF_CONDUCT.md
rename to .github/CODE_OF_CONDUCT.md
diff --git a/.github/labeler.yml b/.github/labeler.yml
new file mode 100644
index 00000000..7b296400
--- /dev/null
+++ b/.github/labeler.yml
@@ -0,0 +1,14 @@
+---
+
+# this file is for the labeler workflow job
+# Documentation https://github.com/marketplace/actions/labeler
+
+"type: documentation":
+ - changed-files:
+ - any-glob-to-any-file: [resources/*, .github/*, ./*.md]
+
+"type: maintenance":
+ - changed-files:
+ - any-glob-to-any-file: [tests/**/*, .github/workflows/*]
+
+...
diff --git a/.github/workflows/apply-labels.yml b/.github/workflows/apply-labels.yml
new file mode 100644
index 00000000..c9b1196b
--- /dev/null
+++ b/.github/workflows/apply-labels.yml
@@ -0,0 +1,23 @@
+---
+
+# This workflow will triage pull requests and apply a label based on the
+# paths that are modified in the pull request.
+#
+# To use this workflow, you will need to set up a .github/labeler.yml
+# file with configuration. For more information, see:
+# https://github.com/actions/labeler/blob/master/README.md
+
+on: # yamllint disable-line rule:truthy
+ pull_request:
+
+name: ๐ท๏ธ Add labels
+
+jobs:
+ label:
+ uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master
+ with:
+ os: ubuntu-latest
+ secrets:
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+...
diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml
index 4eec0818..525baa5f 100644
--- a/.github/workflows/ci-mssql.yml
+++ b/.github/workflows/ci-mssql.yml
@@ -1,88 +1,78 @@
-on:
- push:
+---
+
+on: # yamllint disable-line rule:truthy
+ pull_request:
branches:
- - master
- - '*.*'
- - '*.*.*'
- pull_request: null
+ - 2.x
-name: ci-mssql
+name: ๐ Integration with SQLServer
jobs:
- tests:
- name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }}
-
- env:
- key: cache
-
- runs-on: ubuntu-latest
-
+ test-mssql:
+ timeout-minutes: 4
+ runs-on: ${{ matrix.os }}
strategy:
- fail-fast: false
+ fail-fast: true
matrix:
- include:
- - php: '8.0'
- extensions: pdo, pdo_sqlsrv
- mssql: 'server:2017-latest'
- - php: '8.0'
- extensions: pdo, pdo_sqlsrv
- mssql: 'server:2019-latest'
- - php: '8.1'
- extensions: pdo, pdo_sqlsrv
- mssql: 'server:2019-latest'
- - php: '8.2'
- extensions: pdo, pdo_sqlsrv
- mssql: 'server:2019-latest'
- - php: '8.3'
- extensions: pdo, pdo_sqlsrv
- mssql: 'server:2019-latest'
+ os:
+ - 'ubuntu-latest'
+ php-version:
+ - '8.2'
+ dependencies:
+ - locked
+ mssql-version:
+ - latest
services:
mssql:
- image: mcr.microsoft.com/mssql/${{ matrix.mssql }}
- env:
- SA_PASSWORD: SSpaSS__1
- ACCEPT_EULA: Y
- MSSQL_PID: Developer
- ports:
- - 11433:1433
- options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'SSpaSS__1' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
+ image: mcr.microsoft.com/mssql/server:2019-latest
+ env:
+ ACCEPT_EULA: 'Y'
+ SA_PASSWORD: 'SSpaSS__1'
+ ports:
+ - 11433:1433
steps:
- - name: Checkout
- uses: actions/checkout@v2
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
- - name: Install PHP with extensions
- uses: shivammathur/setup-php@v2
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
with:
- php-version: ${{ matrix.php }}
- extensions: ${{ matrix.extensions }}
- ini-values: date.timezone='UTC'
- tools: composer:v2, pecl
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, pdo, pdo_sqlite, pdo_sqlsrv, json
+ ini-values: error_reporting=E_ALL
+ coverage: none
- - name: Determine composer cache directory on Linux
- run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- - name: Cache dependencies installed with composer
- uses: actions/cache@v2
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
- key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: |
- php${{ matrix.php }}-composer-
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- - name: Update composer
- run: composer self-update
+ - name: ๐๏ธ Remove PHP platform configuration
+ if: "matrix.dependencies != 'locked'"
+ run: composer config platform.php --ansi --unset
- - name: Install dependencies with composer
- if: matrix.php != '8.3'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
- - name: Install dependencies with composer php 8.3
- if: matrix.php == '8.3'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐งช Run unit tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=Unit
- - name: Run tests with phpunit without coverage
- env:
- DB: sqlserver
- run: vendor/bin/phpunit --group driver-sqlserver --colors=always
+ - name: ๐งช Run integration tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-sqlserver
diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml
index 68493a65..b15aba26 100644
--- a/.github/workflows/ci-mysql.yml
+++ b/.github/workflows/ci-mysql.yml
@@ -1,98 +1,84 @@
-on:
- push:
+---
+
+on: # yamllint disable-line rule:truthy
+ pull_request:
branches:
- - master
- - '*.*'
- - '*.*.*'
- pull_request: null
+ - 2.x
-name: ci-mysql
+name: ๐ Integration with MySQL
jobs:
- tests:
- name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }}
- env:
- extensions: curl, intl, pdo, pdo_mysql
- key: cache-v1
-
+ test-mysql:
+ timeout-minutes: 4
runs-on: ${{ matrix.os }}
-
strategy:
- fail-fast: false
+ fail-fast: true
matrix:
os:
- - ubuntu-latest
-
+ - 'ubuntu-latest'
php-version:
- - "8.0"
- - "8.1"
- - "8.2"
- - "8.3"
-
+ - '8.2'
+ dependencies:
+ - locked
mysql-version:
- - "5.7"
- - "8.0"
+ - latest
services:
mysql:
image: mysql:${{ matrix.mysql-version }}
env:
- MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: spiral
- MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
+ MYSQL_ROOT_PASSWORD: root
+ MYSQL_ROOT_HOST: '%'
+ options: >-
+ --health-cmd="mysqladmin ping"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
ports:
- 13306:3306
- options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- - name: Checkout
- uses: actions/checkout@v2
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
- - name: Setup cache environment
- id: cache-env
- uses: shivammathur/cache-extensions@v1
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
with:
php-version: ${{ matrix.php-version }}
- extensions: ${{ env.extensions }}
- key: ${{ env.key }}
+ extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, json
+ ini-values: error_reporting=E_ALL
+ coverage: none
- - name: Cache extensions
- uses: actions/cache@v2
- with:
- path: ${{ steps.cache-env.outputs.dir }}
- key: ${{ steps.cache-env.outputs.key }}
- restore-keys: ${{ steps.cache-env.outputs.key }}
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- - name: Install PHP with extensions
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-version }}
- extensions: ${{ env.extensions }}
- ini-values: date.timezone='UTC'
- coverage: pcov
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
- - name: Determine composer cache directory
- if: matrix.os == 'ubuntu-latest'
- run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
- - name: Cache dependencies installed with composer
- uses: actions/cache@v2
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
- key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
- restore-keys: |
- php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- - name: Install dependencies with composer
- if: matrix.php-version != '8.3'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐๏ธ Remove PHP platform configuration
+ if: "matrix.dependencies != 'locked'"
+ run: composer config platform.php --ansi --unset
- - name: Install dependencies with composer php 8.3
- if: matrix.php-version == '8.3'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
- - name: Run mysql tests with phpunit
- env:
- DB: mysql
- MYSQL: ${{ matrix.mysql-version }}
- run: vendor/bin/phpunit --group driver-mysql --colors=always
+ - name: ๐งช Run unit tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=Unit
+
+ - name: ๐งช Run integration tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-mysql
diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml
index 2e18020b..343e46b3 100644
--- a/.github/workflows/ci-pgsql.yml
+++ b/.github/workflows/ci-pgsql.yml
@@ -1,99 +1,88 @@
-on:
- push:
+---
+
+on: # yamllint disable-line rule:truthy
+ pull_request:
branches:
- - master
- - '*.*'
- - '*.*.*'
- pull_request: null
+ - 2.x
-name: ci-pgsql
+name: ๐ Integration with PostgreSQL
jobs:
- tests:
- name: PHP ${{ matrix.php-version }}-pgsql-${{ matrix.pgsql-version }}
- env:
- extensions: curl, intl, pdo, pdo_pgsql
- key: cache-v1
-
+ test-pgsql:
+ timeout-minutes: 4
runs-on: ${{ matrix.os }}
-
strategy:
- fail-fast: false
+ fail-fast: true
matrix:
os:
- - ubuntu-latest
+ - 'ubuntu-latest'
php-version:
- - "8.0"
- - "8.1"
- - "8.2"
- - "8.3"
-
+ - '8.1'
+ - '8.2'
+ - '8.3'
+ dependencies:
+ - lowest
+ - locked
+ - highest
pgsql-version:
- - "10"
- - "11"
- - "12"
- - "13"
+ - '13-alpine'
services:
- postgres:
+ pgsql:
image: postgres:${{ matrix.pgsql-version }}
env:
+ POSTGRES_DB: spiral
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- POSTGRES_DB: spiral
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
ports:
- 15432:5432
- options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- - name: Checkout
- uses: actions/checkout@v2
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
- - name: Setup cache environment
- id: cache-env
- uses: shivammathur/cache-extensions@v1
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
with:
php-version: ${{ matrix.php-version }}
- extensions: ${{ env.extensions }}
- key: ${{ env.key }}
+ extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, json
+ ini-values: error_reporting=E_ALL
+ coverage: none
- - name: Cache extensions
- uses: actions/cache@v2
- with:
- path: ${{ steps.cache-env.outputs.dir }}
- key: ${{ steps.cache-env.outputs.key }}
- restore-keys: ${{ steps.cache-env.outputs.key }}
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- - name: Install PHP with extensions
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-version }}
- extensions: ${{ env.extensions }}
- ini-values: date.timezone='UTC'
- coverage: pcov
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
- - name: Determine composer cache directory
- if: matrix.os == 'ubuntu-latest'
- run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
- - name: Cache dependencies installed with composer
- uses: actions/cache@v2
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
- key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
- restore-keys: |
- php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- - name: Install dependencies with composer
- if: matrix.php-version != '8.3'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐๏ธ Remove PHP platform configuration
+ if: "matrix.dependencies != 'locked'"
+ run: composer config platform.php --ansi --unset
- - name: Install dependencies with composer php 8.3
- if: matrix.php-version == '8.3'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
- - name: Run pgsql tests with phpunit
- env:
- DB: postgres
- POSTGRES: ${{ matrix.pgsql-version }}
- run: vendor/bin/phpunit --group driver-postgres --colors=always
+ - name: ๐งช Run unit tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=Unit
+
+ - name: ๐งช Run integration tests with phpunit
+ run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-postgres
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..67af2a38
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,354 @@
+---
+
+on: # yamllint disable-line rule:truthy
+ pull_request:
+ branches:
+ - 2.x
+
+name: ๐ Integration
+
+jobs:
+ code-coverage:
+ timeout-minutes: 4
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - ubuntu-latest
+ php-version:
+ - '8.1'
+ dependencies:
+ - locked
+
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, pdo, pdo_sqlite
+ ini-values: error_reporting=E_ALL
+ coverage: xdebug
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐งช Collect code coverage with Xdebug and phpunit/phpunit
+ env:
+ XDEBUG_MODE: coverage
+ run: vendor/bin/phpunit --group=driver-sqlite --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml
+
+ - name: ๐ค Upload code coverage report to Codecov
+ uses: codecov/codecov-action@v4.1.1
+ with:
+ files: .build/phpunit/logs/clover.xml
+ token: ${{ secrets.CODECOV_TOKEN }}
+ verbose: true
+
+ coding-standards:
+ timeout-minutes: 16
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - "ubuntu-latest"
+ php-version:
+ - "8.1"
+ dependencies:
+ - "locked"
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, pdo, pdo_sqlite
+ ini-values: error_reporting=E_ALL
+ coverage: xdebug
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐ ๏ธ Prepare environment
+ run: |
+ mkdir -p ./.build/php-cs-fixer
+
+ - name: โป๏ธ Restore php-cs-fixer cache
+ uses: actions/cache@v4
+ with:
+ path: .build/php-cs-fixer
+ key: php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}
+ restore-keys: |
+ php-${{ matrix.php-version }}-php-cs-fixer-master
+ php-${{ matrix.php-version }}-php-cs-fixer-
+
+ - name: ๐จ Run coding standards task
+ run: composer cs:diff
+ env:
+ PHP_CS_FIXER_IGNORE_ENV: true
+
+ static-analysis:
+ timeout-minutes: 4
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: static-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - "ubuntu-latest"
+ php-version:
+ - "8.1"
+ dependencies:
+ - "locked"
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, pdo, pdo_sqlite
+ ini-values: error_reporting=E_ALL
+ coverage: xdebug
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: |
+ echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐ Run static analysis using psalm
+ run: composer psalm:ci
+
+ mutation-testing:
+ timeout-minutes: 16
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: mutation-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - "ubuntu-latest"
+ php-version:
+ - "8.1"
+ dependencies:
+ - "locked"
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, pdo, pdo_sqlite
+ ini-values: error_reporting=E_ALL
+ coverage: xdebug
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐งช Run mutation testing using Xdebug and infection/infection
+ run: composer infection:ci
+
+ security-analysis:
+ timeout-minutes: 4
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - "ubuntu-latest"
+ php-version:
+ - "8.1"
+ dependencies:
+ - "locked"
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, json
+ ini-values: error_reporting=E_ALL
+ coverage: none
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐ Check installed packages for security vulnerability advisories
+ run: composer audit --ansi
+
+ dependency-analysis:
+ timeout-minutes: 4
+ runs-on: ${{ matrix.os }}
+ concurrency:
+ cancel-in-progress: true
+ group: dependency-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ strategy:
+ fail-fast: true
+ matrix:
+ os:
+ - "ubuntu-latest"
+ php-version:
+ - "8.2"
+ dependencies:
+ - "locked"
+
+ steps:
+ - name: ๐ฆ Check out the codebase
+ uses: actions/checkout@v4.1.1
+
+ - name: ๐ ๏ธ Setup PHP
+ uses: shivammathur/setup-php@2.30.1
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: mbstring, json, curl, dom, xml, phar
+ ini-values: error_reporting=E_ALL
+ coverage: none
+ tools: phive
+
+ - name: ๐ ๏ธ Setup problem matchers
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+
+ - name: ๐ค Validate composer.json and composer.lock
+ run: composer validate --ansi --strict
+
+ - name: ๐ Get composer cache directory
+ uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master
+
+ - name: โป๏ธ Restore cached dependencies installed with composer
+ uses: actions/cache@v4.0.2
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
+ restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
+
+ - name: ๐ฅ Install "${{ matrix.dependencies }}" dependencies
+ uses: wayofdev/gh-actions/actions/composer/install@master
+ with:
+ dependencies: ${{ matrix.dependencies }}
+
+ - name: ๐ฅ Install dependencies with phive
+ uses: wayofdev/gh-actions/actions/phive/install@master
+ with:
+ phive-home: '.phive'
+ trust-gpg-keys: '0x033E5F8D801A2F8D'
+
+ - name: ๐ฌ Run maglnet/composer-require-checker
+ run: .phive/composer-require-checker check --ansi --config-file=$(pwd)/composer-require-checker.json --verbose
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
new file mode 100644
index 00000000..0766379a
--- /dev/null
+++ b/.github/workflows/create-release.yml
@@ -0,0 +1,26 @@
+---
+
+# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml
+# https://github.com/google-github-actions/release-please-action#release-types-supported
+
+on: # yamllint disable-line rule:truthy
+ push:
+ branches:
+ - master
+
+name: ๐ฆ Create release
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - name: ๐ Create release
+ uses: google-github-actions/release-please-action@v4
+ id: release
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ config-file: .github/.release-please-config.json
+ manifest-file: .github/.release-please-manifest.json
+ target-branch: 2.x
+
+...
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index f8281536..00000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,104 +0,0 @@
-name: build
-
-on:
- push:
- branches:
- - master
- - '*.*'
- - '*.*.*'
- pull_request: null
-
-jobs:
- test:
- name: Test PHP ${{ matrix.php-versions }} with Code Coverage
- runs-on: ubuntu-latest
- strategy:
- matrix:
- php-versions: ['8.0', '8.1', '8.2', '8.3']
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- - name: Setup DB services
- run: |
- cd tests
- docker-compose up -d
- cd ..
- - name: Setup PHP ${{ matrix.php-versions }}
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- coverage: pcov
- tools: pecl
- extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql
- - name: Get Composer Cache Directory
- id: composer-cache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- - name: Restore Composer Cache
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies with composer
- if: matrix.php-versions != '8.3'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
-
- - name: Install dependencies with composer php 8.3
- if: matrix.php-versions == '8.3'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
-
- - name: Execute Tests
- run: |
- vendor/bin/phpunit --coverage-clover=coverage.clover
- - name: Upload coverage to Codecov
- continue-on-error: true # if is fork
- uses: codecov/codecov-action@v1
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
- file: ./coverage.clover
- - name: Upload coverage to Scrutinizer
- continue-on-error: true # if is fork
- uses: sudo-bot/action-scrutinizer@latest
- with:
- cli-args: "--format=php-clover coverage.clover"
-
- sqlite:
- name: SQLite PHP ${{ matrix.php-versions }}
- runs-on: ubuntu-latest
- strategy:
- matrix:
- php-versions: ['8.0', '8.1', '8.2', '8.3']
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- - name: Setup PHP ${{ matrix.php-versions }}
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- coverage: pcov
- tools: pecl
- extensions: mbstring, pdo, pdo_sqlite
- - name: Get Composer Cache Directory
- id: composer-cache
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- - name: Restore Composer Cache
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
- restore-keys: ${{ runner.os }}-composer-
-
- - name: Install dependencies with composer
- if: matrix.php-versions != '8.3'
- run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
-
- - name: Install dependencies with composer php 8.3
- if: matrix.php-versions == '8.3'
- run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
-
- - name: Execute Tests
- env:
- DB: sqlite
- run: |
- vendor/bin/phpunit --group driver-sqlite --colors=always
diff --git a/.gitignore b/.gitignore
index d89a76d9..edbcea6d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
.idea/
-.env
.coveralls.yml
composer.lock
vendor/
@@ -11,3 +10,4 @@ clover.xml
clover.json
.php_cs.cache
.phpunit.result.cache
+.env
diff --git a/.phive/.gitignore b/.phive/.gitignore
new file mode 100644
index 00000000..71d2e19d
--- /dev/null
+++ b/.phive/.gitignore
@@ -0,0 +1,3 @@
+*
+!.gitignore
+!phars.xml
diff --git a/.phive/phars.xml b/.phive/phars.xml
new file mode 100644
index 00000000..8fa992c8
--- /dev/null
+++ b/.phive/phars.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 00000000..2e9ca19f
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,20 @@
+ false]))
+ ->inDir(__DIR__ . '/resources')
+ ->inDir(__DIR__ . '/src')
+ ->inDir(__DIR__ . '/tests')
+ ->addFiles([__FILE__])
+ ->getConfig()
+;
+
+$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache');
+
+return $config;
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..de88b0f5
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,23 @@
+---
+
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.5.0
+ hooks:
+ - id: check-executables-have-shebangs
+ - id: check-shebang-scripts-are-executable
+ - id: check-json
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-added-large-files
+ args: ['--maxkb=600']
+ - id: fix-encoding-pragma
+
+ - repo: https://github.com/commitizen-tools/commitizen
+ rev: v3.20.0
+ hooks:
+ - id: commitizen
+ stages:
+ - commit-msg
+
+...
diff --git a/.yamllint.yaml b/.yamllint.yaml
new file mode 100644
index 00000000..7cb7cbbc
--- /dev/null
+++ b/.yamllint.yaml
@@ -0,0 +1,56 @@
+---
+
+extends: default
+
+ignore: |
+ .build/
+ vendor/
+
+# Overwrite above default rules
+rules:
+ braces:
+ # Defaults
+ # min-spaces-inside: 0
+ # max-spaces-inside: 0
+
+ # Keep 0 min-spaces to not error on empty {} collection definitions
+ min-spaces-inside: 0
+
+ # Allow one space inside braces to improve code readability
+ max-spaces-inside: 1
+
+ brackets:
+ # Defaults
+ # min-spaces-inside: 0
+ # max-spaces-inside: 0
+
+ # Keep 0 min-spaces to not error on empty [] collection definitions
+ min-spaces-inside: 0
+
+ # Allow one space inside braces to improve code readability
+ max-spaces-inside: 1
+
+ colons:
+ # Defaults
+ # min-spaces-before: 0
+ # max-spaces-after: 1
+
+ # Allow multiple spaces after a colon to allow indentation of YAML
+ # dictionary values
+ max-spaces-after: -1
+
+ commas:
+ # Defaults
+ # max-spaces-after: 1
+
+ # Allow multiple spaces after a comma to allow indentation of YAML
+ # dictionary values
+ max-spaces-after: -1
+
+ comments:
+ require-starting-space: true
+ min-spaces-from-content: 1
+
+ line-length: disable
+
+...
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1f1c575..06c28017 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,85 +1,141 @@
-# CHANGELOG
-
-v2.9.0 (27.03.2024)
--------------------
-- Added `logInterpolatedQueries` for detailed query logging and refined `logQueryParameters` to accurately log query parameters as arrays, enhancing ORM debugging and monitoring. @lotyp (#165)
-- Improved logging with enriched context in Driver.php, including driver details and query parameters. @lotyp (#165)
-- Improved `orderBy` method to accept a null direction parameter, providing more flexibility when constructing queries by @butschster (#167)
-- Added support for PostgreSQL-specific directions **NULLS FIRST** and **NULLS LAST** for more control over null value ordering in result sets by @butschster (#167)
-
-v2.8.1 (08.02.2024)
--------------------
-- Fix compiling of Fragment with parameters in the returning() definition by @msmakouz (#161)
-- Fix comparison of Fragment in Column default value by @msmakouz (#162)
-
-v2.8.0 (08.02.2024)
--------------------
-- The `withDatetimeMicroseconds` option now affects the interpolator by @msmakouz (#155)
-- Postgres: support for multiple returning columns by @roxblnfk and @msmakouz (#157)
-- MSSQL: support for multiple returning columns by @msmakouz (#160)
-
-v2.7.1 (22.12.2023)
--------------------
-- Fix setting `precision` and `scale` through attributes by @msmakouz (#148)
-- Fix quoting with an underscore at the beginning by @msmakouz (#151)
-- Fix behavior of the `Column::type()` method by adding default size to column type mappings by @msmakouz (#150)
-
-v2.7.0 (04.12.2023)
--------------------
-- Add `varbinary` support in MySQL; optimize `size` attribute by @msmakouz (#146)
-- Add the ability to use WHERE IN and WHERE NOT IN with array values
- The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147)
-
-v2.6.0 (02.11.2023)
--------------------
-- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133)
+# Changelog
+
+## [3.0.0](https://github.com/cycle/database/compare/2.9.0...v3.0.0) (2024-03-27)
+
+
+### โ BREAKING CHANGES
+
+* bump minimal php version from 8.0 to 8.1
+
+### Features
+
+* add .env file for local development and testing ([c8c6e57](https://github.com/cycle/database/commit/c8c6e5777fa64e38490564ba3c00b6f4db0c1c47))
+* add googleapis/release-please auto changelog generator configs ([2cbbff8](https://github.com/cycle/database/commit/2cbbff84dc5e14e0badd32b00e095860738002fe))
+* add pre-commit config file ([e963a39](https://github.com/cycle/database/commit/e963a399945c9aa652aee7fd11ba5ad099b29a4e))
+* add self-documenting Makefile and docker-compose for local dev dokerization ([fa62923](https://github.com/cycle/database/commit/fa6292300396c70fe1c36bbd46a000b53adfca7b))
+* add wayofdev/php-cs-fixer and roave/security-advisories ([43b6b87](https://github.com/cycle/database/commit/43b6b87ed55462f53d09d477aa82118b9171c3e9))
+* add yamllint ([397b07a](https://github.com/cycle/database/commit/397b07a180de3be5c844111c4f27d0d38ac0cb64))
+* bump minimal php version from 8.0 to 8.1 ([c3bdc70](https://github.com/cycle/database/commit/c3bdc701dfba6892a0fe6bc421d5869ce320dc2a))
+* remove style-ci dependency ([6e6a07c](https://github.com/cycle/database/commit/6e6a07c83a9365bcaf723a2863890539ab1d63d7))
+
+
+### Bug Fixes
+
+* .editorconfig ([2258e90](https://github.com/cycle/database/commit/2258e90a8a793d41af79d190bb5d235de3c58e5f))
+* production release should not contain development files ([35218e4](https://github.com/cycle/database/commit/35218e4be5ffbe30539b9fb36ab40d00e20b10b0))
+
+
+### Documentation
+
+* mention make commands in CONTRIBUTING.md ([cedd95e](https://github.com/cycle/database/commit/cedd95e94594cdd072e6c5e736727a7271351f22))
+
+
+### Miscellaneous
+
+* move CODE_OF_CONDUCT ([1a01cfb](https://github.com/cycle/database/commit/1a01cfb025b28e89995a9c97be45e6706941b5dd))
+* return back .styleci, as it bloats commits ([8a7014f](https://github.com/cycle/database/commit/8a7014f683d56da2cdfbf29bfac9cabafa27c26b))
+
+## [2.9.0](https://github.com/cycle/database/compare/2.8.1...v2.9.0) (2024-03-27)
+
+### Features
+* Added `logInterpolatedQueries` for detailed query logging and refined `logQueryParameters` to accurately log query parameters as arrays, enhancing ORM debugging and monitoring. @lotyp (#165)
+* Improved logging with enriched context in Driver.php, including driver details and query parameters. @lotyp (#165)
+* Improved `orderBy` method to accept a null direction parameter, providing more flexibility when constructing queries by @butschster (#167)
+* Added support for PostgreSQL-specific directions **NULLS FIRST** and **NULLS LAST** for more control over null value ordering in result sets by @butschster (#167)
+
+## [2.8.1](https://github.com/cycle/database/compare/2.8.0...v2.8.1) (2024-02-08)
+
+### Bug Fixes
+* Fix compiling of Fragment with parameters in the returning() definition by @msmakouz (#161)
+* Fix comparison of Fragment in Column default value by @msmakouz (#162)
+
+## [2.8.0](https://github.com/cycle/database/compare/2.7.1...v2.8.0) (2024-02-08)
+
+### Features
+* The `withDatetimeMicroseconds` option now affects the interpolator by @msmakouz (#155)
+* Postgres: support for multiple returning columns by @roxblnfk and @msmakouz (#157)
+* MSSQL: support for multiple returning columns by @msmakouz (#160)
+
+## [2.7.1](https://github.com/cycle/database/compare/2.7.0...v2.7.1) (2023-12-22)
+
+### Bug Fixes
+* Fix setting `precision` and `scale` through attributes by @msmakouz (#148)
+* Fix quoting with an underscore at the beginning by @msmakouz (#151)
+* Fix behavior of the `Column::type()` method by adding default size to column type mappings by @msmakouz (#150)
+
+## [2.7.0](https://github.com/cycle/database/compare/2.6.0...v2.7.0) (2023-12-04)
+
+### Features
+* Add `varbinary` support in MySQL; optimize `size` attribute by @msmakouz (#146)
+* Add the ability to use WHERE IN and WHERE NOT IN with array values. The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147)
+
+## [2.6.0](https://github.com/cycle/database/compare/2.5.2...v2.6.0) (2023-11-02)
+
+### Features
- MySQL driver:
- - Add the type `smallInteger` by @gam6itko (#128)
- - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121)
+ - Add the type `smallInteger` by @gam6itko (#128)
+ - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121)
- Postgres driver:
- - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132)
- - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134)
-- All the drivers:
- - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130)
- - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137)
+ - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132)
+ - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134)
+- All the drivers:
+ - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130)
+ - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137)
- JSON support:
- - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135)
- - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138)
+ - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135)
+ - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138)
+
+### Bug Fixes
+- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133)
+
+## [2.5.2](https://github.com/cycle/database/compare/2.5.1...v2.5.2) (2023-07-03)
-v2.5.2 (03.07.2023)
--------------------
+### Bug Fixes
- Fix Postgres schema restoring after reconnect by @msmakouz in (#126)
-v2.5.1 (09.06.2023)
--------------------
+## [2.5.1](https://github.com/cycle/database/compare/2.5.0...v2.5.1) (2023-06-09)
+
+### Bug Fixes
- Fix drastic increase of insert statements on pg driver with complex primary keys by @wolfy-j (#122)
-v2.5.0 (12.05.2023)
--------------------
+## [2.5.0](https://github.com/cycle/database/compare/2.4.1...v2.5.0) (2023-05-12)
+
+### Features
- Add ability to use non-primary serial column by @msmakouz (#106)
- Add ability to configure DB port passing a string by @msmakouz (#109)
- Add ability to define a custom type column by @msmakouz (#104)
- Add the ability to define `readonlySchema` for columns by @msmakouz (#116)
- Add `AbstractForeignKey::$index` property to enable/disable index creation by @msmakouz (#119)
+
+### Bug Fixes
- Fix inserting an array of rowsets without calling the columns method by @msmakouz (#120)
+
+### Miscellaneous
- Improve types for `TableInterface` and `ColumnInterface` by @vjik (#108)
- Fix typos by @arogachev (#110, #111)
-v2.4.1 (08.03.2023)
--------------------
+## [2.4.1](https://github.com/cycle/database/compare/2.4.0...v2.4.1) (2023-03-08)
+
+### Bug Fixes
- Fix: add schema to Postgres dependency table names by @msmakouz (#102)
- Fix: don't add a table prefix when a column is quoting by @msmakouz (#103)
-v2.4.0 (01.02.2023)
--------------------
-- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs.
- Since **v2.4.0**, interpolation in logs is **disabled** by default by @msmakouz (#95)
+## [2.4.0](https://github.com/cycle/database/compare/2.3.0...v2.4.0) (2023-02-01)
+
+### โ BREAKING CHANGES
+* Since **v2.4.0**, interpolation in logs is **disabled** by default
+
+### Features
+- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs by @msmakouz (#95)
- Add PostgreSQL specific data types by @msmakouz (#93)
- Add MySQL `SET` type support by @msmakouz (#92)
+
+### Bug Fixes
- Fix Interpolator performance by @msmakouz (#94) thx @hustlahusky
-v2.3.0 (27.12.2022)
--------------------
+## [2.3.0](https://github.com/cycle/database/compare/2.2.2...v2.3.0) (2022-12-27)
+
+### Features
- Add support for array values in the `IN` and `NOT IN` operators by @roxblnfk (#69, #70, #71)
- Add `PdoInterface` as a possible return type for the `Driver::getPDO()` method by @roxblnfk (#76)
- Add the `options` array parameter to all driver configs to pass additional driver options.
@@ -88,53 +144,73 @@ v2.3.0 (27.12.2022)
- Add the ability to define the `size` of a `datetime` column by @msmakouz (#86)
- Add support for the unsigned and zerofill properties in MySQL Integer types by @roxblnfk (#88)
-v2.2.2 (27.09.2022)
--------------------
+## [2.2.2](https://github.com/cycle/database/compare/2.2.1...v2.2.2) (2022-09-27)
+
+### Bug Fixes
- Fix transaction level changing on disconnect when transaction is starting by @roxblnfk (#76)
-v2.2.1 (02.07.2022)
--------------------
+## [2.2.1](https://github.com/cycle/database/compare/2.2.0...v2.2.1) (2022-07-02)
+
+### Bug Fixes
- Hotfix: make the `$config` parameter of the `DatabaseConfig` constructor optional again by @roxblnfk
-v2.2.0 (23.06.2022)
--------------------
+## [2.2.0](https://github.com/cycle/database/compare/2.1.3...v2.2.0) (2022-06-23)
+
+### Features
- Add supporting for PHP 8.1 Enumerations by @roxblnfk (#67)
- Add supporting for smallint column type by @gam6itko (#58)
+
+### Bug Fixes
- Fix typo in the `\Cycle\Database\Schema\State::forgerForeignKey` method by @BeMySlaveDarlin (#53)
-- Fix compatibility with Spiral Framework 3 packages:
- - Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64)
- - Update `composer.json` dependencies
-v2.1.3 (20.05.2022)
--------------------
+### Miscellaneous
+- Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64)
+- Update `composer.json` dependencies
+
+## [2.1.3](https://github.com/cycle/database/compare/2.1.2...v2.1.3) (2022-05-20)
+
+### Bug Fixes
- Fix query interpolation by @roxblnfk (#60)
-v2.1.2 (20.01.2022)
--------------------
+## [2.1.2](https://github.com/cycle/database/compare/2.1.1...v2.1.2) (2022-01-20)
+
+### Bug Fixes
- Fix wrong bind parameter order in a select query with join by @roxblnfk (#48)
- Fix access to unitialized driver property on `ActiveQuery::__debugInfo()` call by @roxblnfk (#46)
-v2.1.1 (12.01.2022)
--------------------
+## [2.1.1](https://github.com/cycle/database/compare/2.1.0...v2.1.1) (2022-01-12)
+
+### Miscellaneous
- Fix phpdoc for the `SelectQuery::orderBy` method by @butschster (#45)
- Fix problem with driver cloning by @butschster (#44)
-v2.1.0 (31.12.2021)
--------------------
-- Add `psr/log` dependency by @thgs (#35)
+## [2.1.0](https://github.com/cycle/database/compare/2.0.0...v2.1.0) (2021-12-31)
+
+### Features
+- Added `psr/log` dependency by @thgs (#35)
- Add ability to get/set driver name by @butschster (#38)
- Optimize fetching indexes and primary keys in Postgres driver by @hustlahusky (#37)
+
+### Bug Fixes
- Fix type casting for column size value in the PG Column class by @rauanmayemir (#34)
+
+### Miscellaneous
+- Add `psr/log` dependency by @thgs (#35)
- Downgrade spiral dependencies to stable by @roxblnfk (#40)
-v2.0.0 (22.12.2021)
--------------------
-- The package moved from `spiral/database` to `cycle/database`
+## [2.0.0](https://github.com/cycle/database/compare/1.0.0...v2.0.0) (2021-12-22)
+
+### โ BREAKING CHANGES
- Namespace `Spiral\Database` replaced with `Cycle\Database` @butschster (#1)
-- Minimal PHP version is 8.0 (#26, #31)
+- Minimal PHP version is 8.0
+
+### Features
- Added supporting for postgres schemas @butschster (#2)
-- Added DTO configs @SerafimArts, @msmakouz (#10, #14)
-- Improvements to `join` methods @butschster
-- Tests have been restructured @butschster (#21)
+- Added DTO configs @SerafimArts, @msmakouz (#10, #14)
- Added method to get transaction level @msmakouz (#23)
- Added `ColumnReturnableInterface` for database drivers @butschster (#25)
+
+### Miscellaneous
+- The package moved from `spiral/database` to `cycle/database`
+- Improvements to `join` methods @butschster
+- Tests have been restructured @butschster (#21)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 251b148a..ec0fc57b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,4 +1,5 @@
# Contributing
+
Feel free to contribute to the development of the Cycle DBAL.
Please make sure that the following requirements are satisfied before submitting your pull request:
@@ -13,20 +14,27 @@ Please make sure that the following requirements are satisfied before submitting
To test Cycle DBAL locally, download the `cycle/database` repository and start docker containers inside the tests folder:
```bash
-$ cd tests/
-$ docker-composer up
+## to set up the environment with one command
+make
+
+## or, manually
+make env
+make prepare
+make install
+make hooks
+make up
```
To run full test suite:
```bash
-$ ./vendor/bin/phpunit
+make test
```
To run quick test suite:
```bash
-$ ./vendor/bin/phpunit --group driver-sqlite
+make test-sqlite
```
## Help Needed In
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..c3dc73fa
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,242 @@
+-include .env
+
+# BuildKit enables higher performance docker builds and caching possibility
+# to decrease build times and increase productivity for free.
+# https://docs.docker.com/compose/environment-variables/envvars/
+export DOCKER_BUILDKIT ?= 1
+
+# Binary to use, when executing docker-compose tasks
+DOCKER_COMPOSE ?= docker compose
+
+# Support image with all needed binaries, like envsubst, mkcert, wait4x
+SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest
+
+APP_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app
+APP_COMPOSER ?= $(APP_RUNNER) composer
+
+BUILDER_PARAMS ?= docker run --rm -i \
+ --env-file ./.env \
+ --env COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
+ --env COMPOSER_AUTH="$(COMPOSER_AUTH)"
+
+BUILDER ?= $(BUILDER_PARAMS) $(SUPPORT_IMAGE)
+BUILDER_WIRED ?= $(BUILDER_PARAMS) --network project.$(COMPOSE_PROJECT_NAME) $(SUPPORT_IMAGE)
+
+# Shorthand envsubst command, executed through build-deps
+ENVSUBST ?= $(BUILDER) envsubst
+
+# Commitizen docker image
+CZ_RUNNER ?= docker run --rm --name commitizen \
+ --platform linux/amd64 \
+ -v $(shell pwd):/app \
+ commitizen/commitizen:latest
+
+EXPORT_VARS = '\
+ $${COMPOSE_PROJECT_NAME} \
+ $${COMPOSER_AUTH}'
+
+#
+# Self documenting Makefile code
+# ------------------------------------------------------------------------------------
+ifneq ($(TERM),)
+ BLACK := $(shell tput setaf 0)
+ RED := $(shell tput setaf 1)
+ GREEN := $(shell tput setaf 2)
+ YELLOW := $(shell tput setaf 3)
+ LIGHTPURPLE := $(shell tput setaf 4)
+ PURPLE := $(shell tput setaf 5)
+ BLUE := $(shell tput setaf 6)
+ WHITE := $(shell tput setaf 7)
+ RST := $(shell tput sgr0)
+else
+ BLACK := ""
+ RED := ""
+ GREEN := ""
+ YELLOW := ""
+ LIGHTPURPLE := ""
+ PURPLE := ""
+ BLUE := ""
+ WHITE := ""
+ RST := ""
+endif
+MAKE_LOGFILE = /tmp/cycle-database.log
+MAKE_CMD_COLOR := $(BLUE)
+
+default: all
+
+help:
+ @echo 'Management commands for package:'
+ @echo 'Usage:'
+ @echo ' ${MAKE_CMD_COLOR}make${RST} Setups dependencies for fresh-project, like composer install, git hooks and others...'
+ @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
+ @echo
+ @echo ' ๐ Logs are stored in $(MAKE_LOGFILE)'
+ @echo
+ @echo ' ๐ฆ Package database (https://github.com/cycle/database)'
+ @echo ' ๐ค Makefile Author Andrij Orlenko (https://github.com/lotyp)'
+ @echo ' ๐ข ${YELLOW}Org cycle (https://github.com/cycle)${RST}'
+.PHONY: help
+
+.EXPORT_ALL_VARIABLES:
+
+#
+# Default action
+# Defines default command when `make` is executed without additional parameters
+# ------------------------------------------------------------------------------------
+all: env prepare install hooks phive up
+.PHONY: all
+
+#
+# System Actions
+# ------------------------------------------------------------------------------------
+env: ## Generate .env file from example, use `make env force=true`, to force re-create file
+ifeq ($(FORCE),true)
+ @echo "${YELLOW}Force re-creating .env file from example...${RST}"
+ $(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env
+else ifneq ("$(wildcard ./.env)","")
+ @echo ""
+ @echo "${YELLOW}The .env file already exists! Use FORCE=true to re-create.${RST}"
+else
+ @echo "Creating .env file from example"
+ $(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env
+endif
+.PHONY: env
+
+prepare:
+ mkdir -p .build/php-cs-fixer
+.PHONY: prepare
+
+#
+# Docker Actions
+# ------------------------------------------------------------------------------------
+up: # Creates and starts containers, defined in docker-compose and override file
+ $(DOCKER_COMPOSE) up --remove-orphans -d
+.PHONY: up
+
+down: # Stops and removes containers of this project
+ $(DOCKER_COMPOSE) down --remove-orphans --volumes
+.PHONY: down
+
+restart: down up ## Runs down and up commands
+.PHONY: restart
+
+clean: ## Stops containers if required and removes from system
+ $(DOCKER_COMPOSE) rm --force --stop
+.PHONY: clean
+
+ps: ## List running project containers
+ $(DOCKER_COMPOSE) ps
+.PHONY: ps
+
+logs: ## Show project docker logs with follow up mode enabled
+ $(DOCKER_COMPOSE) logs -f
+.PHONY: logs
+
+pull: ## Pull and update docker images in this project
+ $(DOCKER_COMPOSE) pull
+.PHONY: pull
+
+ssh: ## Login inside running docker container
+ $(APP_RUNNER) sh
+.PHONY: ssh
+
+#
+# Composer
+# ------------------------------------------------------------------------------------
+install: ## Installs composer dependencies
+ $(APP_COMPOSER) install
+.PHONY: install
+
+update: ## Updates composer dependencies by running composer update command
+ $(APP_COMPOSER) update
+.PHONY: update
+
+phive: ## Installs dependencies with phive
+ PHIVE_HOME=.build/phive phive install --trust-gpg-keys 0x033E5F8D801A2F8D
+.PHONY: phive
+
+#
+# Code Quality, Git, Linting
+# ------------------------------------------------------------------------------------
+hooks: ## Install git hooks from pre-commit-config
+ pre-commit install
+ pre-commit autoupdate
+.PHONY: hooks
+
+lint: lint-yaml lint-php lint-psalm ## Runs all linting commands
+.PHONY: lint
+
+lint-yaml: ## Lints yaml files inside project
+ yamllint .
+.PHONY: lint-yaml
+
+lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer
+ $(APP_COMPOSER) cs:fix
+.PHONY: lint-php
+
+lint-diff: prepare ## Runs php-cs-fixer in dry-run mode and shows diff which will by applied
+ $(APP_COMPOSER) cs:diff
+.PHONY: lint-diff
+
+lint-psalm: ## Runs psalm โ static analysis tool
+ $(APP_COMPOSER) psalm
+.PHONY: lint-psalm
+
+lint-psalm-ci:
+ $(APP_COMPOSER) psalm:ci
+.PHONY: lint-psalm-ci
+
+lint-psalm-baseline: ## Runs psalm to update its baseline
+ $(APP_COMPOSER) psalm:baseline:update
+.PHONY: lint-psalm-baseline
+
+lint-infect: ## Runs infection โ mutation testing framework
+ $(APP_COMPOSER) infection
+.PHONY: lint-infect
+
+lint-infect-ci: ## Runs infection โ mutation testing framework
+ $(APP_COMPOSER) infection:ci
+.PHONY: lint-infect-ci
+
+lint-deps: ## Runs composer-require-checker โ checks for dependencies that are not used
+ .phive/composer-require-checker check --config-file=$(shell pwd)/composer-require-checker.json --verbose
+.PHONY: lint-deps
+
+#
+# Testing
+# ------------------------------------------------------------------------------------
+test: ## Run project php-unit tests
+ $(APP_COMPOSER) test
+.PHONY: test
+
+test-cc: ## Run project php-unit tests in coverage mode and build report
+ $(APP_COMPOSER) test:cc
+.PHONY: test-cc
+
+test-sqlite: ## Run project php-unit tests with sqlite database
+ $(APP_COMPOSER) test:sqlite
+.PHONY: test-sqlite
+
+test-mysql: ## Run project php-unit tests with mysql database
+ $(APP_COMPOSER) test:mysql
+.PHONY: test-mysql
+
+test-pgsql: ## Run project php-unit tests with postgres database
+ $(APP_COMPOSER) test:pgsql
+.PHONY: test-pgsql
+
+#
+# Release
+# ------------------------------------------------------------------------------------
+commit:
+ $(CZ_RUNNER) commit
+.PHONY: commit
+
+release: ## Create a new release
+ release-please release-pr \
+ --token=$(GITHUB_TOKEN) \
+ --repo-url=cycle/database \
+ --target-branch=feat/infra-dx-v2 \
+ --config-file=.github/.release-please-config.json \
+ --manifest-file=.github/.release-please-manifest.json
+.PHONE: release
diff --git a/composer-require-checker.json b/composer-require-checker.json
new file mode 100644
index 00000000..c49ade90
--- /dev/null
+++ b/composer-require-checker.json
@@ -0,0 +1,6 @@
+{
+ "symbol-whitelist": [
+ "Cycle\\Database\\Driver\\SQLServer\\Schema\\SQlServerForeignKey",
+ "Spiral\\Database\\Driver\\SQLServer\\Schema\\SQlServerForeignKey"
+ ]
+}
diff --git a/composer.json b/composer.json
index 0385c29b..663d0ee1 100644
--- a/composer.json
+++ b/composer.json
@@ -1,24 +1,18 @@
{
"name": "cycle/database",
- "type": "library",
"description": "DBAL, schema introspection, migration and pagination",
- "keywords": ["dbal", "database", "mysql", "mssql", "sqlite", "postgresql", "orm", "sql", "query-builder"],
"license": "MIT",
- "conflict": {
- "spiral/database": "*"
- },
- "homepage": "https://cycle-orm.dev",
- "support": {
- "issues": "https://github.com/cycle/database/issues",
- "source": "https://github.com/cycle/database",
- "docs": "https://cycle-orm.dev/docs",
- "chat": "https://discord.gg/spiralphp"
- },
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/cycle"
- }
+ "type": "library",
+ "keywords": [
+ "dbal",
+ "database",
+ "mysql",
+ "mssql",
+ "sqlite",
+ "postgresql",
+ "orm",
+ "sql",
+ "query-builder"
],
"authors": [
{
@@ -38,48 +32,92 @@
"email": "pavel.buchnev@spiralscout.com"
}
],
+ "homepage": "https://cycle-orm.dev",
+ "support": {
+ "issues": "https://github.com/cycle/database/issues",
+ "chat": "https://discord.gg/spiralphp",
+ "source": "https://github.com/cycle/database",
+ "docs": "https://cycle-orm.dev/docs"
+ },
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/cycle"
+ }
+ ],
"require": {
- "php": ">=8.0",
+ "php": ">=8.1",
+ "ext-filter": "*",
"ext-pdo": "*",
"psr/log": "1 - 3",
"spiral/core": "^2.8 || ^3.0",
"spiral/pagination": "^2.8 || ^3.0",
- "symfony/polyfill-php83": "^1.28"
+ "symfony/polyfill-php83": "^1.29"
},
+ "require-dev": {
+ "ergebnis/composer-normalize": "^2.42",
+ "infection/infection": "^0.26",
+ "mockery/mockery": "^1.6",
+ "phpunit/phpunit": "^9.6",
+ "psalm/plugin-phpunit": "^0.19.0",
+ "roave/security-advisories": "dev-latest",
+ "spiral/tokenizer": "^2.14 || ^3.0",
+ "vimeo/psalm": "^5.23",
+ "wayofdev/cs-fixer-config": "^1.2"
+ },
+ "conflict": {
+ "spiral/database": "*"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true,
"autoload": {
+ "psr-4": {
+ "Cycle\\Database\\": "src"
+ },
"files": [
"src/polyfill.php",
"src/functions_polyfill.php"
- ],
- "psr-4": {
- "Cycle\\Database\\": "src"
- }
- },
- "require-dev": {
- "infection/infection": "^0.26.10",
- "mockery/mockery": "^1.5",
- "phpunit/phpunit": "^9.5",
- "spiral/tokenizer": "^2.14 | ^3.0",
- "vimeo/psalm": "^5.18"
+ ]
},
"autoload-dev": {
+ "files": [
+ "tests/helpers.php"
+ ],
"psr-4": {
"Cycle\\Database\\Tests\\": "tests/Database"
}
},
- "scripts": {
- "test": [
- "phpcs --standard=phpcs.xml",
- "psalm --no-cache",
- "phpunit"
- ]
- },
"config": {
- "sort-packages": true,
"allow-plugins": {
+ "ergebnis/composer-normalize": true,
"infection/extension-installer": true
+ },
+ "audit": {
+ "abandoned": "report"
+ },
+ "platform": {
+ "php": "8.1.26"
+ },
+ "sort-packages": true
+ },
+ "extra": {
+ "composer-normalize": {
+ "indent-size": 4,
+ "indent-style": "space"
}
},
- "minimum-stability": "dev",
- "prefer-stable": true
+ "scripts": {
+ "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots",
+ "cs:fix": "php vendor/bin/php-cs-fixer fix -v",
+ "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github",
+ "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github",
+ "psalm": "php vendor/bin/psalm",
+ "psalm:baseline:update": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml",
+ "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4",
+ "test": "php vendor/bin/phpunit --colors=always",
+ "test:cc": "php vendor/bin/phpunit --colors=always --coverage",
+ "test:mysql": "php vendor/bin/phpunit --colors=always --group=driver-mysql",
+ "test:pgsql": "php vendor/bin/phpunit --colors=always --group=driver-postgres",
+ "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite"
+ }
}
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 00000000..6f970381
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,77 @@
+---
+
+version: '3.9'
+
+services:
+ app:
+ image: wayofdev/php-dev:8.2-cli-alpine-latest
+ container_name: ${COMPOSE_PROJECT_NAME}-app
+ restart: on-failure
+ networks:
+ - default
+ volumes:
+ - ./:/app:rw
+ - ~/.composer:/.composer
+ env_file:
+ - .env
+
+ sqlserver:
+ image: mcr.microsoft.com/mssql/server:2022-latest
+ platform: linux/amd64
+ container_name: ${COMPOSE_PROJECT_NAME}-sqlserver
+ restart: on-failure
+ networks:
+ - default
+ ports:
+ - '${DB_SQLSERVER_FORWARD_PORT:-11433}:1433'
+ environment:
+ SA_PASSWORD: ${DB_PASSWORD}
+ ACCEPT_EULA: 'Y'
+
+ mysql:
+ image: mysql:latest
+ container_name: ${COMPOSE_PROJECT_NAME}-mysql
+ restart: on-failure
+ networks:
+ - default
+ ports:
+ - '${DB_MYSQL_FORWARD_PORT:-13306}:3306'
+ env_file:
+ - .env
+ environment:
+ MYSQL_ROOT_HOST: '%'
+ MYSQL_USER: ${DB_USERNAME}
+ MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
+ MYSQL_DATABASE: ${DB_DATABASE}
+ volumes:
+ - mysql-data:/var/lib/mysql:cached
+ command: --default-authentication-plugin=mysql_native_password
+
+ pgsql:
+ image: wayofdev/postgres:15-alpine-latest
+ container_name: ${COMPOSE_PROJECT_NAME}-pgsql
+ restart: on-failure
+ networks:
+ - default
+ ports:
+ - '${DB_PGSQL_FORWARD_PORT:-15432}:5432'
+ env_file:
+ - .env
+ environment:
+ POSTGRES_USER: ${DB_USERNAME}
+ POSTGRES_PASSWORD: ${DB_PASSWORD}
+ POSTGRES_DB: ${DB_DATABASE}
+ volumes:
+ - pgsql-data:/var/lib/postgresql/data:cached
+
+volumes:
+ pgsql-data:
+ name: ${COMPOSE_PROJECT_NAME}-pgsql-data
+ mysql-data:
+ name: ${COMPOSE_PROJECT_NAME}-mysql-data
+
+networks:
+ default:
+ name: project.${COMPOSE_PROJECT_NAME}
+
+...
diff --git a/infection.json.dist b/infection.json.dist
index e2767669..ea28d9c3 100644
--- a/infection.json.dist
+++ b/infection.json.dist
@@ -15,5 +15,7 @@
"mutators": {
"@default": true,
"@function_signature": false
- }
+ },
+ "testFramework":"phpunit",
+ "testFrameworkOptions": "--group=driver-sqlite"
}
diff --git a/phpunit.xml b/phpunit.xml
index fe94c277..904ec5b5 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,16 +1,12 @@
@@ -18,7 +14,7 @@
-
+
./tests/
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
new file mode 100644
index 00000000..43d9e57a
--- /dev/null
+++ b/psalm-baseline.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/psalm.xml b/psalm.xml
index cee9b773..b3ac1541 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -7,21 +7,24 @@
findUnusedBaselineEntry="true"
findUnusedCode="false"
hoistConstants="true"
- resolveFromConfigFile="true"
findUnusedPsalmSuppress="true"
findUnusedVariablesAndParams="true"
ensureArrayStringOffsetsExist="true"
addParamDefaultToDocblockType="true"
+ errorBaseline="psalm-baseline.xml"
>
-
-
-
+
+
+
-
+
-
+
+
+
+
diff --git a/src/Driver/PDOStatementInterface.php b/src/Driver/PDOStatementInterface.php
index 7a02409e..f6e1b36c 100644
--- a/src/Driver/PDOStatementInterface.php
+++ b/src/Driver/PDOStatementInterface.php
@@ -12,7 +12,6 @@
namespace Cycle\Database\Driver;
use IteratorAggregate;
-use JetBrains\PhpStorm\ArrayShape;
use PDO;
use PDOStatement;
use stdClass;
@@ -64,7 +63,9 @@ public function fetchObject(string|null $class = stdClass::class, array $constru
public function errorCode(): ?string;
- #[ArrayShape([0 => 'string', 1 => 'int', 2 => 'string'])]
+ /**
+ * @return array{0:non-empty-string, 1:positive-int, 2:non-empty-string}
+ */
public function errorInfo(): array;
public function setAttribute(int $attribute, mixed $value): bool;
diff --git a/tests/Database/Stub/Driver/TestPDOStatement.php b/tests/Database/Stub/Driver/TestPDOStatement.php
index 08701852..de1df349 100644
--- a/tests/Database/Stub/Driver/TestPDOStatement.php
+++ b/tests/Database/Stub/Driver/TestPDOStatement.php
@@ -6,7 +6,6 @@
use Closure;
use Cycle\Database\Driver\PDOStatementInterface;
-use JetBrains\PhpStorm\ArrayShape;
use PDO;
use stdClass;
use Traversable;
@@ -96,7 +95,9 @@ public function errorCode(): ?string
return $this->statement->errorCode(...\func_get_args());
}
- #[ArrayShape([0 => 'string', 1 => 'int', 2 => 'string'])]
+ /**
+ * @return array{0:non-empty-string, 1:positive-int, 2:non-empty-string}
+ */
public function errorInfo(): array
{
return $this->statement->errorInfo(...\func_get_args());
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index f86ea148..c6da8ce4 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -20,21 +20,21 @@
),
'mysql' => new Database\Config\MySQLDriverConfig(
connection: new Database\Config\MySQL\TcpConnectionConfig(
- database: 'spiral',
- host: '127.0.0.1',
- port: 13306,
- user: 'root',
- password: 'root',
+ database: env('DB_DATABASE', 'spiral'),
+ host: 'mysql',
+ port: 3306,
+ user: env('DB_USER', 'root'),
+ password: env('DB_PASSWORD', 'root'),
),
queryCache: true
),
'postgres' => new Database\Config\PostgresDriverConfig(
connection: new Database\Config\Postgres\TcpConnectionConfig(
- database: 'spiral',
- host: '127.0.0.1',
- port: 15432,
- user: 'postgres',
- password: 'postgres',
+ database: env('DB_DATABASE', 'spiral'),
+ host: 'pgsql',
+ port: 5432,
+ user: env('DB_USER', 'postgres'),
+ password: env('DB_PASSWORD', 'postgres'),
),
schema: 'public',
queryCache: true,
@@ -42,10 +42,10 @@
'sqlserver' => new Database\Config\SQLServerDriverConfig(
connection: new Database\Config\SQLServer\TcpConnectionConfig(
database: 'tempdb',
- host: '127.0.0.1',
- port: 11433,
+ host: 'sqlserver',
+ port: 1433,
user: 'SA',
- password: 'SSpaSS__1'
+ password: env('DB_PASSWORD', 'SSpaSS__1')
),
queryCache: true
),
@@ -56,11 +56,11 @@
),
'postgres-mock' => new Database\Config\PostgresDriverConfig(
connection: new Database\Config\Postgres\TcpConnectionConfig(
- database: 'spiral',
- host: '127.0.0.1',
- port: 15432,
- user: 'postgres',
- password: 'postgres',
+ database: env('DB_DATABASE', 'spiral'),
+ host: 'pgsql',
+ port: 5432,
+ user: env('DB_USER', 'postgres'),
+ password: env('DB_PASSWORD', 'postgres'),
),
schema: 'public',
driver: Database\Tests\Stub\Driver\PostgresWrapDriver::class,
@@ -68,11 +68,11 @@
),
'mysql-mock' => new Database\Config\MySQLDriverConfig(
connection: new Database\Config\MySQL\TcpConnectionConfig(
- database: 'spiral',
- host: '127.0.0.1',
- port: 13306,
- user: 'root',
- password: 'root',
+ database: env('DB_DATABASE', 'spiral'),
+ host: 'mysql',
+ port: 3306,
+ user: env('DB_USER', 'root'),
+ password: env('DB_PASSWORD', 'root'),
),
driver: Database\Tests\Stub\Driver\MysqlWrapDriver::class,
queryCache: true,
@@ -80,10 +80,10 @@
'sqlserver-mock' => new Database\Config\SQLServerDriverConfig(
connection: new Database\Config\SQLServer\TcpConnectionConfig(
database: 'tempdb',
- host: '127.0.0.1',
- port: 11433,
+ host: 'sqlserver',
+ port: 1433,
user: 'SA',
- password: 'SSpaSS__1'
+ password: env('DB_PASSWORD', 'SSpaSS__1')
),
driver: Database\Tests\Stub\Driver\MSSQLWrapDriver::class,
queryCache: true,
diff --git a/tests/helpers.php b/tests/helpers.php
new file mode 100644
index 00000000..f3cadd11
--- /dev/null
+++ b/tests/helpers.php
@@ -0,0 +1,21 @@
+