-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
correct type inference for PhpStorm #106
Conversation
supposedly, this will help other IDE's too
@@ -148,7 +148,7 @@ public function getType() | |||
* sets the last modification time of the stream content | |||
* | |||
* @param int $filemtime | |||
* @return vfsStreamContent | |||
* @return $this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt it be self
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, self may be used for static methods, but for instance appropriate one is $this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to http://www.phpdoc.org/docs/latest/references/phpdoc/types.html $this
is not a valid type, only self could be used. But in this case it would be interpreted as vfsStreamAbstractContent
, and I'm not particularly happy about that as the abstract type should not be visible in the API.
I'm not sure if self
would help with PhpStorm then, but I'd rather follow a standard then to change it to something IDE specific. Maybe it would be a better idea to simply use fully qualified class names in this places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who uses documentation produced by phpdoc
? I don't. But me myself and many many my collegues uses IDE and it comes very important to have expected behaviour. @mikey179 which IDE you use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikey179 please see http://phpdoc.org/docs/latest/guides/types.html here u can find $this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please see https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#keyword
$this, the element to which this type applies is the same exact instance as the current class in the given context. As such this type is a stricter version of static as, in addition, the returned instance must not only be of the same class but also the same instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must have overlooked $this.
1 similar comment
correct type inference for PhpStorm
thank you 👍 |
supposedly, this will help other IDE's too