Skip to content

Update the schema stub to use iterable for the fields and filters - #308

Open
shanginn wants to merge 2 commits into
laravel-json-api:developfrom
shanginn:develop
Open

Update the schema stub to use iterable for the fields and filters#308
shanginn wants to merge 2 commits into
laravel-json-api:developfrom
shanginn:develop

Conversation

@shanginn

Copy link
Copy Markdown

In the core/src/Core/Schema/Schema.php both fields and filters returns iterable, but stubs still generate them as arrays:

abstract public function fields(): iterable;

public function filters(): iterable

…rs methods, enhancing type consistency and clarity. Additionally, include the Filter contract for improved functionality.
@lindyhopchris

Copy link
Copy Markdown
Contributor

Thanks for the PR. I'm not sure it needs to be iterable as the generated schema is returning an array, and array is allowed as the return type as it is a covariant.

Do you have a specific reason for changing this? I.e. are you not returning array from those methods?

@shanginn

Copy link
Copy Markdown
Author

yeah, you are right, array is a covariant of iterable. all I want to do is make PHPStan happy with the default generated schemas.
how about this then? Just add iterable type to the phpdoc?

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

Successfully merging this pull request may close these issues.

2 participants