Skip to content

Incorrect behavior of CountOnNullRector #8016

@markdorison

Description

@markdorison

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/4239ac15-dcf4-4803-a463-bfe14312e1f2

<?php

trait SitesConfigTrait
{
    public function getAllSiteNames(): array
    {
        return array_keys($this->getAllSitesConfig());
    }

    public function getSitesCount(): int
    {
        return count($this->getAllSitesConfig());
    }

}

Responsible rules

  • CountOnNullRector

Expected Behavior

I expect no issue on this line since the called method getAllSiteNames() specifies a return type of array, but rector is behaving as if it could return NULL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions