Php Inspections (EA Ultimate): address some of one-time used local variables

This commit is contained in:
Vladimir Reznichenko 2018-03-10 10:27:05 +01:00
parent c202a373c3
commit f16d99ecfa
6 changed files with 10 additions and 20 deletions

View File

@ -54,8 +54,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
*/
public function extract($resource, MessageCatalogue $catalogue)
{
$files = $this->extractFiles($resource);
foreach ($files as $file) {
foreach ($this->extractFiles($resource) as $file) {
try {
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
} catch (Error $e) {

View File

@ -1039,8 +1039,6 @@ class Crawler extends \SplObjectStorage
*/
private function createSubCrawler($nodes)
{
$crawler = new static($nodes, $this->uri, $this->baseHref);
return $crawler;
return new static($nodes, $this->uri, $this->baseHref);
}
}

View File

@ -133,9 +133,7 @@ class LegacyChoiceListAdapter implements ChoiceListInterface
$this->values = array();
$this->structuredValues = $this->adaptedList->getValues();
$innerChoices = $this->adaptedList->getChoices();
foreach ($innerChoices as $index => $choice) {
foreach ($this->adaptedList->getChoices() as $index => $choice) {
$value = $this->structuredValues[$index];
$this->values[] = $value;
$this->choices[$value] = $choice;

View File

@ -81,6 +81,7 @@ class FormType extends BaseType
}
}
$formConfig = $form->getConfig();
$view->vars = array_replace($view->vars, array(
'read_only' => $readOnly,
'errors' => $form->getErrors(),
@ -92,9 +93,9 @@ class FormType extends BaseType
'pattern' => isset($options['attr']['pattern']) ? $options['attr']['pattern'] : null, // Deprecated
'size' => null,
'label_attr' => $options['label_attr'],
'compound' => $form->getConfig()->getCompound(),
'method' => $form->getConfig()->getMethod(),
'action' => $form->getConfig()->getAction(),
'compound' => $formConfig->getCompound(),
'method' => $formConfig->getMethod(),
'action' => $formConfig->getAction(),
'submitted' => $form->isSubmitted(),
));
}

View File

@ -61,9 +61,7 @@ class ValidationListener implements EventSubscriberInterface
if ($form->isRoot()) {
// Validate the form in group "Default"
$violations = $this->validator->validate($form);
foreach ($violations as $violation) {
foreach ($this->validator->validate($form) as $violation) {
// Allow the "invalid" constraint to be put onto
// non-synchronized forms
// ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0)

View File

@ -261,12 +261,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
$classMetadata = $this->metadataFactory->getMetadataFor($class);
if ($classMetadata instanceof ClassMetadataInterface && $classMetadata->hasPropertyMetadata($property)) {
$memberMetadatas = $classMetadata->getPropertyMetadata($property);
foreach ($memberMetadatas as $memberMetadata) {
$constraints = $memberMetadata->getConstraints();
foreach ($constraints as $constraint) {
foreach ($classMetadata->getPropertyMetadata($property) as $memberMetadata) {
foreach ($memberMetadata->getConstraints() as $constraint) {
if ($guess = $closure($constraint)) {
$guesses[] = $guess;
}