Skip to content

Commit 0c96d3a

Browse files
committed
CI - GH Actions: Increase PHPStan version, fix a load of errors.
1 parent 631032c commit 0c96d3a

Some content is hidden

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

69 files changed

+494
-190
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ jobs:
137137
strategy:
138138
matrix:
139139
php-version:
140-
- "7.1"
141140
- "7.3"
142141
- "7.4"
143142

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.1.0",
16+
"php": ">=7.2.0",
1717
"mouf/utils.common.conditioninterface": "~2.0",
1818
"mouf/utils.value.value-interface": "~1.0",
1919
"mouf/utils.common.paginable-interface": "~1.0",
@@ -27,7 +27,7 @@
2727
"phpunit/phpunit": "^7.5.10",
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",

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: 7
36
paths:
47
- src
58
inferPrivatePropertyTypeFromConstructor: true
9+
checkMissingIterableValueType: false
10+
checkGenericClassInNonGenericObjectType: false
611
ignoreErrors:
712
- "#Mouf\\\\MoufManager#"
813
- "#Mouf\\\\MoufInstanceDescriptor#"

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
}

src/Mouf/Database/MagicQuery/Twig/SqlTwigEnvironmentFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
*/
1313
class SqlTwigEnvironmentFactory
1414
{
15+
/** @var Environment|null */
1516
private static $twig;
1617

17-
public static function getTwigEnvironment()
18+
public static function getTwigEnvironment(): Environment
1819
{
1920
if (self::$twig) {
2021
return self::$twig;
@@ -45,7 +46,7 @@ public static function getTwigEnvironment()
4546
return $twig;
4647
}
4748

48-
private static function getCacheDirectory()
49+
private static function getCacheDirectory(): string
4950
{
5051
// If we are running on a Unix environment, let's prepend the cache with the user id of the PHP process.
5152
// This way, we can avoid rights conflicts.

src/Mouf/Database/MagicQuery/Twig/StringLoader.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ class StringLoader implements LoaderInterface
1919
{
2020
/**
2121
* {@inheritdoc}
22-
*/
23-
public function getSource($name)
24-
{
25-
return $name;
26-
}
27-
/**
28-
* {@inheritdoc}
22+
*
23+
* @param string $name
2924
*/
3025
public function getCacheKey($name): string
3126
{
3227
return $name;
3328
}
3429
/**
3530
* {@inheritdoc}
31+
*
32+
* @param string $name
33+
* @param int $time
3634
*/
3735
public function isFresh($name, $time): bool
3836
{

0 commit comments

Comments
 (0)