From 0f6ff4fc652c0745610eb85a1bb813cc80caceff Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 3 Sep 2022 00:19:01 +0900 Subject: [PATCH 1/2] PHPStan 1.8.3 --- tools/.phpstan/composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/.phpstan/composer.json b/tools/.phpstan/composer.json index 8d0083e..4e6f70d 100644 --- a/tools/.phpstan/composer.json +++ b/tools/.phpstan/composer.json @@ -1,8 +1,8 @@ { "require": { - "phpstan/phpstan": "^1.7", + "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.2" + "phpstan/phpstan-strict-rules": "^1.4" }, "config": { "optimize-autoloader": true, From e47771abcb5023235b4fd854cacc2ef08db7d316 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sat, 3 Sep 2022 01:12:09 +0900 Subject: [PATCH 2/2] Fix @int[] type to accept 0 --- src/Replacer/Placeholder.php | 2 +- tests/Replacer/PlaceholderTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Replacer/Placeholder.php b/src/Replacer/Placeholder.php index 121236a..ecbb24e 100644 --- a/src/Replacer/Placeholder.php +++ b/src/Replacer/Placeholder.php @@ -111,7 +111,7 @@ public function replaceHolder($pdo, $key, $type, $value, &$bind_values) throw new \LogicException('Validation Error.'); } - if ($value !== '0' && !\preg_match('/\A(?:-?[1-9][0-9]*)(?:,-?[1-9][0-9]*)*\z/', $valuesString)) { + if ($valuesString !== '0' && !\preg_match('/\A(?:-?[1-9][0-9]*|0)(?:,(?:-?[1-9][0-9]*|0))*\z/', $valuesString)) { throw new \DomainException(\sprintf('param "%s" must be int array', $key)); } diff --git a/tests/Replacer/PlaceholderTest.php b/tests/Replacer/PlaceholderTest.php index 20d625c..28b15be 100644 --- a/tests/Replacer/PlaceholderTest.php +++ b/tests/Replacer/PlaceholderTest.php @@ -58,8 +58,20 @@ public function acceptDataProvider() ['int', '0', 0], ['int', '9223372036854775807', 9223372036854775807], ['int', '-9223372036854775808', (int)'-9223372036854775808'], + ['int[]', [0], '0'], + ['int[]', ['0'], '0'], + ['int[]', [0, 0], '0,0'], + ['int[]', ['0', '0'], '0,0'], ['int[]', [1, 2, 3], '1,2,3'], ['int[]', ['1', '2', '3'], '1,2,3'], + ['int[]', [0, 1, 2, 3], '0,1,2,3'], + ['int[]', ['0', '1', '2', '3'], '0,1,2,3'], + ['int[]', [1, 0, 2, 3], '1,0,2,3'], + ['int[]', ['1', '0', '2', '3'], '1,0,2,3'], + ['int[]', [1, 2, 0, 3], '1,2,0,3'], + ['int[]', ['1', '2', '0', '3'], '1,2,0,3'], + ['int[]', [1, 2, 3, 0], '1,2,3,0'], + ['int[]', ['1', '2', '3', '0'], '1,2,3,0'], ['int[]', ['9223372036854775807', '-9223372036854775808'], '9223372036854775807,-9223372036854775808', @@ -99,11 +111,15 @@ public function rejeceptDataProvider() ['@piyo', null, 'unexpected type "@piyo"'], ['@ascdesc', 'foo', 'param ":key" must be "ASC", "DESC", "asc" or "desc"'], ['@int', '-0', 'param ":key" is unexpected integer notation'], + ['@int', '00', 'param ":key" is unexpected integer notation'], ['@int', '9223372036854775808', 'param ":key" is integer out of range.'], ['@int', '-9223372036854775809', 'param ":key" is integer out of range.'], ['@int[]', 0, 'param ":key" must be int array'], ['@int[]', [], 'param ":key" must be not empty int array'], ['@int[]', ['1', 'a', '3'], 'param ":key[1]" is integer out of range.'], + ['@int[]', ['00'], 'param ":key" must be int array'], + ['@int[]', ['9223372036854775808'], 'param ":key[0]" is integer out of range.'], + ['@int[]', ['-9223372036854775809'], 'param ":key[0]" is integer out of range.'], ['@string', [], 'param ":key" must be string or numeric'], ['@string[]', '', 'param ":key" must be string array'], ['@string[]', [], 'param ":key" must be not empty string array'],