-
Notifications
You must be signed in to change notification settings - Fork 185
Support type hinting for variables #350
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
Comments
Definitely, there is already handling for |
Would you be able to give me a hint as to where to implement this? I could probably handle it if I had an idea of where to look :) |
I guess I'm not advanced enough a PHP coder, I can't work out how to actually test any changes I make. Trying to run the web server just produces a bunch of Undefined Index errors related to headers in the ProtocolStreamer.php file. I'm seeing around line 798 that variables should have @var tags supported, unless I'm just horribly misreading the code? Does that make the fact that this isn't working a bug? If it isn't a bug and I'm just failing at reading your code, would you please consider adding it yourself, as you're more intimately familiar with the code? I would really appreciate it! Sorry I couldn't be of more help :( |
The language server has nothing to do with a web server or headers ;) |
I still don't understand, sorry. The only mention of testing that I could find in the README file was a reference to unit testing. I don't have much experience with unit testing, so me running a command that says "149 / 149 (100%)" doesn't do much when I'm struggling with actually working out how to read the stubs file to find out if any changes are working. I guess I just have to hope someone is kind enough to implement this for me :) |
Well, then I take a look and check wether I can do that. This is very important to me, so I'll do it first. @felixfbecker Can you assign me to this issue in any way? So I don't get lost what I should do or not? |
ah... thanks. Didn't expected that. |
Is this still an issue in the latest version? |
@felixfbecker I have tested this in v1.4.1 and it is still an issue. /** @var \DBTech\Credits\Entity\Currency $currency */
if (!$currency = DBTech::em()->findOne('DBTech\Credits:Currency', $cleanedInput['id']))
{
// Bad currency
throw $this->errorException(DBTech::phrase('dbtech_credits_invalid_currency'));
}
if (!$currency->isActive())
{
// Bad currency
throw $this->errorException(DBTech::phrase('dbtech_credits_invalid_currency'));
} I receive no type hinting for isActive. That method of docblocking allegedly works in phpStorm (untested, but this information comes from the XenForo product developers who use phpStorm internally) but does not appear to work here. |
Does it work if you write it like /** @var \DBTech\Credits\Entity\Currency $currency */
$currency = DBTech::em()->findOne('DBTech\Credits:Currency', $cleanedInput['id']); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This does not work completly. Indeed it will be shown, but there are no suggestions for a type hinted var. When I create a new instance of it and make it explicit, it works: I'm using |
yes, that's why this issue is open |
Ah, I thought it's not even implemented. I was kinda suprised why this issue exists, when it exists, but there is no handling... Hmm. |
Hi! Now with the new language server version with the speed optimization, I think this is the most important feature, IMHO. I would like to know if @Property should also be adedd to this type hinting issue, or if it should be in another issue. Thank you. |
Sorry, it works if I add 1 more *, just a little bit difference from PHPStorm |
Thanks for adding this feature, any chance to also support Netbeans/Eclipse/Zend style? The reason behind this request is not having to convert hundreds of files of legacy code so they work with VSCode. Example of Netbeans/Eclipse/Zend style: |
Hi, Making some traits here... Cheers! |
So are we just waiting for PR #701 to have a unit test or two added and then this feature is ready to go? |
need support :) |
so that PR #701 is still sitting there - 4 years now? Or did some other change make variable type hinting work (I can't get it to) |
If I have a variable that's type hinted like so:
I expect to see the method definitions for the methods I call on the $emailChange variable. This does not happen:
This type hinting syntax is allegedly supported by phpStorm, and it would be wonderful to have support for this in VSCode via your IntelliSense plugin as well.
Thank you in advance :)
The text was updated successfully, but these errors were encountered: