Skip to content

Commit 3df6471

Browse files
More short closures + isset instead of null checks + etc.
1 parent 7efa075 commit 3df6471

File tree

68 files changed

+194
-226
lines changed

Some content is hidden

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

68 files changed

+194
-226
lines changed

.github/expected-missing-return-types.diff

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/
13431343
diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
13441344
--- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
13451345
+++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
1346-
@@ -71,5 +71,5 @@ class MemcachedAdapter extends AbstractAdapter
1346+
@@ -72,5 +72,5 @@ class MemcachedAdapter extends AbstractAdapter
13471347
* @return bool
13481348
*/
13491349
- public static function isSupported()
@@ -1353,7 +1353,7 @@ diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symf
13531353
diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php
13541354
--- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php
13551355
+++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php
1356-
@@ -101,5 +101,5 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
1356+
@@ -102,5 +102,5 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
13571357
* @throws \DomainException When an unsupported PDO driver is used
13581358
*/
13591359
- public function createTable()
@@ -1505,7 +1505,7 @@ diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/
15051505
+ protected function doUnlink(string $file): bool
15061506
{
15071507
return @unlink($file);
1508-
@@ -175,5 +175,5 @@ trait FilesystemCommonTrait
1508+
@@ -167,5 +167,5 @@ trait FilesystemCommonTrait
15091509
* @return void
15101510
*/
15111511
- public function __wakeup()
@@ -7313,14 +7313,14 @@ diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Comp
73137313
- public function setMethod(string $method)
73147314
+ public function setMethod(string $method): void
73157315
{
7316-
$this->method = null;
7316+
unset($this->method);
73177317
@@ -1301,5 +1301,5 @@ class Request
73187318
* @return void
73197319
*/
73207320
- public function setFormat(?string $format, string|array $mimeTypes)
73217321
+ public function setFormat(?string $format, string|array $mimeTypes): void
73227322
{
7323-
if (null === static::$formats) {
7323+
if (!isset(static::$formats)) {
73247324
@@ -1333,5 +1333,5 @@ class Request
73257325
* @return void
73267326
*/
@@ -7342,14 +7342,14 @@ diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Comp
73427342
+ public function setLocale(string $locale): void
73437343
{
73447344
$this->setPhpDefaultLocale($this->locale = $locale);
7345-
@@ -1756,5 +1756,5 @@ class Request
7345+
@@ -1744,5 +1744,5 @@ class Request
73467346
* @return string
73477347
*/
73487348
- protected function prepareRequestUri()
73497349
+ protected function prepareRequestUri(): string
73507350
{
73517351
$requestUri = '';
7352-
@@ -1927,5 +1927,5 @@ class Request
7352+
@@ -1915,5 +1915,5 @@ class Request
73537353
* @return void
73547354
*/
73557355
- protected static function initializeFormats()
@@ -11059,14 +11059,14 @@ diff --git a/src/Symfony/Component/Security/Core/Exception/AccountStatusExceptio
1105911059
diff --git a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
1106011060
--- a/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
1106111061
+++ b/src/Symfony/Component/Security/Core/Exception/AuthenticationException.php
11062-
@@ -43,5 +43,5 @@ class AuthenticationException extends RuntimeException
11062+
@@ -34,5 +34,5 @@ class AuthenticationException extends RuntimeException
1106311063
* @return void
1106411064
*/
1106511065
- public function setToken(TokenInterface $token)
1106611066
+ public function setToken(TokenInterface $token): void
1106711067
{
1106811068
$this->token = $token;
11069-
@@ -94,5 +94,5 @@ class AuthenticationException extends RuntimeException
11069+
@@ -85,5 +85,5 @@ class AuthenticationException extends RuntimeException
1107011070
* @return string
1107111071
*/
1107211072
- public function getMessageKey()
@@ -11778,7 +11778,7 @@ diff --git a/src/Symfony/Component/String/Slugger/AsciiSlugger.php b/src/Symfony
1177811778
diff --git a/src/Symfony/Component/String/UnicodeString.php b/src/Symfony/Component/String/UnicodeString.php
1177911779
--- a/src/Symfony/Component/String/UnicodeString.php
1178011780
+++ b/src/Symfony/Component/String/UnicodeString.php
11781-
@@ -342,5 +342,5 @@ class UnicodeString extends AbstractUnicodeString
11781+
@@ -366,5 +366,5 @@ class UnicodeString extends AbstractUnicodeString
1178211782
* @return void
1178311783
*/
1178411784
- public function __wakeup()
@@ -12075,14 +12075,14 @@ diff --git a/src/Symfony/Component/Translation/Dumper/DumperInterface.php b/src/
1207512075
diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php
1207612076
--- a/src/Symfony/Component/Translation/Dumper/FileDumper.php
1207712077
+++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php
12078-
@@ -40,5 +40,5 @@ abstract class FileDumper implements DumperInterface
12078+
@@ -38,5 +38,5 @@ abstract class FileDumper implements DumperInterface
1207912079
* @return void
1208012080
*/
1208112081
- public function setRelativePathTemplate(string $relativePathTemplate)
1208212082
+ public function setRelativePathTemplate(string $relativePathTemplate): void
1208312083
{
1208412084
$this->relativePathTemplate = $relativePathTemplate;
12085-
@@ -48,5 +48,5 @@ abstract class FileDumper implements DumperInterface
12085+
@@ -46,5 +46,5 @@ abstract class FileDumper implements DumperInterface
1208612086
* @return void
1208712087
*/
1208812088
- public function dump(MessageCatalogue $messages, array $options = [])

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener;
4545
use Symfony\Component\WebLink\GenericLinkProvider;
4646
use Symfony\Component\WebLink\HttpHeaderSerializer;
47-
use Symfony\Component\WebLink\Link;
4847
use Symfony\Contracts\Service\Attribute\Required;
4948
use Symfony\Contracts\Service\ServiceSubscriberInterface;
5049
use Twig\Environment;
@@ -64,7 +63,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
6463
#[Required]
6564
public function setContainer(ContainerInterface $container): ?ContainerInterface
6665
{
67-
$previous = $this->container;
66+
$previous = $this->container ?? null;
6867
$this->container = $container;
6968

7069
return $previous;

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(ContainerInterface $container, mixed $resource, arra
6161

6262
public function getRouteCollection(): RouteCollection
6363
{
64-
if (null === $this->collection) {
64+
if (!isset($this->collection)) {
6565
$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
6666
$this->resolveParameters($this->collection);
6767
$this->collection->addResource(new ContainerParametersResource($this->collectedParameters));

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AccessTokenFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ public function addConfiguration(NodeDefinition $node): void
6868

6969
->beforeNormalization()
7070
->ifString()
71-
->then(static function (string $v): array { return ['id' => $v]; })
71+
->then(static fn ($v) => ['id' => $v])
7272
->end()
7373

7474
->beforeNormalization()
75-
->ifTrue(static function ($v) { return \is_array($v) && 1 < \count($v); })
76-
->then(static function () { throw new InvalidConfigurationException('You cannot configure multiple token handlers.'); })
75+
->ifTrue(static fn ($v) => \is_array($v) && 1 < \count($v))
76+
->then(static fn () => throw new InvalidConfigurationException('You cannot configure multiple token handlers.'))
7777
->end()
7878

7979
// "isRequired" must be set otherwise the following custom validation is not called
8080
->isRequired()
8181
->beforeNormalization()
82-
->ifTrue(static function ($v) { return \is_array($v) && !$v; })
83-
->then(static function () { throw new InvalidConfigurationException('You must set a token handler.'); })
82+
->ifTrue(static fn ($v) => \is_array($v) && !$v)
83+
->then(static fn () => throw new InvalidConfigurationException('You must set a token handler.'))
8484
->end()
8585

8686
->children()

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class Cookie
6161
public function __construct(string $name, ?string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false, string $samesite = null)
6262
{
6363
if ($encodedValue) {
64-
$this->value = urldecode($value);
65-
$this->rawValue = $value;
64+
$this->rawValue = $value ?? '';
65+
$this->value = urldecode($this->rawValue);
6666
} else {
67-
$this->value = $value;
68-
$this->rawValue = rawurlencode($value ?? '');
67+
$this->value = $value ?? '';
68+
$this->rawValue = rawurlencode($this->value);
6969
}
7070
$this->name = $name;
7171
$this->path = empty($path) ? '/' : $path;

src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function createConnection(#[\SensitiveParameter] array|string $ser
6464
throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
6565
}
6666

67-
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
67+
set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
6868

6969
$dsnPattern = '/^(?<protocol>couchbase(?:s)?)\:\/\/(?:(?<username>[^\:]+)\:(?<password>[^\@]{6,})@)?'
7070
.'(?<host>[^\:]+(?:\:\d+)?)(?:\/(?<bucketName>[^\?]+))(?:\?(?<options>.*))?$/i';

src/Symfony/Component/Cache/Adapter/CouchbaseCollectionAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function createConnection(#[\SensitiveParameter] array|string $dsn
5757
throw new CacheException('Couchbase >= 3.0.0 < 4.0.0 is required.');
5858
}
5959

60-
set_error_handler(function ($type, $msg, $file, $line): bool { throw new \ErrorException($msg, 0, $type, $file, $line); });
60+
set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
6161

6262
$dsnPattern = '/^(?<protocol>couchbase(?:s)?)\:\/\/(?:(?<username>[^\:]+)\:(?<password>[^\@]{6,})@)?'
6363
.'(?<host>[^\:]+(?:\:\d+)?)(?:\/(?<bucketName>[^\/\?]+))(?:(?:\/(?<scopeName>[^\/]+))'

src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
3131
{
32-
protected $maxIdLength = 255;
32+
private const MAX_KEY_LENGTH = 255;
3333

3434
private MarshallerInterface $marshaller;
3535
private Connection $conn;
@@ -94,6 +94,7 @@ public function __construct(Connection|string $connOrDsn, string $namespace = ''
9494
$this->conn = DriverManager::getConnection($params, $config);
9595
}
9696

97+
$this->maxIdLength = self::MAX_KEY_LENGTH;
9798
$this->table = $options['db_table'] ?? $this->table;
9899
$this->idCol = $options['db_id_col'] ?? $this->idCol;
99100
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class MemcachedAdapter extends AbstractAdapter
2929
*/
3030
private const RESERVED_MEMCACHED = " \n\r\t\v\f\0";
3131
private const RESERVED_PSR6 = '@()\{}/';
32-
33-
protected $maxIdLength = 250;
32+
private const MAX_KEY_LENGTH = 250;
3433

3534
private MarshallerInterface $marshaller;
3635
private \Memcached $client;
@@ -51,6 +50,8 @@ public function __construct(\Memcached $client, string $namespace = '', int $def
5150
if (!static::isSupported()) {
5251
throw new CacheException('Memcached > 3.1.5 is required.');
5352
}
53+
$this->maxIdLength = self::MAX_KEY_LENGTH;
54+
5455
if ('Memcached' === $client::class) {
5556
$opt = $client->getOption(\Memcached::OPT_SERIALIZER);
5657
if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
@@ -96,7 +97,7 @@ public static function createConnection(#[\SensitiveParameter] array|string $ser
9697
if (!static::isSupported()) {
9798
throw new CacheException('Memcached > 3.1.5 is required.');
9899
}
99-
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
100+
set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
100101
try {
101102
$client = new \Memcached($options['persistent_id'] ?? null);
102103
$username = $options['username'] ?? null;

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class PdoAdapter extends AbstractAdapter implements PruneableInterface
2121
{
22-
protected $maxIdLength = 255;
22+
private const MAX_KEY_LENGTH = 255;
2323

2424
private MarshallerInterface $marshaller;
2525
private \PDO|Connection $conn;
@@ -75,6 +75,7 @@ public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, strin
7575
$this->dsn = $connOrDsn;
7676
}
7777

78+
$this->maxIdLength = self::MAX_KEY_LENGTH;
7879
$this->table = $options['db_table'] ?? $this->table;
7980
$this->idCol = $options['db_id_col'] ?? $this->idCol;
8081
$this->dataCol = $options['db_data_col'] ?? $this->dataCol;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy