Skip to content

Commit 5d66cca

Browse files
minor #61103 Fix various bool-type coercions (Girgias)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- Fix various bool-type coercions | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | | License | MIT This is cherry-picking some of the commits from #60890 which are basically bugs. Not sure what the commit naming policy is so do let me know if you want me to manually rebase and rename commits following some guidelines. Commits ------- b3d30e3 Fix various bool-type coercions
2 parents 3c9cdc6 + b3d30e3 commit 5d66cca

File tree

17 files changed

+37
-30
lines changed

17 files changed

+37
-30
lines changed

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function generateSignature(\ReflectionClass $class): iterable
123123
yield print_r($attributes, true);
124124
$attributes = [];
125125

126-
yield $class->getDocComment();
126+
yield $class->getDocComment() ?: '';
127127
yield (int) $class->isFinal();
128128
yield (int) $class->isAbstract();
129129

@@ -145,7 +145,7 @@ private function generateSignature(\ReflectionClass $class): iterable
145145
yield print_r($attributes, true);
146146
$attributes = [];
147147

148-
yield $p->getDocComment();
148+
yield $p->getDocComment() ?: '';
149149
yield $p->isDefault() ? '<default>' : '';
150150
yield $p->isPublic() ? 'public' : 'protected';
151151
yield $p->isStatic() ? 'static' : '';

src/Symfony/Component/Config/Tests/Builder/GeneratedConfigTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ private function assertDirectorySame($expected, $current)
198198
}
199199
$currentFiles[substr($file->getPathname(), \strlen($current))] = $file->getPathname();
200200
}
201+
ksort($expectedFiles);
202+
ksort($currentFiles);
201203

202204
$this->assertSame(array_keys($expectedFiles), array_keys($currentFiles));
203205
foreach ($expectedFiles as $fileName => $filePath) {

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ private function createService(Definition $definition, array &$inlineServices, b
11251125
if (!$definition->isDeprecated() && \is_array($factory) && \is_string($factory[0])) {
11261126
$r = new \ReflectionClass($factory[0]);
11271127

1128-
if (0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
1128+
if (0 < strpos($r->getDocComment() ?: '', "\n * @deprecated ")) {
11291129
trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name);
11301130
}
11311131
}
@@ -1142,7 +1142,7 @@ private function createService(Definition $definition, array &$inlineServices, b
11421142
$service = $r->getConstructor() ? $r->newInstanceArgs($arguments) : $r->newInstance();
11431143
}
11441144

1145-
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
1145+
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment() ?: '', "\n * @deprecated ")) {
11461146
trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name);
11471147
}
11481148
}

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ private function collectLineage(string $class, array &$lineage): void
542542
return;
543543
}
544544
$file = $r->getFileName();
545-
if (str_ends_with($file, ') : eval()\'d code')) {
545+
if ($file && str_ends_with($file, ') : eval()\'d code')) {
546546
$file = substr($file, 0, strrpos($file, '(', -17));
547547
}
548548
if (!$file || $this->doExport($file) === $exportedFile = $this->export($file)) {
@@ -589,12 +589,13 @@ private function generateProxyClasses(): array
589589
continue;
590590
}
591591
do {
592-
$file = $r->getFileName();
593-
if (str_ends_with($file, ') : eval()\'d code')) {
594-
$file = substr($file, 0, strrpos($file, '(', -17));
595-
}
596-
if (is_file($file)) {
597-
$this->container->addResource(new FileResource($file));
592+
if ($file = $r->getFileName()) {
593+
if (str_ends_with($file, ') : eval()\'d code')) {
594+
$file = substr($file, 0, strrpos($file, '(', -17));
595+
}
596+
if (is_file($file)) {
597+
$this->container->addResource(new FileResource($file));
598+
}
598599
}
599600
$r = $r->getParentClass() ?: null;
600601
} while ($r?->isUserDefined());

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,11 @@ private function parseDefinition(\DOMElement $service, string $file, Definition
339339
}
340340

341341
foreach ($this->getChildren($service, 'call') as $call) {
342-
$definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file), XmlUtils::phpize($call->getAttribute('returns-clone')));
342+
$definition->addMethodCall(
343+
$call->getAttribute('method'),
344+
$this->getArgumentsAsPhp($call, 'argument', $file),
345+
XmlUtils::phpize($call->getAttribute('returns-clone')) ?: false
346+
);
343347
}
344348

345349
$tags = $this->getChildren($service, 'tag');

src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function getTestFilterData()
7272

7373
$inner[] = new MockSplFileInfo([
7474
'name' => 'unreadable-file.txt',
75-
'contents' => false,
75+
'contents' => '',
7676
'type' => 'file',
7777
'mode' => 'r+', ]
7878
);

src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CountryTypeTest extends BaseTypeTestCase
2020

2121
protected function setUp(): void
2222
{
23-
IntlTestHelper::requireIntl($this, false);
23+
IntlTestHelper::requireIntl($this);
2424

2525
parent::setUp();
2626
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CurrencyTypeTest extends BaseTypeTestCase
2020

2121
protected function setUp(): void
2222
{
23-
IntlTestHelper::requireIntl($this, false);
23+
IntlTestHelper::requireIntl($this);
2424

2525
parent::setUp();
2626
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class IntegerTypeTest extends BaseTypeTestCase
2121

2222
protected function setUp(): void
2323
{
24-
IntlTestHelper::requireIntl($this, false);
24+
IntlTestHelper::requireIntl($this);
2525
$this->previousLocale = \Locale::getDefault();
2626
parent::setUp();
2727
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LanguageTypeTest extends BaseTypeTestCase
2121

2222
protected function setUp(): void
2323
{
24-
IntlTestHelper::requireIntl($this, false);
24+
IntlTestHelper::requireIntl($this);
2525

2626
parent::setUp();
2727
}

0 commit comments

Comments
 (0)