Skip to content

Commit 8680ce4

Browse files
Girgiasnicolas-grekas
authored andcommitted
Remove some implicit bool type juggling
1 parent e7f13b0 commit 8680ce4

File tree

19 files changed

+30
-28
lines changed

19 files changed

+30
-28
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/SecurityExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public static function provideObjectFieldAclCases()
9191
return [
9292
[null, null, null],
9393
['object', null, 'object'],
94-
['object', false, new FieldVote('object', false)],
95-
['object', 0, new FieldVote('object', 0)],
94+
['object', '', new FieldVote('object', false)],
95+
['object', '0', new FieldVote('object', 0)],
9696
['object', '', new FieldVote('object', '')],
9797
['object', 'field', new FieldVote('object', 'field')],
9898
];

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private function getFileLink(string $class): string
184184
return '';
185185
}
186186

187-
return (string) $this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine());
187+
return $r->getFileName() ? ($this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine()) ?: '') : '';
188188
}
189189

190190
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void

src/Symfony/Bundle/TwigBundle/Tests/Functional/AttributeExtensionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ public static function fooTest(bool $value): bool
139139

140140
class RuntimeExtensionWithAttributes
141141
{
142-
public function __construct(private bool $prefix)
143-
{
142+
public function __construct(
143+
private string $prefix,
144+
) {
144145
}
145146

146147
#[AsTwigFilter('prefix_foo')]

src/Symfony/Bundle/WebProfilerBundle/Profiler/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function formatArgs(array $args): string
9494
$formattedValue = '<em>'.strtolower(htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset)).'</em>';
9595
} elseif ('resource' === $item[0]) {
9696
$formattedValue = '<em>resource</em>';
97-
} elseif (preg_match('/[^\x07-\x0D\x1B\x20-\xFF]/', $item[1])) {
97+
} elseif (\is_string($item[1]) && preg_match('/[^\x07-\x0D\x1B\x20-\xFF]/', $item[1])) {
9898
$formattedValue = '<em>binary string</em>';
9999
} else {
100100
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));

src/Symfony/Component/AssetMapper/AssetMapperDevServerSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function onKernelRequest(RequestEvent $event): void
146146
if ($mediaType = $this->getMediaType($asset->publicPath)) {
147147
$response->headers->set('Content-Type', $mediaType);
148148
}
149-
$response->headers->set('X-Assets-Dev', true);
149+
$response->headers->set('X-Assets-Dev', '1');
150150

151151
$event->setResponse($response);
152152
$event->stopPropagation();

src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testUrlDecodeParameters()
5656

5757
public static function provideCreateConnection(): array
5858
{
59-
$hosts = array_map(fn ($host) => \sprintf('host[%s]', $host), explode(' ', getenv('REDIS_CLUSTER_HOSTS')));
59+
$hosts = array_map(fn ($host) => \sprintf('host[%s]', $host), explode(' ', getenv('REDIS_CLUSTER_HOSTS') ?: ''));
6060

6161
return [
6262
[
@@ -79,7 +79,7 @@ public static function provideCreateConnection(): array
7979
}
8080

8181
/**
82-
* Due to a bug in phpredis, the persistent connection will keep its last selected database. So when re-using
82+
* Due to a bug in phpredis, the persistent connection will keep its last selected database. So when reusing
8383
* a persistent connection, the database has to be re-selected, too.
8484
*
8585
* @see https://github.com/phpredis/phpredis/issues/1920

src/Symfony/Component/DependencyInjection/Tests/AliasTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public static function invalidDeprecationMessageProvider(): array
8787
"With \ns" => ["invalid \n message %alias_id%"],
8888
'With */s' => ['invalid */ message %alias_id%'],
8989
'message not containing required %alias_id% variable' => ['this is deprecated'],
90-
'template not containing required %alias_id% variable' => [true],
9190
];
9291
}
9392
}

src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ public static function invalidDeprecationMessageProvider(): array
204204
"With \ns" => ["invalid \n message %service_id%"],
205205
'With */s' => ['invalid */ message %service_id%'],
206206
'message not containing require %service_id% variable' => ['this is deprecated'],
207-
'template not containing require %service_id% variable' => [true],
208207
];
209208
}
210209

src/Symfony/Component/DomCrawler/UriResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function resolve(string $uri, ?string $baseUri): string
7171

7272
// relative path
7373
$path = parse_url(substr($baseUri, \strlen($baseUriCleaned)), \PHP_URL_PATH) ?? '';
74-
$path = self::canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri);
74+
$path = self::canonicalizePath((str_contains($path, '/') ? substr($path, 0, strrpos($path, '/')) : '').'/'.$uri);
7575

7676
return $baseUriCleaned.('' === $path || '/' !== $path[0] ? '/' : '').$path;
7777
}

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
380380

381381
// Don't trigger deprecations for classes in the same vendor
382382
if ($class !== $className) {
383-
$vendor = preg_match('/^namespace ([^;\\\\\s]++)[;\\\\]/m', @file_get_contents($refl->getFileName()), $vendor) ? $vendor[1].'\\' : '';
383+
$vendor = $refl->getFileName() && preg_match('/^namespace ([^;\\\\\s]++)[;\\\\]/m', @file_get_contents($refl->getFileName()) ?: '', $vendor) ? $vendor[1].'\\' : '';
384384
$vendorLen = \strlen($vendor);
385385
} elseif (2 > $vendorLen = 1 + (strpos($class, '\\') ?: strpos($class, '_'))) {
386386
$vendorLen = 0;

0 commit comments

Comments
 (0)