Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4fb4bf5

Browse filesBrowse files
committed
cs
1 parent 0b9ff02 commit 4fb4bf5
Copy full SHA for 4fb4bf5

9 files changed

+118
-70
lines changed

‎src/Symfony/Component/Dsn/ConnectionFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/ConnectionFactory.php
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn;
715

816
/**
9-
*
1017
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1118
*/
1219
class ConnectionFactory implements ConnectionFactoryInterface
@@ -19,7 +26,7 @@ class ConnectionFactory implements ConnectionFactoryInterface
1926
public static function addFactory(string $factory, $prepend = false): void
2027
{
2128
if (!is_a($factory, ConnectionFactoryInterface::class, true)) {
22-
throw new \LogicException(sprintf('Argument to "%s::addFactory()" must be a class string to a class implementing "%s"', self::class, ConnectionFactoryInterface::class));
29+
throw new \LogicException(sprintf('Argument to "%s::addFactory()" must be a class string to a class implementing "%s".', self::class, ConnectionFactoryInterface::class));
2330
}
2431

2532
if ($prepend) {

‎src/Symfony/Component/Dsn/ConnectionFactoryInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/ConnectionFactoryInterface.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn;
715

‎src/Symfony/Component/Dsn/ConnectionRegistry.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/ConnectionRegistry.php
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn;
715

8-
916
class ConnectionRegistry
1017
{
1118
/**
@@ -18,14 +25,11 @@ class ConnectionRegistry
1825
*/
1926
private $factory;
2027

21-
/**
22-
*/
2328
public function __construct(ConnectionFactoryInterface $factory)
2429
{
2530
$this->factory = $factory;
2631
}
2732

28-
2933
public function addConnection(string $dsn, object $connection)
3034
{
3135
$this->connections[$dsn] = $connection;

‎src/Symfony/Component/Dsn/Exception/ExceptionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/Exception/ExceptionInterface.php
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn\Exception;
715

8-
916
/**
1017
* Base ExceptionInterface for the Dsn Component.
1118
*

‎src/Symfony/Component/Dsn/Exception/InvalidArgumentException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/Exception/InvalidArgumentException.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn\Exception;
715

‎src/Symfony/Component/Dsn/Factory/MemcachedFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/Factory/MemcachedFactory.php
+22-14Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
declare(strict_types=1);
413

514
namespace Symfony\Component\Dsn\Factory;
@@ -19,26 +28,25 @@
1928
*/
2029
class MemcachedFactory implements ConnectionFactoryInterface
2130
{
22-
private static $defaultClientOptions = array(
31+
private static $defaultClientOptions = [
2332
'class' => null,
2433
'persistent_id' => null,
2534
'username' => null,
2635
'password' => null,
2736
'serializer' => 'php',
28-
);
37+
];
2938

3039
/**
31-
* Example DSN strings
40+
* Example DSN strings.
3241
*
3342
* - memcached://localhost:11222?retry_timeout=10
3443
* - memcached(memcached://127.0.0.1)?persistent_id=foobar
3544
* - memcached(memcached://127.0.0.1 memcached://127.0.0.2?retry_timeout=10)?persistent_id=foobar
36-
*
3745
*/
3846
public static function create(string $dsnString): object
3947
{
4048
$rootDsn = DsnParser::parseFunc($dsnString);
41-
if ($rootDsn->getName() !== 'dsn' && $rootDsn->getName() !== 'memcached') {
49+
if ('dsn' !== $rootDsn->getName() && 'memcached' !== $rootDsn->getName()) {
4250
throw new FunctionNotSupportedException($dsnString, $rootDsn->getName());
4351
}
4452

@@ -52,21 +60,21 @@ public static function create(string $dsnString): object
5260
if (is_a($class, \Memcached::class, true)) {
5361
$client = new $class($options['persistent_id']);
5462
} elseif (class_exists($class, false)) {
55-
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Memcached"', $class));
63+
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Memcached".', $class));
5664
} else {
57-
throw new InvalidArgumentException(sprintf('Class "%s" does not exist', $class));
65+
throw new InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
5866
}
5967

6068
$username = $options['username'];
6169
$password = $options['password'];
6270

63-
$servers = array();
71+
$servers = [];
6472
foreach ($rootDsn->getArguments() as $dsn) {
6573
if (!$dsn instanceof Dsn) {
6674
throw new InvalidArgumentException('Only one DSN function is allowed.');
6775
}
6876

69-
if ($dsn->getScheme() !== 'memcached') {
77+
if ('memcached' !== $dsn->getScheme()) {
7078
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached://"', $dsn));
7179
}
7280

@@ -77,7 +85,7 @@ public static function create(string $dsnString): object
7785

7886
if (null !== $path && preg_match('#/(\d+)$#', $path, $m)) {
7987
$params['weight'] = $m[1];
80-
$path = substr($path, 0, -strlen($m[0]));
88+
$path = substr($path, 0, -\strlen($m[0]));
8189
}
8290

8391
if ($dsn instanceof Url) {
@@ -106,17 +114,17 @@ public static function create(string $dsnString): object
106114
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
107115
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
108116
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
109-
if (!array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
117+
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
110118
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
111119
}
112120
foreach ($options as $name => $value) {
113-
if (is_int($name)) {
121+
if (\is_int($name)) {
114122
continue;
115123
}
116124
if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
117-
$value = constant('Memcached::'.$name.'_'.strtoupper($value));
125+
$value = \constant('Memcached::'.$name.'_'.strtoupper($value));
118126
}
119-
$opt = constant('Memcached::OPT_'.$name);
127+
$opt = \constant('Memcached::OPT_'.$name);
120128

121129
unset($options[$name]);
122130
$options[$opt] = $value;

‎src/Symfony/Component/Dsn/Factory/RedisFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dsn/Factory/RedisFactory.php
+17-11Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?php
22

3-
declare(strict_types=1);
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
411

12+
declare(strict_types=1);
513

614
namespace Symfony\Component\Dsn\Factory;
715

8-
use Predis\Connection\Factory;
916
use Symfony\Component\Cache\Traits\RedisProxy;
1017
use Symfony\Component\Dsn\Configuration\Dsn;
1118
use Symfony\Component\Dsn\Configuration\Path;
1219
use Symfony\Component\Dsn\Configuration\Url;
1320
use Symfony\Component\Dsn\ConnectionFactoryInterface;
1421
use Symfony\Component\Dsn\DsnParser;
15-
use Symfony\Component\Dsn\Exception\DsnTypeNotSupported;
1622
use Symfony\Component\Dsn\Exception\FunctionNotSupportedException;
1723
use Symfony\Component\Dsn\Exception\InvalidArgumentException;
1824

@@ -41,27 +47,27 @@ class RedisFactory implements ConnectionFactoryInterface
4147
public static function create(string $dsnString): object
4248
{
4349
$rootDsn = DsnParser::parseFunc($dsnString);
44-
if ($rootDsn->getName() !== 'dsn' && $rootDsn->getName() !== 'memcached') {
50+
if ('dsn' !== $rootDsn->getName() && 'memcached' !== $rootDsn->getName()) {
4551
throw new FunctionNotSupportedException($dsnString, $rootDsn->getName());
4652
}
4753
$params = $rootDsn->getParameters() + self::$defaultConnectionOptions;
4854
$auth = null;
4955

50-
$hosts = array();
56+
$hosts = [];
5157
foreach ($rootDsn->getArguments() as $dsn) {
5258
if (!$dsn instanceof Dsn) {
5359
throw new InvalidArgumentException('Only one DSN function is allowed.');
5460
}
55-
if ($dsn->getScheme() !== 'redis' && $dsn->getScheme() !== 'rediss') {
61+
if ('redis' !== $dsn->getScheme() && 'rediss' !== $dsn->getScheme()) {
5662
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s" does not start with "redis:" or "rediss".', $dsn));
5763
}
5864

5965
$auth = $dsn->getPassword() ?? $dsn->getUser();
6066
$path = $dsn->getPath();
6167
$params['dbindex'] = 0;
6268
if (null !== $path && preg_match('#/(\d+)$#', $path, $m)) {
63-
$params['dbindex'] = (int)$m[1];
64-
$path = substr($path, 0, -strlen($m[0]));
69+
$params['dbindex'] = (int) $m[1];
70+
$path = substr($path, 0, -\strlen($m[0]));
6571
}
6672

6773
if ($dsn instanceof Url) {
@@ -75,7 +81,7 @@ public static function create(string $dsnString): object
7581
}
7682
if (false === $i = strrpos($host, ':')) {
7783
$hosts[$host] = ['scheme' => 'tcp', 'host' => $host, 'port' => 6379] + $parameters;
78-
} elseif ($port = (int)substr($host, 1 + $i)) {
84+
} elseif ($port = (int) substr($host, 1 + $i)) {
7985
$hosts[$host] = ['scheme' => 'tcp', 'host' => substr($host, 0, $i), 'port' => $port] + $parameters;
8086
} else {
8187
$hosts[$host] = ['scheme' => 'unix', 'path' => substr($host, 0, $i)] + $parameters;
@@ -87,7 +93,7 @@ public static function create(string $dsnString): object
8793
$params = $dsn->getParameters() + $params;
8894
}
8995

90-
if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class)) {
96+
if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class)) {
9197
throw new CacheException(sprintf('Redis Sentinel support requires the "predis/predis" package: "%s".', $dsn));
9298
}
9399

@@ -223,6 +229,6 @@ public static function create(string $dsnString): object
223229

224230
public static function supports(string $dsn): bool
225231
{
226-
return strpos($dsn, 'redis:') === 0 || strpos($dsn, 'rediss:') === 0;
232+
return 0 === strpos($dsn, 'redis:') || 0 === strpos($dsn, 'rediss:');
227233
}
228234
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.