Skip to content

Commit 0b6d95e

Browse files
TomasVotrubastaabm
andauthored
Allow PHP 7.2 (#511)
Co-authored-by: Markus Staab <[email protected]>
1 parent ff4eac0 commit 0b6d95e

9 files changed

+81
-41
lines changed

.github/workflows/php-linter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP Linter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
10+
jobs:
11+
php-linter:
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.draft == false
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
19+
ref: ${{ github.event.client_payload.pull_request.head.ref }}
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: 7.2
25+
coverage: none # disable xdebug, pcov
26+
27+
- name: Composer install
28+
uses: ramsey/composer-install@v2
29+
with:
30+
composer-options: --ansi --prefer-dist
31+
32+
- name: Lint PHP
33+
run: vendor/bin/parallel-lint src tests config

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"keywords": ["dev", "phpstan", "phpstan-extension", "static analysis", "database access layer", "code quality"],
66
"require": {
7-
"php": "^7.3 || ^8.0",
7+
"php": "^7.2 || ^8.0",
88
"composer-runtime-api": "^2.0",
99
"composer/semver": "^3.2",
1010
"phpstan/phpstan": "^1.5.6"
@@ -13,14 +13,14 @@
1313
"ext-mysqli": "*",
1414
"ext-pdo": "*",
1515
"dibi/dibi": "^4.2",
16-
"doctrine/dbal": "^3.2",
16+
"doctrine/dbal": "^2.13|^3.0",
1717
"friendsofphp/php-cs-fixer": "3.4.0",
1818
"php-parallel-lint/php-parallel-lint": "^1.3",
1919
"phpstan/extension-installer": "^1.2",
2020
"phpstan/phpstan-php-parser": "^1.1",
2121
"phpstan/phpstan-phpunit": "^1.0",
2222
"phpstan/phpstan-strict-rules": "^1.1",
23-
"phpunit/phpunit": "^9",
23+
"phpunit/phpunit": "^8.5|^9.5",
2424
"tomasvotruba/unused-public": "^0.0.34",
2525
"vlucas/phpdotenv": "^5.4"
2626
},

src/Extensions/MysqliQueryDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function inferResultType(Expr $queryExpr, Scope $scope): ?Type
133133
if (!QueryReflection::getRuntimeConfiguration()->throwsMysqliExceptions($this->phpVersion)) {
134134
return TypeCombinator::union(
135135
$resultType,
136-
new ConstantBooleanType(false),
136+
new ConstantBooleanType(false)
137137
);
138138
}
139139

src/Extensions/PdoQueryDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
5050
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
5151
$scope,
5252
$methodCall->getArgs(),
53-
$methodReflection->getVariants(),
53+
$methodReflection->getVariants()
5454
)->getReturnType();
5555

5656
if (QueryReflection::getRuntimeConfiguration()->throwsPdoExceptions($this->phpVersion)) {

src/QueryReflection/PdoPgSqlQueryReflector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ protected function checkInformationSchema(string $tableName): Iterator
106106
{
107107
if (null === $this->stmt) {
108108
$this->stmt = $this->pdo->prepare(
109-
<<<'PSQL'
109+
<<<'PSQL'
110110
SELECT column_name, column_default, is_nullable
111111
FROM information_schema.columns
112112
WHERE table_name = ?
113-
PSQL
113+
PSQL
114114
);
115115
}
116116

tests/ReflectorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function create(string $cacheDir): QueryReflector
4444
$cacheFile = sprintf(
4545
'%s/.phpunit-phpstan-dba-%s.cache',
4646
$cacheDir,
47-
$reflector,
47+
$reflector
4848
);
4949
if (\defined('__PHPSTAN_RUNNING__')) {
5050
$cacheFile = $cacheDir.'/.phpstan-dba-'.$reflector.'.cache';

tests/rules/SyntaxErrorInPreparedStatementMethodSubclassedRuleTest.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,28 @@ public function getExpectedErrors(): array
6262
return [
6363
[
6464
<<<TEXT
65-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "with"
66-
LINE 1: SELECT with syntax error GROUPY by x LIMIT 0
67-
^ (42601).
68-
TEXT,
65+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "with"
66+
LINE 1: SELECT with syntax error GROUPY by x LIMIT 0
67+
^ (42601).
68+
TEXT,
6969
12,
7070
],
7171
[
72-
<<<TEXT
73-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
74-
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
75-
^ (42601).
76-
TEXT,
72+
<<<'TEXT'
73+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
74+
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
75+
^ (42601).
76+
TEXT
77+
,
7778
18,
7879
],
7980
[
8081
<<<TEXT
81-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM"
82-
LINE 3: FROM ada LIMIT 0
83-
^ (42601).
84-
TEXT,
82+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM"
83+
LINE 3: FROM ada LIMIT 0
84+
^ (42601).
85+
TEXT
86+
,
8587
20,
8688
],
8789
];

tests/rules/SyntaxErrorInQueryFunctionRuleTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,29 @@ public function getExpectedErrors(): array
6262
return [
6363
[
6464
<<<TEXT
65-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
66-
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
67-
^ (42601).
68-
TEXT,
65+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
66+
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
67+
^ (42601).
68+
TEXT
69+
,
6970
9,
7071
],
7172
[
7273
<<<TEXT
73-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
74-
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
75-
^ (42601).
76-
TEXT,
74+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
75+
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
76+
^ (42601).
77+
TEXT
78+
,
7779
19,
7880
],
7981
[
8082
<<<TEXT
81-
Query error: SQLSTATE[42703]: Undefined column: 7 ERROR: column "asdsa" does not exist
82-
LINE 1: ...mail, adaid, gesperrt, freigabe1u1 FROM ada WHERE asdsa=1 LI...
83-
^ (42703).
84-
TEXT,
83+
Query error: SQLSTATE[42703]: Undefined column: 7 ERROR: column "asdsa" does not exist
84+
LINE 1: ...mail, adaid, gesperrt, freigabe1u1 FROM ada WHERE asdsa=1 LI...
85+
^ (42703).
86+
TEXT
87+
,
8588
39,
8689
],
8790
];

tests/rules/SyntaxErrorInQueryMethodSubclassedRuleTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,20 @@ public function getExpectedErrors(): array
5858
return [
5959
[
6060
<<<TEXT
61-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "with"
62-
LINE 1: SELECT with syntax error GROUPY by x LIMIT 0
63-
^ (42601).
64-
TEXT,
61+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "with"
62+
LINE 1: SELECT with syntax error GROUPY by x LIMIT 0
63+
^ (42601).
64+
TEXT
65+
,
6566
12,
6667
],
6768
[
6869
<<<TEXT
69-
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
70-
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
71-
^ (42601).
72-
TEXT,
70+
Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "freigabe1u1"
71+
LINE 1: SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada LIMIT...
72+
^ (42601).
73+
TEXT
74+
,
7375
18,
7476
],
7577
];

0 commit comments

Comments
 (0)