Skip to content

Commit 28249b0

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent ea28f99 commit 28249b0

File tree

12 files changed

+14
-14
lines changed

12 files changed

+14
-14
lines changed

Command/ConsumeMessagesCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
142142
*/
143143
protected function execute(InputInterface $input, OutputInterface $output)
144144
{
145-
if (false !== strpos($input->getFirstArgument(), ':consume-')) {
145+
if (str_contains($input->getFirstArgument(), ':consume-')) {
146146
$message = 'The use of the "messenger:consume-messages" command is deprecated since version 4.3 and will be removed in 5.0. Use "messenger:consume" instead.';
147147
@trigger_error($message, \E_USER_DEPRECATED);
148148
$output->writeln(sprintf('<comment>%s</comment>', $message));
@@ -209,9 +209,9 @@ private function convertToBytes(string $memoryLimit): int
209209
{
210210
$memoryLimit = strtolower($memoryLimit);
211211
$max = ltrim($memoryLimit, '+');
212-
if (0 === strpos($max, '0x')) {
212+
if (str_starts_with($max, '0x')) {
213213
$max = \intval($max, 16);
214-
} elseif (0 === strpos($max, '0')) {
214+
} elseif (str_starts_with($max, '0')) {
215215
$max = \intval($max, 8);
216216
} else {
217217
$max = (int) $max;

Handler/HandlerDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private function callableName(callable $handler): string
6565

6666
if ($handler instanceof \Closure) {
6767
$r = new \ReflectionFunction($handler);
68-
if (false !== strpos($r->name, '{closure}')) {
68+
if (str_contains($r->name, '{closure}')) {
6969
return 'Closure';
7070
}
7171
if ($class = $r->getClosureScopeClass()) {

Tests/Transport/AmqpExt/AmqpExtIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function waitForOutput(Process $process, string $output, $timeoutInSecon
210210
$timedOutTime = time() + $timeoutInSeconds;
211211

212212
while (time() < $timedOutTime) {
213-
if (0 === strpos($process->getOutput(), $output)) {
213+
if (str_starts_with($process->getOutput(), $output)) {
214214
return;
215215
}
216216

Tests/Transport/RedisExt/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function setUpBeforeClass(): void
2828
$redis = Connection::fromDsn('redis://localhost/queue');
2929
$redis->get();
3030
} catch (TransportException $e) {
31-
if (0 === strpos($e->getMessage(), 'ERR unknown command \'X')) {
31+
if (str_starts_with($e->getMessage(), 'ERR unknown command \'X')) {
3232
throw new SkippedTestSuiteError('Redis server >= 5 is required');
3333
}
3434

TraceableMessageBus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function getCaller(): array
8686
$line = $trace[$i]['line'];
8787

8888
while (++$i < 8) {
89-
if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) {
89+
if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && !str_starts_with($trace[$i]['function'], 'call_user_func')) {
9090
$file = $trace[$i]['file'];
9191
$line = $trace[$i]['line'];
9292

Transport/AmqpExt/AmqpTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function createTransport(string $dsn, array $options, SerializerInterface
2929

3030
public function supports(string $dsn, array $options): bool
3131
{
32-
return 0 === strpos($dsn, 'amqp://');
32+
return str_starts_with($dsn, 'amqp://');
3333
}
3434
}

Transport/Doctrine/DoctrineTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function createTransport(string $dsn, array $options, SerializerInterface
5252

5353
public function supports(string $dsn, array $options): bool
5454
{
55-
return 0 === strpos($dsn, 'doctrine://');
55+
return str_starts_with($dsn, 'doctrine://');
5656
}
5757
}

Transport/InMemoryTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function createTransport(string $dsn, array $options, SerializerInterface
3131

3232
public function supports(string $dsn, array $options): bool
3333
{
34-
return 0 === strpos($dsn, 'in-memory://');
34+
return str_starts_with($dsn, 'in-memory://');
3535
}
3636

3737
public function reset()

Transport/RedisExt/RedisTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function createTransport(string $dsn, array $options, SerializerInterface
3030

3131
public function supports(string $dsn, array $options): bool
3232
{
33-
return 0 === strpos($dsn, 'redis://');
33+
return str_starts_with($dsn, 'redis://');
3434
}
3535
}

Transport/Serialization/PhpSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function decode(array $encodedEnvelope): Envelope
2929
throw new MessageDecodingFailedException('Encoded envelope should have at least a "body".');
3030
}
3131

32-
if (false === strpos($encodedEnvelope['body'], '}', -1)) {
32+
if (!str_contains($encodedEnvelope['body'], '}', -1)) {
3333
$encodedEnvelope['body'] = base64_decode($encodedEnvelope['body']);
3434
}
3535

Transport/Serialization/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private function decodeStamps(array $encodedEnvelope): array
111111
{
112112
$stamps = [];
113113
foreach ($encodedEnvelope['headers'] as $name => $value) {
114-
if (0 !== strpos($name, self::STAMP_HEADER_PREFIX)) {
114+
if (!str_starts_with($name, self::STAMP_HEADER_PREFIX)) {
115115
continue;
116116
}
117117

Transport/Sync/SyncTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public function createTransport(string $dsn, array $options, SerializerInterface
3535

3636
public function supports(string $dsn, array $options): bool
3737
{
38-
return 0 === strpos($dsn, 'sync://');
38+
return str_starts_with($dsn, 'sync://');
3939
}
4040
}

0 commit comments

Comments
 (0)