phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

OpenCart / Go to Definition

Open cagatay117 opened this issue 2 years ago • 5 comments

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?

cagatay117 avatar Oct 02 '23 17:10 cagatay117

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

jakubmisek avatar Oct 02 '23 19:10 jakubmisek

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.

cagatay117 avatar Oct 03 '23 07:10 cagatay117

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

Thank you

jakubmisek avatar Oct 03 '23 08:10 jakubmisek

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

cagatay117 avatar Mar 30 '24 18:03 cagatay117

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 .

jakubmisek avatar Apr 01 '24 13:04 jakubmisek