Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit 1def426

Browse files
committed
Require PHP 8
1 parent 868f09b commit 1def426

8 files changed

Lines changed: 20 additions & 18 deletions

File tree

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
"license": "MIT",
1414
"require-dev": {
1515
"friendsofphp/php-cs-fixer": "^3",
16-
"overtrue/phplint": "^2.3",
17-
"phpstan/phpstan": "0.*",
16+
"phpstan/phpstan": "^1",
1817
"phpunit/phpunit": "^9 || ^10",
19-
"squizlabs/php_codesniffer": "^3.5"
18+
"squizlabs/php_codesniffer": "^3"
2019
},
2120
"require": {
2221
"php": "^8.0",
@@ -39,15 +38,11 @@
3938
"scripts": {
4039
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi",
4140
"cs:fix": "php-cs-fixer fix --config=.cs.php --ansi",
42-
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache --ansi",
43-
"phoenix": "phoenix --ansi",
44-
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi --xdebug",
45-
"schema:dump": "php bin/console.php schema-dump --ansi",
4641
"sniffer:check": "phpcs --standard=phpcs.xml",
4742
"sniffer:fix": "phpcbf --standard=phpcs.xml",
43+
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi --xdebug",
4844
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
4945
"test:all": [
50-
"@lint",
5146
"@cs:check",
5247
"@sniffer:check",
5348
"@stan",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parameters:
22
level: max
33
checkGenericClassInNonGenericObjectType: false
44
checkMissingIterableValueType: false
5+
treatPhpDocTypesAsCertain: false
56
paths:
67
- src
78
- tests

src/Condition.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public function getConditionSql(array $sql, array $where, string $conditionType)
107107
*
108108
* https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html
109109
*
110-
* @param mixed $rightField The right field
111-
* @param mixed $comparison The comparison
110+
* @param string|array $rightField The right field
111+
* @param string|mixed $comparison The comparison
112112
*
113113
* @return array The value
114114
*/
@@ -132,6 +132,7 @@ private function getRightFieldValue($rightField, $comparison): array
132132
$comparison = 'IS NOT';
133133
$rightField = $this->quoter->quoteValue($rightField);
134134
} elseif ($comparison === 'between' || $comparison === 'not between') {
135+
/** @var array $rightField */
135136
$between1 = $this->quoter->quoteValue($rightField[0]);
136137
$between2 = $this->quoter->quoteValue($rightField[1]);
137138
$rightField = sprintf('%s AND %s', $between1, $between2);
@@ -141,6 +142,7 @@ private function getRightFieldValue($rightField, $comparison): array
141142
$rightField = $this->quoter->quoteValue($rightField);
142143
}
143144

145+
// @phpstan-ignore-next-line
144146
return [$rightField, strtoupper($comparison)];
145147
}
146148

src/InsertQuery.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ public function build(): string
212212
public function lastInsertId(string $name = null): string
213213
{
214214
if ($name === null) {
215-
return $this->pdo->lastInsertId();
215+
return $this->pdo->lastInsertId() ?: '0';
216216
}
217217

218-
return $this->pdo->lastInsertId($name);
218+
return $this->pdo->lastInsertId($name) ?: '0';
219219
}
220220

221221
/**
@@ -230,7 +230,7 @@ public function insertGetId(array $values): string
230230
$stmt = $this->set($values)->prepare();
231231
$stmt->execute();
232232

233-
return $this->pdo->lastInsertId();
233+
return $this->lastInsertId();
234234
}
235235

236236
/**

src/Operator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ final class Operator
1818
public const LTE = '<=';
1919
public const IS = 'is';
2020
public const IS_NOT = 'is not';
21-
//public const IS_NOT_NULL = 'is not null';
2221
public const LIKE = 'like';
2322
public const NOT_LIKE = 'not like';
2423
public const SOUNDS_LIKE = 'sounds like';

src/Quoter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use PDO;
66
use RuntimeException;
7+
use UnexpectedValueException;
8+
79
use function array_key_first;
810

911
/**
@@ -65,10 +67,11 @@ public function quoteValue($value): string
6567
return 'NULL';
6668
}
6769

68-
$result = $this->pdo->quote($value);
70+
// @phpstan-ignore-next-line
71+
$result = $this->pdo->quote((string)$value);
6972

7073
if (!is_string($result)) {
71-
throw new RuntimeException('The database driver does not support quoting in this way.');
74+
throw new UnexpectedValueException('The database driver does not support quoting in this way.');
7275
}
7376

7477
return $result;

src/UpdateQuery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ final class UpdateQuery implements QueryInterface
5656
private $orderBy = [];
5757

5858
/**
59-
* @var int Limit
59+
* @var int|null Limit
6060
*/
61-
private $limit;
61+
private $limit = null;
6262

6363
/**
6464
* Constructor.

tests/ConnectionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function testPrepareQuery(): void
3636
$statement = $select->prepare();
3737

3838
$statement->execute();
39+
40+
/** @var array $row */
3941
$row = $statement->fetch(PDO::FETCH_ASSOC);
4042

4143
$this->assertNotEmpty($row['TABLE_NAME']);

0 commit comments

Comments
 (0)