Skip to content

Commit 8b036a5

Browse files
committed
minor #1374 Update PHPDoc and remove unnecessary PHPDoc applied to fix PHP-CS-Fixer errors #1334 (kniziol)
This PR was squashed before being merged into the main branch. Discussion ---------- Update PHPDoc and remove unnecessary PHPDoc applied to fix PHP-CS-Fixer errors #1334 Commits ------- 0d10adb Update PHPDoc and remove unnecessary PHPDoc applied to fix PHP-CS-Fixer errors #1334
2 parents 5fbfdb7 + 0d10adb commit 8b036a5

File tree

10 files changed

+27
-18
lines changed

10 files changed

+27
-18
lines changed

phpstan-baseline.neon

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
5+
count: 1
6+
path: src/Twig/SourceCodeExtension.php

phpstan.neon.dist

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
14
parameters:
25
level: max
36
paths:

src/Command/ListUsersCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
105105
};
106106

107107
// Doctrine query returns an array of objects, and we need an array of plain arrays
108-
/** @var callable $createUserArray */
109108
$usersAsPlainArrays = array_map($createUserArray, $allUsers);
110109

111110
// In your console commands you should always use the regular output type,
@@ -124,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
124123
$usersAsATable = $bufferedOutput->fetch();
125124
$output->write($usersAsATable);
126125

127-
/** @var string $email */
126+
/** @var string|null $email */
128127
$email = $input->getOption('send-to');
129128

130129
if (null !== $email) {

src/Controller/BlogController.php

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use App\Entity\Comment;
1515
use App\Entity\Post;
16-
use App\Entity\Tag;
1716
use App\Entity\User;
1817
use App\Event\CommentCreatedEvent;
1918
use App\Form\CommentType;
@@ -53,7 +52,6 @@ public function index(Request $request, int $page, string $_format, PostReposito
5352
{
5453
$tag = null;
5554
if ($request->query->has('tag')) {
56-
/** @var Tag $tag */
5755
$tag = $tags->findOneBy(['name' => $request->query->get('tag')]);
5856
}
5957
$latestPosts = $posts->findLatest($page, $tag);

src/DataFixtures/AppFixtures.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Form/DataTransformer/TagArrayToStringTransformer.php

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public function __construct(
3636

3737
/**
3838
* {@inheritdoc}
39-
*
40-
* @phpstan-param array<Tag>|null $tags
4139
*/
4240
public function transform($tags): string
4341
{

src/Security/PostVoter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PostVoter extends Voter
3535
/**
3636
* {@inheritdoc}
3737
*
38-
* @phpstan-param Post $subject
38+
* @phpstan-param object $subject
3939
*/
4040
protected function supports(string $attribute, $subject): bool
4141
{

src/Twig/AppExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AppExtension extends AbstractExtension
3030
private array $localeCodes;
3131

3232
/**
33-
* @var array<int, array<string, string>>|null
33+
* @var list<array{code: string, name: string}>|null
3434
*/
3535
private ?array $locales = null;
3636

src/Twig/SourceCodeExtension.php

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ private function getCallableReflector(callable $callable): \ReflectionFunctionAb
117117
return $r->getMethod('__invoke');
118118
}
119119

120-
// @phpstan-ignore-next-line
121120
return new \ReflectionFunction($callable);
122121
}
123122

tests/Command/AddUserCommandTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ private function assertUserCreated(bool $isAdmin): void
9191
/** @var UserRepository $repository */
9292
$repository = $this->getContainer()->get(UserRepository::class);
9393

94-
/** @var \App\Entity\User $user */
95-
$user = $repository->findOneByEmail($this->userData['email']);
96-
9794
/** @var UserPasswordHasherInterface $passwordHasher */
9895
$passwordHasher = $this->getContainer()->get('test.user_password_hasher');
9996

97+
$user = $repository->findOneByEmail($this->userData['email']);
98+
10099
$this->assertNotNull($user);
101100
$this->assertSame($this->userData['full-name'], $user->getFullName());
102101
$this->assertSame($this->userData['username'], $user->getUsername());

0 commit comments

Comments
 (0)