Skip to content

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

@jens1o

Description

@jens1o
Contributor
<?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

Activity

changed the title [-]Feature Request: When a class instance implements `Countable`, show it as a suggestion when using `count()`[/-] [+]Only suggest variables that are compatible with the type in the context they are used[/+] on Jan 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @felixfbecker@jens1o

        Issue actions

          Only suggest variables that are compatible with the type in the context they are used · Issue #571 · felixfbecker/php-language-server