Skip to content

Commit 03ca7e1

Browse files
authored
Use shipmonk/coding-standard (#19)
1 parent c22923b commit 03ca7e1

17 files changed

+77
-421
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"phpstan/phpstan-strict-rules": "^2.0",
2121
"phpunit/phpunit": "^10.5",
2222
"psr/log": "^3",
23+
"shipmonk/coding-standard": "^0.1.3",
2324
"shipmonk/composer-dependency-analyser": "^1.7",
2425
"shipmonk/name-collision-detector": "^2.1.1",
2526
"shipmonk/phpstan-rules": "^4.0",
26-
"slevomat/coding-standard": "^8.15.0",
2727
"symfony/cache": "^6 || ^7"
2828
},
2929
"autoload": {

phpcs.xml.dist

Lines changed: 1 addition & 395 deletions
Large diffs are not rendered by default.

src/EntityPreloader.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function __construct(
3535
* @param positive-int|null $batchSize
3636
* @param non-negative-int|null $maxFetchJoinSameFieldCount
3737
* @return list<E>
38+
*
3839
* @template S of E
3940
*/
4041
public function preload(
@@ -75,6 +76,7 @@ public function preload(
7576
/**
7677
* @param list<S> $entities
7778
* @return class-string<S>|null
79+
*
7880
* @template S of E
7981
*/
8082
private function getCommonAncestor(array $entities): ?string
@@ -108,6 +110,7 @@ private function getCommonAncestor(array $entities): ?string
108110
* @param positive-int $batchSize
109111
* @param non-negative-int $maxFetchJoinSameFieldCount
110112
* @return list<T>
113+
*
111114
* @template T of E
112115
*/
113116
private function loadProxies(
@@ -151,6 +154,7 @@ private function loadProxies(
151154
* @param positive-int|null $batchSize
152155
* @param non-negative-int $maxFetchJoinSameFieldCount
153156
* @return list<T>
157+
*
154158
* @template S of E
155159
* @template T of E
156160
*/
@@ -239,6 +243,7 @@ private function preloadToMany(
239243
* @param array<string, PersistentCollection<int, T>> $uninitializedCollections
240244
* @param non-negative-int $maxFetchJoinSameFieldCount
241245
* @return array<string, T>
246+
*
242247
* @template S of E
243248
* @template T of E
244249
*/
@@ -290,6 +295,7 @@ private function preloadOneToManyInner(
290295
* @param array<string, PersistentCollection<int, T>> $uninitializedCollections
291296
* @param non-negative-int $maxFetchJoinSameFieldCount
292297
* @return array<string, T>
298+
*
293299
* @template S of E
294300
* @template T of E
295301
*/
@@ -360,6 +366,7 @@ private function preloadManyToManyInner(
360366
* @param positive-int|null $batchSize
361367
* @param non-negative-int $maxFetchJoinSameFieldCount
362368
* @return list<T>
369+
*
363370
* @template S of E
364371
* @template T of E
365372
*/
@@ -400,6 +407,7 @@ private function preloadToOne(
400407
* @param non-negative-int $maxFetchJoinSameFieldCount
401408
* @param array<string, 'asc'|'desc'> $orderBy
402409
* @return list<T>
410+
*
403411
* @template T of E
404412
*/
405413
private function loadEntitiesBy(
@@ -434,6 +442,7 @@ private function loadEntitiesBy(
434442
/**
435443
* @param ClassMetadata<S> $sourceClassMetadata
436444
* @param array<string, array<string, int>> $alreadyPreloadedJoins
445+
*
437446
* @template S of E
438447
*/
439448
private function addFetchJoinsToPreventFetchDuringHydration(

tests/EntityPreloadBlogOneHasManyDeepTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testOneHasManyDeepWithWithManualPreloadUsingPartial(): void
5151
->getQuery()
5252
->getResult();
5353

54-
$subCategories = array_merge(...array_map(static fn(Category $category) => $category->getChildren()->toArray(), $rootCategories));
54+
$subCategories = array_merge(...array_map(static fn (Category $category) => $category->getChildren()->toArray(), $rootCategories));
5555
$this->getEntityManager()->createQueryBuilder()
5656
->select('PARTIAL subCategory.{id}', 'subSubCategory')
5757
->from(Category::class, 'subCategory')
@@ -134,7 +134,11 @@ public function testOneHasManyDeepWithPreload(): void
134134
]);
135135
}
136136

137-
private function createCategoryTree(int $depth, int $branchingFactor, ?Category $parent = null): void
137+
private function createCategoryTree(
138+
int $depth,
139+
int $branchingFactor,
140+
?Category $parent = null,
141+
): void
138142
{
139143
for ($i = 0; $i < $branchingFactor; $i++) {
140144
$category = new Category("Category $depth-$i", $parent);

tests/EntityPreloadSyntheticTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ private function givenEntityWithNoRelations(): EntityWithNoRelations
902902
}
903903

904904
private function givenEntityWithManyToOneEntityWithNoRelations(
905-
EntityWithNoRelations $entityWithNoRelations
905+
EntityWithNoRelations $entityWithNoRelations,
906906
): EntityWithManyToOneEntityWithNoRelations
907907
{
908908
$entityWithManyToOneEntityWithNoRelations = new EntityWithManyToOneEntityWithNoRelations($entityWithNoRelations);
@@ -920,7 +920,7 @@ private function givenChildEntityWithNoRelationsA(): ChildEntityWithNoRelationsA
920920
}
921921

922922
private function givenEntityWithManyToOneAbstractEntityWithNoRelations(
923-
AbstractEntityWithNoRelations $abstractEntityWithNoRelations
923+
AbstractEntityWithNoRelations $abstractEntityWithNoRelations,
924924
): EntityWithManyToOneAbstractEntityWithNoRelations
925925
{
926926
$entityWithManyToOneAbstractEntityWithNoRelations = new EntityWithManyToOneAbstractEntityWithNoRelations($abstractEntityWithNoRelations);
@@ -930,7 +930,7 @@ private function givenEntityWithManyToOneAbstractEntityWithNoRelations(
930930
}
931931

932932
private function givenEntityWithManyToOneOfManyToOneAbstractEntities(
933-
EntityWithManyToOneAbstractEntityWithNoRelations $entityWithManyToOneAbstractEntityWithNoRelations
933+
EntityWithManyToOneAbstractEntityWithNoRelations $entityWithManyToOneAbstractEntityWithNoRelations,
934934
): EntityWithManyToOneOfManyToOneAbstractEntities
935935
{
936936
$entityWithManyToOneOfManyToOneAbstractEntities = new EntityWithManyToOneOfManyToOneAbstractEntities($entityWithManyToOneAbstractEntityWithNoRelations);
@@ -969,7 +969,7 @@ private function thenExpectedQueriesArePerformed(array $expectedQueries): void
969969
}
970970

971971
private function givenConcreteEntityWithOptionalManyToOneItselfRelation(
972-
?ConcreteStiEntityWithOptionalManyToOneOfItselfRelation $parent
972+
?ConcreteStiEntityWithOptionalManyToOneOfItselfRelation $parent,
973973
): ConcreteStiEntityWithOptionalManyToOneOfItselfRelation
974974
{
975975
$entity = new ConcreteStiEntityWithOptionalManyToOneOfItselfRelation($parent);
@@ -980,7 +980,7 @@ private function givenConcreteEntityWithOptionalManyToOneItselfRelation(
980980
}
981981

982982
private function givenWithManyToOneOfManyToOneItselfRelation(
983-
ConcreteStiEntityWithOptionalManyToOneOfItselfRelation $currentEntityWithRelationToItself
983+
ConcreteStiEntityWithOptionalManyToOneOfItselfRelation $currentEntityWithRelationToItself,
984984
): EntityWithManyToOneOfManyToOneItselfStiRelation
985985
{
986986
$entityWithManyToOneOfManyToOneItselfRelation = new EntityWithManyToOneOfManyToOneItselfStiRelation($currentEntityWithRelationToItself);
@@ -991,7 +991,7 @@ private function givenWithManyToOneOfManyToOneItselfRelation(
991991
}
992992

993993
private function givenWithManyToOneOfManyToOneOfManyToOneItselfRelation(
994-
EntityWithManyToOneOfManyToOneItselfStiRelation $entityWithManyToOneOfManyToOneItselfRelation
994+
EntityWithManyToOneOfManyToOneItselfStiRelation $entityWithManyToOneOfManyToOneItselfRelation,
995995
): EntityWithManyToOneOfManyToOneOfManyToOneItselfRelation
996996
{
997997
$entityWithManyToOneOfManyToOneOfManyToOneItselfRelation = new EntityWithManyToOneOfManyToOneOfManyToOneItselfRelation($entityWithManyToOneOfManyToOneItselfRelation);

tests/Fixtures/Blog/Article.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class Article
4545
#[OrderBy(['id' => 'DESC'])]
4646
private Collection $comments;
4747

48-
public function __construct(string $title, string $content, ?Category $category = null)
48+
public function __construct(
49+
string $title,
50+
string $content,
51+
?Category $category = null,
52+
)
4953
{
5054
$this->title = $title;
5155
$this->content = $content;

tests/Fixtures/Blog/Bot.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class Bot extends Contributor
1818
#[Column]
1919
private string $apiKeyHash;
2020

21-
public function __construct(string $name, string $apiKey, string $prompt)
21+
public function __construct(
22+
string $name,
23+
string $apiKey,
24+
string $prompt,
25+
)
2226
{
2327
parent::__construct($name);
2428
$this->activePrompt = new BotPromptVersion($prompt);

tests/Fixtures/Blog/BotPromptVersion.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ class BotPromptVersion
2929
#[OneToOne(mappedBy: 'prevVersion')]
3030
private ?BotPromptVersion $nextVersion;
3131

32-
public function __construct(string $prompt, ?self $prevScript = null)
32+
public function __construct(
33+
string $prompt,
34+
?self $prevScript = null,
35+
)
3336
{
3437
$this->version = ($prevScript->version ?? 0) + 1;
3538
$this->prompt = $prompt;
@@ -56,12 +59,12 @@ public function getPrompt(): string
5659
return $this->prompt;
5760
}
5861

59-
public function getPrevVersion(): ?BotPromptVersion
62+
public function getPrevVersion(): ?self
6063
{
6164
return $this->prevVersion;
6265
}
6366

64-
public function getNextVersion(): ?BotPromptVersion
67+
public function getNextVersion(): ?self
6568
{
6669
return $this->nextVersion;
6770
}

tests/Fixtures/Blog/Category.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ class Category
3939
#[OneToMany(targetEntity: Article::class, mappedBy: 'category')]
4040
private Collection $articles;
4141

42-
public function __construct(string $name, ?self $parent = null)
42+
public function __construct(
43+
string $name,
44+
?self $parent = null,
45+
)
4346
{
4447
$this->name = $name;
4548
$this->parent = $parent;
@@ -83,7 +86,7 @@ public function getArticles(): ReadableCollection
8386
/**
8487
* @internal
8588
*/
86-
public function addChild(Category $category): void
89+
public function addChild(self $category): void
8790
{
8891
if (!$this->children->contains($category)) {
8992
$this->children->add($category);

tests/Fixtures/Blog/Comment.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class Comment
2626
#[Column]
2727
private string $content;
2828

29-
public function __construct(Article $article, Contributor $author, string $content)
29+
public function __construct(
30+
Article $article,
31+
Contributor $author,
32+
string $content,
33+
)
3034
{
3135
$this->article = $article;
3236
$this->author = $author;

0 commit comments

Comments
 (0)