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

preg_replace_callback and preg_replace_callback_array allows array #3639

Closed
snapshotpl opened this issue Jun 22, 2020 · 1 comment
Closed
Labels

Comments

@snapshotpl
Copy link
Contributor

Subject can be string|string[] https://www.php.net/manual/en/function.preg-replace-callback.php

https://psalm.dev/r/09ffdd3f6a

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/09ffdd3f6a
<?php

/** @param string[] $ids */
function(array $ids): array {
    return \preg_replace_callback('', fn (array $matches) => $matches[4], $ids);
};
Psalm output (using commit fc8212e):

INFO: PossiblyUndefinedIntArrayOffset - 5:62 - Possibly undefined array offset 'int(4)' is risky given expected type 'array-key'. Consider using isset beforehand.

INFO: MissingClosureReturnType - 5:39 - Closure does not have a return type, expecting mixed

INFO: MixedArgumentTypeCoercion - 5:39 - Argument 2 of preg_replace_callback expects callable(array<int, string>):string, parent type Closure(array<array-key, mixed>):mixed provided

ERROR: InvalidArgument - 5:75 - Argument 3 of preg_replace_callback expects string, array<array-key, string> provided

@weirdan weirdan added the bug label Jun 23, 2020
@muglug muglug closed this as completed in 9b86021 Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants