1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add one more check is anything captured, it doesn't look like -1 actually expects

This commit is contained in:
Semyon 2021-10-13 18:06:10 +03:00
parent a109d1ab27
commit 531aafc0c6

View File

@ -259,7 +259,7 @@ class CodeLocation
}
if (preg_match($regex, $preview_snippet, $matches, PREG_OFFSET_CAPTURE)) {
if (!isset($matches[1])) {
if (!isset($matches[1]) || (int)$matches[1][1] === -1) {
throw new \LogicException(
"Failed to match anything to 1st capturing group, "
. "or regex doesn't contain 1st capturing group, regex type " . $this->regex_type