8000 Php Inspections (EA Ultimate): address some of one-time used local va… · symfony/symfony@f16d99e · GitHub
[go: up one dir, main page]

Skip to content

Commit f16d99e

Browse files
committed
Php Inspections (EA Ultimate): address some of one-time used local variables
1 parent c202a37 commit f16d99e

File tree

6 files changed

+10
-20
lines changed

6 files changed

+10
-20
lines changed

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function __construct(Environment $twig)
5454
*/
5555
public function extract($resource, MessageCatalogue $catalogue)
5656
{
57-
$files = $this->extractFiles($resource);
58-
foreach ($files as $file) {
57+
foreach ($this->extractFiles($resource) as $file) {
5958
try {
6059
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
6160
} catch (Error $e) {

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,6 @@ private function findNamespacePrefixes($xpath)
10391039
*/
10401040
private function createSubCrawler($nodes)
10411041
{
1042-
$crawler = new static($nodes, $this->uri, $this->baseHref);
1043-
1044-
return $crawler;
1042+
return new static($nodes, $this->uri, $this->baseHref);
10451043
}
10461044
}

src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ private function initialize()
133133
$this->values = array();
134134
$this->structuredValues = $this->adaptedList->getValues();
135135

136-
$innerChoices = $this->adaptedList->getChoices();
137-
138-
foreach ($innerChoices as $index => $choice) {
136+
foreach ($this->adaptedList->getChoices() as $index => $choice) {
139137
$value = $this->structuredValues[$index];
140138
$this->values[] = $value;
141139
$this->choices[$value] = $choice;

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
8181
}
8282
}
8383

84+
$formConfig = $form->getConfig();
8485
$view->vars = array_replace($view->vars, array(
8586
'read_only' => $readOnly,
8687
'errors' => $form->getErrors(),
@@ -92,9 +93,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
9293
'pattern' => isset($options['attr']['pattern']) ? $options['attr']['pattern'] : null, // Deprecated
9394
'size' => null,
9495
'label_attr' => $options['label_attr'],
95-
'compound' => $form->getConfig()->getCompound(),
96-
'method' => $form->getConfig()->getMethod(),
97-
'action' => $form->getConfig()->getAction(),
96+
'compound' => $formConfig->getCompound(),
97+
'method' => $formConfig->getMethod(),
98+
'action' => $formConfig->getAction(),
9899
'submitted' => $form->isSubmitted(),
99100
));
100101
}

src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public function validateForm(FormEvent $event)
6161

6262
if ($form->isRoot()) {
6363
// Validate the form in group "Default"
64-
$violations = $this->validator->validate($form);
65-
66-
foreach ($violations as $violation) {
64+
foreach ($this->validator->validate($form) as $violation) {
6765
// Allow the "invalid" constraint to be put onto
6866
// non-synchronized forms
6967
// ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0)

src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,8 @@ protected function guess($class, $property, \Closure $closure, $defaultValue = n
261261
$classMetadata = $this->metadataFactory->getMetadataFor($class);
262262

263263
if ($classMetadata instanceof ClassMetadataInterface && $classMetadata->hasPropertyMetadata($property)) {
264-
$memberMetadatas = $classMetadata->getPropertyMetadata($property);
265-
266-
foreach ($memberMetadatas as $memberMetadata) {
267-
$constraints = $memberMetadata->getConstraints();
268-
269-
foreach ($constraints as $constraint) {
264+
foreach ($classMetadata->getPropertyMetadata($property) as $memberMetadata) {
265+
foreach ($memberMetadata->getConstraints() as $constraint) {
270266
if ($guess = $closure($constraint)) {
271267
$guesses[] = $guess;
272268
}

0 commit comments

Comments
 (0)
0