innovacy Posted January 13, 2014 Share Posted January 13, 2014 (edited) I have been working some time now with Prestashop and before some months switched to develop with PHPStorm, the best and most complete PHP IDE out there. Unfortunately, I had always issues with code completion in Prestashop, which is based on how Prestashop uses the override class model. One example: The code for the class "Cart" that is instantiated as object is residing in the core file classes/Cart.php, the core class however is not named "Cart" but "CartCore". Only when a class is overriden, it is named "Cart" and inherited from "CartCore" and as that, an IDE can create this association only by that time. Additionally, Prestashop's PHPDoc is incomplete and where it exists, the wrong return classes are sometimes specified etc. To ease my development with Prestashop and PHPStorm and make code completion work a great way nearly everywhere, since I couldn't find the slightest solution anywhere, I went into creating an "extension" that helps achieve that. You can download it here and integrate it into your PHPStorm project the way it is described and you will have immediately code completion for almost any instantiated class, $this variables and more. https://github.com/dkarvounaris/PHPStorm-CC-PrestaShop It's not covering 100% yet, but is nearly complete and should have everything that is daily required. Please let me know if there is something to improve it. Contributions are welcomed too. I hope, this will be helpful to many. Edited January 13, 2014 by innovacy (see edit history) 12 1 Link to comment Share on other sites More sharing options...
Arakiss Posted March 20, 2014 Share Posted March 20, 2014 Thank you very much! Link to comment Share on other sites More sharing options...
livindeadfr Posted June 23, 2014 Share Posted June 23, 2014 Hi I'm looking for such extension, unfortunatly github does not work. Could you republish it somewhere else or send by email ? Regards David Link to comment Share on other sites More sharing options...
innovacy Posted June 23, 2014 Author Share Posted June 23, 2014 Hi I'm looking for such extension, unfortunatly github does not work. Could you republish it somewhere else or send by email ? Regards David Hi David? Why isn't it working for you? Try again maybe, it works for me. Here is a direct link to the zip file: https://github.com/dkarvounaris/PHPStorm-CC-PrestaShop/archive/master.zip Please let me know if this one works, before I upload it somewhere else. Best Regards, Dimitri Link to comment Share on other sites More sharing options...
livindeadfr Posted June 23, 2014 Share Posted June 23, 2014 @innovacy : thanks for your reply. It is not working for me. I try with firefox got "connection failed" and with Chrome : Page Web inaccessible Regards David Link to comment Share on other sites More sharing options...
innovacy Posted June 23, 2014 Author Share Posted June 23, 2014 It sounds like you might have a connectivity problem. Anyway, try getting it from here: https://gitlab.com/dkarvounaris/phpstorm-cc-prestashop Link to comment Share on other sites More sharing options...
innovacy Posted June 23, 2014 Author Share Posted June 23, 2014 (edited) Btw, here is an alternative way, that might be preferred by some, to use it in PHPStorm, as the autocompletion support won't be in your project view and you can have it in a central location more project-independent, making updates in all your projects possibly easier. In PHPStorm go under File -> Settings -> PHP. There click on the "+" under "Include Path" and add the folder in which you have stored the sources. Edited June 23, 2014 by innovacy (see edit history) Link to comment Share on other sites More sharing options...
livindeadfr Posted June 23, 2014 Share Posted June 23, 2014 @innovacy your link in gitlab works very well. Thanks David Link to comment Share on other sites More sharing options...
Orange35 Posted September 15, 2014 Share Posted September 15, 2014 innovacy! Many thanks for your solution! It is simple and great! Link to comment Share on other sites More sharing options...
gytske Posted September 28, 2014 Share Posted September 28, 2014 Thank you so much! I was just about to start investigating how to make these errors go away by writing my own extensions, and I found this. The solution is actually quite simple Link to comment Share on other sites More sharing options...
innovacy Posted October 17, 2014 Author Share Posted October 17, 2014 There's a new small update out. It can be downloaded at: https://github.com/dkarvounaris/PHPStorm-CC-PrestaShop or https://gitlab.com/dkarvounaris/phpstorm-cc-prestashop 2 Link to comment Share on other sites More sharing options...
seeN Posted October 31, 2014 Share Posted October 31, 2014 Thank you so much! You just made my life easier! Link to comment Share on other sites More sharing options...
Julien Bourdeau Posted February 18, 2015 Share Posted February 18, 2015 Hi, I wrote my own version. It supports every classes from PrestaShop into only one file. You can have a look and GitHub: https://github.com/julienbourdeau/PhpStorm-PrestaShop-Autocomplete Thanks to @innovacy for research and original idea. I'll keep this project up to date since I use PhpStorm. Feedback is very much appreciated. Explanation in French are also available (follow the link on GitHub) Julien 1 Link to comment Share on other sites More sharing options...
innovacy Posted February 18, 2015 Author Share Posted February 18, 2015 (edited) Hello Julien! I really enjoy, that my idea has been helpful to you and so many others and thank you that you referenced my work! When I first wrote it, I thought about creating one file with all classes. And it seemed simpler that way. However, there was reasons why I finally went with the idea of creating separate files. My solution allows to set one of these files as "text only" in PHPStorm and that way deactivate selectively the autocompletion through these files specific by each project. This might be useful in cases, when someone needs/wants to make it part of the project and receives the "Multiple declarations" warning, as example because he might have already overwritten the class. I like to have this luxury to deal per project without modifying the autocompletion files. Additionally, I'm going a bit further, fixing some errors that have existed in Prestashop's source at some point (or might still), that could selectively make autocomplete fail, like in cases of a return value that is used, because it's PHPDoc declaration was wrong. One such example is "Collection" and "PrestashopCollection". It contains also the one or other additional PHPDoc fix. Ultimately, I have been submitting fixes to the Prestashop repository for these. I would like if developers keep contributing and using my solution, as I believe it is still a very useful extension for those working extensively in several Prestashop projects. I'm keeping it up to date when there needs something to be updated or someone contributes. Btw, I like your README, feels more straightforward in yours. Maybe I should rework mine Dimitri https://github.com/dkarvounaris/PHPStorm-CC-PrestaShop Edited February 18, 2015 by innovacy (see edit history) 1 Link to comment Share on other sites More sharing options...
Julien Bourdeau Posted February 18, 2015 Share Posted February 18, 2015 Hi Innovacy, I don't handle override indeed, since I work mostly on the core I didn't have this issue yet. I guess people will have to comment/remove lines in the file. I'll try to find a better idea. If you fix phpdoc declaration, feel free to make a pull request, we'll be happy to accept it. It will help a lot of people Julien Link to comment Share on other sites More sharing options...
gytske Posted February 18, 2015 Share Posted February 18, 2015 @innovacy Hi, which PHPDoc comments are you going to fix? I was recently thinking about contributing fixed PHPDocs too. For example proper PHPDoc as AdminControllerCore, protected $object would be very useful; /*@var ObjectModel */ Link to comment Share on other sites More sharing options...
innovacy Posted February 18, 2015 Author Share Posted February 18, 2015 @gytske Well, don't wait for my fixes, just go on and submit to the Prestashop repository what you think should be fixed, so anyone profits asap. @Julien I have submitted several fixes in the past, which was accepted. I also have several other core fixes or improvements laying around, just didn't find the time yet to check through them all again, filter (as some might be in the meanwhile obsolete) and prepare them properly for the official repository, planning to do it soon though. Link to comment Share on other sites More sharing options...
Raphaël Malié Posted March 16, 2015 Share Posted March 16, 2015 Hello, I added these classes some year before, for same reasons (autocompletion), as you can see in these commits from 2011/2012 : https://github.com/PrestaShop/PrestaShop/commit/c1c857b586bfac3ba956eafccd6a9e75be5d4c0c https://github.com/PrestaShop/PrestaShop/commit/0210a5af36814c7b3422ea5d0474ac3d9553b6c8 https://github.com/PrestaShop/PrestaShop/commit/11a180175c4db40995b77f8def1c09ff2e5fd868 https://github.com/PrestaShop/PrestaShop/commit/5464c1d0ae9d50142429e3068145ff01dc489562 The other reason was to show developpers how to override the code in a "clean" way. Sadly, Remi removed them in this commit https://github.com/PrestaShop/PrestaShop/commit/0cd10335271a9ef9f353a4d965313e812174a98b for bad reasons (IMO). So I'm sad when I read "Thanks to innovacy for research and original idea." (Well I'm kidding, I'm not sad, but it hurts a bit my feelings ) PS : PHPStorm FTW ! Link to comment Share on other sites More sharing options...
Julien Bourdeau Posted March 17, 2015 Share Posted March 17, 2015 Hi Raphaël, I'm not sure PrestaShop should override every classes (his own code especially) just for an IDE. If a developer he's looking for a clean way to override PrestaShop's behavior, he should just check out the doc (http://doc.prestashop.com/display/PS16/Overriding+default+behaviors) @innovacy introduced a way to add it as an external library, which seems perfect to me. Best regards, Link to comment Share on other sites More sharing options...
Raphaël Malié Posted March 23, 2015 Share Posted March 23, 2015 (edited) Hi Raphaël, I'm not sure PrestaShop should override every classes (his own code especially) just for an IDE. If a developer he's looking for a clean way to override PrestaShop's behavior, he should just check out the doc (http://doc.prestashop.com/display/PS16/Overriding+default+behaviors) @innovacy introduced a way to add it as an external library, which seems perfect to me. Best regards, Hi Julien, yes but 3 years ago, people were not aware about the override feature, so it was a part of the education plan. But this argument is now invalid I agree Don't forget that PrestaShop is using eval() without these files, and eval() = satan Edited March 23, 2015 by Raphaël Malié (see edit history) Link to comment Share on other sites More sharing options...
innovacy Posted October 11, 2015 Author Share Posted October 11, 2015 A new release is available, containing additional classes, it can be downloaded here: https://github.com/dkarvounaris/PHPStorm-CC-PrestaShop/releases/latest or here: https://gitlab.com/dkarvounaris/phpstorm-cc-prestashop Enjoy! Link to comment Share on other sites More sharing options...
Recommended Posts