Skip to content

Commit 268bc12

Browse files
committed
Remove the no longer needed temp vars
1 parent a872fdf commit 268bc12

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/DataFixtures/AppFixtures.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@ private function loadPosts(ObjectManager $manager): void
8181
$post->addTag(...$tags);
8282

8383
foreach (range(1, 5) as $i) {
84-
/** @var User $commentAuthor */
85-
$commentAuthor = $this->getReference('john_user', User::class);
86-
8784
$comment = new Comment();
88-
$comment->setAuthor($commentAuthor);
85+
$comment->setAuthor($this->getReference('john_user', User::class));
8986
$comment->setContent($this->getRandomText(random_int(255, 512)));
9087
$comment->setPublishedAt(new \DateTimeImmutable('now + '.$i.'seconds'));
9188

@@ -140,18 +137,14 @@ private function getPostData(): array
140137

141138
foreach ($this->getPhrases() as $i => $title) {
142139
// $postData = [$title, $slug, $summary, $content, $publishedAt, $author, $tags, $comments];
143-
144-
/** @var User $user */
145-
$user = $this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)], User::class);
146-
147140
$posts[] = [
148141
$title,
149142
$this->slugger->slug($title)->lower(),
150143
$this->getRandomText(),
151144
$this->getPostContent(),
152145
(new \DateTimeImmutable('now - '.$i.'days'))->setTime(random_int(8, 17), random_int(7, 49), random_int(0, 59)),
153146
// Ensure that the first post is written by Jane Doe to simplify tests
154-
$user,
147+
$this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)], User::class),
155148
$this->getRandomTags(),
156149
];
157150
}
@@ -262,11 +255,9 @@ private function getRandomTags(): array
262255
shuffle($tagNames);
263256
$selectedTags = \array_slice($tagNames, 0, random_int(2, 4));
264257

265-
return array_map(function ($tagName) {
266-
/** @var Tag $tag */
267-
$tag = $this->getReference('tag-'.$tagName, Tag::class);
268-
269-
return $tag;
270-
}, $selectedTags);
258+
return array_map(
259+
fn ($tagName) => $this->getReference('tag-'.$tagName, Tag::class),
260+
$selectedTags
261+
);
271262
}
272263
}

0 commit comments

Comments
 (0)