Skip to content

Misc. fixes and improvements #1229

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
Jul 12, 2021
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
2 changes: 1 addition & 1 deletion src/Command/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
* quite a lot of work. However, if the command is meant to be used by external
* users, this method is a nice way to fall back and prevent errors.
*/
protected function interact(InputInterface $input, OutputInterface $output)
protected function interact(InputInterface $input, OutputInterface $output): void
{
if (null !== $input->getArgument('username') && null !== $input->getArgument('password') && null !== $input->getArgument('email') && null !== $input->getArgument('full-name')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DeleteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
$this->io = new SymfonyStyle($input, $output);
}

protected function interact(InputInterface $input, OutputInterface $output)
protected function interact(InputInterface $input, OutputInterface $output): void
{
if (null !== $input->getArgument('username')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ListUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$allUsers = $this->users->findBy([], ['id' => 'DESC'], $maxResults);

// Doctrine query returns an array of objects and we need an array of plain arrays
$usersAsPlainArrays = array_map(function (User $user) {
$usersAsPlainArrays = array_map(static function (User $user) {
return [
$user->getId(),
$user->getFullName(),
Expand Down
74 changes: 37 additions & 37 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private function loadUsers(ObjectManager $manager): void

private function loadTags(ObjectManager $manager): void
{
foreach ($this->getTagData() as $index => $name) {
foreach ($this->getTagData() as $name) {
$tag = new Tag();
$tag->setName($name);

Expand Down Expand Up @@ -121,7 +121,7 @@ private function getTagData(): array
];
}

private function getPostData()
private function getPostData(): array
{
$posts = [];
foreach ($this->getPhrases() as $i => $title) {
Expand Down Expand Up @@ -193,41 +193,41 @@ private function getRandomText(int $maxLength = 255): string
private function getPostContent(): string
{
return <<<'MARKDOWN'
Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et **dolore magna aliqua**: Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.

* Ut enim ad minim veniam
* Quis nostrud exercitation *ullamco laboris*
* Nisi ut aliquip ex ea commodo consequat

Praesent id fermentum lorem. Ut est lorem, fringilla at accumsan nec, euismod at
nunc. Aenean mattis sollicitudin mattis. Nullam pulvinar vestibulum bibendum.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos
himenaeos. Fusce nulla purus, gravida ac interdum ut, blandit eget ex. Duis a
luctus dolor.

Integer auctor massa maximus nulla scelerisque accumsan. *Aliquam ac malesuada*
ex. Pellentesque tortor magna, vulputate eu vulputate ut, venenatis ac lectus.
Praesent ut lacinia sem. Mauris a lectus eget felis mollis feugiat. Quisque
efficitur, mi ut semper pulvinar, urna urna blandit massa, eget tincidunt augue
nulla vitae est.

Ut posuere aliquet tincidunt. Aliquam erat volutpat. **Class aptent taciti**
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi
arcu orci, gravida eget aliquam eu, suscipit et ante. Morbi vulputate metus vel
ipsum finibus, ut dapibus massa feugiat. Vestibulum vel lobortis libero. Sed
tincidunt tellus et viverra scelerisque. Pellentesque tincidunt cursus felis.
Sed in egestas erat.

Aliquam pulvinar interdum massa, vel ullamcorper ante consectetur eu. Vestibulum
lacinia ac enim vel placerat. Integer pulvinar magna nec dui malesuada, nec
congue nisl dictum. Donec mollis nisl tortor, at congue erat consequat a. Nam
tempus elit porta, blandit elit vel, viverra lorem. Sed sit amet tellus
tincidunt, faucibus nisl in, aliquet libero.
MARKDOWN;
Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et **dolore magna aliqua**: Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.

* Ut enim ad minim veniam
* Quis nostrud exercitation *ullamco laboris*
* Nisi ut aliquip ex ea commodo consequat

Praesent id fermentum lorem. Ut est lorem, fringilla at accumsan nec, euismod at
nunc. Aenean mattis sollicitudin mattis. Nullam pulvinar vestibulum bibendum.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos
himenaeos. Fusce nulla purus, gravida ac interdum ut, blandit eget ex. Duis a
luctus dolor.

Integer auctor massa maximus nulla scelerisque accumsan. *Aliquam ac malesuada*
ex. Pellentesque tortor magna, vulputate eu vulputate ut, venenatis ac lectus.
Praesent ut lacinia sem. Mauris a lectus eget felis mollis feugiat. Quisque
efficitur, mi ut semper pulvinar, urna urna blandit massa, eget tincidunt augue
nulla vitae est.

Ut posuere aliquet tincidunt. Aliquam erat volutpat. **Class aptent taciti**
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi
arcu orci, gravida eget aliquam eu, suscipit et ante. Morbi vulputate metus vel
ipsum finibus, ut dapibus massa feugiat. Vestibulum vel lobortis libero. Sed
tincidunt tellus et viverra scelerisque. Pellentesque tincidunt cursus felis.
Sed in egestas erat.

Aliquam pulvinar interdum massa, vel ullamcorper ante consectetur eu. Vestibulum
lacinia ac enim vel placerat. Integer pulvinar magna nec dui malesuada, nec
congue nisl dictum. Donec mollis nisl tortor, at congue erat consequat a. Nam
tempus elit porta, blandit elit vel, viverra lorem. Sed sit amet tellus
tincidunt, faucibus nisl in, aliquet libero.
MARKDOWN;
}

private function getRandomTags(): array
Expand Down
6 changes: 0 additions & 6 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,12 @@ public function eraseCredentials(): void
// $this->plainPassword = null;
}

/**
* {@inheritdoc}
*/
public function __serialize(): array
{
// add $this->salt too if you don't use Bcrypt or Argon2i
return [$this->id, $this->username, $this->password];
}

/**
* {@inheritdoc}
*/
public function __unserialize(array $data): void
{
// add $this->salt too if you don't use Bcrypt or Argon2i
Expand Down
2 changes: 0 additions & 2 deletions src/EventSubscriber/CommentNotificationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace App\EventSubscriber;

use App\Entity\Comment;
use App\Event\CommentCreatedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Mailer\MailerInterface;
Expand Down Expand Up @@ -48,7 +47,6 @@ public static function getSubscribedEvents(): array

public function onCommentCreated(CommentCreatedEvent $event): void
{
/** @var Comment $comment */
$comment = $event->getComment();
$post = $comment->getPost();

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function extractSearchTerms(string $searchQuery): array
$terms = array_unique($searchQuery->split(' '));

// ignore the search terms that are too short
return array_filter($terms, function ($term) {
return array_filter($terms, static function ($term) {
return 2 <= $term->length();
});
}
Expand Down
9 changes: 4 additions & 5 deletions src/Twig/SourceCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use function Symfony\Component\String\u;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\Template;
use Twig\TemplateWrapper;
use Twig\TwigFunction;

Expand All @@ -31,7 +30,7 @@ class SourceCodeExtension extends AbstractExtension
{
private $controller;

public function setController(?callable $controller)
public function setController(?callable $controller): void
{
$this->controller = $controller;
}
Expand Down Expand Up @@ -120,16 +119,16 @@ private function unindentCode(string $code): string
{
$codeLines = u($code)->split("\n");

$indentedOrBlankLines = array_filter($codeLines, function ($lineOfCode) {
$indentedOrBlankLines = array_filter($codeLines, static function ($lineOfCode) {
return u($lineOfCode)->isEmpty() || u($lineOfCode)->startsWith(' ');
});

$codeIsIndented = \count($indentedOrBlankLines) === \count($codeLines);
if ($codeIsIndented) {
$unindentedLines = array_map(function ($lineOfCode) {
$unindentedLines = array_map(static function ($lineOfCode) {
return u($lineOfCode)->after(' ');
}, $codeLines);
$code = u("\n")->join($unindentedLines);
$code = u("\n")->join($unindentedLines)->toString();
}

return $code;
Expand Down