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
Do not merge BenevolentUnionType
with UnionType
#2058
base: 1.10.x
Are you sure you want to change the base?
Do not merge BenevolentUnionType
with UnionType
#2058
Conversation
175fd36
to
7c3ff7b
Compare
OK close, better than I thought. I guess I deleted too much and am loosing the benevolent template object.. |
You should measure whether these changes have a perf impact |
Since |
Good question, I'm not sure if it should be tbh. If we explicitly want a union, shouldn't it be non-benevolent? 🤔 I guess what I'm saying is, are we expecting this to be simplified if we call |
7c3ff7b
to
ff51d9f
Compare
c2c716e
to
8c77918
Compare
assertType('int|null', findKey($unknownList, $callback)); | ||
assertType('string|null', findKey($unknownMap, $callback)); | ||
|
||
assertType('int|null', findKey($nonEmptyList, $callback)); | ||
assertType('string|null', findKey($nonEmptyMap, $callback)); |
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.
both L83 and L86 are different to the snippet where 'id'|'name'|null
was asserted/expected. but this is either not supported or something different than the main problem that was fixed here IMO
This pull request has been marked as ready for review. |
3515799
to
3e7fff1
Compare
ecb2fc4
to
23bee84
Compare
I'm struggling a bit with this one. What is your thinking behind this PR? I see that it fixes a bunch of issues, but to me it looks like it's just a matter of luck, not an intention (please take no offense :)). What's a typical situation that this PR improves/fixes? Also, I think we need some more tests around this. Let's say for example we have
|
The main intention behind this is that I believe, and I think the linked issues confirm it, that union with a benevolent union should not suddenly get rid of the benevolence. E.g. https://phpstan.org/r/498cd1d0-4568-4cbf-8b0b-11ed722552e8 Calling But it's basically what you suggested at phpstan/phpstan#8268 (comment) (which I just found later via issue bot). |
23bee84
to
322a89a
Compare
Added the test cases for union with
that looks OK to me 😊 |
I'd argue that Another idea for a test - if we have Also we can test what happens with Also |
Ok, added your mentioned cases again, the result is a bit different, I got
so most likely there's still work needed / it can be improved? I pushed them in this state, but need to think about this another time. Such benevolent cases are still hard for me to think through properly |
c99a035
to
6e10519
Compare
https://phpstan.org/r/9be20c04-429f-4dc0-b245-9d23628ae2db Both
Technically, it should be Because if it's transformed into
|
c9865e5
to
3251d3d
Compare
@drupol are you referring to the bot message you got in your issue (which is unrelated to this PR) or https://github.com/phpstan/phpstan-src/actions/runs/3910108845? :) |
Sorry, here's the proper link: phpstan/phpstan#7423 I also fixed it in my previous message. |
yeah and why do you mean this PR does not fix it? the bot message there is unrelated. but in https://github.com/phpstan/phpstan-src/actions/runs/3910108845 I can see no errors for PHP 8+ because the type should be correct now? and that is also checked via regression test here. |
Oh if it's unrelated, please ignore my message then. Sorry for the noise. |
f6fb159
to
aad632d
Compare
Did we come to a conclusion about this one? :) I rebased it on 1.10.x in the meantime. Thought the behavior change might be better there. In case it gets merged. So far it still makes sense to me |
70d77ae
to
9d76dfa
Compare
9d76dfa
to
a5de12b
Compare
Going to rebase this one tomorrow morning. Is there anything else I can do here? This still makes sense to me :) |
@herndlm I have some issues with it. For example I've seen a type For example if you compare |
This was inspired by phpstan/phpstan#8458 (comment)
Closes phpstan/phpstan#7049
Closes phpstan/phpstan#7279
Closes phpstan/phpstan#7423
Closes phpstan/phpstan#8268
Regarding the performance impact (#2058 (comment))
before:
after:
not sure if that is enough, the system is a bit trashy I guess. but looks like things don't really change perf.-wise. I'm pretty sure things also don't get faster, the variance is just too big on my system, I think we can go with 49s before and after.
Regarding the 3 failures
Cannot access offset (float|int<1, max>) on mixed.
https://github.com/pmmp/PocketMine-MP/blob/e0b07ff3087b652407439a29c941f3b66ca92c86/src/pocketmine/CrashDump.php#L314 / https://github.com/pmmp/PocketMine-MP/blob/e0b07ff3087b652407439a29c941f3b66ca92c86/src/pocketmine/CrashDump.php#L111ArrayObject<*NEVER*, *NEVER*>
https://github.com/PrestaShop/PrestaShop/blob/ca9d81aae0bb17f3e767bb5d835348ed144a3ab5/src/Adapter/Presenter/AbstractLazyArray.php#L98ArrayObject<*NEVER*, *NEVER*>
, e.g. https://github.com/sebastianbergmann/phpunit/blob/93d4bf4c37aec6384bb9e5d390d9049a463a7256/tests/unit/Framework/AssertTest.php#L153all of those are expected IMO, but I can create PRs for Prestashop and PHPUnit to add PHPDoc types to the collection if wanted