-
Notifications
You must be signed in to change notification settings - Fork 6
General: Add phpstan array shapes #35
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
base: release/0.11.x
Are you sure you want to change the base?
General: Add phpstan array shapes #35
Conversation
| * @phpstan-type Endpoint array{ | ||
| * platform: string, | ||
| * payloadType: string, | ||
| * endpoint: string, | ||
| * message_id?: string|null, | ||
| * } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's this easy. This breaks the current pass-through use-case, where any additional fields coming in are also going out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean it should be more generic? That for example there could be more fields in the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had a revelation that we can intersect array types, I changed that here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be documented yet, but I think this would be preferred over an intersection: https://github.com/phpstan/phpdoc-parser/pull/250/files
The main problem is the "in = out" part though. So, typing that the output of one method is equals to the input of another. That just might be too hard to statically do though.
The alternative is to make this a strict shape somehow, and break all current flows that allow extra fields in there.
6a648f6 to
009f633
Compare
|
009f633 to
100f164
Compare
|



Depends on #36 for the typos fix