-
Notifications
You must be signed in to change notification settings - Fork 650
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
DateInterval::$days false return isn't ignored #9995
Comments
I found these snippets: https://psalm.dev/r/083ee5e953<?php
$date_time = new DateTime( gmdate( 'Y-m-d' ) );
$date_interval = $date_time->diff( new DateTime( '2023-03-03' ) );
/** @psalm-trace $date_interval */;
$x = $date_interval->days;
/** @psalm-trace $x */;
|
Yes, removing it in both files fixes the issue, is it ok to change this? @orklah Not sure what role Reflection class plays here. |
One of those files is autogenerated from the other. I think changes must be in the Manual file. There was a comment on the top of the autogenerated file... |
Yeah I saw that and ran it, but it's the same thing as just changing this little thing in both manually it seems. I don't have time to get into how/why the Reflection.php stuff is ignored in this case, I just removed it for now and put a comment. If there's someone who's more familiar with that part of psalm or has some time to check it, would be appreciated. |
Reflection is there to get type from PHP core data. So in theory, it should pick up the correct type from what's in PHP but that property is weird enough that we have to make a PropertyMap to correct it's type so it's normal that the map is overriding Reflection. However, this https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Codebase/Reflection.php#L155 should be put in the PropertyMap parsing too (so, here:
|
Wouldn't that break cases where |
I found these snippets: https://psalm.dev/r/f309122a6a<?php
function getDays(): int {
return (new DateInterval('P1D'))->days;
}
|
@orklah thanks for pointing me there. This is actually the wrong place to put that, but I fixed it now at the correct place and removed the initial change. It's fixed correctly now and the PR can be merged (and this issue closed) @tscni this is a convenience thing to avoid having to create lots of boilerplate code for most users, see https://psalm.dev/docs/running_psalm/configuration/#ignoreinternalfunctionfalsereturn if you don't want to ignore false |
https://psalm.dev/r/083ee5e953
But I guess it should be ignored https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Codebase/Reflection.php#L157
I guess it's bc of https://github.com/vimeo/psalm/blob/master/dictionaries/ManualPropertyMap.php#L20 ? (and/or https://github.com/vimeo/psalm/blob/master/dictionaries/PropertyMap.php#L69) where the property map has precedence over things set in code? (which would be bad) @orklah
The text was updated successfully, but these errors were encountered: