diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e59e15a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: CI + +on: + push: + branches: [release] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + tests: + name: Tests (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3', '8.4', '8.5'] + services: + mysql: + image: mysql:8.4 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: glpdo2 + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping -h 127.0.0.1 -proot" + --health-interval=5s + --health-timeout=5s + --health-retries=20 + env: + MYSQLHOST: 127.0.0.1 + MYSQLDB: glpdo2 + MYSQLUSER: root + MYSQLPASS: root + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - uses: ramsey/composer-install@v3 + with: + dependency-versions: highest + + - run: vendor/bin/phpunit + + quality: + name: PHPStan & PSR-12 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + coverage: none + + - uses: ramsey/composer-install@v3 + + - run: composer phpstan + - run: composer phpcs diff --git a/README.md b/README.md index 2d4e12c..0172206 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![License: BSD](https://img.shields.io/badge/License-BSD-yellow.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![phpstan enabled](https://img.shields.io/badge/phpstan-enabled-green.svg)](https://github.com/phpstan/phpstan) -[![Build Status](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/badges/build.png?b=release)](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/build-status/) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/badges/quality-score.png?b=release)](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/?branch=release) -[![Code Coverage](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/badges/coverage.png?b=release)](https://scrutinizer-ci.com/g/ellisgl/GeekLab-GLPDO2/?branch=release) +[![CI](https://github.com/ellisgl/GeekLab-GLPDO2/actions/workflows/ci.yml/badge.svg)](https://github.com/ellisgl/GeekLab-GLPDO2/actions/workflows/ci.yml) +[![Packagist Version](https://img.shields.io/packagist/v/geeklab/glpdo2)](https://packagist.org/packages/geeklab/glpdo2) +[![PHP Version](https://img.shields.io/packagist/dependency-v/geeklab/glpdo2/php)](https://packagist.org/packages/geeklab/glpdo2) +[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen)](https://phpstan.org/) +[![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD--3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) GeekLab\GLPDO2 ============ diff --git a/composer.json b/composer.json index ac5d1ae..73dd4a6 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,12 @@ "require-dev" : { "phpunit/phpunit" : "^9", "squizlabs/php_codesniffer": "^3.7", - "phpstan/phpstan": "^1.9", + "phpstan/phpstan": "^2", "phpmd/phpmd": "^2.13" }, "scripts": { "test": "phpunit", - "phpstan": "phpstan analyse src --level=7", + "phpstan": "phpstan analyse --no-progress", "phpcs" : "phpcs src/ --standard=PSR12 -n" } } diff --git a/composer.lock b/composer.lock index 7f4e37d..92c248f 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": "58f83b0144e075728541bf1d049cf06f", + "content-hash": "38890f41707ad307fe2fa41006a84453", "packages": [], "packages-dev": [ { @@ -592,20 +592,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.9.2", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa" - }, + "version": "2.3.7", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa", - "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/90c91c2498849ab8cc4e873864bbf1cb2bf6ea12", + "reference": "90c91c2498849ab8cc4e873864bbf1cb2bf6ea12", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -624,14 +619,28 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], "description": "PHPStan - PHP Static Analysis Tool", "keywords": [ "dev", "static analysis" ], "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.9.2" + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { @@ -641,13 +650,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2022-11-10T09:56:11+00:00" + "time": "2026-11-19T10:31:11+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..1ff472c --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 8 + paths: + - src diff --git a/src/Bindings/Bindings.php b/src/Bindings/Bindings.php index c3954e0..d08b796 100644 --- a/src/Bindings/Bindings.php +++ b/src/Bindings/Bindings.php @@ -93,7 +93,7 @@ public function bDateTime(?string $value = null, bool $null = false): array * @param int $decimals * @param bool $null * - * @return array{?string} + * @return array{string} * @throws Exception */ public function bFloat(float | int | string | null $value = null, int $decimals = 3, bool $null = false): array diff --git a/src/Bindings/MySQL/MySQLDateTimeBindings.php b/src/Bindings/MySQL/MySQLDateTimeBindings.php index bf04f42..8de71c6 100644 --- a/src/Bindings/MySQL/MySQLDateTimeBindings.php +++ b/src/Bindings/MySQL/MySQLDateTimeBindings.php @@ -65,7 +65,7 @@ public function bDateTime(?string $value = null, bool $null = false): array return [null, PDO::PARAM_NULL]; } - if ($isDateTime === 0 && $value !== null) { + if ($isDateTime === 0) { // $value is not a valid date string, set to the earliest date time available (GMT). // Or $value is a valid date string, add midnight time. $value = preg_match(self::DATE_REGEX, $value) === 0 ? '1970-01-01 00:00:00' : $value . ' 00:00:00'; diff --git a/src/Bindings/MySQL/MySQLLogicBindings.php b/src/Bindings/MySQL/MySQLLogicBindings.php index a90d2b5..0f2ac42 100644 --- a/src/Bindings/MySQL/MySQLLogicBindings.php +++ b/src/Bindings/MySQL/MySQLLogicBindings.php @@ -24,7 +24,7 @@ public function bBool(bool | int | null $value = null, bool $null = false): arra return [null, PDO::PARAM_NULL]; } - if ($value === null && $null === false) { + if ($value === null) { throw new InvalidArgumentException('Can not bind NULL in boolean spot.'); } @@ -47,7 +47,7 @@ public function bBoolInt(bool | int | null $value = null, bool $null = false): a return [null, PDO::PARAM_NULL]; } - if ($value === null && $null === false) { + if ($value === null) { throw new InvalidArgumentException('Can not bind NULL in boolean spot.'); } diff --git a/src/Bindings/MySQL/MySQLNumericBindings.php b/src/Bindings/MySQL/MySQLNumericBindings.php index b309c2e..7f3ece6 100644 --- a/src/Bindings/MySQL/MySQLNumericBindings.php +++ b/src/Bindings/MySQL/MySQLNumericBindings.php @@ -15,7 +15,7 @@ class MySQLNumericBindings implements NumericBindingInterface * @param int $decimals * @param bool $null * - * @return array{?string} + * @return array{string} * @throws InvalidArgumentException */ public function bFloat(float | int | string | null $value = null, int $decimals = 3, bool $null = false): array diff --git a/src/Bindings/NumericBindingInterface.php b/src/Bindings/NumericBindingInterface.php index dd30927..1c81dee 100644 --- a/src/Bindings/NumericBindingInterface.php +++ b/src/Bindings/NumericBindingInterface.php @@ -13,7 +13,7 @@ interface NumericBindingInterface * @param int $decimals * @param bool $null * - * @return array{?string} + * @return array{string} * @throws Exception */ public function bFloat(float | int | string | null $value = null, int $decimals = 3, bool $null = false): array;