Skip to content
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

Not using return value of array_map in ClassGenerator->setImplementedInterfaces #3

Closed
weierophinney opened this issue Dec 31, 2019 · 1 comment · Fixed by #57
Closed
Assignees
Labels
Bug Something isn't working Won't Fix This will not be worked on
Milestone

Comments

@weierophinney
Copy link
Member

https://github.com/zendframework/zend-code/blob/master/src/Generator/ClassGenerator.php#L476-L482 has the following snippet

        array_map(function ($implementedInterface) {
            return (string) TypeGenerator::fromTypeString($implementedInterface);
        }, $implementedInterfaces);

        $this->implementedInterfaces = $implementedInterfaces;

That's a no-op, since the return value of the array_map isn't used. I think that the array_map should be removed, replaced with array_walk (probably pointless unless it would throw), or (probably) be changed to:

        $this->implementedInterfaces = array_map(function ($implementedInterface) {
            return (string) TypeGenerator::fromTypeString($implementedInterface);
        }, $implementedInterfaces);

The latter seems likely given the rest of the changes in zendframework/zend-code@ec09875

This was detected via static analysis, I'm not sure of the impact of fixing this.

http://php.net/array_map


Originally posted by @TysonAndre at zendframework/zend-code#165

@Ocramius
Copy link
Member

This is correct: that filter is not supposed to use the returned value, but just to check that the input is somewhat used.

Should've been an array_walk(), but closing here, as in #57 I documented it briefly, and we can further improve it when moving to aggressive vimeo/psalm analysis.

@Ocramius Ocramius added Bug Something isn't working Won't Fix This will not be worked on labels Nov 30, 2020
@Ocramius Ocramius self-assigned this Nov 30, 2020
@Ocramius Ocramius added this to the 4.0.0 milestone Nov 30, 2020
@Ocramius Ocramius linked a pull request Nov 30, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Won't Fix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants