Skip to content

Commit bae0f92

Browse files
authored
Merge pull request #79 from homersimpsons/fix/gh-actions
[FIX] CI - GH Actions
2 parents 3a2a552 + 3b10344 commit bae0f92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+511
-222
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
matrix:
4949
php-version:
50-
- "7.2"
50+
- "7.4"
5151

5252
services:
5353
mysql:
@@ -81,7 +81,7 @@ jobs:
8181
run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest"
8282

8383
- name: "Run PHPUnit"
84-
run: "vendor/bin/phpunit -c phpunit.mysql8.xml --coverage-clover=coverage.xml"
84+
run: "vendor/bin/phpunit --no-coverage"
8585

8686
phpunit-code-coverage:
8787
name: "PHPUnit with Code Coverage"
@@ -90,7 +90,7 @@ jobs:
9090
strategy:
9191
matrix:
9292
php-version:
93-
- "7.2"
93+
- "7.4"
9494

9595
services:
9696
mysql:
@@ -137,9 +137,7 @@ jobs:
137137
strategy:
138138
matrix:
139139
php-version:
140-
- "7.1"
141-
- "7.3"
142-
- "7.4"
140+
- "8.0"
143141

144142
services:
145143
mysql:
@@ -161,7 +159,6 @@ jobs:
161159
with:
162160
php-version: "${{ matrix.php-version }}"
163161
extensions: ""
164-
coverage: "pcov"
165162

166163
- name: "Cache dependencies installed with composer"
167164
uses: "actions/cache@v1"
@@ -174,4 +171,4 @@ jobs:
174171
run: "composer install --no-interaction --no-progress --no-suggest"
175172

176173
- name: "Run PHPUnit"
177-
run: "vendor/bin/phpunit"
174+
run: "vendor/bin/phpunit --no-coverage"

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.1.0",
16+
"php": ">=7.4.0 || ^8.0",
1717
"mouf/utils.common.conditioninterface": "~2.0",
1818
"mouf/utils.value.value-interface": "~1.0",
1919
"mouf/utils.common.paginable-interface": "~1.0",
2020
"mouf/utils.common.sortable-interface": "~1.0",
2121
"mouf/schema-analyzer": "~1.0",
2222
"twig/twig": "^2.11 || ^3",
23-
"greenlion/php-sql-parser": "^4.1.2",
23+
"greenlion/php-sql-parser": "^4.3",
2424
"doctrine/cache": "^1.5"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^7.5.10",
27+
"phpunit/phpunit": "^9.5",
2828
"satooshi/php-coveralls": "~1.0",
2929
"doctrine/dbal": "~2.5",
30-
"phpstan/phpstan": "^0.11.7"
30+
"phpstan/phpstan": "^0.12.82"
3131
},
3232
"suggest": {
3333
"doctrine/dbal": "To support more databases than just MySQL and to use MagicJoin feature",
@@ -67,6 +67,6 @@
6767
"minimum-stability": "dev",
6868
"prefer-stable": true,
6969
"scripts": {
70-
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon src"
70+
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon"
7171
}
7272
}

phpstan-baseline.neon

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Method Mouf\\\\Database\\\\QueryWriter\\\\QueryResult\\:\\:val\\(\\) should return array but returns Mouf\\\\Database\\\\QueryWriter\\\\ResultSet\\.$#"
5+
count: 1
6+
path: src/Mouf/Database/QueryWriter/QueryResult.php
7+
8+
-
9+
message: "#^Method Mouf\\\\Database\\\\QueryWriter\\\\Utils\\\\DbHelper\\:\\:getAll\\(\\) has no return typehint specified\\.$#"
10+
count: 1
11+
path: src/Mouf/Database/QueryWriter/Utils/DbHelper.php
12+
13+
-
14+
message: "#^Parameter \\#1 \\$rightOperand of method SQLParser\\\\Node\\\\AbstractInListOperator\\:\\:refactorParameterToExpression\\(\\) expects SQLParser\\\\Node\\\\NodeInterface, array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\|string given\\.$#"
15+
count: 1
16+
path: src/SQLParser/Node/AbstractInListOperator.php
17+
18+
-
19+
message: "#^Cannot access offset 0 on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\.$#"
20+
count: 1
21+
path: src/SQLParser/Node/AbstractInListOperator.php
22+
23+
-
24+
message: "#^Method SQLParser\\\\Node\\\\AbstractTwoOperandsOperator\\:\\:setLeftOperand\\(\\) has no return typehint specified\\.$#"
25+
count: 1
26+
path: src/SQLParser/Node/AbstractTwoOperandsOperator.php
27+
28+
-
29+
message: "#^Method SQLParser\\\\Node\\\\AbstractTwoOperandsOperator\\:\\:setRightOperand\\(\\) has no return typehint specified\\.$#"
30+
count: 1
31+
path: src/SQLParser/Node/AbstractTwoOperandsOperator.php
32+
33+
-
34+
message: "#^Cannot call method walk\\(\\) on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\|string\\.$#"
35+
count: 2
36+
path: src/SQLParser/Node/AbstractTwoOperandsOperator.php
37+
38+
-
39+
message: "#^Method SQLParser\\\\Node\\\\Between\\:\\:setLeftOperand\\(\\) has no return typehint specified\\.$#"
40+
count: 1
41+
path: src/SQLParser/Node/Between.php
42+
43+
-
44+
message: "#^Method SQLParser\\\\Node\\\\Between\\:\\:setMinValueOperand\\(\\) has no return typehint specified\\.$#"
45+
count: 1
46+
path: src/SQLParser/Node/Between.php
47+
48+
-
49+
message: "#^Cannot call method walk\\(\\) on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\|string\\.$#"
50+
count: 1
51+
path: src/SQLParser/Node/Between.php
52+
53+
-
54+
message: "#^Cannot call method walk\\(\\) on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\|string\\.$#"
55+
count: 1
56+
path: src/SQLParser/Node/CaseOperation.php
57+
58+
-
59+
message: "#^Cannot access offset mixed on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\.$#"
60+
count: 2
61+
path: src/SQLParser/Node/Expression.php
62+
63+
-
64+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:toObject\\(\\) has no return typehint specified\\.$#"
65+
count: 1
66+
path: src/SQLParser/Node/NodeFactory.php
67+
68+
-
69+
message: "#^Parameter \\#1 \\$refClause of method SQLParser\\\\Node\\\\SubQuery\\:\\:setRefClause\\(\\) expects array\\<SQLParser\\\\Node\\\\NodeInterface\\>, array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface given\\.$#"
70+
count: 1
71+
path: src/SQLParser/Node/NodeFactory.php
72+
73+
-
74+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:buildFromSubtree\\(\\) has no return typehint specified\\.$#"
75+
count: 1
76+
path: src/SQLParser/Node/NodeFactory.php
77+
78+
-
79+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:buildFromSubtree\\(\\) has parameter \\$subTree with no typehint specified\\.$#"
80+
count: 1
81+
path: src/SQLParser/Node/NodeFactory.php
82+
83+
-
84+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:mapArrayToNodeObjectList\\(\\) has no return typehint specified\\.$#"
85+
count: 1
86+
path: src/SQLParser/Node/NodeFactory.php
87+
88+
-
89+
message: "#^Property SQLParser\\\\Node\\\\NodeFactory\\:\\:\\$PRECEDENCE has no typehint specified\\.$#"
90+
count: 1
91+
path: src/SQLParser/Node/NodeFactory.php
92+
93+
-
94+
message: "#^Property SQLParser\\\\Node\\\\NodeFactory\\:\\:\\$OPERATOR_TO_CLASS has no typehint specified\\.$#"
95+
count: 1
96+
path: src/SQLParser/Node/NodeFactory.php
97+
98+
-
99+
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface given\\.$#"
100+
count: 1
101+
path: src/SQLParser/Node/NodeFactory.php
102+
103+
-
104+
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface given\\.$#"
105+
count: 1
106+
path: src/SQLParser/Node/NodeFactory.php
107+
108+
-
109+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:array_map_deep\\(\\) has no return typehint specified\\.$#"
110+
count: 1
111+
path: src/SQLParser/Node/NodeFactory.php
112+
113+
-
114+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:array_map_deep\\(\\) has parameter \\$array with no typehint specified\\.$#"
115+
count: 1
116+
path: src/SQLParser/Node/NodeFactory.php
117+
118+
-
119+
message: "#^Method SQLParser\\\\Node\\\\NodeFactory\\:\\:array_map_deep\\(\\) has parameter \\$callback with no typehint specified\\.$#"
120+
count: 1
121+
path: src/SQLParser/Node/NodeFactory.php
122+
123+
-
124+
message: "#^Property SQLParser\\\\Node\\\\Operator\\:\\:\\$value has no typehint specified\\.$#"
125+
count: 1
126+
path: src/SQLParser/Node/Operator.php
127+
128+
-
129+
message: "#^Method SQLParser\\\\Node\\\\Operator\\:\\:getValue\\(\\) has no return typehint specified\\.$#"
130+
count: 1
131+
path: src/SQLParser/Node/Operator.php
132+
133+
-
134+
message: "#^Method SQLParser\\\\Node\\\\Operator\\:\\:setValue\\(\\) has no return typehint specified\\.$#"
135+
count: 1
136+
path: src/SQLParser/Node/Operator.php
137+
138+
-
139+
message: "#^Strict comparison using \\=\\=\\= between mixed and null will always evaluate to false\\.$#"
140+
count: 1
141+
path: src/SQLParser/Node/Parameter.php
142+
143+
-
144+
message: "#^Argument of an invalid type array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface supplied for foreach, only iterables are supported\\.$#"
145+
count: 1
146+
path: src/SQLParser/Node/SimpleFunction.php
147+
148+
-
149+
message: "#^Cannot access offset mixed on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\.$#"
150+
count: 2
151+
path: src/SQLParser/Node/SimpleFunction.php
152+
153+
-
154+
message: "#^Cannot access offset mixed on array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\.$#"
155+
count: 2
156+
path: src/SQLParser/Node/Table.php
157+
158+
-
159+
message: "#^Elseif condition is always true\\.$#"
160+
count: 1
161+
path: src/SQLParser/Node/Table.php
162+
163+
-
164+
message: "#^Property SQLParser\\\\Node\\\\Table\\:\\:\\$refClause \\(array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface\\) does not accept null\\.$#"
165+
count: 1
166+
path: src/SQLParser/Node/Table.php
167+
168+
-
169+
message: "#^Method SQLParser\\\\Query\\\\Select\\:\\:overwriteInstanceDescriptor\\(\\) has parameter \\$name with no typehint specified\\.$#"
170+
count: 1
171+
path: src/SQLParser/Query/Select.php
172+
173+
-
174+
message: "#^Method SQLParser\\\\Query\\\\Select\\:\\:walkChildren\\(\\) has parameter \\$children with no typehint specified\\.$#"
175+
count: 1
176+
path: src/SQLParser/Query/Select.php
177+
178+
-
179+
message: "#^Argument of an invalid type array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface supplied for foreach, only iterables are supported\\.$#"
180+
count: 1
181+
path: src/SQLParser/Query/StatementFactory.php
182+
183+
-
184+
message: "#^Cannot access offset mixed on \\(array\\<SQLParser\\\\Node\\\\NodeInterface\\>&nonEmpty\\)\\|SQLParser\\\\Node\\\\NodeInterface\\.$#"
185+
count: 1
186+
path: src/SQLParser/Query/StatementFactory.php
187+
188+
-
189+
message: "#^Parameter \\#1 \\$columns of method SQLParser\\\\Query\\\\Select\\:\\:setColumns\\(\\) expects array\\<SQLParser\\\\Node\\\\NodeInterface\\>, array\\<SQLParser\\\\Node\\\\NodeInterface\\>\\|SQLParser\\\\Node\\\\NodeInterface given\\.$#"
190+
count: 1
191+
path: src/SQLParser/Query/StatementFactory.php
192+
193+
-
194+
message: "#^Method SQLParser\\\\Query\\\\Union\\:\\:overwriteInstanceDescriptor\\(\\) has parameter \\$name with no typehint specified\\.$#"
195+
count: 1
196+
path: src/SQLParser/Query/Union.php
197+

phpstan.neon

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: 7
6+
paths:
7+
- src
38
inferPrivatePropertyTypeFromConstructor: true
9+
checkMissingIterableValueType: false
10+
checkGenericClassInNonGenericObjectType: false
411
ignoreErrors:
512
- "#Mouf\\\\MoufManager#"
613
- "#Mouf\\\\MoufInstanceDescriptor#"
7-
- '#Method Mouf\\Database\\QueryWriter\\Utils\\FindParametersService::findParameters\(\) should return array<string> but returns array<int, int\|string>#'
14+
- '#Method Mouf\\Database\\QueryWriter\\Utils\\FindParametersService::findParameters\(\) should return array<string> but returns array<int, int\|string>#'

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
>
1313

1414
<php>
15-
<var name="db_host" value="localhost" />
15+
<var name="db_host" value="127.0.0.1" />
16+
<var name="db_port" value="3306"/>
1617
<var name="db_username" value="root" />
1718
<var name="db_password" value="" />
1819
<var name="db_driver" value="pdo_mysql"/>

src/Mouf/Database/MagicQuery.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Mouf\Database;
44

5+
use Doctrine\Common\Cache\Cache;
56
use Doctrine\DBAL\Connection;
67
use Doctrine\DBAL\Platforms\AbstractPlatform;
78
use Doctrine\DBAL\Platforms\MySqlPlatform;
@@ -34,21 +35,20 @@
3435
class MagicQuery
3536
{
3637
private $connection;
38+
/** @var Cache */
3739
private $cache;
40+
/** @var SchemaAnalyzer */
3841
private $schemaAnalyzer;
39-
/**
40-
* @var AbstractPlatform
41-
*/
42+
/** @var AbstractPlatform */
4243
private $platform;
43-
/**
44-
* @var Environment
45-
*/
44+
/** @var Environment */
4645
private $twigEnvironment;
46+
/** @var bool */
4747
private $enableTwig = false;
4848

4949
/**
5050
* @param \Doctrine\DBAL\Connection $connection
51-
* @param \Doctrine\Common\Cache\Cache $cache
51+
* @param Cache $cache
5252
* @param SchemaAnalyzer $schemaAnalyzer (optional). If not set, it is initialized from the connection.
5353
*/
5454
public function __construct($connection = null, $cache = null, SchemaAnalyzer $schemaAnalyzer = null)
@@ -205,11 +205,9 @@ public function toSql(NodeInterface $sqlNode, array $parameters = array(), bool
205205
/**
206206
* Scans the SQL statement and replaces the "magicjoin" part with the correct joins.
207207
*
208-
* @param NodeInterface $select
209-
*
210208
* @throws MagicQueryMissingConnectionException
211209
*/
212-
private function magicJoin(NodeInterface $select)
210+
private function magicJoin(NodeInterface $select): void
213211
{
214212
// Let's find if this is a MagicJoin query.
215213
$magicJoinDetector = new DetectMagicJoinSelectVisitor();
@@ -227,12 +225,8 @@ private function magicJoin(NodeInterface $select)
227225

228226
/**
229227
* For one given MagicJoin select, let's apply MagicJoin.
230-
*
231-
* @param MagicJoinSelect $magicJoinSelect
232-
*
233-
* @return Select
234228
*/
235-
private function magicJoinOnOneQuery(MagicJoinSelect $magicJoinSelect)
229+
private function magicJoinOnOneQuery(MagicJoinSelect $magicJoinSelect): void
236230
{
237231
$tableSearchNodeTraverser = new NodeTraverser();
238232
$detectTableVisitor = new DetectTablesVisitor($magicJoinSelect->getMainTable());
@@ -316,7 +310,7 @@ private function getSchemaAnalyzer()
316310
return $this->schemaAnalyzer;
317311
}
318312

319-
private function getConnectionUniqueId(Connection $connection)
313+
private function getConnectionUniqueId(Connection $connection): string
320314
{
321315
return hash('md4', $connection->getHost().'-'.$connection->getPort().'-'.$connection->getDatabase().'-'.$connection->getDriver()->getName());
322316
}

0 commit comments

Comments
 (0)