Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
============
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
37 changes: 21 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 8
paths:
- src
2 changes: 1 addition & 1 deletion src/Bindings/Bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Bindings/MySQL/MySQLDateTimeBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/Bindings/MySQL/MySQLLogicBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand All @@ -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.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bindings/MySQL/MySQLNumericBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Bindings/NumericBindingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading