Skip to content

Commit 4d9888d

Browse files
committed
minor #1491 More consistent code style (shuraknows)
This PR was squashed before being merged into the main branch. Discussion ---------- More consistent code style Multiple-line code blocks is being separated with new line from single-line code blocks. Also php-cs-fixer suggested fix: functions with default null arguments should accept null value. Commits ------- cb82e93 More consistent code style
2 parents dc20a11 + cb82e93 commit 4d9888d

10 files changed

+17
-2
lines changed

src/Command/AddUserCommand.php

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
138138

139139
// Ask for the email if it's not defined
140140
$email = $input->getArgument('email');
141+
141142
if (null !== $email) {
142143
$this->io->text(' > <info>Email</info>: '.$email);
143144
} else {
@@ -147,6 +148,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
147148

148149
// Ask for the full name if it's not defined
149150
$fullName = $input->getArgument('full-name');
151+
150152
if (null !== $fullName) {
151153
$this->io->text(' > <info>Full Name</info>: '.$fullName);
152154
} else {
@@ -198,6 +200,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
198200
$this->io->success(sprintf('%s was successfully created: %s (%s)', $isAdmin ? 'Administrator user' : 'User', $user->getUsername(), $user->getEmail()));
199201

200202
$event = $stopwatch->stop('add-user-command');
203+
201204
if ($output->isVerbose()) {
202205
$this->io->comment(sprintf('New user database id: %d / Elapsed time: %.2f ms / Consumed memory: %.2f MB', $user->getId(), $event->getDuration(), $event->getMemory() / (1024 ** 2)));
203206
}

src/Controller/BlogController.php

+2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ final class BlogController extends AbstractController
5151
public function index(Request $request, int $page, string $_format, PostRepository $posts, TagRepository $tags): Response
5252
{
5353
$tag = null;
54+
5455
if ($request->query->has('tag')) {
5556
$tag = $tags->findOneBy(['name' => $request->query->get('tag')]);
5657
}
58+
5759
$latestPosts = $posts->findLatest($page, $tag);
5860

5961
// Every template name also has two extensions that specify the format and

src/DataFixtures/AppFixtures.php

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private function getTagData(): array
135135
private function getPostData(): array
136136
{
137137
$posts = [];
138+
138139
foreach ($this->getPhrases() as $i => $title) {
139140
// $postData = [$title, $slug, $summary, $content, $publishedAt, $author, $tags, $comments];
140141

src/Entity/Post.php

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public function getComments(): Collection
154154
public function addComment(Comment $comment): void
155155
{
156156
$comment->setPost($this);
157+
157158
if (!$this->comments->contains($comment)) {
158159
$this->comments->add($comment);
159160
}

src/EventSubscriber/CommentNotificationSubscriber.php

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function onCommentCreated(CommentCreatedEvent $event): void
6363
], UrlGeneratorInterface::ABSOLUTE_URL);
6464

6565
$subject = $this->translator->trans('notification.comment_created');
66+
6667
$body = $this->translator->trans('notification.comment_created.description', [
6768
'title' => $post->getTitle(),
6869
'link' => $linkToPost,

src/EventSubscriber/RedirectToPreferredLocaleSubscriber.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ final class RedirectToPreferredLocaleSubscriber implements EventSubscriberInterf
3737
public function __construct(
3838
private readonly UrlGeneratorInterface $urlGenerator,
3939
string $locales,
40-
string $defaultLocale = null
40+
?string $defaultLocale = null
4141
) {
4242
$this->locales = explode('|', trim($locales));
43+
4344
if (empty($this->locales)) {
4445
throw new \UnexpectedValueException('The list of supported locales must not be empty.');
4546
}
@@ -75,6 +76,7 @@ public function onKernelRequest(RequestEvent $event): void
7576
// Ignore requests from referrers with the same HTTP host in order to prevent
7677
// changing language for users who possibly already selected it for this application.
7778
$referrer = $request->headers->get('referer');
79+
7880
if (null !== $referrer && u($referrer)->ignoreCase()->startsWith($request->getSchemeAndHttpHost())) {
7981
return;
8082
}

src/Form/DataTransformer/TagArrayToStringTransformer.php

+2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public function reverseTransform($string): array
6161
$tags = $this->tags->findBy([
6262
'name' => $names,
6363
]);
64+
6465
$newNames = array_diff($names, $tags);
66+
6567
foreach ($newNames as $name) {
6668
$tags[] = new Tag($name);
6769

src/Repository/PostRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(ManagerRegistry $registry)
3939
parent::__construct($registry, Post::class);
4040
}
4141

42-
public function findLatest(int $page = 1, Tag $tag = null): Paginator
42+
public function findLatest(int $page = 1, ?Tag $tag = null): Paginator
4343
{
4444
$qb = $this->createQueryBuilder('p')
4545
->addSelect('a', 't')

src/Twig/AppExtension.php

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function getLocales(): array
6464
}
6565

6666
$this->locales = [];
67+
6768
foreach ($this->localeCodes as $localeCode) {
6869
$this->locales[] = ['code' => $localeCode, 'name' => Locales::getName($localeCode, $localeCode)];
6970
}

src/Twig/SourceCodeExtension.php

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function getFunctions(): array
6565
public function linkSourceFile(Environment $twig, string $file, int $line): string
6666
{
6767
$text = str_replace('\\', '/', $file);
68+
6869
if (str_starts_with($text, $this->projectDir)) {
6970
$text = mb_substr($text, mb_strlen($this->projectDir));
7071
}
@@ -180,6 +181,7 @@ private function unindentCode(string $code): string
180181
});
181182

182183
$codeIsIndented = \count($indentedOrBlankLines) === \count($codeLines);
184+
183185
if ($codeIsIndented) {
184186
$unindentedLines = array_map(static function ($lineOfCode) {
185187
return u($lineOfCode)->after(' ');

0 commit comments

Comments
 (0)