Skip to content

Commit 43b44d6

Browse files
committed
Code: apply phpstan
1 parent 01d10da commit 43b44d6

5 files changed

Lines changed: 157 additions & 5 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
5+
count: 1
6+
path: src/Image.php
7+
8+
-
9+
message: "#^Variable property access on \\$this\\(Contributte\\\\ImageStorage\\\\Image\\)\\.$#"
10+
count: 1
11+
path: src/Image.php
12+
13+
-
14+
message: "#^Only booleans are allowed in &&, array\\<int\\> given on the left side\\.$#"
15+
count: 1
16+
path: src/ImageNameScript.php
17+
18+
-
19+
message: "#^Only booleans are allowed in &&, int given on the right side\\.$#"
20+
count: 2
21+
path: src/ImageNameScript.php
22+
23+
-
24+
message: "#^Only booleans are allowed in &&, string given on the left side\\.$#"
25+
count: 1
26+
path: src/ImageNameScript.php
27+
28+
-
29+
message: "#^Only booleans are allowed in &&, string given on the right side\\.$#"
30+
count: 3
31+
path: src/ImageNameScript.php
32+
33+
-
34+
message: "#^Only booleans are allowed in an if condition, array\\<int\\> given\\.$#"
35+
count: 1
36+
path: src/ImageNameScript.php
37+
38+
-
39+
message: "#^Only booleans are allowed in an if condition, int given\\.$#"
40+
count: 2
41+
path: src/ImageNameScript.php
42+
43+
-
44+
message: "#^Only booleans are allowed in an if condition, int\\<0, max\\> given\\.$#"
45+
count: 2
46+
path: src/ImageNameScript.php
47+
48+
-
49+
message: "#^Parameter \\#1 \\$pattern of function preg_match expects string, string\\|null given\\.$#"
50+
count: 1
51+
path: src/ImageNameScript.php
52+
53+
-
54+
message: "#^Cannot use array destructuring on array\\<int, Contributte\\\\ImageStorage\\\\ImageNameScript\\|string\\>\\|Contributte\\\\ImageStorage\\\\Image\\.$#"
55+
count: 2
56+
path: src/ImageStorage.php
57+
58+
-
59+
message: "#^Method Contributte\\\\ImageStorage\\\\ImageStorage\\:\\:fromIdentifier\\(\\) should return Contributte\\\\ImageStorage\\\\Image but returns array\\<int, Contributte\\\\ImageStorage\\\\ImageNameScript\\|string\\>\\|Contributte\\\\ImageStorage\\\\Image\\.$#"
60+
count: 1
61+
path: src/ImageStorage.php
62+
63+
-
64+
message: "#^Only booleans are allowed in &&, int given on the right side\\.$#"
65+
count: 1
66+
path: src/ImageStorage.php
67+
68+
-
69+
message: "#^Only booleans are allowed in a negated boolean, int given\\.$#"
70+
count: 2
71+
path: src/ImageStorage.php
72+
73+
-
74+
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
75+
count: 1
76+
path: src/ImageStorage.php
77+
78+
-
79+
message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
80+
count: 1
81+
path: src/ImageStorage.php
82+
83+
-
84+
message: "#^Only booleans are allowed in a negated boolean, string\\|null given\\.$#"
85+
count: 2
86+
path: src/ImageStorage.php
87+
88+
-
89+
message: "#^Parameter \\#1 \\$name of static method Contributte\\\\ImageStorage\\\\ImageNameScript\\:\\:fromName\\(\\) expects string, mixed given\\.$#"
90+
count: 1
91+
path: src/ImageStorage.php
92+
93+
-
94+
message: "#^Parameter \\#1 \\$pattern of function preg_match expects string, string\\|null given\\.$#"
95+
count: 1
96+
path: src/ImageStorage.php
97+
98+
-
99+
message: "#^Parameter \\#1 \\$s of static method Nette\\\\Utils\\\\Image\\:\\:fromString\\(\\) expects string, string\\|false given\\.$#"
100+
count: 1
101+
path: src/ImageStorage.php
102+
103+
-
104+
message: "#^Parameter \\#3 \\$checksum of method Contributte\\\\ImageStorage\\\\ImageStorage\\:\\:getSavePath\\(\\) expects string, mixed given\\.$#"
105+
count: 2
106+
path: src/ImageStorage.php
107+
108+
-
109+
message: "#^Parameter \\#3 \\$mode of method Nette\\\\Utils\\\\Image\\:\\:resize\\(\\) expects int\\<0, 15\\>, int given\\.$#"
110+
count: 1
111+
path: src/ImageStorage.php
112+
113+
-
114+
message: "#^Parameter \\#5 \\$props of class Contributte\\\\ImageStorage\\\\Image constructor expects array\\<bool\\|Contributte\\\\ImageStorage\\\\ImageNameScript\\|string\\|null\\>, array\\<string, mixed\\> given\\.$#"
115+
count: 2
116+
path: src/ImageStorage.php
117+
118+
-
119+
message: "#^Right side of && is always true\\.$#"
120+
count: 1
121+
path: src/ImageStorage.php
122+
123+
-
124+
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
125+
count: 1
126+
path: src/ImageStorage.php
127+
128+
-
129+
message: "#^Undefined variable\\: \\$i$#"
130+
count: 1
131+
path: src/ImageStorage.php
132+
133+
-
134+
message: "#^Variable \\$i might not be defined\\.$#"
135+
count: 1
136+
path: src/ImageStorage.php
137+
138+
-
139+
message: "#^Variable \\$path might not be defined\\.$#"
140+
count: 1
141+
path: src/ImageStorage.php
142+
143+
-
144+
message: "#^Return type \\(array\\) of method Contributte\\\\ImageStorage\\\\Latte\\\\LatteExtension\\:\\:getTags\\(\\) should be covariant with return type \\(array\\<string, \\(callable\\(Latte\\\\Compiler\\\\Tag, Latte\\\\Compiler\\\\TemplateParser\\)\\: \\(Generator\\|Latte\\\\Compiler\\\\Node\\|void\\)\\)\\|stdClass\\>\\) of method Latte\\\\Extension\\:\\:getTags\\(\\)$#"
145+
count: 1
146+
path: src/Latte/LatteExtension.php

‎phpstan.neon‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
includes:
22
- vendor/contributte/phpstan/phpstan.neon
3+
- phpstan-baseline.neon
34

45
parameters:
56
level: 9

‎src/DI/ImageStorageExtension.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
use Nette\DI\Definitions\FactoryDefinition;
99
use Nette\Schema\Expect;
1010
use Nette\Schema\Schema;
11+
use stdClass;
1112

13+
/**
14+
* @method stdClass getConfig()
15+
*/
1216
class ImageStorageExtension extends CompilerExtension
1317
{
1418

@@ -30,12 +34,13 @@ public function getConfigSchema(): Schema
3034
public function loadConfiguration(): void
3135
{
3236
$builder = $this->getContainerBuilder();
33-
$this->config->orig_path ??= $this->config->data_path;
34-
$config = (array) $this->config;
37+
$config = $this->getConfig();
38+
$config->orig_path ??= $config->data_path;
39+
3540
$builder->addDefinition($this->prefix('storage'))
3641
->setType(ImageStorage::class)
3742
->setFactory(ImageStorage::class)
38-
->setArguments($config);
43+
->setArguments((array) $config);
3944
}
4045

4146
public function beforeCompile(): void

‎src/ImageNameScript.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function fromName(string $name): ImageNameScript
5858
$script->name = $matches[3];
5959
$script->size = [(int) $matches[5], (int) $matches[6]];
6060
$script->flag = $matches[12];
61-
$script->quality = $matches[14];
61+
$script->quality = intval($matches[14]);
6262
$script->extension = $matches[15];
6363

6464
if ($matches[8] && $matches[9] && $matches[10] && $matches[11]) {

‎src/Latte/LatteExtension.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LatteExtension extends Extension
1212
{
1313

1414
/**
15-
* @return array<string, callable>
15+
* @return array<mixed>
1616
*/
1717
public function getTags(): array
1818
{

0 commit comments

Comments
 (0)