statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Add methods to Statamic's various interfaces #1162

Open heidkaemper opened 2 months ago

heidkaemper commented 2 months ago

Bug description

When executing queries on Statamic content repositories, tools like PHP Intelephense and Larastan report errors like Undefined method ‘where’.

image

The code above works, but quality checks and autocomplete do not. Is there a reason for this? Is it intentional?

How to reproduce

Some examples from a fresh Statamic installation:

Entry::query()->where('collection', 'pages')->get();
Entry::query()->orderBy('updated_at', 'desc')->limit(10)->get();
User::current()->can('view pages entries');

The where(), orderBy() and can() methods are marked as undefined.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 10.48.9
PHP Version: 8.2.18
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: test.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: runtime
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.57.2 Solo

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

None

Additional details

No response

duncanmcclean commented 1 month ago

This will likely be because most of our interfaces are empty or don't include all of the methods, like this one.

We can fix this by adding the methods to the interfaces.

heidkaemper commented 1 month ago

Yea, makes sense. It's not really an issue but a improvement suggestion. Being able to use tools like PHPStan would definitely be very nice.

duncanmcclean commented 1 month ago

I've moved this to the statamic/ideas repository since this is more of a feature request/improvement, than a bug.