-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narrow the type for the
mb_ereg_replace_callback()
callable.
- Loading branch information
1 parent
fc839cf
commit 17f826f
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/PHPStan/Rules/Functions/data/mb_ereg_replace_callback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
// Incorrect | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function(string $string): string { | ||
return $string; | ||
}, | ||
'subject' | ||
); | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function(string $string) { | ||
return $string; | ||
}, | ||
'subject' | ||
); | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function(array $matches) {}, | ||
'subject' | ||
); | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function() {}, | ||
'subject' | ||
); | ||
|
||
// Correct | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function(array $matches): string { | ||
return $matches[0]; | ||
}, | ||
'subject' | ||
); | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function(array $matches) { | ||
return $matches[0]; | ||
}, | ||
'subject' | ||
); | ||
$string = mb_ereg_replace_callback( | ||
'pattern', | ||
function() { | ||
return 'Hello'; | ||
}, | ||
'subject' | ||
); |