Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function loginUser(object $user, string $firewallContext = 'main'): stati
}

if (!$user instanceof UserInterface) {
throw new \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, UserInterface::class, \is_object($user) ? \get_class($user) : \gettype($user)));
throw new \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, UserInterface::class, get_debug_type($user)));
}

$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private function writeLine(string $text, int $indent = 0)

private function writeArray(array $array, int $depth)
{
$isIndexed = array_values($array) === $array;
$isIndexed = array_is_list($array);

foreach ($array as $key => $value) {
if (\is_array($value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function matches($crawler): bool
$this->hasNode = true;
$this->nodeText = $crawler->text(null, true);

return false !== mb_strpos($this->nodeText, $this->expectedText);
return str_contains($this->nodeText, $this->expectedText);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the str_contains RFC:

In a recent discussion in the internals mailing list, we came to the conclusion, there is no need for a multibyte variant of this function (e.g. mb_str_contains). The reason behind this is: A multibyte variant of this function would behave no different than the non-multibyte function. Multibyte variants behave differently when the offset/position has relevance at which the string was found. As this is not the case for this function, there is no need for that.

And from what I understood, it's the same for str_starts_with() and str_ends_with().

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$last = $exceptionAsArrayCount - 1;
foreach ($exceptionAsArray as $i => $e) {
foreach ($e['trace'] as $trace) {
if ($trace['file'] && false === mb_strpos($trace['file'], '/vendor/') && false === mb_strpos($trace['file'], '/var/cache/') && $i < $last) {
if ($trace['file'] && !str_contains($trace['file'], '/vendor/') && !str_contains($trace['file'], '/var/cache/') && $i < $last) {
$exceptionWithUserCode[] = $i;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<?php
$isFirstUserCode = true;
foreach ($exception['trace'] as $i => $trace) {
$isVendorTrace = $trace['file'] && (false !== mb_strpos($trace['file'], '/vendor/') || false !== mb_strpos($trace['file'], '/var/cache/'));
$isVendorTrace = $trace['file'] && (str_contains($trace['file'], '/vendor/') || str_contains($trace['file'], '/var/cache/'));
$displayCodeSnippet = $isFirstUserCode && !$isVendorTrace;
if ($displayCodeSnippet) {
$isFirstUserCode = false;
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Filesystem/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public static function makeRelative(string $path, string $basePath): string
*/
public static function isLocal(string $path): bool
{
return '' !== $path && false === mb_strpos($path, '://');
return '' !== $path && !str_contains($path, '://');
}

/**
Expand Down Expand Up @@ -638,7 +638,7 @@ public static function getLongestCommonBasePath(string ...$paths): ?string

// Prevent false positives for common prefixes
// see isBasePath()
if (0 === mb_strpos($path.'/', $basePath.'/')) {
if (str_starts_with($path.'/', $basePath.'/')) {
// next path
continue 2;
}
Expand Down Expand Up @@ -666,7 +666,7 @@ public static function join(string ...$paths): string
if (null === $finalPath) {
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
$finalPath = $path;
$wasScheme = (false !== mb_strpos($path, '://'));
$wasScheme = str_contains($path, '://');
continue;
}

Expand Down Expand Up @@ -717,7 +717,7 @@ public static function isBasePath(string $basePath, string $ofPath): bool
// Don't append a slash for the root "/", because then that root
// won't be discovered as common prefix ("//" is not a prefix of
// "/foobar/").
return 0 === mb_strpos($ofPath.'/', rtrim($basePath, '/').'/');
return str_starts_with($ofPath.'/', rtrim($basePath, '/').'/');
}

/**
Expand Down Expand Up @@ -786,7 +786,7 @@ private static function split(string $path): array
$length = mb_strlen($path);

// Remove and remember root directory
if (0 === mb_strpos($path, '/')) {
if (str_starts_with($path, '/')) {
$root .= '/';
$path = $length > 1 ? mb_substr($path, 1) : '';
} elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public function isEmpty(): bool

return FormUtil::isEmpty($this->modelData) ||
// arrays, countables
((\is_array($this->modelData) || $this->modelData instanceof \Countable) && 0 === \count($this->modelData)) ||
(is_countable($this->modelData) && 0 === \count($this->modelData)) ||
// traversables that are not countable
($this->modelData instanceof \Traversable && 0 === iterator_count($this->modelData));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/MockHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function request(string $method, string $url, array $options = []): Respo
++$this->requestsCount;

if (!$response instanceof ResponseInterface) {
throw new TransportException(sprintf('The response factory passed to MockHttpClient must return/yield an instance of ResponseInterface, "%s" given.', \is_object($response) ? \get_class($response) : \gettype($response)));
throw new TransportException(sprintf('The response factory passed to MockHttpClient must return/yield an instance of ResponseInterface, "%s" given.', get_debug_type($response)));
}

return MockResponse::fromRequest($method, $url, $options, $response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function matches($message): bool
throw new \LogicException('Unable to test a message HTML body on a RawMessage or Message instance.');
}

return false !== mb_strpos($message->getHtmlBody(), $this->expectedText);
return str_contains($message->getHtmlBody(), $this->expectedText);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function matches($message): bool
throw new \LogicException('Unable to test a message text body on a RawMessage or Message instance.');
}

return false !== mb_strpos($message->getTextBody(), $this->expectedText);
return str_contains($message->getTextBody(), $this->expectedText);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function supports(Request $request): ?bool
if (null !== $this->logger) {
$context = ['firewall_name' => $this->firewallName];

if ($this->authenticators instanceof \Countable || \is_array($this->authenticators)) {
if (is_countable($this->authenticators)) {
$context['authenticators'] = \count($this->authenticators);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Semaphore/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
return $this->redis->eval(...array_merge([$script, 1, $resource], $args));
}

throw new InvalidArgumentException(sprintf('"%s()" expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
throw new InvalidArgumentException(sprintf('"%s()" expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($this->redis)));
}

private function getUniqueToken(Key $key): string
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/String/AbstractString.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF
*/
public function trimPrefix($prefix): static
{
if (\is_array($prefix) || $prefix instanceof \Traversable) {
if (is_iterable($prefix)) {
foreach ($prefix as $s) {
$t = $this->trimPrefix($s);

Expand Down Expand Up @@ -592,7 +592,7 @@ abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FE
*/
public function trimSuffix($suffix): static
{
if (\is_array($suffix) || $suffix instanceof \Traversable) {
if (is_iterable($suffix)) {
foreach ($suffix as $s) {
$t = $this->trimSuffix($s);

Expand Down