Search code examples
phpmagentonetbeansdocblocks

PHP Docblock Type Hinting for Current Object in Magento Template?


How might I hint at what $this is in the context of a Magento template, with a DocBlock?

As an example, head.phtml within the template/page/html/ directory is an object of Mage_Page_Block_Html_Head. The method I tried was:

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

Unfortunately, it doesn't seem my IDE (NetBeans) is picking up on the hint. So my question is if there is a correct way of doing this so that NetBeans recognizes the hint.


Solution

  • Netbeans should accept it, at least my version 6.9 for

    /* @var $this Bar */
    

    does this:

    enter image description here

    and that is an example with the include scenario (no class around).

    Take care to use the single-line - single-asterisk - type-of - commment.

    Also take care Netbeans updated the index. As in your case:

    NetBeans had to scan for changes in this case, which I would have assumed it would do automatically. [...]. In my case it only periodically scans.


    Docblock variable hinting related: