Adopt larastan and resolve PHPStan level 2 errors#616
Draft
pushpak1300 wants to merge 2 commits into
Draft
Conversation
Switches the static analyzer from vanilla phpstan/phpstan to larastan/larastan and fixes the resulting level 2 errors. Adds two new contracts (Contracts\Providers\Provider, Contracts\RemembersConversation) so capability providers and conversation-aware agents are discoverable via interfaces rather than abstract-class identity or class_uses_recursive checks.
4174128 to
c7d1825
Compare
|
Thought all laravel packages we're enforced on phpstan lvl.5 minimum by default this will break any contract? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumping phpstan to level 2 surfaced 180 errors, most of them Laravel-shaped:
Storage::disk()->mimeType()on theFilesystemcontract, higher-order collection proxies (->map->delta->join('')), facade returns, etc. Fixing those with vanilla phpstan means writing workarounds that obscure intent.Switching to larastan resolves the Laravel-specific noise outright and surfaces only the real structural gaps in the codebase, which this PR addresses.
Real fixes (not larastan stubs)
A new base contract makes the four methods every provider exposes part of the type system instead of being only on the abstract
Providers\Providerclass:A new
Contracts\RemembersConversationinterface replacesclass_uses_recursivesniffing for conversation-aware agents:BC note:
StoreProvider::addFileToStoregains an optionalarray $metadata = []parameter to match theManagesStorestrait implementation. Third-party implementers will need to add it.