Sorien / silex-idea-plugin

Idea plugin for Silex Framework - plugin is not compatible with PHPStorm 2016.2
MIT License
26 stars 8 forks source link

Plugin breaks type inference when accessing objects inside of an array within a foreach loop #35

Closed bashofmann closed 8 years ago

bashofmann commented 8 years ago

Example code

<?php

class Publication  {

    public function getPublicationDate() {

    }
}

class Event {
    /** @var int */
    public $publicationUid;
}
class MailPublishedFulltextList {

    /**
     * @var Event[]
     */
    public $events = [];

    /** @var Publication[] */
    public $publications;

    public function collect() {
        $this->publications[123]->getPublicationDate();

        foreach ($this->events as $fulltextEvent) {
            $this->publications[$fulltextEvent->publicationUid]->getPublicationDate();
        }
    }
}

Expected result:

PhpStorm recognizes that getPublicationDate is a method of Publication.

When the plugin is installed actually PhpStorm $this->publications[$fulltextEvent->publicationUid] references Publication[] instead of Publication.

Sorien commented 8 years ago

i'll try to look at it, plugin shouldn't modify autocomplete in any way until $this is not instance of pimple class ... please provide IDEA/PhpStorm Version

bashofmann commented 8 years ago

PhpStorm 9.5 EAP 143.129, but the bug is also present in the current stable 9.x releases

Sorien commented 8 years ago

@bashofmann could you test it a bit http://silex.sorien.sk/download/master