-
Notifications
You must be signed in to change notification settings - Fork 147
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
#213 implemented Assert::positiveInteger()
to have psalm positive-int
assertions
#214
#213 implemented Assert::positiveInteger()
to have psalm positive-int
assertions
#214
Conversation
No, style-ci, that stuff is not valid/to be fixed :P |
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.
Got one minor comment.
I can see the use case for this assertion, especially with prices etc, where 0 would also not be allowed.
…ToString()` for `Assert::positiveInteger()` failures Ref: webmozarts#214 (comment)
CI failure unrelated |
@BackEndTea can we ship this? |
@BackEndTea sorry to page again - can I somehow help here? Can I perhaps help by introducing release automation? |
@BackEndTea sorry, didn't see that you pushed to my fork - currently rebasing to get this merged |
…ToString()` for `Assert::positiveInteger()` failures Ref: webmozarts#214 (comment)
727bbbc
to
864876c
Compare
349e997
to
da39c25
Compare
Note to maintainers: please do not squash this! |
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.
Im super impressed. Great work.
Thank you for the rebase.
I see that psalm complains. The error seam valid. Is it related to your PR?
That would be the first TODO that is left above - I'm waiting for a merge (if applicable) and release of vimeo/psalm#5050. |
@Ocramius I initially was pro-trait/base-class, so it definitely looks good to me :-) |
… `positive-int` assertions
…ToString()` for `Assert::positiveInteger()` failures Ref: webmozarts#214 (comment)
…Assert` type inference mechanism Ref: https://symfony-devs.slack.com/archives/C8SFXTD2M/p1611064766060600 Quoting: ``` ocramius 2:59 PM can anyone help me tackle down vimeo/psalm#4381 ? Mostly trying to figure out whether the assertions are being read differently for @mixin and concrete instances 😐 muglug 3:18 PM mixins are a massive hack, both whenever they're used but also in Psalm anything that relies on magic methods to work is going to be more flaky, so I'd encourage you to think of a non-mixin approach if at all possible ocramius 3:19 PM yeah, I'm thinking of doing that indeed, just unsure about approach yet 😐 can't they somehow be unified with traits though? they're the same thing, no? muglug 3:22 PM if they were, you'd just use a trait! ocramius 3:22 PM ack, gonna actually try that approach for webmozart/assert then 🙂 muglug 3:24 PM with mixins the method that's actually being called is either __call or __callStatic, whereas with traits it's still that exact method ocramius 3:24 PM yes, I was just wondering if it could import the method as if it was a trait (at type level) that would squash out *a lot* of code, but it's also true that a mixin does not have a trait definition I think it makes sense to use the language feature for this 🙂 ``` The `@mixin` support in `vimeo/psalm` is a massive hack, which also requires other tooling to increase complexity in the static analysis parsing capabilities. In order to reduce that complexity, we instead rely on `Assert` importing `Mixin` as a trait, which is much simpler and much more stable long-term. While this indeed leads to `Mixin` being changed from an `interface` to a `trait`, that is not really a BC break, as `Mixin` was explicitly documented to be used only as a type system aid, and not as an usable symbol.
…ural()` doing the same thing Note: we refined the assertion on `Assert::natural()` to correctly restrict to `positive-int|0`, but we had to remove some minor test on `Assert::allNaturalNumber()` due to `@psalm-assert iterable<positive-int|0>` not yet working in upstream. See vimeo/psalm#5052
… broken as per vimeo/psalm#5310) While there is no guarantee that `vimeo/psalm:4.6.3` will fix the issue, we know for sure that `vimeo/psalm:4.6.2` is broken, as per vimeo/psalm#5310, and we cannot therefore rely on its static analysis there until upstream issue is fixed. Meanwhile, this allows for installation of `webmozart/assert` with `vimeo/psalm:4.6.1` and `vimeo/psalm:>4.6.2`, hoping for a brighter future.
da39c25
to
6d7d868
Compare
@BackEndTea @Nyholm I've now rebased and everything looks OK. Only failure seems to be with scrutinizer-ci, which doesn't seem to accept coverage anymore:
Meanwhile, I reported vimeo/psalm#5310 and excluded If you have time, let's roll with this, as it fixes a gazillion issues, and could really need a new release \o/ |
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.
A gazillion issues fixed in one PR? This is great.
I've reviewed the code and I'm happy with merging.
Thank you Marco
@Nyholm was the merge held off then? 🤔 |
I wanted to wait a day or two for @BackEndTea to have a chance to review it again. |
Thank you |
@Nyholm @BackEndTea thank you! Eager to try it out, lemme know if there's anything I can help with to get it released. If releases are currently onerous, I can help setting up automation, like I did for https://github.com/webmozarts/glob |
I've seen this https://github.com/webmozarts/glob/blob/4.4.x/.github/workflows/release-on-milestone-closed.yml My mind has not matured for this yet. =) I'll get there eventually. |
Oh no! All of yesterday, I had this feeling that I've read this note somewhere but I could not remember where. I remembered. Sorry, I did squash the commits. Unrelated, Im preparing the release now. |
Heh, I mostly did say that because, if you look at the patch history, the commits are made individually, each with a decent commit message, useful to pinpoint regressions :( Still happy about a release though, but as a good habit, squashing is the exception, not the norm :P |
Fixes #213
Needs:
true
orfalse
from aUnion
should turnbool
into respectivelyfalse
ortrue
vimeo/psalm#5050 (and updatevimeo/psalm
conflict)Regression:worked around by removing@psalm-assert empty
not recognized on@mixin
imports vimeo/psalm#5051@mixin
(skipped - suppressed for now, IMO not a blocker)@psalm-assert iterable<T1|T2>
isn't being picked up, and leads to failed type inference vimeo/psalm#5052Regression: in(not fixed - reported regression in upstream, then locked dependency here)4.6.2
,@psalm-assert iterable<T>
does not refineArrayIterator
value vimeo/psalm#5310vimeo/psalm
, updatevimeo/psalm
conflict constraintFixes #213
Fixes #214
Fixes #97
Fixes #229