Skip to content
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

IntlDateFormatter::__construct (and probably other methods) CallMap is incorrect #8735

Closed
niconoe- opened this issue Nov 22, 2022 · 5 comments
Labels
easy problems Issues that can be fixed without background knowledge of Psalm Help wanted internal stubs/callmap

Comments

@niconoe-
Copy link

Regarding https://psalm.dev/r/b6ebba0bf1 and the PHP Documentation, it looks like the CallMap is KO about this.

Looking at the current CallMap I found, it looks like also IntlDateFormatter::create(…) is not OK, so maybe a global review of the CallMap for this class could be done.

I wish I could update it but looking as PhpStorm's stubs, this method changed a lot from PHP 5.3 to PHP 8.1 and I'm not sure how can I update the CallMap files accordingly, neither how can I test it.
If someone can provide just a single example of how to update the CallMap (+ maybe specific CallMaps for PHP 8.0, PHP 8.1…) correctly of one single method, then I could spend some time to replicate this to the whole class myself.

Thanks a lot.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/b6ebba0bf1
<?php

new IntlDateFormatter('en_US', timeType: IntlDateFormatter::SHORT);
Psalm output (using commit 7869cb5):

ERROR: InvalidNamedArgument - 3:32 - Parameter $timeType does not exist on function IntlDateFormatter::__construct

ERROR: TooFewArguments - 3:1 - Too few arguments for IntlDateFormatter::__construct - expecting datetype to be passed

ERROR: TooFewArguments - 3:1 - Too few arguments for IntlDateFormatter::__construct - expecting timetype to be passed

@orklah
Copy link
Collaborator

orklah commented Nov 22, 2022

Hey! We have a full article on callmap editing! https://psalm.dev/docs/contributing/editing_callmaps/

The short version is: you start with Callmap.php which represent the more up to date signatures (for 8.2 currently). Then, for each version you want to "erase", you process the delta files. That means if you want to analyse using 8.1, you first take the Callmap.php file and then you remove all function marked as "added" in Callmap_82_delta.php, you re-add all function marked as "removed" and replace every "changed" function by taking the "new" signature and swapping it with the "old"

And that gives you the state of the signature in 8.1. If you do that for each version, you roll back to 7.1 (the full file is described in Callmap_historical.php)

The CI includes all the tests needed to make sure everything is consistent so you can go with your eyes closed, if there's an error, we'll know :)

@orklah orklah added easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap Help wanted labels Nov 22, 2022
@niconoe-
Copy link
Author

Thank you very much for the docs and the explainations. I'll try to provide something for today 😉

@niconoe-
Copy link
Author

niconoe- commented Nov 23, 2022

Here it is. It took longer than expected as I wasn't able to find official PHP Documentation of the previous versions. Cheers to "the wayback machine" archive for giving me access to old PHP website's documentation.

I only took care of the IntlDateFormatter class in an object-oriented-style, procedural functions are not changed.
The Reflection system for older PHP version is a complete mess so it's hard to be 100% sure everything is well declared. I hope I'm not breaking anything, otherwise, please let me know and I'll try to fix my mistakes ASAP.

Thanks a lot!

EDIT: This check does not pass, but it doesn't look like related to my changes. Is it a problem or a false-positive?

@orklah orklah closed this as completed in 18bd412 Nov 23, 2022
orklah added a commit that referenced this issue Nov 23, 2022
Fix #8735: IntlDateFormatter CallMaps.
@orklah
Copy link
Collaborator

orklah commented Nov 23, 2022

The signatures were pretty broken before! Thanks for your efforts! Don't worry about procedural functions, if it bothers someone, it will end up fixed in the end!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy problems Issues that can be fixed without background knowledge of Psalm Help wanted internal stubs/callmap
Projects
None yet
Development

No branches or pull requests

2 participants