Skip to content

Commit b1d2ab6

Browse files
committed
[BUGFIX] Use the safe regexp functions in Selector
Part of #1168
1 parent 995442b commit b1d2ab6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Property/Selector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Sabberworm\CSS\Property\Selector\SpecificityCalculator;
99
use Sabberworm\CSS\Renderable;
1010

11+
use function Safe\preg_match;
12+
1113
/**
1214
* Class representing a single CSS selector. Selectors have to be split by the comma prior to being passed into this
1315
* class.
@@ -42,7 +44,7 @@ class Selector implements Renderable
4244
public static function isValid(string $selector): bool
4345
{
4446
// Note: We need to use `static::` here as the constant is overridden in the `KeyframeSelector` class.
45-
$numberOfMatches = \preg_match(static::SELECTOR_VALIDATION_RX, $selector);
47+
$numberOfMatches = preg_match(static::SELECTOR_VALIDATION_RX, $selector);
4648

4749
return $numberOfMatches === 1;
4850
}

tests/ParserTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ public function files(): void
7373
continue;
7474
}
7575
$parser = new Parser(\file_get_contents($directory . '/' . $filename));
76-
try {
77-
self::assertNotEquals('', $parser->parse()->render());
78-
} catch (\Exception $e) {
79-
self::fail($e);
80-
}
76+
self::assertNotSame('', $parser->parse()->render());
8177
}
8278
\closedir($directoryHandle);
8379
}

0 commit comments

Comments
 (0)