Answers.Body: <p>It's 95% an IDE issue.  Craft can take advantage of this because it provides PHP DocBlock <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/etc/web/WebApp.php#L5" rel="nofollow">property information</a> in <a href="http://buildwithcraft.com/classreference/etc/web/WebApp" rel="nofollow">WebApp</a> (which is what <code>craft()</code> is a reference to) and IDE's like PhpStorm are smart enough to analyze that and find the classes you're referencing for autocompletion.</p>
  
  <p>It's impossible for Craft to let plugins dynamically add properties to that DocBlock, but I have seen some clever <a href="https://github.com/selvinortiz/craft.spamguard" rel="nofollow">plugins</a> provide their own abstraction around <code>craft()</code> so they can add their own <a href="https://github.com/selvinortiz/craft.spamguard/blob/master/SpamGuardPlugin.php#L161" rel="nofollow">plugin specific DocBlock info</a> that enables autocompletion around services.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-30T15:42:58.977Z
Answers.LastActivityDate: 2015-06-30T15:58:19.807Z
Answers.LastEditDate: 2015-06-30T15:58:19.807Z
Answers.UserDisplayName: Brad Bell
Body: <p>My IDE knows about craft() from an autocomplete and code validation point of view, but it knows nothing about the plugin services that have to be accessed in this way.</p>
  
  <p>Any suggestions on how this could be improved to aid with easier development? Is it an IDE issue, or perhaps a Craft 3 feature request?</p>
  
Tags: <plugin-development>
Title: Autocomplete of craft()->craft_pluginservice->foo()
ThreadText: # Autocomplete of craft()->craft_pluginservice->foo()
  
  (Asked by: username_0 on 2015-06-30)
  
  My IDE knows about craft() from an autocomplete and code validation point of view, but it knows nothing about the plugin services that have to be accessed in this way.
  
  Any suggestions on how this could be improved to aid with easier development? Is it an IDE issue, or perhaps a Craft 3 feature request?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-30. Score: 1 | Accepted answer
  
  It's 95% an IDE issue. Craft can take advantage of this because it provides PHP DocBlock [property information](https://github.com/pixelandtonic/Craft-Release/blob/master/app/etc/web/WebApp.php#L5) in [WebApp](http://buildwithcraft.com/classreference/etc/web/WebApp) (which is what `craft()` is a reference to) and IDE's like PhpStorm are smart enough to analyze that and find the classes you're referencing for autocompletion.
  
  It's impossible for Craft to let plugins dynamically add properties to that DocBlock, but I have seen some clever [plugins](https://github.com/selvinortiz/craft.spamguard) provide their own abstraction around `craft()` so they can add their own [plugin specific DocBlock info](https://github.com/selvinortiz/craft.spamguard/blob/master/SpamGuardPlugin.php#L161) that enables autocompletion around services.
  
  
  ---
  
  