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

mb_str_split signature missing #6217

Closed
bitwise-operators opened this issue Aug 1, 2021 · 5 comments · Fixed by #6219
Closed

mb_str_split signature missing #6217

bitwise-operators opened this issue Aug 1, 2021 · 5 comments · Fixed by #6219
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap

Comments

@bitwise-operators
Copy link
Contributor

PHP 7.4 added the mb_str_split function to the multibyte string library.

However, it appears to be missing form the CallMap_74_delta.php dictionary, as well as from the main CallMap.php

I believe the signature should be:

'mb_str_split' => ['list<string>', 'string'=>'string', 'limit='=>'int', 'encoding='=>'string|null'],

@psalm-github-bot
Copy link

Hey @bitwise-operators, can you reproduce the issue on https://psalm.dev ?

@bitwise-operators
Copy link
Contributor Author

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/3d06280737
<?php
//	This works
function getFirstChar(string $input):string {
	$chars = str_split($input);
    return $chars[0] ?? '';
}

//	Should be the same
function getFirstCharMultibyte(string $input):string {
	$chars = mb_str_split($input);
    return $chars[0] ?? '';
}
Psalm output (using commit 00c0622):

INFO: MixedAssignment - 10:2 - Unable to determine the type that $chars is being assigned to

INFO: MixedArrayAccess - 11:12 - Cannot access array value on mixed variable $chars

INFO: MixedReturnStatement - 11:12 - Possibly-mixed return value

INFO: MixedInferredReturnType - 9:47 - Could not verify return type 'string' for getFirstCharMultibyte

@orklah
Copy link
Collaborator

orklah commented Aug 1, 2021

Thanks!

Do you mind adding that to the callmap yourself?

@orklah orklah added bug easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap labels Aug 1, 2021
@bitwise-operators
Copy link
Contributor Author

Sure, I'll have a look

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

Successfully merging a pull request may close this issue.

2 participants