Skip to content

Commit 2d3d918

Browse files
Merge branch '5.4' into 6.0
* 5.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents ef1636f + 4e82052 commit 2d3d918

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Command/DebugCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
212212
foreach ($types as $index => $type) {
213213
$items = [];
214214
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
215-
if (!$filter || false !== strpos($name, $filter)) {
215+
if (!$filter || str_contains($name, $filter)) {
216216
$items[$name] = $name.$this->getPrettyMetadata($type, $entity, $decorated);
217217
}
218218
}
@@ -246,7 +246,7 @@ private function displayGeneralJson(SymfonyStyle $io, ?string $filter)
246246
$data = [];
247247
foreach ($types as $type) {
248248
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
249-
if (!$filter || false !== strpos($name, $filter)) {
249+
if (!$filter || str_contains($name, $filter)) {
250250
$data[$type][$name] = $this->getMetadata($type, $entity);
251251
}
252252
}
@@ -396,7 +396,7 @@ private function findWrongBundleOverrides(): array
396396
$folders = glob($this->twigDefaultPath.'/bundles/*', \GLOB_ONLYDIR);
397397
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
398398
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
399-
if (0 === strpos($absolutePath, $this->projectDir)) {
399+
if (str_starts_with($absolutePath, $this->projectDir)) {
400400
$name = basename($absolutePath);
401401
$path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR);
402402
$carry[$name] = $path;
@@ -526,7 +526,7 @@ private function findAlternatives(string $name, array $collection): array
526526
$alternatives = [];
527527
foreach ($collection as $item) {
528528
$lev = levenshtein($name, $item);
529-
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
529+
if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
530530
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
531531
}
532532
}
@@ -540,7 +540,7 @@ private function findAlternatives(string $name, array $collection): array
540540

541541
private function getRelativePath(string $path): string
542542
{
543-
if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) {
543+
if (null !== $this->projectDir && str_starts_with($path, $this->projectDir)) {
544544
return ltrim(substr($path, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
545545
}
546546

Extension/CodeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function abbrClass(string $class): string
6262

6363
public function abbrMethod(string $method): string
6464
{
65-
if (false !== strpos($method, '::')) {
65+
if (str_contains($method, '::')) {
6666
[$class, $method] = explode('::', $method, 2);
6767
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
6868
} elseif ('Closure' === $method) {
@@ -182,7 +182,7 @@ public function getFileRelative(string $file): ?string
182182
{
183183
$file = str_replace('\\', '/', $file);
184184

185-
if (null !== $this->projectDir && 0 === strpos($file, $this->projectDir)) {
185+
if (null !== $this->projectDir && str_starts_with($file, $this->projectDir)) {
186186
return ltrim(substr($file, \strlen($this->projectDir)), '/');
187187
}
188188

@@ -201,7 +201,7 @@ public function formatFileFromText(string $text): string
201201
*/
202202
public function formatLogMessage(string $message, array $context): string
203203
{
204-
if ($context && false !== strpos($message, '{')) {
204+
if ($context && str_contains($message, '{')) {
205205
$replacements = [];
206206
foreach ($context as $key => $val) {
207207
if (is_scalar($val)) {

0 commit comments

Comments
 (0)