Skip to content

Commit fb074aa

Browse files
committed
wip
1 parent e095738 commit fb074aa

Some content is hidden

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

47 files changed

+1291
-511
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
},
4747
"autoload-dev": {
4848
"psr-4": {
49-
"App\\": "tests/app/src/",
49+
"App\\": [
50+
"tests/app/src/",
51+
"tests/app_invalid/src/"
52+
],
5053
"SoureCode\\Bundle\\DoctrineExtension\\Tests\\": "tests/"
5154
}
5255
},

infection.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"source": {
33
"directories": [
44
"src"
5+
],
6+
"excludes": [
7+
"SoureCodeDoctrineExtensionBundle.php",
8+
"/Interface\\.php/"
59
]
610
},
711
"timeout": 10,

phpstan-baseline.neon

Lines changed: 115 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ parameters:
5454
count: 2
5555
path: tests/AbstractWebTestCase.php
5656

57+
-
58+
message: '#^Call to function assert\(\) with true will always evaluate to true\.$#'
59+
identifier: function.alreadyNarrowedType
60+
count: 2
61+
path: tests/Benchmark/TimestampableListenerBench.php
62+
5763
-
5864
message: '#^Cannot call method clear\(\) on Doctrine\\ORM\\EntityManagerInterface\|null\.$#'
5965
identifier: method.nonObject
@@ -90,17 +96,47 @@ parameters:
9096
count: 1
9197
path: tests/Benchmark/TimestampableListenerBench.php
9298

99+
-
100+
message: '#^Strict comparison using \!\=\= between null and DateTimeInterface will always evaluate to true\.$#'
101+
identifier: notIdentical.alwaysTrue
102+
count: 2
103+
path: tests/Benchmark/TimestampableListenerBench.php
104+
93105
-
94106
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
95107
identifier: method.notFound
96-
count: 1
97-
path: tests/EventListener/BlameableListenerTest.php
108+
count: 2
109+
path: tests/EventListener/PropertyListenerTest.php
98110

99111
-
100112
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
101113
identifier: method.notFound
114+
count: 2
115+
path: tests/EventListener/PropertyListenerTest.php
116+
117+
-
118+
message: '#^Call to an undefined method object\:\:reset\(\)\.$#'
119+
identifier: method.notFound
120+
count: 1
121+
path: tests/EventListener/PropertyListenerTest.php
122+
123+
-
124+
message: '#^Call to an undefined method object\:\:setToken\(\)\.$#'
125+
identifier: method.notFound
102126
count: 1
103-
path: tests/EventListener/BlameableListenerTest.php
127+
path: tests/EventListener/PropertyListenerTest.php
128+
129+
-
130+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNotNull\(\) with Symfony\\Component\\Security\\Core\\User\\UserInterface will always evaluate to true\.$#'
131+
identifier: method.alreadyNarrowedType
132+
count: 2
133+
path: tests/EventListener/PropertyListenerTest.php
134+
135+
-
136+
message: '#^Parameter \#1 \$user of method Symfony\\Bundle\\FrameworkBundle\\KernelBrowser\:\:loginUser\(\) expects Symfony\\Component\\Security\\Core\\User\\UserInterface, App\\Entity\\User\|null given\.$#'
137+
identifier: argument.type
138+
count: 1
139+
path: tests/EventListener/PropertyListenerTest.php
104140

105141
-
106142
message: '#^Call to an undefined method object\:\:clear\(\)\.$#'
@@ -126,6 +162,12 @@ parameters:
126162
count: 3
127163
path: tests/EventListener/TimestampableListenerTest.php
128164

165+
-
166+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNotNull\(\) with DateTimeInterface will always evaluate to true\.$#'
167+
identifier: method.alreadyNarrowedType
168+
count: 2
169+
path: tests/EventListener/TimestampableListenerTest.php
170+
129171
-
130172
message: '#^Cannot call method find\(\) on mixed\.$#'
131173
identifier: method.nonObject
@@ -151,70 +193,70 @@ parameters:
151193
path: tests/EventListener/TimestampableListenerTest.php
152194

153195
-
154-
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
196+
message: '#^Call to an undefined method object\:\:clear\(\)\.$#'
155197
identifier: method.notFound
156198
count: 2
157-
path: tests/Traits/BlameableTraitTest.php
199+
path: tests/Traits/TimestampableTraitTest.php
158200

159201
-
160-
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
202+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
161203
identifier: method.notFound
162-
count: 2
163-
path: tests/Traits/BlameableTraitTest.php
204+
count: 4
205+
path: tests/Traits/TimestampableTraitTest.php
164206

165207
-
166-
message: '#^Call to an undefined method object\:\:clear\(\)\.$#'
208+
message: '#^Call to an undefined method object\:\:getRepository\(\)\.$#'
167209
identifier: method.notFound
168-
count: 1
210+
count: 2
169211
path: tests/Traits/TimestampableTraitTest.php
170212

171213
-
172-
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
214+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
173215
identifier: method.notFound
174-
count: 3
216+
count: 4
175217
path: tests/Traits/TimestampableTraitTest.php
176218

177219
-
178-
message: '#^Call to an undefined method object\:\:getRepository\(\)\.$#'
220+
message: '#^Call to an undefined method object\:\:reset\(\)\.$#'
179221
identifier: method.notFound
180222
count: 1
181223
path: tests/Traits/TimestampableTraitTest.php
182224

183225
-
184-
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
185-
identifier: method.notFound
186-
count: 3
226+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNotNull\(\) with DateTimeInterface will always evaluate to true\.$#'
227+
identifier: method.alreadyNarrowedType
228+
count: 2
187229
path: tests/Traits/TimestampableTraitTest.php
188230

189231
-
190232
message: '#^Cannot call method find\(\) on mixed\.$#'
191233
identifier: method.nonObject
192-
count: 1
234+
count: 2
193235
path: tests/Traits/TimestampableTraitTest.php
194236

195237
-
196238
message: '#^Cannot call method getCreatedAt\(\) on mixed\.$#'
197239
identifier: method.nonObject
198-
count: 1
240+
count: 2
199241
path: tests/Traits/TimestampableTraitTest.php
200242

201243
-
202-
message: '#^Cannot call method getUpdatedAt\(\) on mixed\.$#'
244+
message: '#^Cannot call method getId\(\) on mixed\.$#'
203245
identifier: method.nonObject
204246
count: 1
205247
path: tests/Traits/TimestampableTraitTest.php
206248

207249
-
208-
message: '#^Cannot call method setTitle\(\) on mixed\.$#'
250+
message: '#^Cannot call method getUpdatedAt\(\) on mixed\.$#'
209251
identifier: method.nonObject
210-
count: 1
252+
count: 2
211253
path: tests/Traits/TimestampableTraitTest.php
212254

213255
-
214-
message: '#^Cannot call method getLocale\(\) on App\\Entity\\ProductTranslation\|false\.$#'
256+
message: '#^Cannot call method setTitle\(\) on mixed\.$#'
215257
identifier: method.nonObject
216258
count: 2
217-
path: tests/Traits/TranslatableTraitTest.php
259+
path: tests/Traits/TimestampableTraitTest.php
218260

219261
-
220262
message: '#^Cannot call method getLocale\(\) on App\\Entity\\ProductTranslation\|null\.$#'
@@ -223,9 +265,9 @@ parameters:
223265
path: tests/Traits/TranslatableTraitTest.php
224266

225267
-
226-
message: '#^Cannot call method getName\(\) on App\\Entity\\ProductTranslation\|false\.$#'
268+
message: '#^Cannot call method getLocale\(\) on mixed\.$#'
227269
identifier: method.nonObject
228-
count: 1
270+
count: 2
229271
path: tests/Traits/TranslatableTraitTest.php
230272

231273
-
@@ -234,6 +276,12 @@ parameters:
234276
count: 4
235277
path: tests/Traits/TranslatableTraitTest.php
236278

279+
-
280+
message: '#^Cannot call method getName\(\) on mixed\.$#'
281+
identifier: method.nonObject
282+
count: 1
283+
path: tests/Traits/TranslatableTraitTest.php
284+
237285
-
238286
message: '#^Cannot call method getTranslation\(\) on App\\Entity\\Product\|null\.$#'
239287
identifier: method.nonObject
@@ -246,12 +294,54 @@ parameters:
246294
count: 5
247295
path: tests/Traits/TranslatableTraitTest.php
248296

297+
-
298+
message: '#^Call to an undefined method object\:\:flush\(\)\.$#'
299+
identifier: method.notFound
300+
count: 2
301+
path: tests/Traits/UserRelatedTraitsTest.php
302+
303+
-
304+
message: '#^Call to an undefined method object\:\:persist\(\)\.$#'
305+
identifier: method.notFound
306+
count: 2
307+
path: tests/Traits/UserRelatedTraitsTest.php
308+
309+
-
310+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNotNull\(\) with Symfony\\Component\\Security\\Core\\User\\UserInterface will always evaluate to true\.$#'
311+
identifier: method.alreadyNarrowedType
312+
count: 3
313+
path: tests/Traits/UserRelatedTraitsTest.php
314+
249315
-
250316
message: '#^Cannot call method getTranslations\(\) on App\\Entity\\Product\|null\.$#'
251317
identifier: method.nonObject
252318
count: 1
253319
path: tests/Translation/EntityTranslatorTest.php
254320

321+
-
322+
message: '#^Property App\\Entity\\Article\:\:\$createdBy type mapping mismatch\: database can contain App\\Entity\\User\|null but property expects Symfony\\Component\\Security\\Core\\User\\UserInterface\.$#'
323+
identifier: doctrine.associationType
324+
count: 1
325+
path: tests/app/src/Entity/Article.php
326+
327+
-
328+
message: '#^Property App\\Entity\\Article\:\:\$createdBy type mapping mismatch\: property can contain Symfony\\Component\\Security\\Core\\User\\UserInterface but database expects App\\Entity\\User\|null\.$#'
329+
identifier: doctrine.associationType
330+
count: 1
331+
path: tests/app/src/Entity/Article.php
332+
333+
-
334+
message: '#^Property App\\Entity\\Article\:\:\$updatedBy type mapping mismatch\: property can contain Symfony\\Component\\Security\\Core\\User\\UserInterface\|null but database expects App\\Entity\\User\|null\.$#'
335+
identifier: doctrine.associationType
336+
count: 1
337+
path: tests/app/src/Entity/Article.php
338+
339+
-
340+
message: '#^Method App\\Entity\\Product\:\:getTranslations\(\) return type with generic interface Doctrine\\Common\\Collections\\Collection does not specify its types\: TKey, T$#'
341+
identifier: missingType.generics
342+
count: 1
343+
path: tests/app/src/Entity/Product.php
344+
255345
-
256346
message: '#^Method App\\Entity\\User\:\:getUserIdentifier\(\) should return non\-empty\-string but returns ''''\|numeric\-string\.$#'
257347
identifier: return.type

scripts/baseline.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
CURRENT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
PROJECT_DIRECTORY="$(dirname "$CURRENT_DIRECTORY")"
7+
8+
pushd "$PROJECT_DIRECTORY" >/dev/null
9+
10+
# <editor-fold desc="Install tools">
11+
if [ ! -d "tools" ]; then
12+
mkdir -p tools
13+
fi
14+
15+
if [ ! -f "tools/phpstan.phar" ]; then
16+
wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar -O tools/phpstan.phar
17+
chmod +x tools/phpstan.phar
18+
fi
19+
# </editor-fold>
20+
21+
composer update --no-interaction --no-progress --ansi
22+
composer validate --no-ansi --strict composer.json
23+
24+
php tools/phpstan.phar analyse --memory-limit=512M --ansi --no-progress --error-format=table --generate-baseline=phpstan-baseline.neon
25+
26+
popd >/dev/null

scripts/ci.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ if [ ! -f "tools/infection.phar" ]; then
3838
fi
3939
# </editor-fold>
4040

41-
composer update --no-interaction --no-progress --ansi
41+
if [ ! -d "vendor" ]; then
42+
composer update --no-interaction --no-progress --ansi
43+
fi
44+
4245
composer validate --no-ansi --strict composer.json
4346

4447
php tools/composer-normalize.phar --dry-run

scripts/fix.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ if [ ! -f "tools/php-cs-fixer.phar" ]; then
2323
fi
2424
# </editor-fold>
2525

26-
composer update --no-interaction --no-progress --ansi
26+
if [ ! -d "vendor" ]; then
27+
composer update --no-interaction --no-progress --ansi
28+
fi
29+
2730
php tools/composer-normalize.phar
2831
PHP_CS_FIXER_IGNORE_ENV=1 php tools/php-cs-fixer.phar fix --show-progress=dots --using-cache=no --verbose
2932

src/Attributes/Translatable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(string $translationClass)
2020
if (!is_subclass_of($translationClass, TranslationInterface::class)) {
2121
throw new \InvalidArgumentException(\sprintf('The class "%s" must implement "%s".', $translationClass, TranslationInterface::class));
2222
}
23-
23+
2424
$this->translationClass = $translationClass;
2525
}
2626
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace SoureCode\Bundle\DoctrineExtension\Cache;
4+
5+
use SoureCode\Bundle\DoctrineExtension\Mapping\ClassMetadataGenerator;
6+
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
7+
8+
final class ClassMetadataCacheWarmer implements CacheWarmerInterface
9+
{
10+
public function __construct(
11+
private readonly ClassMetadataGenerator $classMetadataGenerator,
12+
)
13+
{
14+
}
15+
16+
public function warmUp(string $cacheDir, ?string $buildDir = null): array
17+
{
18+
$this->classMetadataGenerator->generateAll();
19+
20+
return [];
21+
}
22+
23+
public function isOptional(): bool
24+
{
25+
return true;
26+
}
27+
}

src/Contracts/LocaleAwareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ interface LocaleAwareInterface
77
public function getLocale(): string;
88

99
public function setLocale(string $locale): self;
10-
}
10+
}

src/Contracts/TranslationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ interface TranslationInterface extends LocaleAwareInterface
77
public function setTranslatable(object $translatable): self;
88

99
public function getTranslatable(): object;
10-
}
10+
}

0 commit comments

Comments
 (0)