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

Fix nullable return types for CallMap functions #8228

Merged
merged 1 commit into from Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 28 additions & 28 deletions dictionaries/CallMap.php
Expand Up @@ -1066,7 +1066,7 @@
'classObj::settext' => ['int', 'text'=>'string'],
'classObj::updateFromString' => ['int', 'snippet'=>'string'],
'clearstatcache' => ['void', 'clear_realpath_cache='=>'bool', 'filename='=>'string'],
'cli_get_process_title' => ['string'],
'cli_get_process_title' => ['?string'],
'cli_set_process_title' => ['bool', 'title'=>'string'],
'ClosedGeneratorException::__clone' => ['void'],
'ClosedGeneratorException::__toString' => ['string'],
Expand Down Expand Up @@ -1106,7 +1106,7 @@
'Collator::sortWithSortKeys' => ['bool', '&rw_arr'=>'array'],
'collator_asort' => ['bool', 'object'=>'collator', '&rw_array'=>'array', 'flags='=>'int'],
'collator_compare' => ['int', 'object'=>'collator', 'string1'=>'string', 'string2'=>'string'],
'collator_create' => ['Collator', 'locale'=>'string'],
'collator_create' => ['?Collator', 'locale'=>'string'],
'collator_get_attribute' => ['int|false', 'object'=>'collator', 'attribute'=>'int'],
'collator_get_error_code' => ['int', 'object'=>'collator'],
'collator_get_error_message' => ['string', 'object'=>'collator'],
Expand Down Expand Up @@ -1678,7 +1678,7 @@
'curl_multi_close' => ['void', 'multi_handle'=>'CurlMultiHandle'],
'curl_multi_errno' => ['int', 'multi_handle'=>'CurlMultiHandle'],
'curl_multi_exec' => ['int', 'multi_handle'=>'CurlMultiHandle', '&w_still_running'=>'int'],
'curl_multi_getcontent' => ['string', 'handle'=>'CurlHandle'],
'curl_multi_getcontent' => ['?string', 'handle'=>'CurlHandle'],
'curl_multi_info_read' => ['array|false', 'multi_handle'=>'CurlMultiHandle', '&w_queued_messages='=>'int'],
'curl_multi_init' => ['CurlMultiHandle|false'],
'curl_multi_remove_handle' => ['int', 'multi_handle'=>'CurlMultiHandle', 'handle'=>'CurlHandle'],
Expand Down Expand Up @@ -1744,7 +1744,7 @@
'datefmt_format' => ['string|false', 'formatter'=>'IntlDateFormatter', 'datetime'=>'DateTime|IntlCalendar|array|int'],
'datefmt_format_object' => ['string|false', 'datetime'=>'object', 'format='=>'mixed', 'locale='=>'string'],
'datefmt_get_calendar' => ['int', 'formatter'=>'IntlDateFormatter'],
'datefmt_get_calendar_object' => ['IntlCalendar', 'formatter'=>'IntlDateFormatter'],
'datefmt_get_calendar_object' => ['IntlCalendar|false|null', 'formatter'=>'IntlDateFormatter'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also adds missing false.

'datefmt_get_datetype' => ['int', 'formatter'=>'IntlDateFormatter'],
'datefmt_get_error_code' => ['int', 'formatter'=>'IntlDateFormatter'],
'datefmt_get_error_message' => ['string', 'formatter'=>'IntlDateFormatter'],
Expand Down Expand Up @@ -3362,7 +3362,7 @@
'ftp_put' => ['bool', 'ftp'=>'FTP\Connection', 'remote_filename'=>'string', 'local_filename'=>'string', 'mode='=>'int', 'offset='=>'int'],
'ftp_pwd' => ['string|false', 'ftp'=>'FTP\Connection'],
'ftp_quit' => ['bool', 'ftp'=>'FTP\Connection'],
'ftp_raw' => ['array', 'ftp'=>'FTP\Connection', 'command'=>'string'],
'ftp_raw' => ['?array', 'ftp'=>'FTP\Connection', 'command'=>'string'],
'ftp_rawlist' => ['array|false', 'ftp'=>'FTP\Connection', 'directory'=>'string', 'recursive='=>'bool'],
'ftp_rename' => ['bool', 'ftp'=>'FTP\Connection', 'from'=>'string', 'to'=>'string'],
'ftp_rmdir' => ['bool', 'ftp'=>'FTP\Connection', 'directory'=>'string'],
Expand Down Expand Up @@ -6190,7 +6190,7 @@
'intlcal_after' => ['bool', 'calendar'=>'IntlCalendar', 'other'=>'IntlCalendar'],
'intlcal_before' => ['bool', 'calendar'=>'IntlCalendar', 'other'=>'IntlCalendar'],
'intlcal_clear' => ['bool', 'calendar'=>'IntlCalendar', 'field='=>'int'],
'intlcal_create_instance' => ['IntlCalendar', 'timezone='=>'mixed', 'locale='=>'string'],
'intlcal_create_instance' => ['?IntlCalendar', 'timezone='=>'mixed', 'locale='=>'string'],
'intlcal_equals' => ['bool', 'calendar'=>'IntlCalendar', 'other'=>'IntlCalendar'],
'intlcal_field_difference' => ['int', 'calendar'=>'IntlCalendar', 'timestamp'=>'float', 'field'=>'int'],
'intlcal_from_date_time' => ['IntlCalendar', 'datetime'=>'DateTime|string'],
Expand Down Expand Up @@ -6503,8 +6503,8 @@
'IntlTimeZone::useDaylightTime' => ['bool'],
'intltz_count_equivalent_ids' => ['int', 'timezoneId'=>'string'],
'intltz_create_enumeration' => ['IntlIterator', 'countryOrRawOffset'=>'mixed'],
'intltz_create_time_zone' => ['IntlTimeZone', 'timezoneId'=>'string'],
'intltz_from_date_time_zone' => ['IntlTimeZone', 'timezone'=>'DateTimeZone'],
'intltz_create_time_zone' => ['?IntlTimeZone', 'timezoneId'=>'string'],
'intltz_from_date_time_zone' => ['?IntlTimeZone', 'timezone'=>'DateTimeZone'],
'intltz_get_canonical_id' => ['string', 'timezoneId'=>'string', '&isSystemId'=>'bool'],
'intltz_get_display_name' => ['string', 'timezone'=>'IntlTimeZone', 'dst'=>'bool', 'style'=>'int', 'locale'=>'string'],
'intltz_get_dst_savings' => ['int', 'timezone'=>'IntlTimeZone'],
Expand Down Expand Up @@ -6923,22 +6923,22 @@
'Locale::parseLocale' => ['array', 'locale'=>'string'],
'Locale::setDefault' => ['bool', 'locale'=>'string'],
'locale_accept_from_http' => ['string|false', 'header'=>'string'],
'locale_canonicalize' => ['string', 'locale'=>'string'],
'locale_canonicalize' => ['?string', 'locale'=>'string'],
'locale_compose' => ['string|false', 'subtags'=>'array'],
'locale_filter_matches' => ['bool', 'languageTag'=>'string', 'locale'=>'string', 'canonicalize='=>'bool'],
'locale_get_all_variants' => ['array', 'locale'=>'string'],
'locale_filter_matches' => ['?bool', 'languageTag'=>'string', 'locale'=>'string', 'canonicalize='=>'bool'],
'locale_get_all_variants' => ['?array', 'locale'=>'string'],
'locale_get_default' => ['string'],
'locale_get_display_language' => ['string', 'locale'=>'string', 'displayLocale='=>'string'],
'locale_get_display_name' => ['string', 'locale'=>'string', 'displayLocale='=>'string'],
'locale_get_display_region' => ['string', 'locale'=>'string', 'displayLocale='=>'string'],
'locale_get_display_script' => ['string', 'locale'=>'string', 'displayLocale='=>'string'],
'locale_get_display_variant' => ['string', 'locale'=>'string', 'displayLocale='=>'string'],
'locale_get_keywords' => ['array|false', 'locale'=>'string'],
'locale_get_primary_language' => ['string', 'locale'=>'string'],
'locale_get_region' => ['string', 'locale'=>'string'],
'locale_get_script' => ['string', 'locale'=>'string'],
'locale_lookup' => ['string', 'languageTag'=>'array', 'locale'=>'string', 'canonicalize='=>'bool', 'defaultLocale='=>'string'],
'locale_parse' => ['array', 'locale'=>'string'],
'locale_get_keywords' => ['array|false|null', 'locale'=>'string'],
'locale_get_primary_language' => ['?string', 'locale'=>'string'],
'locale_get_region' => ['?string', 'locale'=>'string'],
'locale_get_script' => ['?string', 'locale'=>'string'],
'locale_lookup' => ['?string', 'languageTag'=>'array', 'locale'=>'string', 'canonicalize='=>'bool', 'defaultLocale='=>'string'],
'locale_parse' => ['?array', 'locale'=>'string'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These locale functions return null when locale string is too big. Do we want to ignore this possibility?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a valid concern for some usage so we should allow users to guard against it. Note that Psalm has two configs (ignoreInternalFunctionNullReturn and ignoreInternalFunctionFalseReturn) that will make Psalm less strict about unhandled false/null returns from internal functions. Adding false or null to signature should not disturb users very much

'locale_set_default' => ['bool', 'locale'=>'string'],
'localeconv' => ['array'],
'localtime' => ['array', 'timestamp='=>'int', 'associative='=>'bool'],
Expand Down Expand Up @@ -7279,7 +7279,7 @@
'mb_ereg' => ['bool', 'pattern'=>'string', 'string'=>'string', '&w_matches='=>'array|null'],
'mb_ereg_match' => ['bool', 'pattern'=>'string', 'string'=>'string', 'options='=>'string|null'],
'mb_ereg_replace' => ['string|false|null', 'pattern'=>'string', 'replacement'=>'string', 'string'=>'string', 'options='=>'string|null'],
'mb_ereg_replace_callback' => ['string|false', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string|null'],
'mb_ereg_replace_callback' => ['string|false|null', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string|null'],
'mb_ereg_search' => ['bool', 'pattern='=>'string|null', 'options='=>'string|null'],
'mb_ereg_search_getpos' => ['int'],
'mb_ereg_search_getregs' => ['string[]|false'],
Expand Down Expand Up @@ -8167,7 +8167,7 @@
'msg_send' => ['bool', 'queue'=>'resource', 'message_type'=>'int', 'message'=>'mixed', 'serialize='=>'bool', 'blocking='=>'bool', '&w_error_code='=>'int'],
'msg_set_queue' => ['bool', 'queue'=>'resource', 'data'=>'array'],
'msg_stat_queue' => ['array', 'queue'=>'resource'],
'msgfmt_create' => ['MessageFormatter', 'locale'=>'string', 'pattern'=>'string'],
'msgfmt_create' => ['?MessageFormatter', 'locale'=>'string', 'pattern'=>'string'],
'msgfmt_format' => ['string|false', 'formatter'=>'MessageFormatter', 'values'=>'array'],
'msgfmt_format_message' => ['string|false', 'locale'=>'string', 'pattern'=>'string', 'values'=>'array'],
'msgfmt_get_error_code' => ['int', 'formatter'=>'MessageFormatter'],
Expand Down Expand Up @@ -8481,7 +8481,7 @@
'mysqli_field_tell' => ['int', 'result'=>'mysqli_result'],
'mysqli_free_result' => ['void', 'result'=>'mysqli_result'],
'mysqli_get_cache_stats' => ['array|false'],
'mysqli_get_charset' => ['object', 'mysql'=>'mysqli'],
'mysqli_get_charset' => ['?object', 'mysql'=>'mysqli'],
'mysqli_get_client_info' => ['string', 'mysql='=>'?mysqli'],
'mysqli_get_client_stats' => ['array'],
'mysqli_get_client_version' => ['int', 'link'=>'mysqli'],
Expand Down Expand Up @@ -11783,7 +11783,7 @@
'SAMConnection::unsubscribe' => ['bool', 'subscriptionid'=>'string', 'targettopic='=>'string'],
'SAMMessage::body' => ['string'],
'SAMMessage::header' => ['object'],
'sapi_windows_cp_conv' => ['string', 'in_codepage'=>'int|string', 'out_codepage'=>'int|string', 'subject'=>'string'],
'sapi_windows_cp_conv' => ['?string', 'in_codepage'=>'int|string', 'out_codepage'=>'int|string', 'subject'=>'string'],
'sapi_windows_cp_get' => ['int'],
'sapi_windows_cp_is_utf8' => ['bool'],
'sapi_windows_cp_set' => ['bool', 'codepage'=>'int'],
Expand Down Expand Up @@ -13786,7 +13786,7 @@
'strcoll' => ['int', 'string1'=>'string', 'string2'=>'string'],
'strcspn' => ['int', 'string'=>'string', 'characters'=>'string', 'offset='=>'int', 'length='=>'int'],
'stream_bucket_append' => ['void', 'brigade'=>'resource', 'bucket'=>'object'],
'stream_bucket_make_writeable' => ['object', 'brigade'=>'resource'],
'stream_bucket_make_writeable' => ['?object', 'brigade'=>'resource'],
'stream_bucket_new' => ['object|false', 'stream'=>'resource', 'buffer'=>'string'],
'stream_bucket_prepend' => ['void', 'brigade'=>'resource', 'bucket'=>'object'],
'stream_context_create' => ['resource', 'options='=>'array', 'params='=>'array'],
Expand Down Expand Up @@ -14590,16 +14590,16 @@
'tidy_config_count' => ['int', 'tidy'=>'tidy'],
'tidy_diagnose' => ['bool', 'tidy'=>'tidy'],
'tidy_error_count' => ['int', 'tidy'=>'tidy'],
'tidy_get_body' => ['tidyNode', 'tidy'=>'tidy'],
'tidy_get_body' => ['?tidyNode', 'tidy'=>'tidy'],
'tidy_get_config' => ['array', 'tidy'=>'tidy'],
'tidy_get_error_buffer' => ['string', 'tidy'=>'tidy'],
'tidy_get_head' => ['tidyNode', 'tidy'=>'tidy'],
'tidy_get_html' => ['tidyNode', 'tidy'=>'tidy'],
'tidy_get_head' => ['?tidyNode', 'tidy'=>'tidy'],
'tidy_get_html' => ['?tidyNode', 'tidy'=>'tidy'],
'tidy_get_html_ver' => ['int', 'tidy'=>'tidy'],
'tidy_get_opt_doc' => ['string', 'tidy'=>'tidy', 'option'=>'string'],
'tidy_get_output' => ['string', 'tidy'=>'tidy'],
'tidy_get_release' => ['string'],
'tidy_get_root' => ['tidyNode', 'tidy'=>'tidy'],
'tidy_get_root' => ['?tidyNode', 'tidy'=>'tidy'],
'tidy_get_status' => ['int', 'tidy'=>'tidy'],
'tidy_getopt' => ['mixed', 'tidy'=>'string', 'option'=>'tidy'],
'tidy_is_xhtml' => ['bool', 'tidy'=>'tidy'],
Expand Down Expand Up @@ -14868,7 +14868,7 @@
'Transliterator::transliterate' => ['string|false', 'subject'=>'string', 'start='=>'int', 'end='=>'int'],
'transliterator_create' => ['?Transliterator', 'id'=>'string', 'direction='=>'int'],
'transliterator_create_from_rules' => ['?Transliterator', 'rules'=>'string', 'direction='=>'int'],
'transliterator_create_inverse' => ['Transliterator', 'transliterator'=>'Transliterator'],
'transliterator_create_inverse' => ['?Transliterator', 'transliterator'=>'Transliterator'],
'transliterator_get_error_code' => ['int', 'transliterator'=>'Transliterator'],
'transliterator_get_error_message' => ['string', 'transliterator'=>'Transliterator'],
'transliterator_list_ids' => ['array'],
Expand Down Expand Up @@ -15597,7 +15597,7 @@
'xhprof_sample_enable' => ['void'],
'xlswriter_get_author' => ['string'],
'xlswriter_get_version' => ['string'],
'xml_error_string' => ['string', 'error_code'=>'int'],
'xml_error_string' => ['?string', 'error_code'=>'int'],
'xml_get_current_byte_index' => ['int|false', 'parser'=>'XMLParser'],
'xml_get_current_column_number' => ['int|false', 'parser'=>'XMLParser'],
'xml_get_current_line_number' => ['int|false', 'parser'=>'XMLParser'],
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_71_delta.php
Expand Up @@ -26,7 +26,7 @@
'openssl_get_curve_names' => ['list<string>'],
'pcntl_async_signals' => ['bool', 'enable='=>'bool'],
'pcntl_signal_get_handler' => ['int|string', 'signal'=>'int'],
'sapi_windows_cp_conv' => ['string', 'in_codepage'=>'int|string', 'out_codepage'=>'int|string', 'subject'=>'string'],
'sapi_windows_cp_conv' => ['?string', 'in_codepage'=>'int|string', 'out_codepage'=>'int|string', 'subject'=>'string'],
'sapi_windows_cp_get' => ['int'],
'sapi_windows_cp_is_utf8' => ['bool'],
'sapi_windows_cp_set' => ['bool', 'codepage'=>'int'],
Expand Down
8 changes: 4 additions & 4 deletions dictionaries/CallMap_80_delta.php
Expand Up @@ -278,8 +278,8 @@
'new' => ['int', 'multi_handle'=>'CurlMultiHandle', '&w_still_running'=>'int'],
],
'curl_multi_getcontent' => [
'old' => ['string', 'ch'=>'resource'],
'new' => ['string', 'handle'=>'CurlHandle'],
'old' => ['?string', 'ch'=>'resource'],
'new' => ['?string', 'handle'=>'CurlHandle'],
],
'curl_multi_info_read' => [
'old' => ['array|false', 'mh'=>'resource', '&w_msgs_in_queue='=>'int'],
Expand Down Expand Up @@ -834,8 +834,8 @@
'new' => ['string|false|null', 'pattern'=>'string', 'replacement'=>'string', 'string'=>'string', 'options='=>'string|null'],
],
'mb_ereg_replace_callback' => [
'old' => ['string|false', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string'],
'new' => ['string|false', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string|null'],
'old' => ['string|false|null', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string'],
'new' => ['string|false|null', 'pattern'=>'string', 'callback'=>'callable', 'string'=>'string', 'options='=>'string|null'],
],
'mb_ereg_search' => [
'old' => ['bool', 'pattern='=>'string', 'options='=>'string'],
Expand Down
4 changes: 2 additions & 2 deletions dictionaries/CallMap_81_delta.php
Expand Up @@ -106,8 +106,8 @@
'new' => ['bool', 'ftp' => 'FTP\Connection', 'command' => 'string'],
],
'ftp_raw' => [
'old' => ['array', 'ftp' => 'resource', 'command' => 'string'],
'new' => ['array', 'ftp' => 'FTP\Connection', 'command' => 'string'],
'old' => ['?array', 'ftp' => 'resource', 'command' => 'string'],
'new' => ['?array', 'ftp' => 'FTP\Connection', 'command' => 'string'],
],
'ftp_mkdir' => [
'old' => ['string|false', 'ftp' => 'resource', 'directory' => 'string'],
Expand Down