Yes, I tried casting, but you can't cast to a user object, which seems a bit crazy. I think I'll raise this with Zend as a support ticket.
Main Topics
Browse All TopicsHi,
I’ve got a PHP class called User which I am using across sessions by implementing the __sleep and __wakeup methods. The class itself is working fine, but I’ve lost introspection within the visual studio IDE as I have to get it from the session object and not via the new object keyword.
So when I do $user = new User(); code completion works fine as the IDE knows it’s a User object.
However, when I do $user = $_SESSION['user']; the IDE doesn’t know what type it is and I lose the code completion.
Does anyone know how I could get around this?
Regards
Graham
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I got a response from Zend. The answer is PHPDOC!
This was the solution:
**
* Returns the user object
*
* The user object contains all data about the user including the signed on flag
*
* @return User Returns the User object
*/
function get_user_obj() {
if (!isset($_SESSION['user'])
$_SESSION['user'] = new User();
}
return $_SESSION['user'];
}
$user = get_user_obj();
Now code completion with work for $user
Business Accounts
Answer for Membership
by: nizsmoPosted on 2007-11-17 at 13:29:31ID: 20305444
I wouldn't think you can get around this. This is because:
$_SESSION["user"] you know will be a User() object, however it has the potential to be anything else, string, integer, etc... thus the IDE cannot be sure therefore doesn't auto-complete for you.
You can always try casting, if this doesn't work then I wouldn't think there's a way to fix this.
$user = (User) $_SESSION['user'];
Hope this helps.