Skip to content

Commit f9dce4b

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 64485aa + 18bbe2d commit f9dce4b

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
@@ -211,7 +211,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
211211
foreach ($types as $index => $type) {
212212
$items = [];
213213
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
214-
if (!$filter || false !== strpos($name, $filter)) {
214+
if (!$filter || str_contains($name, $filter)) {
215215
$items[$name] = $name.$this->getPrettyMetadata($type, $entity, $decorated);
216216
}
217217
}
@@ -245,7 +245,7 @@ private function displayGeneralJson(SymfonyStyle $io, ?string $filter)
245245
$data = [];
246246
foreach ($types as $type) {
247247
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
248-
if (!$filter || false !== strpos($name, $filter)) {
248+
if (!$filter || str_contains($name, $filter)) {
249249
$data[$type][$name] = $this->getMetadata($type, $entity);
250250
}
251251
}
@@ -395,7 +395,7 @@ private function findWrongBundleOverrides(): array
395395
$folders = glob($this->twigDefaultPath.'/bundles/*', \GLOB_ONLYDIR);
396396
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
397397
$bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) {
398-
if (0 === strpos($absolutePath, $this->projectDir)) {
398+
if (str_starts_with($absolutePath, $this->projectDir)) {
399399
$name = basename($absolutePath);
400400
$path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR);
401401
$carry[$name] = $path;
@@ -525,7 +525,7 @@ private function findAlternatives(string $name, array $collection): array
525525
$alternatives = [];
526526
foreach ($collection as $item) {
527527
$lev = levenshtein($name, $item);
528-
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
528+
if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
529529
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
530530
}
531531
}
@@ -539,7 +539,7 @@ private function findAlternatives(string $name, array $collection): array
539539

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

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)