8000 Merge branch '4.4' into 5.2 · symfony/cache@c2bdd34 · GitHub
[go: up one dir, main page]

Skip to content

Commit c2bdd34

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 994c442 + 7cd6642 commit c2bdd34

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

Adapter/AbstractAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public static function createSystemCache(string $namespace, int $defaultLifetime
126126

127127
public static function createConnection(string $dsn, array $options = [])
128128
{
129-
if (0 === strpos($dsn, 'redis:') || 0 === strpos($dsn, 'rediss:')) {
129+
if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:')) {
130130
return RedisAdapter::createConnection($dsn, $options);
131131
}
132-
if (0 === strpos($dsn, 'memcached:')) {
132+
if (str_starts_with($dsn, 'memcached:')) {
133133
return MemcachedAdapter::createConnection($dsn, $options);
134134
}
135135
if (0 === strpos($dsn, 'couchbase:')) {

Adapter/RedisTagAwareAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function __construct($redis, string $namespace = '', int $defaultLifetime
8888
protected function doSave(array $values, int $lifetime, array $addTagData = [], array $delTagData = []): array
8989
{
9090
$eviction = $this->getRedisEvictionPolicy();
91-
if ('noeviction' !== $eviction && 0 !== strpos($eviction, 'volatile-')) {
91+
if ('noeviction' !== $eviction && !str_starts_with($eviction, 'volatile-')) {
9292
throw new LogicException(sprintf('Redis maxmemory-policy setting "%s" is *not* supported by RedisTagAwareAdapter, use "noeviction" or "volatile-*" eviction policies.', $eviction));
9393
}
9494

Adapter/TagAwareAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function clear(string $prefix = '')
233233
{
234234
if ('' !== $prefix) {
235235
foreach ($this->deferred as $key => $item) {
236-
if (0 === strpos($key, $prefix)) {
236+
if (str_starts_with($key, $prefix)) {
237237
unset($this->deferred[$key]);
238238
}
239239
}

Traits/FilesystemCommonTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function doClear(string $namespace)
5858
$ok = true;
5959

6060
foreach ($this->scanHashDir($this->directory) as $file) {
61-
if ('' !== $namespace && 0 !== strpos($this->getFileKey($file), $namespace)) {
61+
if ('' !== $namespace && !str_starts_with($this->getFileKey($file), $namespace)) {
6262
continue;
6363
}
6464

@@ -98,7 +98,7 @@ private function write(string $file, string $data, int $expiresAt = null)
9898
try {
9999
$h = fopen($this->tmp, 'x');
100100
} catch (\ErrorException $e) {
101-
if (false === strpos($e->getMessage(), 'File exists')) {
101+
if (!str_contains($e->getMessage(), 'File exists')) {
102102
throw $e;
103103
}
104104

Traits/RedisTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ private function init($redis, string $namespace, int $defaultLifetime, ?Marshall
9090
*/
9191
public static function createConnection(string $dsn, array $options = [])
9292
{
93-
if (0 === strpos($dsn, 'redis:')) {
93+
if (str_starts_with($dsn, 'redis:')) {
9494
$scheme = 'redis';
95-
} elseif (0 === strpos($dsn, 'rediss:')) {
95+
} elseif (str_starts_with($dsn, 'rediss:')) {
9696
$scheme = 'rediss';
9797
} else {
9898
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s" does not start with "redis:" or "rediss".', $dsn));

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"psr/cache": "^1.0|^2.0",
2626
"psr/log": "^1.1|^2|^3",
2727
"symfony/cache-contracts": "^1.1.7|^2",
28-
"symfony/polyfill-php80": "^1.15",
28+
"symfony/polyfill-php80": "^1.16",
2929
"symfony/service-contracts": "^1.1|^2",
3030
"symfony/var-exporter": "^4.4|^5.0"
3131
},

0 commit comments

Comments
 (0)
0