Skip to content

Commit 95d3cc6

Browse files
committed
Use ConstantIntegerType instead of ints for TypeCombinator::union
1 parent df2c969 commit 95d3cc6

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/PHPStan/PregMatchFlags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static public function getType(?Arg $flagsArg, Scope $scope): ?Type
2929
return null;
3030
}
3131

32-
$internalFlagsTypes[] = $constantScalarValue | PREG_UNMATCHED_AS_NULL;
32+
$internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | PREG_UNMATCHED_AS_NULL);
3333
}
3434
return TypeCombinator::union(...$internalFlagsTypes);
3535
}

tests/PHPStanTests/nsrt/preg-match.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ function doMatch(string $s): void
2929
assertType('array{}|array{0: string, 1?: string|null}', $matches);
3030
}
3131

32-
function identicalMatch(string $s): void
33-
{
34-
if (Preg::match('/Price: /i', $s, $matches) === 1) {
35-
assertType('array{string}', $matches);
36-
} else {
37-
assertType('array{}', $matches);
38-
}
39-
assertType('array{}|array{string}', $matches);
40-
}
41-
4232
// disabled until https://github.com/phpstan/phpstan-src/pull/3185 can be resolved
33+
//
34+
//function identicalMatch(string $s): void
35+
//{
36+
// if (Preg::match('/Price: /i', $s, $matches) === 1) {
37+
// assertType('array{string}', $matches);
38+
// } else {
39+
// assertType('array{}', $matches);
40+
// }
41+
// assertType('array{}|array{string}', $matches);
42+
//}
43+
//
4344
//function equalMatch(string $s): void
4445
//{
4546
// if (Preg::match('/Price: /i', $s, $matches) == 1) {

0 commit comments

Comments
 (0)