Skip to content

Commit 1123d45

Browse files
committed
CS
1 parent 79cfe49 commit 1123d45

File tree

9 files changed

+38
-10
lines changed

9 files changed

+38
-10
lines changed

benchmarks/run-benchmarks.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Forrest79\PhPgSql\Benchmarks;
55

6-
foreach ((array) \glob(__DIR__ . '/*Benchmark.php') as $benchmarkFile) {
6+
$benchmarkFiles = \glob(__DIR__ . '/*Benchmark.php');
7+
assert(is_array($benchmarkFiles));
8+
9+
foreach ($benchmarkFiles as $benchmarkFile) {
710
require $benchmarkFile;
811
}

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"ext-pgsql": "^8.1"
1616
},
1717
"require-dev": {
18-
"forrest79/phpcs": "^1.6",
18+
"forrest79/phpcs": "^1.7",
1919
"forrest79/phpcs-ignores": "^0.5",
2020
"forrest79/phpgsql-phpstan": "^1.7",
2121
"nette/tester": "^2.5",
2222
"phpstan/phpstan": "^1.11",
23-
"phpstan/phpstan-strict-rules": "^1.6"
23+
"phpstan/phpstan-strict-rules": "^1.6",
24+
"shipmonk/phpstan-rules": "^3.2"
2425
},
2526
"suggest": {
2627
"ext-json": "Needed to support parse JSON types from PostgreSQL"

phpcs.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0"?>
22
<ruleset name="PhpFpmRequest">
3-
<rule ref="./vendor/forrest79/phpcs/Forrest79CodingStandard/ruleset.xml"/>
3+
<rule ref="./vendor/forrest79/phpcs/Forrest79CodingStandard/ruleset.xml">
4+
<exclude name="SlevomatCodingStandard.TypeHints.ClassConstantTypeHint.MissingNativeTypeHint"/><!-- PHP 8.3+ -->
5+
</rule>
46

57
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
68
<properties>

phpstan.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
includes:
22
- %rootDir%/conf/bleedingEdge.neon
33
- %rootDir%/../phpstan-strict-rules/rules.neon
4+
- %rootDir%/../../../vendor/shipmonk/phpstan-rules/rules.neon
45
- %rootDir%/../../forrest79/phpgsql-phpstan/extension.neon
56

67
parameters:
78
level: max
89

10+
shipmonkRules:
11+
forbidCheckedExceptionInCallable:
12+
enabled: false
13+
forbidCheckedExceptionInYieldingMethod:
14+
enabled: false
15+
forbidUnsafeArrayKey:
16+
enabled: false
17+
forbidUnsetClassField:
18+
enabled: false
19+
forbidVariableTypeOverwriting:
20+
enabled: false
21+
uselessPrivatePropertyNullability:
22+
enabled: false
23+
924
ignoreErrors:
1025
# === This is OK ===
1126

@@ -47,6 +62,11 @@ parameters:
4762
path: %rootDir%/../../../tests/Integration/FetchMutatorTest.php
4863
count: 28
4964

65+
-
66+
message: '#^Using \+ over non-number \(mixed \+ int\)$#'
67+
path: %rootDir%/../../../tests/Integration/FetchMutatorTest.php
68+
count: 3
69+
5070
-
5171
message: '#^Expression ".+" on a separate line does not do anything\.$#'
5272
path: %rootDir%/../../../tests/Integration/FetchTest.php

src/Db/DataTypeParsers/Basic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public function parse(string $type, string|NULL $value): mixed
3333
case '_date':
3434
return $this->parseArray($value, [$this, 'parseDate']);
3535
case '_timestamp':
36-
return $this->parseArray($value, function ($value): \DateTimeImmutable {
36+
return $this->parseArray($value, function (string $value): \DateTimeImmutable {
3737
return $this->parseTimestamp(\trim($value, '"'));
3838
});
3939
case '_timestamptz':
40-
return $this->parseArray($value, function ($value): \DateTimeImmutable {
40+
return $this->parseArray($value, function (string $value): \DateTimeImmutable {
4141
return $this->parseTimestampTz(\trim($value, '"'));
4242
});
4343
case '_time':

src/Db/PreparedStatementHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected static function prepareQuery(string $query): string
3838

3939
return (string) \preg_replace_callback(
4040
'/([\\\\]?)\?/',
41-
static function ($matches) use (&$paramIndex): string {
41+
static function (array $matches) use (&$paramIndex): string {
4242
if ($matches[1] === '\\') {
4343
return '?';
4444
}
@@ -56,7 +56,7 @@ static function ($matches) use (&$paramIndex): string {
5656
*/
5757
protected static function prepareParams(array $params): array
5858
{
59-
return \array_map(static function ($value) {
59+
return \array_map(static function (mixed $value): mixed {
6060
if (\is_bool($value)) {
6161
return $value ? 'TRUE' : 'FALSE';
6262
}

src/Db/Sql/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private static function prepareQuery(string $sql, array $params, int $paramIndex
6262

6363
$sql = \preg_replace_callback(
6464
'/([\\\\]?)\?/',
65-
static function ($matches) use (&$params, &$parsedParams, &$origParamIndex, &$paramIndex): string {
65+
static function (array $matches) use (&$params, &$parsedParams, &$origParamIndex, &$paramIndex): string {
6666
if ($matches[1] === '\\') {
6767
return '?';
6868
}

tests/Integration/DocsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function testDocs(string $filename, string $source): void
6262
$source,
6363
);
6464

65+
assert(is_string($source));
66+
6567
\file_put_contents($tempFile, '<?php declare(strict_types=1);' . \PHP_EOL . \PHP_EOL . $source);
6668

6769
echo 'Source file: ' . $tempFile . \PHP_EOL;

tests/Integration/PreparedStatementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testQueryEvent(): void
8888
$preparedStatement = $this->connection->prepareStatement('SELECT pg_sleep(1)');
8989
$preparedStatement->execute();
9090

91-
Tester\Assert::true($queryDuration > 0);
91+
Tester\Assert::true(($queryDuration ?? 0) > 0);
9292
Tester\Assert::same('phpgsql1', $queryPrapareStatementName);
9393
}
9494

0 commit comments

Comments
 (0)