Skip to content

Commit 7e33337

Browse files
committed
Enhance CI scripts and migrate to phpstan
1 parent fe31203 commit 7e33337

Some content is hidden

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

45 files changed

+519
-239
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
- uses: shivammathur/setup-php@v2
4343
with:
4444
php-version: 8.4
45-
tools: psalm
45+
tools: phpstan
4646
- uses: "ramsey/composer-install@v3"
47-
- run: psalm --no-cache --threads=4 --output-format=github
47+
- run: phpstan --memory-limit=512M --ansi --no-progress --error-format=github
4848
unit-tests:
4949
name: Unit Tests
5050
needs:

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
->setRiskyAllowed(true)
1818
->setFinder(
1919
(new PhpCsFixer\Finder())
20-
->in([__DIR__.'/src', __DIR__.'/config'])
20+
->in([__DIR__.'/src', __DIR__.'/tests', __DIR__.'/config'])
2121
->append([__FILE__])
2222
)
2323
->setCacheFile('.php-cs-fixer.cache');

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
"require-dev": {
3131
"nyholm/symfony-bundle-test": "^3.0",
3232
"phpbench/phpbench": "^1.4",
33+
"phpstan/extension-installer": "^1.4",
34+
"phpstan/phpstan-doctrine": "^2.0",
35+
"phpstan/phpstan-symfony": "^2.0",
3336
"phpunit/phpunit": "^9.5",
34-
"psalm/plugin-symfony": "^5.2",
3537
"symfony/browser-kit": "^7.1",
3638
"symfony/phpunit-bridge": "^7.1",
3739
"symfony/runtime": "^7.1",
38-
"twig/twig": "^3.2",
39-
"vimeo/psalm": "^6.9"
40+
"twig/twig": "^3.2"
4041
},
4142
"autoload": {
4243
"psr-4": {
@@ -52,6 +53,7 @@
5253
"config": {
5354
"allow-plugins": {
5455
"ergebnis/composer-normalize": true,
56+
"phpstan/extension-installer": true,
5557
"symfony/runtime": true
5658
}
5759
},

phpstan-baseline.neon

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to an undefined method object\:\:getClassMetadata\(\)\.$#'
5+
identifier: method.notFound
6+
count: 1
7+
path: tests/AbstractKernelTestCase.php
8+
9+
-
10+
message: '#^Method SoureCode\\Bundle\\DoctrineExtension\\Tests\\AbstractKernelTestCase\:\:createKernel\(\) has parameter \$options with no value type specified in iterable type array\.$#'
11+
identifier: missingType.iterableValue
12+
count: 1
13+
path: tests/AbstractKernelTestCase.php
14+
15+
-
16+
message: '#^Method SoureCode\\Bundle\\DoctrineExtension\\Tests\\AbstractKernelTestCase\:\:setUpDatabase\(\) has parameter \$classNames with no value type specified in iterable type array\.$#'
17+
identifier: missingType.iterableValue
18+
count: 1
19+
path: tests/AbstractKernelTestCase.php
20+
21+
-
22+
message: '#^Parameter \#1 \$classes of method Doctrine\\ORM\\Tools\\SchemaTool\:\:createSchema\(\) expects list\<Doctrine\\ORM\\Mapping\\ClassMetadata\>, array\<mixed\> given\.$#'
23+
identifier: argument.type
24+
count: 1
25+
path: tests/AbstractKernelTestCase.php
26+
27+
-
28+
message: '#^Parameter \#1 \$em of class Doctrine\\ORM\\Tools\\SchemaTool constructor expects Doctrine\\ORM\\EntityManagerInterface, object given\.$#'
29+
identifier: argument.type
30+
count: 2
31+
path: tests/AbstractKernelTestCase.php
32+
33+
-
34+
message: '#^Call to an undefined method object\:\:getClassMetadata\(\)\.$#'
35+
identifier: method.notFound
36+
count: 1
37+
path: tests/AbstractWebTestCase.php
38+
39+
-
40+
message: '#^Method SoureCode\\Bundle\\DoctrineExtension\\Tests\\AbstractWebTestCase\:\:createKernel\(\) has parameter \$options with no value type specified in iterable type array\.$#'
41+
identifier: missingType.iterableValue
42+
count: 1
43+
path: tests/AbstractWebTestCase.php
44+
45+
-
46+
message: '#^Parameter \#1 \$classes of method Doctrine\\ORM\\Tools\\SchemaTool\:\:createSchema\(\) expects list\<Doctrine\\ORM\\Mapping\\ClassMetadata\>, list\<mixed\> given\.$#'
47+
identifier: argument.type
48+
count: 1
49+
path: tests/AbstractWebTestCase.php
50+
51+
-
52+
message: '#^Parameter \#1 \$em of class Doctrine\\ORM\\Tools\\SchemaTool constructor expects Doctrine\\ORM\\EntityManagerInterface, object given\.$#'
53+
identifier: argument.type
54+
count: 2
55+
path: tests/AbstractWebTestCase.php
56+
57+
-
58+
message: '#^Cannot call method clear\(\) on Doctrine\\ORM\\EntityManagerInterface\|null\.$#'
59+
identifier: method.nonObject
60+
count: 3
61+
path: tests/Benchmark/TimestampableListenerBench.php
62+
63+
-
64+
message: '#^Cannot call method findOneBy\(\) on Doctrine\\ORM\\EntityRepository\<App\\Entity\\Post\>\|null\.$#'
65+
identifier: method.nonObject
66+
count: 1
67+
path: tests/Benchmark/TimestampableListenerBench.php
68+
69+
-
70+
message: '#^Cannot call method flush\(\) on Doctrine\\ORM\\EntityManagerInterface\|null\.$#'
71+
identifier: method.nonObject
72+
count: 3
73+
path: tests/Benchmark/TimestampableListenerBench.php
74+
75+
-
76+
message: '#^Cannot call method getRepository\(\) on Doctrine\\ORM\\EntityManagerInterface\|null\.$#'
77+
identifier: method.nonObject
78+
count: 1
79+
path: tests/Benchmark/TimestampableListenerBench.php
80+
81+
-
82+
message: '#^Cannot call method persist\(\) on Doctrine\\ORM\\EntityManagerInterface\|null\.$#'
83+
identifier: method.nonObject
84+
count: 2
85+
path: tests/Benchmark/TimestampableListenerBench.php
86+
87+
-
88+
message: '#^Property SoureCode\\Bundle\\DoctrineExtension\\Tests\\Benchmark\\TimestampableListenerBench\:\:\$entityManager \(Doctrine\\ORM\\EntityManagerInterface\|null\) does not accept object\.$#'
89+
identifier: assign.propertyType
90+
count: 1
91+
path: tests/Benchmark/TimestampableListenerBench.php
92+
93+
-
94+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
95+
identifier: method.notFound
96+
count: 1
97+
path: tests/EventListener/BlameableListenerTest.php
98+
99+
-
100+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
101+
identifier: method.notFound
102+
count: 1
103+
path: tests/EventListener/BlameableListenerTest.php
104+
105+
-
106+
message: '#^Call to an undefined method object\:\:clear\(\)\.$#'
107+
identifier: method.notFound
108+
count: 1
109+
path: tests/EventListener/TimestampableListenerTest.php
110+
111+
-
112+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
113+
identifier: method.notFound
114+
count: 3
115+
path: tests/EventListener/TimestampableListenerTest.php
116+
117+
-
118+
message: '#^Call to an undefined method object\:\:getRepository\(\)\.$#'
119+
identifier: method.notFound
120+
count: 1
121+
path: tests/EventListener/TimestampableListenerTest.php
122+
123+
-
124+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
125+
identifier: method.notFound
126+
count: 3
127+
path: tests/EventListener/TimestampableListenerTest.php
128+
129+
-
130+
message: '#^Cannot call method find\(\) on mixed\.$#'
131+
identifier: method.nonObject
132+
count: 1
133+
path: tests/EventListener/TimestampableListenerTest.php
134+
135+
-
136+
message: '#^Cannot call method getCreatedAt\(\) on mixed\.$#'
137+
identifier: method.nonObject
138+
count: 1
139+
path: tests/EventListener/TimestampableListenerTest.php
140+
141+
-
142+
message: '#^Cannot call method getUpdatedAt\(\) on mixed\.$#'
143+
identifier: method.nonObject
144+
count: 1
145+
path: tests/EventListener/TimestampableListenerTest.php
146+
147+
-
148+
message: '#^Cannot call method setTitle\(\) on mixed\.$#'
149+
identifier: method.nonObject
150+
count: 1
151+
path: tests/EventListener/TimestampableListenerTest.php
152+
153+
-
154+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
155+
identifier: method.notFound
156+
count: 2
157+
path: tests/Traits/BlameableTraitTest.php
158+
159+
-
160+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
161+
identifier: method.notFound
162+
count: 2
163+
path: tests/Traits/BlameableTraitTest.php
164+
165+
-
166+
message: '#^Call to an undefined method object\:\:clear\(\)\.$#'
167+
identifier: method.notFound
168+
count: 1
169+
path: tests/Traits/TimestampableTraitTest.php
170+
171+
-
172+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
173+
identifier: method.notFound
174+
count: 3
175+
path: tests/Traits/TimestampableTraitTest.php
176+
177+
-
178+
message: '#^Call to an undefined method object\:\:getRepository\(\)\.$#'
179+
identifier: method.notFound
180+
count: 1
181+
path: tests/Traits/TimestampableTraitTest.php
182+
183+
-
184+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
185+
identifier: method.notFound
186+
count: 3
187+
path: tests/Traits/TimestampableTraitTest.php
188+
189+
-
190+
message: '#^Cannot call method find\(\) on mixed\.$#'
191+
identifier: method.nonObject
192+
count: 1
193+
path: tests/Traits/TimestampableTraitTest.php
194+
195+
-
196+
message: '#^Cannot call method getCreatedAt\(\) on mixed\.$#'
197+
identifier: method.nonObject
198+
count: 1
199+
path: tests/Traits/TimestampableTraitTest.php
200+
201+
-
202+
message: '#^Cannot call method getUpdatedAt\(\) on mixed\.$#'
203+
identifier: method.nonObject
204+
count: 1
205+
path: tests/Traits/TimestampableTraitTest.php
206+
207+
-
208+
message: '#^Cannot call method setTitle\(\) on mixed\.$#'
209+
identifier: method.nonObject
210+
count: 1
211+
path: tests/Traits/TimestampableTraitTest.php
212+
213+
-
214+
message: '#^Cannot call method getLocale\(\) on App\\Entity\\ProductTranslation\|false\.$#'
215+
identifier: method.nonObject
216+
count: 2
217+
path: tests/Traits/TranslatableTraitTest.php
218+
219+
-
220+
message: '#^Cannot call method getLocale\(\) on App\\Entity\\ProductTranslation\|null\.$#'
221+
identifier: method.nonObject
222+
count: 4
223+
path: tests/Traits/TranslatableTraitTest.php
224+
225+
-
226+
message: '#^Cannot call method getName\(\) on App\\Entity\\ProductTranslation\|false\.$#'
227+
identifier: method.nonObject
228+
count: 1
229+
path: tests/Traits/TranslatableTraitTest.php
230+
231+
-
232+
message: '#^Cannot call method getName\(\) on App\\Entity\\ProductTranslation\|null\.$#'
233+
identifier: method.nonObject
234+
count: 4
235+
path: tests/Traits/TranslatableTraitTest.php
236+
237+
-
238+
message: '#^Cannot call method getTranslation\(\) on App\\Entity\\Product\|null\.$#'
239+
identifier: method.nonObject
240+
count: 1
241+
path: tests/Traits/TranslatableTraitTest.php
242+
243+
-
244+
message: '#^Cannot call method getTranslations\(\) on App\\Entity\\Product\|null\.$#'
245+
identifier: method.nonObject
246+
count: 5
247+
path: tests/Traits/TranslatableTraitTest.php
248+
249+
-
250+
message: '#^Cannot call method getTranslations\(\) on App\\Entity\\Product\|null\.$#'
251+
identifier: method.nonObject
252+
count: 1
253+
path: tests/Translation/EntityTranslatorTest.php
254+
255+
-
256+
message: '#^Method App\\Entity\\User\:\:getUserIdentifier\(\) should return non\-empty\-string but returns ''''\|numeric\-string\.$#'
257+
identifier: return.type
258+
count: 1
259+
path: tests/app/src/Entity/User.php

phpstan.neon.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
parameters:
4+
editorUrl: '%%file%%:%%line%%'
5+
editorUrlTitle: ' '
6+
level: 10
7+
paths:
8+
- src
9+
- tests

psalm.xml

Lines changed: 0 additions & 34 deletions
This file was deleted.

scripts/ci.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,34 @@ fi
1414

1515
if [ ! -f "tools/composer-normalize.phar" ]; then
1616
wget https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar -O tools/composer-normalize.phar
17+
chmod +x tools/composer-normalize.phar
1718
fi
1819

1920
if [ ! -f "tools/composer-require-checker.phar" ]; then
2021
wget https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar -O tools/composer-require-checker.phar
22+
chmod +x tools/composer-require-checker.phar
2123
fi
2224

2325
if [ ! -f "tools/php-cs-fixer.phar" ]; then
2426
wget https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar -O tools/php-cs-fixer.phar
27+
chmod +x tools/php-cs-fixer.phar
28+
fi
29+
30+
if [ ! -f "tools/phpstan.phar" ]; then
31+
wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar -O tools/phpstan.phar
32+
chmod +x tools/phpstan.phar
2533
fi
2634
# </editor-fold>
2735

28-
composer install --no-interaction --no-progress --ansi
36+
composer update --no-interaction --no-progress --ansi
2937
composer validate --no-ansi --strict composer.json
3038

3139
php tools/composer-normalize.phar --dry-run
3240
php tools/composer-require-checker.phar check
3341
PHP_CS_FIXER_IGNORE_ENV=1 php tools/php-cs-fixer.phar fix --dry-run --show-progress=dots --using-cache=no --verbose
3442

35-
vendor/bin/psalm --no-cache --threads=4
43+
php tools/phpstan.phar analyse --memory-limit=512M --ansi --no-progress --error-format=table
44+
3645
vendor/bin/phpunit
3746

3847
popd >/dev/null

0 commit comments

Comments
 (0)