From f6b9cd24e01f344b1d6d8d292eeec2c6967397e6 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Mon, 21 Jun 2021 16:51:00 -0500 Subject: [PATCH] Fixing composite scope matching --- lib/Scope/Parser.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/Scope/Parser.php b/lib/Scope/Parser.php index dbdbe41..5c8198e 100644 --- a/lib/Scope/Parser.php +++ b/lib/Scope/Parser.php @@ -18,7 +18,7 @@ class Parser { protected function __construct(string $selector) { $this->data = new Data($selector); } - + public static function parse(string $selector): Matcher|false { self::$instance = new self($selector); @@ -40,21 +40,13 @@ class Parser { switch ($token) { case '|': - if ($result instanceof OrMatcher) { - $result = $result->add($new); - } - - $result = new OrMatcher($result, $new); + $result = ($result instanceof OrMatcher) ? $result->add($new) : new OrMatcher($result, $new); break; case '-': $new = new NegateMatcher($new); case '&': - if ($result instanceof AndMatcher) { - $result = $result->add($new); - } - - $result = new AndMatcher($result, $new); + $result = ($result instanceof AndMatcher) ? $result->add($new) : new AndMatcher($result, $new); break; }