Skip to content

Commit f82cfa2

Browse files
Merge branch '5.2' into 5.3
* 5.2: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 7e5339a + f9dce4b commit f82cfa2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
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
@@ -65,7 +65,7 @@ public function abbrClass(string $class): string
6565

6666
public function abbrMethod(string $method): string
6767
{
68-
if (false !== strpos($method, '::')) {
68+
if (str_contains($method, '::')) {
6969
[$class, $method] = explode('::', $method, 2);
7070
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
7171
} elseif ('Closure' === $method) {
@@ -190,7 +190,7 @@ public function getFileRelative(string $file): ?string
190190
{
191191
$file = str_replace('\\', '/', $file);
192192

193-
if (null !== $this->projectDir && 0 === strpos($file, $this->projectDir)) {
193+
if (null !== $this->projectDir && str_starts_with($file, $this->projectDir)) {
194194
return ltrim(substr($file, \strlen($this->projectDir)), '/');
195195
}
196196

@@ -209,7 +209,7 @@ public function formatFileFromText(string $text): string
209209
*/
210210
public function formatLogMessage(string $message, array $context): string
211211
{
212-
if ($context && false !== strpos($message, '{')) {
212+
if ($context && str_contains($message, '{')) {
213213
$replacements = [];
214214
foreach ($context as $key => $val) {
215215
if (is_scalar($val)) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=7.2.5",
20-
"symfony/polyfill-php80": "^1.15",
20+
"symfony/polyfill-php80": "^1.16",
2121
"symfony/translation-contracts": "^1.1|^2",
2222
"twig/twig": "^2.13|^3.0.4"
2323
},

0 commit comments

Comments
 (0)