trongate / trongate-framework

The Trongate PHP framework
https://trongate.io
Other
1.12k stars 100 forks source link

Improvement: expose model to IDE Intellisense #186

Closed gebeer closed 3 months ago

gebeer commented 3 months ago

Hi there, first time user of the framework. I really like it. One little thing that bugs me: when using $this->model I don't get intellisense for the Model class in my IDE (VsCode). This is because $model is not exposed as protected method in Trongate class, like e.g. module. This seems to be done on purpose. The model property is accessible via the Dynamic_properties trait.

To work around that, I added @property-read Model $model to the DocBlock of the Trongate class, so it reads:

/**
 * Manages loading modules and rendering of HTML templates.
 * Also contains methods for assisting with file uploads.
 * 
 * @property-read Model $model exposes the Model class to intellisense
 */
class Trongate {

Now I get intellisense, which really helps for even more rapid development :-) image

From my knowledge and after doing some research, this should not have any other implications than exposing the model to intellisense.

I'd very much appreciate if you considered adding that.

domsinclair commented 3 months ago

Nice way to expose it to intellisense.

DaFa66 commented 3 months ago

Cheers gebeer, this used to work, but with the refactoring, it has stopped. I like your workaround and encourage you to create a PR and become a contributor to the framework 👍

DaFa66 commented 3 months ago

I have merged this in and will close this issue.

Cheers