Skip to content

Incorrect behavior of ArrayToFirstClassCallableRector #9563

Description

@samsonasik

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/faa93c4d-6f7b-4c81-9f36-31a20f50e461

<?php

final class DemoFile
{
    public function run(array $data)
    {
    }

    public function execute()
    {
        return $this->run([$this, 'some']);
    }
    
    public function some()
    {}
}

Responsible rules

  • ArrayToFirstClassCallableRector

Expected Behavior

When used as argument, and caller requires array as type data, it should be skipped, or it will cause error:

Fatal error: Uncaught TypeError: DemoFile::run(): Argument #1 ($data) must be of type array, Closure given, called in /in/9sEbL on line 11 and defined in /in/9sEbL:5

see https://3v4l.org/9sEbL#v8.1.34

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions