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
Generate metadata for factory method auto completion #36
Comments
Edited title to not only support phpstorm... |
Wouldn't this be more of something for the SSTemplate module, than in here? |
Well. It bothers me and the purpose of this module is to support autocompletion. At least thats why I created this module... So think it fits fine in here and once figured out how to map ClassName::create(); to ClassName the generation of the file should be fairly easy... |
If we only had namespaces already... it would be much easier... |
Valid point :) |
I just tried one very risky method. Just because. It's parsing the file, and prepends every |
I noticed that NetBeans has no problem with methods like TextField::create(...)->getMaxlength(); I use the /** @var .. */ etc as well, but it is pretty noisy if you ask me. And for Form I never assign the Fields to a variable. Forms is where I have the most mess in PHPStorm... I guess we should forget this for this module.. Or we need namespaces in SS or we need a PHPStorm build-in/plugin solution. Which I unfortunately do now know how to code... |
Well, namespacing will be done in 4, hopefully. But yeah, for PHPStorm, I think we'll have to fall back on the SilverStripe plugin. |
Which only supports the template language... |
It actually does more, but was never renamed I think. |
By not using create all the time, but just plain 'new ClassName', this is not a big problem... I use create for all my forms, which makes them pretty ugly. No, I favor code like this : new FieldGroup(
(new LimitedTextField('Zip', _t('Site.Zipcode', 'Zipcode')))
->addExtraClass('geocode'),
(new LimitedTextField('City', _t('Site.City', 'City')))
->addExtraClass('geocode toggle')
) Any reason why I 'should' use SomeClass::create instead? |
Because create uses the Injector, which can return a spec faster. But that's all there is to it, I think. There are more reasons probably. But the new statement works I guess. |
I still think though, supporting ::create() would be awesome. |
FY(and others)I: the phpstorm plugin now manages ::create() autocompletion. See raket/idea-silverstripe#66 |
Thanks :) Closed : use this https://github.com/raket/idea-silverstripe |
Currently methods like TextField::create(); does not 'resolve' to the TextField class but stays in Object.
Laravel as a great ide helper:
https://github.com/barryvdh/laravel-ide-helper
which generates a same kind of helper file.
PHPStorm documentation
https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
I looked into this, but it is not as easy as it seems.
The problem is that Object::create(); uses get_called_class(); to get the class to generate.
If any has an idea to tackle this, I think this would be a great feature..
The text was updated successfully, but these errors were encountered: