This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 190861 - PHP code completion does not detect Zend Framework method "url()".
Summary: PHP code completion does not detect Zend Framework method "url()".
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Zend (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 21:27 UTC by eklutna
Modified: 2013-11-19 02:54 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Screen shot of failed code completion. (159.11 KB, image/png)
2010-10-08 21:27 UTC, eklutna
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eklutna 2010-10-08 21:27:19 UTC
Created attachment 102326 [details]
Screen shot of failed code completion.

While attempting to create a link to another page by using Zend Framwork's method "url()", I noticed that NetBeans PHP code completion does not detect the method, even though it is usable in the context of a /views/scripts/index/index.phtml file.

// At this point, code completion does pop up, but method "url()" is not listed.
<a href="<?php echo $this->

// I can manually type the rest of the code, and this does work, so method "url()" was valid in this context, but not picked up by code completion.
<a href="<?php echo $this->url(array(), 'Page2'); ?>">Page 2</a>


Zend Framework Version:  1.10.8
Comment 1 pgebauer 2010-10-19 11:40:40 UTC
I have checked Zend_View_Interface class in the library/Zend/View directory and the function url() isn't there so the code completion works correctly from this point of view. Could you please specify what the function url() should do? Where is a source code for it in the Zend framework?
Comment 2 eklutna 2010-10-31 05:30:16 UTC
Using grep, I found 4 instances of functions named "url" in the Zend Framework version 1.10.8.  The one I'm concerned about is #3 below.  The code and comments are posted below for your convenience, or you can go to the file path listed in #3.

#1
ZendFramework-1.10.8/library/Zend/Controller/Action/Helper/Url.php:    
public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)


#2
ZendFramework-1.10.8/library/Zend/View/Helper/Navigation/Sitemap.php:    
public function url(Zend_Navigation_Page $page)


#3
ZendFramework-1.10.8/library/Zend/View/Helper/Url.php:    
public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)


#4
ZendFramework-1.10.8/tests/Zend/Navigation/_files/My/UrlHelper.php:    
public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)




 * Helper for making easy links and getting urls that depend on the routes and router
 *
 * @package    Zend_View
 * @subpackage Helper
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_View_Helper_Url extends Zend_View_Helper_Abstract
{
    /**
     * Generates an url given the name of a route.
     *
     * @access public
     *
     * @param  array $urlOptions Options passed to the assemble method of the Route object.
     * @param  mixed $name The name of a Route to use. If null it will use the current Route
     * @param  bool $reset Whether or not to reset the route defaults with those provided
     * @return string Url for the link href attribute.
     */
    public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();
        return $router->assemble($urlOptions, $name, $reset, $encode);
    }
}
Comment 3 Tomas Mysik 2010-12-06 17:05:42 UTC
IMHO this is more enhancement than a bug because $view variable is Zend_View_Interface implementation and this interface does not have any url() method (as Petr already wrote). I guess it is a helper function (likely called via magic method __call()?). If I'm wrong, please, correct me. Thanks.

In any case, it would be good to have a look at the official ZF documentation.
Comment 4 pgebauer 2010-12-15 14:38:40 UTC
Yes, url() is a helper function which is available via registering (method addHelperPath() is used for it) in Zend_View_Abstract.
Comment 5 dharkness 2011-03-16 17:28:39 UTC
The problem is that the view helper main functions (the ones named for the helper class) are made available to the view via __call(). Further, in a .phtml file NetBeans has no idea that $this is a Zend_View since no class is declared.

To assist my team I created an interface (HGM_View) and copied into it the method declarations of the most common Zend view helpers as well as our own.

    class HGM_View {
        /**
         * Retrieve rendered contents of a controller action
         * ...
         */
        public function action($action, $controller, $module = null, array $params = array());

        ... rest of view helper main methods ...
    }

By adding

    <?php /* @var $this HGM_View */ ?>

as the first line of every view script, we now have code completion for view helpers. It's not ideal as we need to update the interface whenever we add new helpers, but it works.

Now, if only I could register the [ .phtml -> $this is-a HGM_View ] association with NetBeans so we don't have to include that line in every script...
Comment 6 Tomas Mysik 2011-06-03 10:20:24 UTC
Batch reassigning.
Comment 7 Tomas Mysik 2011-06-03 10:35:51 UTC
Editor area, we need more flexible/extensible editor part.