0

When using factory-like patterns, PhpStorm only recognises classes when docblock comment is used. Example:

/** @var \Some\Thing $thing */
$thing = $this->factory('some/thing');
$thing->doSomething();

Without the @var declaration, PhpStorm doesn't know doSomething() is a method of the \Some\Thing class. If it were entirely up to me, I would just add these docblock comments. However, my coworkers dislike inline docblock comments.

Is there a way to either:

  • Ignore these docblocks when committing (eg filter by regex) or
  • Teach phpstorm how to find the class name based on the 'some/thing' argument or
  • Use another method to keep these comments only in my own working copy?
Just TFS
  • 4,697
  • 1
  • 18
  • 22
Jesse
  • 1
  • possible duplicate of [PHPStorm Namespace support not working for Symfony2 projects](http://stackoverflow.com/questions/7172312/phpstorm-namespace-support-not-working-for-symfony2-projects) – Asenar Oct 24 '14 at 08:48
  • It seems it's a known issue about phpstorm and namespacing. The following video may help you : http://www.youtube.com/watch?v=EVvBKDB1NNQ – Asenar Oct 24 '14 at 08:50
  • 3
    This is a very subjective question (and it doesn't answer the question as you state it), so I'm just going to post this as a comment: Option 4; Continue using them en make your coworkers provide valid reasons against them, because "I don't like them" is not a valid reason. Add a text description in addition to the `@` tags and they'll have even less of a leg to stand on. – RickN Oct 24 '14 at 08:53
  • You can try **DynamicReturnType Plugin** -- may help here. PhpStorm does not currently support such factory methods for **ordinary classes/methods** (see [WI-18075](https://youtrack.jetbrains.com/issue/WI-18075)) -- ATM it only supports [static methods](https://youtrack.jetbrains.com/issue/WI-6027) or [global functions](https://youtrack.jetbrains.com/issue/WI-20096). – LazyOne Oct 24 '14 at 09:13

0 Answers0