Using Object from SESSION with Intellisense
Posted October 7th, 2008 by rsknowles
I store a small instance of a custom class in session and would like to retrieve it into a variable on the page and be able to use the IDEs intellisense.
require_once('myObjClass.php');
$myObj = $_SESSION['MYOBJ'];
$myObj->someMethod();
Intellisense does not work on the $myObj variable. Is there anyway to get it to function when pulling a value from session? I'm not a great PHP programmer so I'm open to any suggestions and improvements.


Where in your code you
Where in your code you assigned $_SESSION['MYOBJ']?
If you have:
$_SESSION['MYOBJ'] = new myObjClass();
then we will know the type of $_SESSION['MYOBJ'] and the type of $myObj.
An alternative is to use PhpDoc comments to set the type of $myObj. VS.Php will pick the information from PhpDoc to identify the type of $myObj.
That worked. Thanks.
PHPDoc comments did the trick. Thanks!