Skip to content

Commit 6ca1d73

Browse files
Leverage first-class callable syntax
1 parent e162d39 commit 6ca1d73

File tree

128 files changed

+251
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+251
-272
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function configureOptions(OptionsResolver $resolver)
156156
$choiceValue = function (Options $options) {
157157
// If the entity has a single-column ID, use that ID as value
158158
if ($options['id_reader'] instanceof IdReader && $options['id_reader']->isSingleId()) {
159-
return ChoiceList::value($this, [$options['id_reader'], 'getIdValue'], $options['id_reader']);
159+
return ChoiceList::value($this, $options['id_reader']->getIdValue(...), $options['id_reader']);
160160
}
161161

162162
// Otherwise, an incrementing integer is used as value automatically

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getQueryBuilderPartsForCachingHash(object $queryBuilder): ?array
8282

8383
return [
8484
$queryBuilder->getQuery()->getSQL(),
85-
array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()),
85+
array_map($this->parameterToArray(...), $queryBuilder->getParameters()->toArray()),
8686
];
8787
}
8888

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ public function __construct(array $options = [])
7272
if (class_exists(VarCloner::class)) {
7373
$this->cloner = new VarCloner();
7474
$this->cloner->addCasters([
75-
'*' => [$this, 'castObject'],
75+
'*' => $this->castObject(...),
7676
]);
7777

7878
$this->outputBuffer = fopen('php://memory', 'r+');
7979
if ($this->options['multiline']) {
8080
$output = $this->outputBuffer;
8181
} else {
82-
$output = [$this, 'echoLine'];
82+
$output = $this->echoLine(...);
8383
}
8484

8585
$this->dumper = new CliDumper($output, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);

src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function handle(array $record): bool
8080

8181
public function handleBatch(array $records): void
8282
{
83-
$records = array_filter($records, [$this, 'isHandling']);
83+
$records = array_filter($records, $this->isHandling(...));
8484

8585
if ($records) {
8686
$this->sendToElasticsearch($records);

src/Symfony/Bridge/Monolog/Handler/MailerHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(MailerInterface $mailer, callable|Email $messageTemp
3232
parent::__construct($level, $bubble);
3333

3434
$this->mailer = $mailer;
35-
$this->messageTemplate = !\is_callable($messageTemplate) || $messageTemplate instanceof \Closure ? $messageTemplate : \Closure::fromCallable($messageTemplate);
35+
$this->messageTemplate = $messageTemplate instanceof Email ? $messageTemplate : $messageTemplate(...);
3636
}
3737

3838
/**

src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function handle(array $record): bool
4646

4747
public function handleBatch(array $records): void
4848
{
49-
if ($records = array_filter($records, [$this, 'isHandling'])) {
49+
if ($records = array_filter($records, $this->isHandling(...))) {
5050
$this->notify($records);
5151
}
5252
}

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private function getLoaderPaths(string $name = null): array
294294
}
295295

296296
foreach ($namespaces as $namespace) {
297-
$paths = array_map([$this, 'getRelativePath'], $loader->getPaths($namespace));
297+
$paths = array_map($this->getRelativePath(...), $loader->getPaths($namespace));
298298

299299
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
300300
$namespace = '(None)';

src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorR
3636
{
3737
$this->twig = $twig;
3838
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
39-
$this->debug = !\is_callable($debug) || $debug instanceof \Closure ? $debug : \Closure::fromCallable($debug);
39+
$this->debug = \is_bool($debug) ? $debug : $debug(...);
4040
}
4141

4242
/**

src/Symfony/Bridge/Twig/Extension/AssetExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct(Packages $packages)
3535
public function getFunctions(): array
3636
{
3737
return [
38-
new TwigFunction('asset', [$this, 'getAssetUrl']),
39-
new TwigFunction('asset_version', [$this, 'getAssetVersion']),
38+
new TwigFunction('asset', $this->getAssetUrl(...)),
39+
new TwigFunction('asset_version', $this->getAssetVersion(...)),
4040
];
4141
}
4242

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ public function __construct(string|FileLinkFormatter $fileLinkFormat, string $pr
3939
public function getFilters(): array
4040
{
4141
return [
42-
new TwigFilter('abbr_class', [$this, 'abbrClass'], ['is_safe' => ['html']]),
43-
new TwigFilter('abbr_method', [$this, 'abbrMethod'], ['is_safe' => ['html']]),
44-
new TwigFilter('format_args', [$this, 'formatArgs'], ['is_safe' => ['html']]),
45-
new TwigFilter('format_args_as_text', [$this, 'formatArgsAsText']),
46-
new TwigFilter('file_excerpt', [$this, 'fileExcerpt'], ['is_safe' => ['html']]),
47-
new TwigFilter('format_file', [$this, 'formatFile'], ['is_safe' => ['html']]),
48-
new TwigFilter('format_file_from_text', [$this, 'formatFileFromText'], ['is_safe' => ['html']]),
49-
new TwigFilter('format_log_message', [$this, 'formatLogMessage'], ['is_safe' => ['html']]),
50-
new TwigFilter('file_link', [$this, 'getFileLink']),
51-
new TwigFilter('file_relative', [$this, 'getFileRelative']),
42+
new TwigFilter('abbr_class', $this->abbrClass(...), ['is_safe' => ['html']]),
43+
new TwigFilter('abbr_method', $this->abbrMethod(...), ['is_safe' => ['html']]),
44+
new TwigFilter('format_args', $this->formatArgs(...), ['is_safe' => ['html']]),
45+
new TwigFilter('format_args_as_text', $this->formatArgsAsText(...)),
46+
new TwigFilter('file_excerpt', $this->fileExcerpt(...), ['is_safe' => ['html']]),
47+
new TwigFilter('format_file', $this->formatFile(...), ['is_safe' => ['html']]),
48+
new TwigFilter('format_file_from_text', $this->formatFileFromText(...), ['is_safe' => ['html']]),
49+
new TwigFilter('format_log_message', $this->formatLogMessage(...), ['is_safe' => ['html']]),
50+
new TwigFilter('file_link', $this->getFileLink(...)),
51+
new TwigFilter('file_relative', $this->getFileRelative(...)),
5252
];
5353
}
5454

0 commit comments

Comments
 (0)