mirror of
https://github.com/symfony/demo.git
synced 2026-03-24 00:02:32 +01:00
PHP CS Fixer: apply PHP 8.2 rules
This commit is contained in:
committed by
Javier Eguiluz
parent
0b4264c040
commit
3350f7719c
@@ -10,13 +10,13 @@
|
||||
*/
|
||||
|
||||
$fileHeaderComment = <<<COMMENT
|
||||
This file is part of the Symfony package.
|
||||
This file is part of the Symfony package.
|
||||
|
||||
(c) Fabien Potencier <fabien@symfony.com>
|
||||
(c) Fabien Potencier <fabien@symfony.com>
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
COMMENT;
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
COMMENT;
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setFinder(
|
||||
@@ -24,8 +24,11 @@ return (new PhpCsFixer\Config())
|
||||
)
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PHP8x2Migration' => true,
|
||||
'@PHP8x2Migration:risky' => true,
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'declare_strict_types' => false, // depends how project wants to handle type matching and untaint user input
|
||||
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
|
||||
'no_useless_else' => true,
|
||||
'no_useless_return' => true,
|
||||
|
||||
@@ -220,25 +220,25 @@ final class AddUserCommand extends Command
|
||||
* code readability.
|
||||
*/
|
||||
public const HELP = <<<'HELP'
|
||||
The <info>%command.name%</info> command creates new users and saves them in the database:
|
||||
The <info>%command.name%</info> command creates new users and saves them in the database:
|
||||
|
||||
<info>php %command.full_name%</info> <comment>username password email</comment>
|
||||
<info>php %command.full_name%</info> <comment>username password email</comment>
|
||||
|
||||
By default the command creates regular users. To create administrator users,
|
||||
add the <comment>--admin</comment> option:
|
||||
By default the command creates regular users. To create administrator users,
|
||||
add the <comment>--admin</comment> option:
|
||||
|
||||
<info>php %command.full_name%</info> username password email <comment>--admin</comment>
|
||||
<info>php %command.full_name%</info> username password email <comment>--admin</comment>
|
||||
|
||||
If you omit any of the three required arguments, the command will ask you to
|
||||
provide the missing values:
|
||||
If you omit any of the three required arguments, the command will ask you to
|
||||
provide the missing values:
|
||||
|
||||
# command will ask you for the email
|
||||
<info>php %command.full_name%</info> <comment>username password</comment>
|
||||
# command will ask you for the email
|
||||
<info>php %command.full_name%</info> <comment>username password</comment>
|
||||
|
||||
# command will ask you for the email and password
|
||||
<info>php %command.full_name%</info> <comment>username</comment>
|
||||
# command will ask you for the email and password
|
||||
<info>php %command.full_name%</info> <comment>username</comment>
|
||||
|
||||
# command will ask you for all arguments
|
||||
<info>php %command.full_name%</info>
|
||||
HELP;
|
||||
# command will ask you for all arguments
|
||||
<info>php %command.full_name%</info>
|
||||
HELP;
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
name: 'app:delete-user',
|
||||
description: 'Deletes users from the database',
|
||||
help: <<<'HELP'
|
||||
The <info>%command.name%</info> command deletes users from the database:
|
||||
The <info>%command.name%</info> command deletes users from the database:
|
||||
|
||||
<info>php %command.full_name%</info> <comment>username</comment>
|
||||
<info>php %command.full_name%</info> <comment>username</comment>
|
||||
|
||||
If you omit the argument, the command will ask you to
|
||||
provide the missing value:
|
||||
If you omit the argument, the command will ask you to
|
||||
provide the missing value:
|
||||
|
||||
<info>php %command.full_name%</info>
|
||||
HELP,
|
||||
<info>php %command.full_name%</info>
|
||||
HELP,
|
||||
)]
|
||||
final class DeleteUserCommand extends Command
|
||||
{
|
||||
|
||||
@@ -86,15 +86,13 @@ final class ListUsersCommand
|
||||
// Use ->findBy() instead of ->findAll() to allow result sorting and limiting
|
||||
$allUsers = $this->users->findBy([], ['id' => 'DESC'], $maxResults);
|
||||
|
||||
$createUserArray = static function (User $user): array {
|
||||
return [
|
||||
$user->getId(),
|
||||
$user->getFullName(),
|
||||
$user->getUsername(),
|
||||
$user->getEmail(),
|
||||
implode(', ', $user->getRoles()),
|
||||
];
|
||||
};
|
||||
$createUserArray = static fn (User $user): array => [
|
||||
$user->getId(),
|
||||
$user->getFullName(),
|
||||
$user->getUsername(),
|
||||
$user->getEmail(),
|
||||
implode(', ', $user->getRoles()),
|
||||
];
|
||||
|
||||
// Doctrine query returns an array of objects, and we need an array of plain arrays
|
||||
$usersAsPlainArrays = array_map($createUserArray, $allUsers);
|
||||
|
||||
@@ -73,7 +73,7 @@ final class PostType extends AbstractType
|
||||
// form events let you modify information or fields at different steps
|
||||
// of the form handling process.
|
||||
// See https://symfony.com/doc/current/form/events.html
|
||||
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
|
||||
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event): void {
|
||||
/** @var Post $post */
|
||||
$post = $event->getData();
|
||||
if (null === $post->getSlug() && null !== $post->getTitle()) {
|
||||
|
||||
@@ -100,8 +100,6 @@ class PostRepository extends ServiceEntityRepository
|
||||
$terms = array_unique(u($searchQuery)->replaceMatches('/[[:space:]]+/', ' ')->trim()->split(' '));
|
||||
|
||||
// ignore the search terms that are too short
|
||||
return array_filter($terms, static function ($term) {
|
||||
return 2 <= $term->length();
|
||||
});
|
||||
return array_filter($terms, static fn ($term) => 2 <= $term->length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ final class AppExtension
|
||||
#[AsTwigFunction('is_rtl')]
|
||||
public function isRtl(?string $locale = null): bool
|
||||
{
|
||||
$locale = $locale ?? $this->defaultLocale;
|
||||
$locale ??= $this->defaultLocale;
|
||||
|
||||
return \in_array($locale, ['ar', 'fa', 'he', 'ur', 'ps', 'sd'], true);
|
||||
}
|
||||
|
||||
@@ -167,16 +167,12 @@ final class SourceCodeExtension
|
||||
{
|
||||
$codeLines = u($code)->split("\n");
|
||||
|
||||
$indentedOrBlankLines = array_filter($codeLines, static function ($lineOfCode) {
|
||||
return u($lineOfCode)->isEmpty() || u($lineOfCode)->startsWith(' ');
|
||||
});
|
||||
$indentedOrBlankLines = array_filter($codeLines, static fn ($lineOfCode) => u($lineOfCode)->isEmpty() || u($lineOfCode)->startsWith(' '));
|
||||
|
||||
$codeIsIndented = \count($indentedOrBlankLines) === \count($codeLines);
|
||||
|
||||
if ($codeIsIndented) {
|
||||
$unindentedLines = array_map(static function ($lineOfCode) {
|
||||
return u($lineOfCode)->after(' ');
|
||||
}, $codeLines);
|
||||
$unindentedLines = array_map(static fn ($lineOfCode) => u($lineOfCode)->after(' '), $codeLines);
|
||||
$code = u("\n")->join($unindentedLines)->toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@ if (method_exists(Dotenv::class, 'bootEnv')) {
|
||||
}
|
||||
|
||||
if ($_SERVER['APP_DEBUG']) {
|
||||
umask(0000);
|
||||
umask(0o000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user