Skip to content

Incorrect behavior of CountArrayToEmptyArrayComparisonRector #7971

Description

@pauci

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/4ffb788a-2744-46bc-8f09-56e20aa5b819

<?php

final class DemoFile implements \Countable
{
    public function isNotEmpty(): bool
    {
        return 0 < \count($this);
    }
    
    public function count(): int
    {
        return 0;
    }
}

Responsible rules

  • CountArrayToEmptyArrayComparisonRector

Expected Behavior

In this case rector should do nothing as counted value is not an array,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions