- Issue created by @Kingdutch
- Merge request !6871Issue #3425201: Implement a Result type in Drupal Core β (Open) created by Kingdutch
- Status changed to Needs work
4 months ago 12:40pm 3 March 2024 - π³π±Netherlands Kingdutch
Added a merge request to show the proposed implementation. However this "Needs Work" because we can't quite tell PHPStan what we want to do :)
However, this allows async issues to start using the type and demonstrate its usefulness.
- Status changed to Needs review
4 months ago 9:27am 6 March 2024 - π³π±Netherlands Kingdutch
I've asked for some help in the PHPStan discussions on GitHub and Ondrej was very kind in providing more insights: https://github.com/phpstan/phpstan/discussions/10667. It turns out I was running into a known issue https://github.com/phpstan/phpstan/issues/6732.
I've now pushed a workaround using a type annotation :)
- Status changed to Needs work
4 months ago 10:07am 6 March 2024 The Needs Review Queue Bot β tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
4 months ago 11:23am 6 March 2024 - π³π±Netherlands Kingdutch
This was failing on some coding standards (parts of which is PHPCS not yet understanding more complex PHPStan types). These were fixed in a commit amend.
- π³π±Netherlands Kingdutch
I missed Catch's feedback on the missing
bool
return types for isOk/isError which I've now added :D - π«π·France andypost
It looks straightforward so not sure a test needed.
But it needs CR with example of use to announce it to module developers and maybe follow-up to apply monadic result to some core places
- π³π±Netherlands Kingdutch
I wasnβt quite sure how to test it. I suppose we could test that the isOk and isError types do what they say.
What Iβve previously done is write a few function calls around it with PHPStan at level 9 to make sure all the type annotations had the right behavior. We donβt really have infrastructure for that though and that should be solidified when we adopt it :)
See the linked PHPStan sandbox for that bit of code
Iβll write a CR proposal in the coming days unless someone is faster
- π³π±Netherlands Kingdutch
I've applied the suggested changes to the documentation and removed the sentence about the list example, instead showing it as code which I hope helps it more easily click with developers.
- Status changed to Needs work
2 months ago 4:18pm 19 April 2024 - πΊπΈUnited States smustgrave
Nice!
Shouldn't we have test coverage though to make sure this does what is expected?