Skip to content

False positive InvalidArgument for count for callable-array #2012

@TysonAndre

Description

@TysonAndre
<?php

class MyClass {
    public function __construct($x) {
        $this->callback = $x;
    }

    /** @var callable|false */
    public $callback;
    function example() : void {
        if (is_array($this->callback)) {
            // Unexpected ERROR: InvalidArgument - Argument 1 of count expects array<array-key, mixed>|Countable|SimpleXMLElement|ResourceBundle, callable-array{0: string|object, 1: string} provided
            echo "Count is: " . count($this->callback);
        }
    }
}

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