Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update PHPDoc and remove unnecessary PHPDoc applied to fix PHP-CS-Fixer errors #1334 #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
count: 1
path: src/Twig/SourceCodeExtension.php
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phpstan-baseline.neon

parameters:
level: max
paths:
Expand Down
3 changes: 1 addition & 2 deletions src/Command/ListUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
};

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

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

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

if (null !== $email) {
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use App\Entity\Comment;
use App\Entity\Post;
use App\Entity\Tag;
use App\Entity\User;
use App\Event\CommentCreatedEvent;
use App\Form\CommentType;
Expand Down Expand Up @@ -53,7 +52,6 @@ public function index(Request $request, int $page, string $_format, PostReposito
{
$tag = null;
if ($request->query->has('tag')) {
/** @var Tag $tag */
$tag = $tags->findOneBy(['name' => $request->query->get('tag')]);
}
$latestPosts = $posts->findLatest($page, $tag);
Expand Down
19 changes: 13 additions & 6 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ private function loadTags(ObjectManager $manager): void

private function loadPosts(ObjectManager $manager): void
{
/** @var User $author */
/** @var array<Tag> $tags */
foreach ($this->getPostData() as [$title, $slug, $summary, $content, $publishedAt, $author, $tags]) {
$post = new Post();
$post->setTitle($title);
Expand Down Expand Up @@ -132,21 +130,25 @@ private function getTagData(): array
/**
* @throws \Exception
*
* @return array<int, array{0: string, 1: AbstractUnicodeString, 2: string, 3: string, 4: \DateTime, 5: object, 6: array<object>}>
* @return array<int, array{0: string, 1: AbstractUnicodeString, 2: string, 3: string, 4: \DateTime, 5: User, 6: array<Tag>}>
*/
private function getPostData(): array
{
$posts = [];
foreach ($this->getPhrases() as $i => $title) {
// $postData = [$title, $slug, $summary, $content, $publishedAt, $author, $tags, $comments];

/** @var User $user */
$user = $this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)]);

$posts[] = [
$title,
$this->slugger->slug($title)->lower(),
$this->getRandomText(),
$this->getPostContent(),
new \DateTime('now - '.$i.'days'),
// Ensure that the first post is written by Jane Doe to simplify tests
$this->getReference(['jane_admin', 'tom_admin'][0 === $i ? 0 : random_int(0, 1)]),
$user,
$this->getRandomTags(),
];
}
Expand Down Expand Up @@ -249,14 +251,19 @@ private function getPostContent(): string
/**
* @throws \Exception
*
* @return array<object>
* @return array<Tag>
*/
private function getRandomTags(): array
{
$tagNames = $this->getTagData();
shuffle($tagNames);
$selectedTags = \array_slice($tagNames, 0, random_int(2, 4));

return array_map(function ($tagName) { return $this->getReference('tag-'.$tagName); }, $selectedTags);
return array_map(function ($tagName) {
/** @var Tag $tag */
$tag = $this->getReference('tag-'.$tagName);

return $tag;
}, $selectedTags);
}
}
2 changes: 0 additions & 2 deletions src/Form/DataTransformer/TagArrayToStringTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function __construct(

/**
* {@inheritdoc}
*
* @phpstan-param array<Tag>|null $tags
*/
public function transform($tags): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Security/PostVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PostVoter extends Voter
/**
* {@inheritdoc}
*
* @phpstan-param Post $subject
* @phpstan-param object $subject
*/
protected function supports(string $attribute, $subject): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppExtension extends AbstractExtension
private array $localeCodes;

/**
* @var array<int, array<string, string>>|null
* @var list<array{code: string, name: string}>|null
*/
private ?array $locales = null;

Expand Down
1 change: 0 additions & 1 deletion src/Twig/SourceCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ private function getCallableReflector(callable $callable): \ReflectionFunctionAb
return $r->getMethod('__invoke');
}

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

Expand Down
5 changes: 2 additions & 3 deletions tests/Command/AddUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ private function assertUserCreated(bool $isAdmin): void
/** @var UserRepository $repository */
$repository = $this->getContainer()->get(UserRepository::class);

/** @var \App\Entity\User $user */
$user = $repository->findOneByEmail($this->userData['email']);

/** @var UserPasswordHasherInterface $passwordHasher */
$passwordHasher = $this->getContainer()->get('test.user_password_hasher');

$user = $repository->findOneByEmail($this->userData['email']);

$this->assertNotNull($user);
$this->assertSame($this->userData['full-name'], $user->getFullName());
$this->assertSame($this->userData['username'], $user->getUsername());
Expand Down