Skip to content

Commit 90e419d

Browse files
committed
minor symfony#40968 [Config] Remove unused sprintf + coding standards (HypeMC)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Config] Remove unused sprintf + coding standards | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - A few things I noticed, redundant `sprintf` and variable and coding standards. Commits ------- 17479e2 Minor code cleanup
2 parents a94de9e + 17479e2 commit 90e419d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Symfony/Component/Config/Builder/ClassBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function build(): string
7979
}
8080
foreach ($this->methods as $method) {
8181
$lines = explode("\n", $method->getContent());
82-
foreach ($lines as $i => $line) {
82+
foreach ($lines as $line) {
8383
$body .= ' '.$line."\n";
8484
}
8585
}

src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function NAME(array $value = []): CLASS
136136
if (null === $this->PROPERTY) {
137137
$this->PROPERTY = new CLASS($value);
138138
} elseif ([] !== $value) {
139-
throw new InvalidConfigurationException(sprintf(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\'));
139+
throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
140140
}
141141
142142
return $this->PROPERTY;
@@ -233,7 +233,7 @@ public function NAME(string $VAR, array $VALUE = []): CLASS
233233
return $this->PROPERTY[$VAR];
234234
}
235235
236-
throw new InvalidConfigurationException(sprintf(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\'));
236+
throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
237237
}';
238238
$class->addUse(InvalidConfigurationException::class);
239239
$class->addMethod($methodName, $body, ['PROPERTY' => $property->getName(), 'CLASS' => $childClass->getFqcn(), 'VAR' => '' === $key ? 'key' : $key, 'VALUE' => 'value' === $key ? 'data' : 'value']);
@@ -300,7 +300,7 @@ private function getComment(VariableNode $node): string
300300
$comment .= ' * '.$info.\PHP_EOL;
301301
}
302302

303-
foreach (((array) $node->getExample() ?? []) as $example) {
303+
foreach ((array) ($node->getExample() ?? []) as $example) {
304304
$comment .= ' * @example '.$example.\PHP_EOL;
305305
}
306306

@@ -356,7 +356,7 @@ private function buildToArray(ClassBuilder $class): void
356356
$code = '$this->PROPERTY';
357357
if (null !== $p->getType()) {
358358
if ($p->isArray()) {
359-
$code = 'array_map(function($v) { return $v->toArray(); }, $this->PROPERTY)';
359+
$code = 'array_map(function ($v) { return $v->toArray(); }, $this->PROPERTY)';
360360
} else {
361361
$code = '$this->PROPERTY->toArray()';
362362
}
@@ -385,7 +385,7 @@ private function buildConstructor(ClassBuilder $class): void
385385
$code = '$value[\'ORG_NAME\']';
386386
if (null !== $p->getType()) {
387387
if ($p->isArray()) {
388-
$code = 'array_map(function($v) { return new '.$p->getType().'($v); }, $value[\'ORG_NAME\'])';
388+
$code = 'array_map(function ($v) { return new '.$p->getType().'($v); }, $value[\'ORG_NAME\'])';
389389
} else {
390390
$code = 'new '.$p->getType().'($value[\'ORG_NAME\'])';
391391
}
@@ -400,8 +400,8 @@ private function buildConstructor(ClassBuilder $class): void
400400
}
401401

402402
$body .= '
403-
if ($value !== []) {
404-
throw new InvalidConfigurationException(sprintf(\'The following keys are not supported by "%s": \', __CLASS__) . implode(\', \', array_keys($value)));
403+
if ([] !== $value) {
404+
throw new InvalidConfigurationException(sprintf(\'The following keys are not supported by "%s": \', __CLASS__).implode(\', \', array_keys($value)));
405405
}';
406406

407407
$class->addUse(InvalidConfigurationException::class);

0 commit comments

Comments
 (0)