Skip to content

Only suggest variables that are compatible with the type in the context they are used #571

Open
@jens1o

Description

@jens1o
<?php

class HitCounter implements Countable {
    
    public function __construct() {
        $this->counter = 0;
    }

    public function hit() {
        ++$this->counter;
    }

    public function count(): int {
        return $this->counter;
    }
}
class RandomClass {}

$random = new RandomClass;
$hits = new HitCounter;
$testArr = [];

$hits->hit();
$hits->hit();

count($|); // <= only suggest `$hits` and `$testArr`, ´$random` is filtered out

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions