This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
4 Replies Last post: Feb 13, 2013 10:34 PM by Eugene Serkin  
Eugene Serkin Newbie 48 posts since
Mar 4, 2011
Currently Being Moderated

Feb 10, 2013 6:08 AM

New static construction needs additional PhpDoc for PhpStorm to see it?

I noticed in Symfony2 in code, that there was $request = new static(...);, but later on, when it was used to get public property from it, then public property was highlightend as if it is unreachable. Explanation was following, when I hovered over it: Property noе found in class.

 

Seems odd and incorrect.

Chris Thompson Newbie 2 posts since
Feb 13, 2013
Currently Being Moderated
Feb 13, 2013 10:17 PM in response to: Eugene Serkin
Re: New static construction needs additional PhpDoc for PhpStorm to see it?

I'm seeing the same issue in the latest EAP release.  Here's a simple code snippet:

 

    $row = new static();

    $row->fromJson($json);

    return $row;

In this case, fromJson is a method of the current class.  PhpStorm claims the method is unreachable.  Also, typing $row-> doesn't give any autocomplete suggestions at all, so it appears that it isn't able to determine what type is being assigned to the variable.

 

If I change that first line to:

 

    $row = new self();

 

PhpStorm stops complaining.

Chris Thompson Newbie 2 posts since
Feb 13, 2013
Currently Being Moderated
Feb 13, 2013 10:26 PM in response to: Eugene Serkin
Re: New static construction needs additional PhpDoc for PhpStorm to see it?

I know that, that's why I'm using static and not self.  However, since the method is part of the parent class, the method should still be valid when the new static() is called from a derived class.  So, shouldn't the code checker recognize the $row variable as an instance of the current class and show the method as reachable?

More Like This

  • Retrieving data ...