Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to Statamic's various interfaces #1162

Open
heidkaemper opened this issue Apr 29, 2024 · 3 comments
Open

Add methods to Statamic's various interfaces #1162

heidkaemper opened this issue Apr 29, 2024 · 3 comments

Comments

@heidkaemper
Copy link

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
Copy link
Member

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
Copy link
Author

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 duncanmcclean transferred this issue from statamic/cms May 1, 2024
@duncanmcclean duncanmcclean changed the title Undefined method on QueryBuilder Add methods to Statamic's various interfaces May 1, 2024
@duncanmcclean
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants