Undefined ______ (field, method) Problem
I am new to PHPStorm, but use several other IDE's fluently (Netbeans, Zend Studio.) PHPStorm's inspection is indicating the methods for a class are undefined, but they are defined. Here is an example:
self::$oProgressTable = new Table_Steps75();
self::$oProgressTable->sTableStyle = "width:100%;font-size:12px;";
self::$oProgressTable->sTableClass = "results";
self::$oProgressTable->iBorder = 1;
self::$oProgressTable->sID = "ProgressTable";
All of these properties are marked undefined. However, they are all defined and all of my other IDE's are able to detect this just fine. I thought it might be because Table_Steps75 is a child of the Table class. However, I modified the code to point to instantiate the parent and it still does not work. The Table class is stored in a file called Table.php, and loaded using _autoloader(), but so are all of my other classes and they are work fine. After some further tests, I discovered the problem is that I am assigning the Table to a property of a static class. I tested this like so:
$oTableTest = new Table();
$oTableTest->sTableClass = "test";
This works just fine. Why is PHPStorm having trouble with the class being assigned to a Static Class property? Is there a workaround for this?
Please sign in to leave a comment.
Wow. No response. We won't buy this product unless this can be resolved. Does support not monitor these forums?
Have you added phpdoc to your static field? Something like:
/**
* @var ClassName
*/
public static $varName;
Please always include IDE version you are referring to in your reports.
Please provide an isolated example, i can't reproduce your problem, in test code like
<?php
class StatInfTest {
static $oProgressTable;
function foobar() {
self::$oProgressTable = new Table_Steps75();
self::$oProgressTable->sID = "ProgressTable";
}
var $oProgressTableD;
function foobarD() {
$this->oProgressTableD = new Table_Steps75();
$this->oProgressTableD->sID = "ProgressTable";
}
}
class Table_Steps75 {
var $sID;
}
sID is resolved properly.
Also, you may be interested in watching http://youtrack.jetbrains.net/issue/WI-2888 its related, however does not affect the resolution but completion only.
I'm trying to get a sample. I can do your test and it works fine too, but in the real class, it does not work.
UPDATE: Oh, and I was using 1.02, but JetBrains support asked me to try this with 2.0. Problem still exists.
haha, it was my phpdoc that was causing the problem. I had it set to
/**
* @var object Progress table variable
*/
Once I changed it to
/**
* @var Table_Steps75 Progress table variable
*/
I no longer get the warning and I do get autocomplete.
Just an FYI, neither Zend Studio nor Netbeans have that issue. They don't use the vdoc to determine, it's actually sourced on the class itself.