zendframework / zend-code

BSD 3-Clause "New" or "Revised" License
1.68k stars 78 forks source link

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

Open TysonAndre opened 5 years ago

TysonAndre commented 5 years ago

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 https://github.com/zendframework/zend-code/commit/ec09875ecc89347a6109e0eaea4a75e4d54dd8c3

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

http://php.net/array_map

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-code; a new issue has been opened at https://github.com/laminas/laminas-code/issues/3.