@var and public property

symfony2 has such code inside:

class Response {
    /**      * @var \Symfony\Component\HttpFoundation\ResponseHeaderBag      */     public $headers;

When I access this property like:


PhpStorn do have auto-complete, but marks function as "not found in class".

1 comment
Comment actions Permalink


     * @var $headers \Symfony\Component\HttpFoundation\ResponseHeaderBag
    public $headers;

In the case where your stuck with someone else's code, try
/* @var $headers \Symfony\Component\HttpFoundation\ResponseHeaderBag */
$headers = $response->headers;

A bit of a pain but well worth the extra line of code in order to get type aheads.  You might even be able to do:

/* @var $response->headers \Symfony\Component\HttpFoundation\ResponseHeaderBag */

Personally, I try to use the following rule:
If I am setting data, I always create a local variable in my method and use a comment to define it if neccessary.

If I am reading data only, I try to use the original object.


Please sign in to leave a comment.