-
-
Notifications
You must be signed in to change notification settings - Fork 22
Implement PHPStan up to level 2 #112
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
Conversation
| { | ||
| if ($date = $this->header(HeaderConsts::DATE)?->getDateTime()) { | ||
| return Carbon::instance($date); | ||
| $dateHeader = $this->header(HeaderConsts::DATE); |
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.
That's what I mean. That's my prefered approach. Runtime checking for the right instance
| { | ||
| /** @var UntaggedResponse $response */ | ||
| if (! $response = $this->id($id, $identifier)->first()) { | ||
| $response = $this->id($id, $identifier)->first(); |
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.
And that's your approach. I changed it to have $response directly at the DocTag. It's easier to understand this way... and PHPStan understands it this way
| return $this->connection()->fetch($fetch, $uids->all())->mapWithKeys(function (UntaggedResponse $response) { | ||
| $data = $response->tokenAt(3); | ||
|
|
||
| if (!$data instanceof ListData) { |
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'm not sure as of right now how you approach exceptions. This is more or less a third approach. For the same problem. -> method returns parent, but specific child is expected
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.
Yea I think this is a good approach -- best to throw an exception here like you've implemented 👍
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.
Looks good, thanks! I'm going to implement a few formatting adjustments but it appears your branch is locked so I can't push them here. I'll merge this and then make the changes on master 👍
After level 1 follows level 2
Nothing too exciting here, i guess.
One thing I want to point out. I prefer to check for the right instance in runtime. I just found out you seem to prefer, to declare the type as it should be.
My runtime check makes sure it's the right instance while running
Your approach is valid, too. It should ideally never be different than expected... but it might be