Skip to content

Fixing typo in variable name #16087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fixing typo in variable name #16087

wants to merge 1 commit into from

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Oct 2, 2015

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
foreach ($reflectionClass->getProperties() as $property) {
    if (!isset($attributeMetadata[$property->name])) { // <--- looks here
        $attributesMetadata[$property->name] = new AttributeMetadata($property->name);
        $classMetadata->addAttributeMetadata($attributesMetadata[$property->name]);
    }

    if ($property->getDeclaringClass()->name === $className) {
        foreach ($this->reader->getPropertyAnnotations($property) as $groups) {
            if ($groups instanceof Groups) {
                foreach ($groups->getGroups() as $group) {
                    $attributesMetadata[$property->name]->addGroup($group);
                }
            }

            $loaded = true;
        }
    }
}

This $attributeMetadata does not exists in this foreach context and the goal of this condition could be unexpected.

This condition is always `true` because `$attributesMetadata` does not exists in this `foreach` context and could overwrite values in the `$attributesMetadata` variable.
@stof
Copy link
Member

stof commented Oct 2, 2015

👍

@Tobion
Copy link
Contributor

Tobion commented Oct 2, 2015

👍 But should be merged in 2.7

@fabpot
Copy link
Member

fabpot commented Oct 3, 2015

Thank you @yceruto.

@fabpot fabpot closed this Oct 3, 2015
fabpot added a commit that referenced this pull request Oct 3, 2015
This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #16087).

Discussion
----------

Fixing typo in variable name

```php
foreach ($reflectionClass->getProperties() as $property) {
    if (!isset($attributeMetadata[$property->name])) {
        $attributesMetadata[$property->name] = new AttributeMetadata($property->name);
        $classMetadata->addAttributeMetadata($attributesMetadata[$property->name]);
    }

    if ($property->getDeclaringClass()->name === $className) {
        foreach ($this->reader->getPropertyAnnotations($property) as $groups) {
            if ($groups instanceof Groups) {
                foreach ($groups->getGroups() as $group) {
                    $attributesMetadata[$property->name]->addGroup($group);
                }
            }

            $loaded = true;
        }
    }
}
```

This `$attributeMetadata` does not exists in this `foreach` context and the goal of this condition could be unexpected.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none

Commits
-------

89499ff Fixing typo in variable name
@fabpot fabpot mentioned this pull request Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants