FEATURE REQUEST: Dynamic Code Completion for Factory methods

General discussion on Zend Studio

FEATURE REQUEST: Dynamic Code Completion for Factory methods

Postby gschmick on Sun Feb 21, 2010 6:24 pm

Often times in the Zend Framework, you use a factory pattern to instantiate child objects. Currently, the best you can do for code completion is to ensure the factory method @return(s) an abstract in order to have partial code completion. I'd like to see the ability to hint to Zend Studio the proper response type.

Example:
Code: Select all
$cache = Zend_Cache::factory('Page',
                             'File',
                             $frontendOptions,
                             $backendOptions);



The above code only sets up Zend Studio with the following @return type: Zend_Cache_Core|Zend_Cache_Frontend

I would love it if I could do something like this:

Code: Select all
$cache = Zend_Cache::factory('Page',
                             'File',
                             $frontendOptions,
                             $backendOptions); // @return: Zend_Cache_Core_Frontend_Page




Obviously this example isn't very great.. but there are literally tons of places where I wish I could programmatically hint to Zend Studio how I want it to behave.
gschmick
 
Posts: 2
Joined: Sat Apr 25, 2009 8:18 pm

Re: FEATURE REQUEST: Dynamic Code Completion for Factory methods

Postby m_dio on Mon Feb 22, 2010 1:35 pm

You can simply use:

Code: Select all
/* @var $cache Zend_Cache_Core_Frontend_Page */
$cache = Zend_Cache::factory('Page',
                             'File',
                             $frontendOptions,
                             $backendOptions);



This gives the hint that $cache is an object of the class Zend_Cache_Core_Frontend_Page and should be exactly what you want.
m_dio
 
Posts: 1
Joined: Mon Feb 22, 2010 1:33 pm

Re: FEATURE REQUEST: Dynamic Code Completion for Factory methods

Postby ziemkowski on Mon Feb 22, 2010 9:58 pm

Would be nice if that worked to sort of declare the vars for the validator too.

That way PHP-based templates that are given variables can not only suggest a type for the passed in vars, but avoid the "Undefined variable ___" message without having to disable those checks from the entire project.

Is there a way to do that or to set validation preferences by a filetype (eg .tpl files having one set of loose validation rules while .php files have another stricter set)?
ziemkowski
 
Posts: 11
Joined: Sun Dec 13, 2009 11:19 pm

Re: FEATURE REQUEST: Dynamic Code Completion for Factory met

Postby fonant on Thu Mar 07, 2013 1:14 pm

Agree, adding comments with @var descriptions for template files would be very useful, for Drupal templates too.
fonant
 
Posts: 37
Joined: Thu Mar 05, 2009 2:56 pm
Location: Lancing, West Sussex, UK


Return to Zend Studio

Who is online

Users browsing this forum: No registered users and 7 guests