Skip to content

Commit 5d57c94

Browse files
authored
Merge branch refs/heads/1.11.x into 1.12.x
2 parents c68202a + 285ca8b commit 5d57c94

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Type/Php/RegexArrayShapeMatcher.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ private function createSubjectValueType(TrinaryLogic $wasMatched, int $flags, bo
351351
$subjectValueType = TypeCombinator::removeNull($this->getValueType(new StringType(), $flags, $matchesAll));
352352

353353
if ($matchesAll) {
354-
if (!$wasMatched->yes() && !$this->containsOffsetCapture($flags)) {
355-
$subjectValueType = TypeCombinator::union($subjectValueType, new ConstantStringType(''));
356-
}
357354
if ($this->containsPatternOrder($flags)) {
358355
$subjectValueType = AccessoryArrayListType::intersectWith(new ArrayType(new IntegerType(), $subjectValueType));
359356
}

tests/PHPStan/Analyser/nsrt/preg_match_all_shapes.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,22 @@ public function sayHello(string $content): void
144144

145145
assertType('array{list<array{string, int<0, max>}>}', $matches);
146146
}
147+
148+
public function sayFoo(string $content): void
149+
{
150+
if (preg_match_all("~text=~mU", $content, $matches, PREG_SET_ORDER) === 0) {
151+
return;
152+
}
153+
154+
assertType('list<array{string}>', $matches);
155+
}
156+
157+
public function sayBar(string $content): void
158+
{
159+
if (preg_match_all("~text=~mU", $content, $matches, PREG_PATTERN_ORDER) === 0) {
160+
return;
161+
}
162+
163+
assertType('array{list<string>}', $matches);
164+
}
147165
}

0 commit comments

Comments
 (0)