Skip to content

Commit 7abed48

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 ------- b3d30e3b60e Fix various bool-type coercions
2 parents 155f766 + bd9edaf commit 7abed48

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

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
}

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());

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');

0 commit comments

Comments
 (0)