Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @var $this comments to templates #52

Closed
FiveDigital opened this issue Jul 27, 2012 · 6 comments
Closed

Add @var $this comments to templates #52

FiveDigital opened this issue Jul 27, 2012 · 6 comments

Comments

@FiveDigital
Copy link

Templates contain comments like this:

/**
* Product view template
*
* @see Mage_Catalog_Block_Product_View
* @see Mage_Review_Block_Product_View
*/

Adding @var $this comments enables code completion in our IDEs:

/**
* Product view template
*
* @var $this Mage_Catalog_Block_Product_View
* @see Mage_Review_Block_Product_View
*/
@stalniy
Copy link

stalniy commented Jul 30, 2012

Not the best idea because template may be used by several blocks.
If you want to determine which template is related to some block class you may "Template Path Hits" (http://www.magentocommerce.com/blog/template-path-hints-tutorial-video/).

@FiveDigital
Copy link
Author

Most templates are used by only one block. I have requested this because I'd like to be able to ctrl click function calls like $this->doSomething() in templates in my IDE.

@stalniy
Copy link

stalniy commented Aug 7, 2012

Anyway idea is bad. Just think, what will happen if somebody rewrites this block using Magento rewrite system?

@magento-team
Copy link
Contributor

@FiveDigital
Thank you for proposing an interesting improvement.
Indeed, if to search among all PHTML templates in the system, notations @var $this and @see are already used ~50/50.
It does make sense to standardize block class(es) hinting. Proposal of declaring a primary block class using @var $this Primary_Block_Class and optionally additional classes using @see Additional_Block_Class has been sent to the technical leads for examination. As soon as there are any updates to the proposal state (rejected, accepted, adopted), corresponding update will be posted to the GutHub ticket.

@stalniy
Yes, you're right, that relation between blocks and templates is not 1 to 1, multiple blocks can utilize the same template. However, it does not contradict to the hinting of a primary and additional block classes.

@FiveDigital
Copy link
Author

I know that @see is used in many templates, but that doesn't enable code completion/code hinting. I'm really a fan of being able to ctrl-click functions and I'm using this in templates, too. When we create/override templates for shop we develop in our company, I assure everyone add a @var $this comment. In fact, I'm always adding comments like /* @var $products Mage_Catalog_Model_Resource_Product_Collection everytime when writing code like $products = Mage::getResourceModel('catalog/product_collection') to be able to auto complete function and jump easily in the core code.

@magento-team
Copy link
Contributor

The proposal was approved by the technical leads and included into Magento 2 coding standards. @var $this Primary_Block_Class is intended for primary class definition and @see Additional_Block_Class for additional classes. The task about updating exisitng templates was added to Magento 2 backlog.

@FiveDigital , thank you for the proposal.

magento-team pushed a commit that referenced this issue Jan 23, 2015
@stevieyu stevieyu mentioned this issue Apr 3, 2015
okorshenko pushed a commit that referenced this issue Oct 28, 2015
magento-team pushed a commit that referenced this issue Mar 18, 2016
slavvka pushed a commit that referenced this issue May 4, 2020
…er/issues/29

magento2-login-as-customer/issues/29: Destroy impersonated customer sessions on admin logout.
@FabXav FabXav mentioned this issue Oct 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants