2

I have been trying to to my PhpStorm configured to auto complete. So far, I managed to make $this auto complete correctly in a view. However I am having problems getting it's sub classes to auto complete.

Currently I am using

/* @var $this \Zend\View\Renderer\PhpRenderer */

Example: enter image description here

As you can see, $this->navigation does not contain menu(), however it does contain other method calls.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Andrew Rayner
  • 1,056
  • 1
  • 6
  • 20
  • 1
    *"however it does contain other method calls"* That's because there is no point to analyze subsequent/chained method calls if previous/parent is unknown. – LazyOne Oct 04 '15 at 10:12
  • Do you know a way to correctly/possibly configure this? – Andrew Rayner Oct 04 '15 at 10:30
  • Nope -- not using Zend Framework myself. How `navigation()` is defined? Maybe you can override it in child class via PHPDoc? One "stupid" idea is to define your own custom class anywhere in the project (will be used by IDE only) and declare such method there; then use `/* @var $this \Zend\View\Renderer\PhpRenderer|\My\Special\Class */` -- PhpStorm will sort of combine them together (if method is not found in first class it will look for it in another). – LazyOne Oct 04 '15 at 12:16
  • I thought of doing a custom class specifically for defining them. I am amazingly surprised no one has done this! – Andrew Rayner Oct 04 '15 at 12:18
  • Maybe there is another way of doing this .. or maybe lots of ZF users simply use Zend Studio for this (where I would expect to be a better support for ZF). See if anybody else will give you a better suggestions (it's weekend now and so it's quite here). Similar question: http://stackoverflow.com/questions/15138746/autocompletion-for-zf2-view-helpers-in-phpstorm – LazyOne Oct 04 '15 at 12:28
  • I have been researching this for 2 days straight. I honestly could not find a darn thing. Zend studio isn't that good of an IDE. I have had many issues with it. Auto completion is buggy as well. – Andrew Rayner Oct 04 '15 at 12:51
  • Well ... my only other suggestion for now is to create already suggested custom class (where you will define all needed/missed methods with correct for you signatures; it will be used by IDE only) but name it exactly the same as original one (same namespace etc). IDE will warn you that you have duplicate class but should still provide completion from both places -- real class + yours. No better ideas unless there would be a special plugin for ZF support. – LazyOne Oct 04 '15 at 13:02
  • PhpStorm devs in their [roadmap](https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Development+Roadmap) claim that they experimenting on ZF2 support .. but [corresponding ticket](https://youtrack.jetbrains.com/issue/WI-9606) does not reflect any progress yet -- maybe in v10 ... – LazyOne Oct 04 '15 at 13:04

1 Answers1

0

The problem is not about your setup, it is about the inconsistent inline documentation of ZF.

As the example shows PhpStorm knows $this->navigation(), because of your @var. The only thing is that it doesn't know of the menu function.

In the renderer (here) you can see there is a hint that navigation is available, even if there is no such function (and returns Zend\View\Helper\Navigation).

In Zend\View\Helper\Navigation (here) you see there are no @methods defined and there is no function menu, so your IDE cannot find menu.

danopz
  • 3,310
  • 5
  • 31
  • 42
  • Yep! I have noticed this a bunch. What I'll do is reference $menu as a new variable with $var but then I run into the same issue again. before I know it I just have them everywhere and starts to look clustered. Amazing framework. Poor structural documentation! – Andrew Rayner Oct 05 '15 at 15:27