Skip to content

Commit 06ad50f

Browse files
Merge branch '5.2' into 5.3
* 5.2: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 69902b2 + 561895c commit 06ad50f

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

Store/StoreFactory.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,46 +63,46 @@ public static function createStore($connection)
6363
case 'flock' === $connection:
6464
return new FlockStore();
6565

66-
case 0 === strpos($connection, 'flock://'):
66+
case str_starts_with($connection, 'flock://'):
6767
return new FlockStore(substr($connection, 8));
6868

6969
case 'semaphore' === $connection:
7070
return new SemaphoreStore();
7171

72-
case 0 === strpos($connection, 'redis:'):
73-
case 0 === strpos($connection, 'rediss:'):
74-
case 0 === strpos($connection, 'memcached:'):
72+
case str_starts_with($connection, 'redis:'):
73+
case str_starts_with($connection, 'rediss:'):
74+
case str_starts_with($connection, 'memcached:'):
7575
if (!class_exists(AbstractAdapter::class)) {
7676
throw new InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require symfony/cache".', $connection));
7777
}
78-
$storeClass = 0 === strpos($connection, 'memcached:') ? MemcachedStore::class : RedisStore::class;
78+
$storeClass = str_starts_with($connection, 'memcached:') ? MemcachedStore::class : RedisStore::class;
7979
$connection = AbstractAdapter::createConnection($connection, ['lazy' => true]);
8080

8181
return new $storeClass($connection);
8282

83-
case 0 === strpos($connection, 'mongodb'):
83+
case str_starts_with($connection, 'mongodb'):
8484
return new MongoDbStore($connection);
8585

86-
case 0 === strpos($connection, 'mssql://'):
87-
case 0 === strpos($connection, 'mysql:'):
88-
case 0 === strpos($connection, 'mysql2://'):
89-
case 0 === strpos($connection, 'oci:'):
90-
case 0 === strpos($connection, 'oci8://'):
91-
case 0 === strpos($connection, 'pdo_oci://'):
92-
case 0 === strpos($connection, 'pgsql:'):
93-
case 0 === strpos($connection, 'postgres://'):
94-
case 0 === strpos($connection, 'postgresql://'):
95-
case 0 === strpos($connection, 'sqlsrv:'):
96-
case 0 === strpos($connection, 'sqlite:'):
97-
case 0 === strpos($connection, 'sqlite3://'):
86+
case str_starts_with($connection, 'mssql://'):
87+
case str_starts_with($connection, 'mysql:'):
88+
case str_starts_with($connection, 'mysql2://'):
89+
case str_starts_with($connection, 'oci:'):
90+
case str_starts_with($connection, 'oci8://'):
91+
case str_starts_with($connection, 'pdo_oci://'):
92+
case str_starts_with($connection, 'pgsql:'):
93+
case str_starts_with($connection, 'postgres://'):
94+
case str_starts_with($connection, 'postgresql://'):
95+
case str_starts_with($connection, 'sqlsrv:'):
96+
case str_starts_with($connection, 'sqlite:'):
97+
case str_starts_with($connection, 'sqlite3://'):
9898
return new PdoStore($connection);
9999

100-
case 0 === strpos($connection, 'pgsql+advisory:'):
101-
case 0 === strpos($connection, 'postgres+advisory://'):
102-
case 0 === strpos($connection, 'postgresql+advisory://'):
100+
case str_starts_with($connection, 'pgsql+advisory:'):
101+
case str_starts_with($connection, 'postgres+advisory://'):
102+
case str_starts_with($connection, 'postgresql+advisory://'):
103103
return new PostgreSqlStore(preg_replace('/^([^:+]+)\+advisory/', '$1', $connection));
104104

105-
case 0 === strpos($connection, 'zookeeper://'):
105+
case str_starts_with($connection, 'zookeeper://'):
106106
return new ZookeeperStore(ZookeeperStore::createConnection($connection));
107107

108108
case 'in-memory' === $connection:

Store/ZookeeperStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(\Zookeeper $zookeeper)
3636

3737
public static function createConnection(string $dsn): \Zookeeper
3838
{
39-
if (0 !== strpos($dsn, 'zookeeper:')) {
39+
if (!str_starts_with($dsn, 'zookeeper:')) {
4040
throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn));
4141
}
4242

@@ -142,7 +142,7 @@ private function getKeyResource(Key $key): string
142142
// For example: foo/bar will become /foo-bar and /foo/bar will become /-foo-bar
143143
$resource = (string) $key;
144144

145-
if (false !== strpos($resource, '/')) {
145+
if (str_contains($resource, '/')) {
146146
$resource = strtr($resource, ['/' => '-']).'-'.sha1($resource);
147147
}
148148

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=7.2.5",
2020
"psr/log": "^1|^2|^3",
2121
"symfony/deprecation-contracts": "^2.1",
22-
"symfony/polyfill-php80": "^1.15"
22+
"symfony/polyfill-php80": "^1.16"
2323
},
2424
"require-dev": {
2525
"doctrine/dbal": "^2.10|^3.0",

0 commit comments

Comments
 (0)