Skip to content

Commit 1f0c925

Browse files
Merge pull request #548 from MauricioFauth/prop-type-hints
Add property type hints
2 parents 8857557 + 8fa72cf commit 1f0c925

44 files changed

Lines changed: 325 additions & 498 deletions

Some content is hidden

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

phpcs.xml.dist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,4 @@
2727
<exclude-pattern>src/Contexts/*</exclude-pattern>
2828
<exclude-pattern>tests/Tools/templates/*</exclude-pattern>
2929
</rule>
30-
31-
<!-- Rules that should be followed, but are not required -->
32-
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
33-
<severity>4</severity>
34-
</rule>
35-
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint">
36-
<severity>4</severity>
37-
</rule>
3830
</ruleset>

phpstan-baseline.neon

Lines changed: 78 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,35 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
5-
count: 1
4+
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
5+
count: 2
66
path: src/Components/AlterOperation.php
77

88
-
9-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\:\\:\\$name \\(string\\) does not accept string\\|null\\.$#"
10-
count: 1
11-
path: src/Components/DataType.php
9+
message: "#^Cannot call method remove\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
10+
count: 3
11+
path: src/Components/AlterOperation.php
1212

1313
-
14-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
14+
message: "#^Cannot clone PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
1515
count: 1
16-
path: src/Components/DataType.php
16+
path: src/Components/AlterOperation.php
1717

1818
-
19-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\GroupKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
19+
message: "#^Parameter \\#1 \\$string of function strtolower expects string, string\\|null given\\.$#"
2020
count: 1
21-
path: src/Components/GroupKeyword.php
21+
path: src/Components/DataType.php
2222

2323
-
2424
message: "#^Parameter \\#2 \\$string2 of function strcasecmp expects string, mixed given\\.$#"
2525
count: 2
2626
path: src/Components/OptionsArray.php
2727

2828
-
29-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OrderKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
30-
count: 1
31-
path: src/Components/OrderKeyword.php
32-
33-
-
34-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$inOut \\(string\\) does not accept string\\|null\\.$#"
29+
message: "#^Parameter \\#1 \\$str of static method PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:escape\\(\\) expects string, string\\|null given\\.$#"
3530
count: 1
3631
path: src/Components/ParameterDefinition.php
3732

38-
-
39-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\) does not accept string\\|null\\.$#"
40-
count: 1
41-
path: src/Components/ParameterDefinition.php
42-
43-
-
44-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$type \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#"
45-
count: 1
46-
path: src/Components/ParameterDefinition.php
47-
48-
-
49-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\) in empty\\(\\) is not falsy\\.$#"
50-
count: 1
51-
path: src/Components/PartitionDefinition.php
52-
53-
-
54-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Reference\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
55-
count: 1
56-
path: src/Components/Reference.php
57-
58-
-
59-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Reference\\:\\:\\$table \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
60-
count: 1
61-
path: src/Components/Reference.php
62-
63-
-
64-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$new \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
65-
count: 1
66-
path: src/Components/RenameOperation.php
67-
68-
-
69-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$old \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
70-
count: 1
71-
path: src/Components/RenameOperation.php
72-
7333
-
7434
message: "#^Static property PhpMyAdmin\\\\SqlParser\\\\Context\\:\\:\\$keywords \\(non\\-empty\\-array\\<non\\-empty\\-string, int\\>\\) does not accept default value of type array\\{\\}\\.$#"
7535
count: 1
@@ -135,6 +95,21 @@ parameters:
13595
count: 1
13696
path: src/Parser.php
13797

98+
-
99+
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
100+
count: 2
101+
path: src/Parsers/AlterOperations.php
102+
103+
-
104+
message: "#^Cannot call method isEmpty\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
105+
count: 1
106+
path: src/Parsers/AlterOperations.php
107+
108+
-
109+
message: "#^Cannot call method merge\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
110+
count: 1
111+
path: src/Parsers/AlterOperations.php
112+
138113
-
139114
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\:\\:\\$partitions \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\>\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
140115
count: 1
@@ -221,19 +196,14 @@ parameters:
221196
path: src/Parsers/Expressions.php
222197

223198
-
224-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\:\\:\\$parameters \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
199+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$function \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
225200
count: 1
226-
path: src/Parsers/FunctionCalls.php
201+
path: src/Parsers/Expressions.php
227202

228203
-
229-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\GroupKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
204+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\:\\:\\$parameters \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
230205
count: 1
231-
path: src/Parsers/GroupKeywords.php
232-
233-
-
234-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\GroupKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) in empty\\(\\) is not falsy\\.$#"
235-
count: 2
236-
path: src/Parsers/GroupKeywords.php
206+
path: src/Parsers/FunctionCalls.php
237207

238208
-
239209
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\IndexHint\\:\\:\\$type \\(string\\|null\\) does not accept mixed\\.$#"
@@ -285,11 +255,6 @@ parameters:
285255
count: 1
286256
path: src/Parsers/Limits.php
287257

288-
-
289-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\LockExpression\\:\\:\\$table \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
290-
count: 1
291-
path: src/Parsers/LockExpressions.php
292-
293258
-
294259
message: "#^Cannot access offset 'equals' on mixed\\.$#"
295260
count: 1
@@ -336,47 +301,17 @@ parameters:
336301
path: src/Parsers/OptionsArrays.php
337302

338303
-
339-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OrderKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
340-
count: 1
341-
path: src/Parsers/OrderKeywords.php
342-
343-
-
344-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OrderKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) in empty\\(\\) is not falsy\\.$#"
345-
count: 2
346-
path: src/Parsers/OrderKeywords.php
347-
348-
-
349-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
304+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
350305
count: 1
351306
path: src/Parsers/ParameterDefinitions.php
352307

353308
-
354-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$name \\(string\\) in isset\\(\\) is not nullable\\.$#"
355-
count: 1
356-
path: src/Parsers/ParameterDefinitions.php
357-
358-
-
359-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\ParameterDefinition\\:\\:\\$type \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#"
360-
count: 1
361-
path: src/Parsers/ParameterDefinitions.php
362-
363-
-
364-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|string\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
309+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$subpartitions \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\>\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
365310
count: 1
366311
path: src/Parsers/PartitionDefinitions.php
367312

368313
-
369-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$name \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
370-
count: 1
371-
path: src/Parsers/PartitionDefinitions.php
372-
373-
-
374-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$subpartitions \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\>\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
375-
count: 1
376-
path: src/Parsers/PartitionDefinitions.php
377-
378-
-
379-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$type \\(string\\) does not accept bool\\|float\\|int\\|string\\.$#"
314+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\:\\:\\$type \\(string\\|null\\) does not accept bool\\|float\\|int\\|string\\.$#"
380315
count: 1
381316
path: src/Parsers/PartitionDefinitions.php
382317

@@ -385,31 +320,6 @@ parameters:
385320
count: 1
386321
path: src/Parsers/References.php
387322

388-
-
389-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Reference\\:\\:\\$table \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
390-
count: 1
391-
path: src/Parsers/References.php
392-
393-
-
394-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$new \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
395-
count: 1
396-
path: src/Parsers/RenameOperations.php
397-
398-
-
399-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$new \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) in empty\\(\\) is not falsy\\.$#"
400-
count: 1
401-
path: src/Parsers/RenameOperations.php
402-
403-
-
404-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$old \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
405-
count: 1
406-
path: src/Parsers/RenameOperations.php
407-
408-
-
409-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\RenameOperation\\:\\:\\$old \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) in empty\\(\\) is not falsy\\.$#"
410-
count: 2
411-
path: src/Parsers/RenameOperations.php
412-
413323
-
414324
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\SetOperation\\:\\:\\$value \\(string\\) does not accept string\\|null\\.$#"
415325
count: 1
@@ -840,19 +750,64 @@ parameters:
840750
count: 3
841751
path: src/Utils/Routine.php
842752

753+
-
754+
message: "#^Cannot access property \\$name on PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#"
755+
count: 2
756+
path: src/Utils/Routine.php
757+
758+
-
759+
message: "#^Cannot access property \\$options on PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#"
760+
count: 2
761+
path: src/Utils/Routine.php
762+
763+
-
764+
message: "#^Cannot access property \\$options on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
765+
count: 3
766+
path: src/Utils/Routine.php
767+
768+
-
769+
message: "#^Cannot access property \\$parameters on PhpMyAdmin\\\\SqlParser\\\\Components\\\\DataType\\|null\\.$#"
770+
count: 3
771+
path: src/Utils/Routine.php
772+
843773
-
844774
message: "#^Cannot assign new offset to array\\<int\\<0, max\\>, mixed\\>\\|string\\.$#"
845775
count: 1
846776
path: src/Utils/Routine.php
847777

778+
-
779+
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Routine\\:\\:getParameter\\(\\) should return array\\<string\\> but returns array\\<int, string\\|null\\>\\.$#"
780+
count: 1
781+
path: src/Utils/Routine.php
782+
783+
-
784+
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Routine\\:\\:getReturnType\\(\\) should return array\\<string\\> but returns array\\<int, string\\|null\\>\\.$#"
785+
count: 1
786+
path: src/Utils/Routine.php
787+
848788
-
849789
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<int\\<0, max\\>, mixed\\>\\|string given\\.$#"
850790
count: 1
851791
path: src/Utils/Routine.php
852792

793+
-
794+
message: "#^Cannot access property \\$database on PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
795+
count: 1
796+
path: src/Utils/Table.php
797+
798+
-
799+
message: "#^Cannot access property \\$table on PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
800+
count: 1
801+
path: src/Utils/Table.php
802+
853803
-
854804
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
855-
count: 2
805+
count: 4
806+
path: src/Utils/Table.php
807+
808+
-
809+
message: "#^Method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Table\\:\\:getFields\\(\\) should return array\\<string, array\\{type\\: string, timestamp_not_null\\: bool, default_value\\?\\: mixed, default_current_timestamp\\?\\: true, on_update_current_timestamp\\?\\: true, expr\\?\\: mixed\\}\\> but returns array\\<string, array\\{default_current_timestamp\\?\\: true, default_value\\?\\: mixed, expr\\?\\: mixed, on_update_current_timestamp\\?\\: true, timestamp_not_null\\: bool, type\\: string\\|null\\}\\>\\.$#"
810+
count: 1
856811
path: src/Utils/Table.php
857812

858813
-

0 commit comments

Comments
 (0)