| Summary: | Type Hinting does not work when using $this | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Sebastian Kübbeler <sebastian.kuebbeler> |
| Component: | PDT | Assignee: | Zhongwei Zhao <zhaozhongwei> |
| Status: | CLOSED WORKSFORME | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | ganoro, silviya, wywrzal, zhaozhongwei, zulus |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
after I tried: $caseStatus->| //"this is not type aware too!" // This is type aware though. Probably due to the assignment.
/* @var $caseStatus Case_Status_Model */
$caseStatus = $this->load->model('Case_Status_Model');
$data = $caseStatus->getOpenCases();
Oh and I am sorry, but without the Case_Status_Model Class this can't be type aware. You can write your own dummy for testing or use my original:
class Case_Status_Model extends Model {
function Case_Status_Model() {
parent::Model();
$this->load->database();
}
function getNewCases () {
// do something
}
}
Hi, Sorry now I understand the bug,thanks for your explanation! hi,
you should change:
/* @var $caseStatus Case_Status_Model */
private $caseStatus;
to
/**
* @var Case_Status_Model
* */
private $caseStatus;
What's now with this issue? Is still active? As I see, Sebastian isn't using phpDoc. I think main problem is that phpDoc was incorrectly used for field declaration. Second problem was that inline @var tag is not working for structure like "$this->caseStatus", but in my opinion it shouldn't work (user must use valid phpDoc @var tag).
<?php
class Case_Status_Model {
public function test() {
}
}
class Case_Status_Report {
private $caseStatus;
function index() {
$this->load->model ( 'Case_Status_Model', 'caseStatus' );
/* @var $this->caseStatus Case_Status_Model */
$this->caseStatus->| // something like this is not working
}
}
Something like this is working well:
<?php
class Case_Status_Model {
public function test() {
}
}
class Case_Status_Report {
/**
*
* @var Case_Status_Model
*/
private $caseStatus;
function index() {
$this->load->model ( 'Case_Status_Model', 'caseStatus' );
$this->caseStatus->| // works ok
}
}
If someone disagree please reopen bug:)
Closing |
Build Identifier: 20100617-1415 When trying to use Type Hinting on object variables, hints are not resolved when referencing the variable using $this. Reproducible: Always Steps to Reproduce: Here a dumbed down version of a CodeIgniter Controller to illustrate: class Case_Status_Report { /* @var $caseStatus Case_Status_Model */ private $caseStatus; function index() { $this->load->model('Case_Status_Model', 'caseStatus'); /* @var $this->caseStatus Case_Status_Model */ $this->caseStatus->"this is not type aware" } }