Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jul 10, 2024
1 parent 399b888 commit fd3c3ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/nsrt/bug-11311-php72.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use function PHPStan\Testing\assertType;

function doFoo() {
if (1 === preg_match('/(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?/', '12.5', $matches, PREG_UNMATCHED_AS_NULL)) {
function doFoo(string $s) {
if (1 === preg_match('/(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?/', $s, $matches, PREG_UNMATCHED_AS_NULL)) {
// on PHP < 7.4, unmatched-as-null does not return null values; see https://3v4l.org/v3HE4
assertType('array{0: string, major: string, 1: string, minor: string, 2: string, patch?: string, 3?: string}', $matches);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/nsrt/bug-11311.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use function PHPStan\Testing\assertType;

function doFoo() {
if (1 === preg_match('/(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?/', '12.5', $matches, PREG_UNMATCHED_AS_NULL)) {
function doFoo(string $s) {
if (1 === preg_match('/(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?/', $s, $matches, PREG_UNMATCHED_AS_NULL)) {

assertType('array{0: string, major: string|null, 1: string|null, minor: string|null, 2: string|null, patch: string|null, 3: string|null}', $matches);
}
Expand Down

0 comments on commit fd3c3ec

Please sign in to comment.