DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
79 stars 10 forks source link

OpenCart / Go to Definition #411

Open cagatay117 opened 1 year ago

cagatay117 commented 1 year ago

Hello, @jakubmisek, I am looking for a solution for Go to Definition specifically for OpenCart framework. When I use F12, I can't go to definition which is expected. Because of this design, I need to browse through lots of files or use search in order to find the symbol.

image

Can you add a feature in one of the upcoming releases so we can use F12 to go directly to the symbol?

jakubmisek commented 1 year ago

May I ask you to mouse-hover over the model_sale_order? It seems the editor does not know the type of it.

Thank you

cagatay117 commented 1 year ago

Nothing shows when I hover over load, model(), model_sale_order, session, data['user_token'](the one on the right side), getTotalOrders(), language(). No definition found for them either.

jakubmisek commented 1 year ago

Ok, that explains it - I'll try the OpenCart framework again and make some tests for it.

Thank you

cagatay117 commented 6 months ago

hello @jakubmisek, do we have any update on this matter?

jakubmisek commented 6 months ago

Thank you for reminding me @cagatay117 ,

The ->load is a property handled in the magic __get() method. Therefore, we have no way of understanding its type or even if it exists.

At this point, the authors of OpenCart should add additional PHPDoc annotation for the IDE to work properly. I was looking for some OpenCart IDE stubs but without luck so far.

You can do it by yourself - if you create a file anywhere in the project (for example \.ide\stubs.php):

<?php
/**
 * @property Loader $load
 */
interface IDashboardMixin {}

and above the class Controller (I don't know OpenCart, so I'm just guessing where the load property should be present), add @mixin IDashboardMixin:

/**
 * @mixin IDashboardMixin
 */
class Controller ...

from now on, $this->load will be treated as instance of Loader .