@@ -68,8 +68,6 @@ private function loadTags(ObjectManager $manager): void
6868
6969 private function loadPosts (ObjectManager $ manager ): void
7070 {
71- /** @var User $author */
72- /** @var array<Tag> $tags */
7371 foreach ($ this ->getPostData () as [$ title , $ slug , $ summary , $ content , $ publishedAt , $ author , $ tags ]) {
7472 $ post = new Post ();
7573 $ post ->setTitle ($ title );
@@ -132,21 +130,25 @@ private function getTagData(): array
132130 /**
133131 * @throws \Exception
134132 *
135- * @return array<int, array{0: string, 1: AbstractUnicodeString, 2: string, 3: string, 4: \DateTime, 5: object , 6: array<object >}>
133+ * @return array<int, array{0: string, 1: AbstractUnicodeString, 2: string, 3: string, 4: \DateTime, 5: User , 6: array<Tag >}>
136134 */
137135 private function getPostData (): array
138136 {
139137 $ posts = [];
140138 foreach ($ this ->getPhrases () as $ i => $ title ) {
141139 // $postData = [$title, $slug, $summary, $content, $publishedAt, $author, $tags, $comments];
140+
141+ /** @var User $user */
142+ $ user = $ this ->getReference (['jane_admin ' , 'tom_admin ' ][0 === $ i ? 0 : random_int (0 , 1 )]);
143+
142144 $ posts [] = [
143145 $ title ,
144146 $ this ->slugger ->slug ($ title )->lower (),
145147 $ this ->getRandomText (),
146148 $ this ->getPostContent (),
147149 new \DateTime ('now - ' .$ i .'days ' ),
148150 // Ensure that the first post is written by Jane Doe to simplify tests
149- $ this -> getReference ([ ' jane_admin ' , ' tom_admin ' ][ 0 === $ i ? 0 : random_int ( 0 , 1 )]) ,
151+ $ user ,
150152 $ this ->getRandomTags (),
151153 ];
152154 }
@@ -249,14 +251,19 @@ private function getPostContent(): string
249251 /**
250252 * @throws \Exception
251253 *
252- * @return array<object >
254+ * @return array<Tag >
253255 */
254256 private function getRandomTags (): array
255257 {
256258 $ tagNames = $ this ->getTagData ();
257259 shuffle ($ tagNames );
258260 $ selectedTags = \array_slice ($ tagNames , 0 , random_int (2 , 4 ));
259261
260- return array_map (function ($ tagName ) { return $ this ->getReference ('tag- ' .$ tagName ); }, $ selectedTags );
262+ return array_map (function ($ tagName ) {
263+ /** @var Tag $tag */
264+ $ tag = $ this ->getReference ('tag- ' .$ tagName );
265+
266+ return $ tag ;
267+ }, $ selectedTags );
261268 }
262269}
0 commit comments