Skip to content

Static analysis - avoid unnecessary counts  #713

@norberttech

Description

@norberttech

It would be nice to have static analysis detect following scenario as invalid:

$array = [];

if (\count($array)) {
   foreach ($array as $element) {
        // some logic
   }
}

Since the array is not nullable foreach would do nothing, so count is unnecessary.

#Ref: #712 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions