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

Update functionMaps #2699

Merged
merged 4 commits into from
Nov 9, 2023
Merged

Update functionMaps #2699

merged 4 commits into from
Nov 9, 2023

Conversation

zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Oct 26, 2023

No description provided.

@@ -3912,14 +3912,14 @@
'HaruPage::textOut' => ['bool', 'x'=>'float', 'y'=>'float', 'text'=>'string'],
'HaruPage::textRect' => ['bool', 'left'=>'float', 'top'=>'float', 'right'=>'float', 'bottom'=>'float', 'text'=>'string', 'align='=>'int'],
'hash' => ['non-empty-string|false', 'algo'=>'string', 'data'=>'string', 'raw_output='=>'bool'],
'hash_algos' => ['list<non-empty-string>'],
'hash_algos' => ['non-empty-list<non-falsy-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.

This function always returns non-empty-list and neither '0' nor ''. https://www.php.net/manual/en/function.hash-algos.php

'hash_copy' => ['HashContext', 'context'=>'HashContext'],
'hash_equals' => ['bool', 'known_string'=>'string', 'user_string'=>'string'],
'hash_file' => ['non-empty-string|false', 'algo'=>'string', 'filename'=>'string', 'raw_output='=>'bool'],
'hash_final' => ['non-empty-string', 'context'=>'HashContext', 'raw_output='=>'bool'],
'hash_hkdf' => ['non-empty-string|false', 'algo'=>'string', 'key'=>'string', 'length='=>'int', 'info='=>'string', 'salt='=>'string'],
'hash_hmac' => ['non-empty-string|false', 'algo'=>'string', 'data'=>'string', 'key'=>'string', 'raw_output='=>'bool'],
'hash_hmac_algos' => ['list<non-empty-string>'],
'hash_hmac_algos' => ['non-empty-list<non-falsy-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.

This function always returns non-empty-list and neither '0' nor ''.
https://www.php.net/manual/en/function.hash-hmac-algos.php

'sha1' => ['non-empty-string', 'str'=>'string', 'raw_output='=>'bool'],
'sha1_file' => ['non-empty-string|false', 'filename'=>'string', 'raw_output='=>'bool'],
'sha1' => ['non-falsy-string', 'str'=>'string', 'raw_output='=>'bool'],
'sha1_file' => ['non-falsy-string|false', 'filename'=>'string', 'raw_output='=>'bool'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MD5 and SHA1 are fixed lengths, so they will never return either '0' or ''.

'min' => ['', '...arg1'=>'non-empty-array'],
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'int-mask<FILE_USE_INCLUDE_PATH|FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES|FILE_NO_DEFAULT_CONTEXT>', 'context='=>'resource'],
'flock' => ['bool', 'fp'=>'resource', 'operation'=>'int-mask<LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB>', '&w_wouldblock='=>'int'],
'flock' => ['bool', 'fp'=>'resource', 'operation'=>'int-mask<LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB>', '&w_wouldblock='=>'0|1'],
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 function sets only 0 and 1 in the variable by reference.

https://github.com/php/php-src/blob/php-8.2.5/ext/standard/file.c#L212-L221

@@ -5,6 +5,9 @@
'error_log' => ['bool', 'message'=>'string', 'message_type='=>'0|1|3|4', 'destination='=>'string', 'extra_headers='=>'string'],
'filter_input' => ['mixed', 'type'=>'INPUT_GET|INPUT_POST|INPUT_COOKIE|INPUT_SERVER|INPUT_ENV', 'variable_name'=>'string', 'filter='=>'int', 'options='=>'array|int'],
'filter_input_array' => ['array|false|null', 'type'=>'INPUT_GET|INPUT_POST|INPUT_COOKIE|INPUT_SERVER|INPUT_ENV', 'definition='=>'int|array', 'add_empty='=>'bool'],
'hash_hkdf' => ['non-empty-string', 'algo'=>'non-falsy-string', 'key'=>'string', 'length='=>'0|positive-int', 'info='=>'string', 'salt='=>'string'],
'hash_pbkdf2' => ['non-empty-string', 'algo'=>'non-falsy-string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'positive-int', 'length='=>'0|positive-int', 'raw_output='=>'bool'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$length = 0 means the default length, so an empty string will never be returned.

https://www.php.net/manual/en/function.hash-hkdf.php

@ondrejmirtes
Copy link
Member

Hi, this looks good but I can't merge it because some tests are still failing.

@zonuexe
Copy link
Contributor Author

zonuexe commented Oct 31, 2023

Sorry, I'll fix it tonight (UTC+9).

@@ -6320,10 +6320,10 @@
'mb_decode_mimeheader' => ['string', 'string'=>'string'],
'mb_decode_numericentity' => ['string', 'string'=>'string', 'convmap'=>'array', 'encoding'=>'string'],
'mb_detect_encoding' => ['string|false', 'str'=>'string', 'encoding_list='=>'mixed', 'strict='=>'bool'],
'mb_detect_order' => ['bool|list<string>', 'encoding_list='=>'mixed'],
'mb_detect_order' => ['bool|list<non-falsy-string>', 'encoding_list='=>'mixed'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this kind of changes actually bring any value at all? I feel like it's counterproductive and might lead to possible mistakes if something is overlooked (i.e. are we 100% sure there can be no falsy string in that list, ever under all circumstances and system setups?).

@ondrejmirtes
Copy link
Member

'session_id' => ['string|false', 'newid='=>'string'],
'session_is_registered' => ['bool', 'name'=>'string'],
'session_module_name' => ['string|false', 'newname='=>'string'],
'session_name' => ['string|false', 'newname='=>'string'],
'session_name' => ['non-falsy-string|false', 'newname='=>'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.

@@ -10373,11 +10373,11 @@
'session_destroy' => ['bool'],
'session_encode' => ['string|false'],
'session_gc' => ['int|false'],
'session_get_cookie_params' => ['array'],
'session_get_cookie_params' => ['array{lifetime:0|positive-int,path:non-falsy-string,domain:string,secure:bool,httponly:bool,samesite: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.

@zonuexe
Copy link
Contributor Author

zonuexe commented Nov 6, 2023

@ondrejmirtes Sorry to keep you waiting, I've pushed the fix.

@ondrejmirtes ondrejmirtes merged commit c86d4af into phpstan:1.10.x Nov 9, 2023
414 of 417 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants