| Summary: | Allow code assist type hinting for templates in other files | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | ChanibaL <eclipse.org> |
| Component: | PDT | Assignee: | Roy Ganor <ganoro> |
| Status: | CLOSED FIXED | QA Contact: | Sylvia Tancheva <silviya> |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | eclipse.org, exceptione, gadi, spektom |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Also exists in 2.0.0 (org.eclipse.php_feature-I20080707.zip) *** This bug has been marked as a duplicate of bug 260330 *** No this is not a duplicate, one of the things to make this work is broken because of that bug, but this itself is a feature request to be able to use some PHP specyfics - including files inside class instances preserving the scope. To sum up it's using /* @var $this TheClass */ to type hint it's the public/private/protected scope, not just public as it would be outside. (In reply to comment #3) > No this is not a duplicate, one of the things to make this work is broken > because of that bug, but this itself is a feature request to be able to use > some PHP specyfics - including files inside class instances preserving the > scope. > > To sum up it's using /* @var $this TheClass */ to type hint it's the > public/private/protected scope, not just public as it would be outside. > You're right, this is not a duplicate. What you're asking for is that for inline docblocs (/* @var $this TheClass */) $this should not only be typed as TheClass , but that the identifier $this should have the class internal scope. You're right here. I suggest that for inline docblocks involving $this, the scope should be widened to the class internals. Use: /* @var $variableName ClassName */ The original bug (260330) was fixed in CVS. *** This bug has been marked as a duplicate of bug 260330 *** Using the sample code given by the reporter works as expected. Code Assist is given for $this when /* @var $this ClassNeedingATemplate */ is used. Closing the bug. [Sylvia Tancheva] |
Hi, this should be an easy fix, I think. Many people (including me) make templates like this: --- ClassNeedingATemplate.php --- <?php class ClassNeedingATemplate extends SomeMoreBasicOne { protected $title; protected $body; public function __construct() { // some logic hydrating the $this->title and $this->body } public function display() { require 'template.php'; } public function where_type_hinting_works_but_an_external_template_is_better() { ?> <div> <h1><?=$this->title?></h1> <?=$this->body?> <div> <?php } } ?> --- tempate.php --- <?php /* @var $this ClassNeedingATemplate */ ?> <div> <h1><?=$this->title?></h1> <?=$this->body?> <div> --- The type hinting for $this works this way, but in the external file it sees the class as from the outer scope, so it only sees the public members of it. A var named $this could be made a special case of type hinting where it gives the full access to type hinting from the class. Problem exists in PDT 1.0.3 (why isn't this version listed here anyway?)