Browse Source

Fixed minor scope parsing bug

main
Dustin Wilson 3 years ago
parent
commit
4a02e07efe
  1. 6
      lib/Scope/Matcher.php
  2. 2
      lib/Scope/Matchers/GroupMatcher.php
  3. 2
      lib/Scope/Matchers/NegateMatcher.php
  4. 2
      lib/Scope/Matchers/ScopeMatcher.php
  5. 4
      lib/Scope/Matchers/SegmentMatcher.php
  6. 4
      lib/Scope/Matchers/TrueMatcher.php
  7. 5
      lib/Scope/Parser.php

6
lib/Scope/Matcher.php

@ -6,8 +6,4 @@
declare(strict_types=1);
namespace dW\Highlighter\Scope;
abstract class Matcher {
public function getPrefix(string $scope): string|null|false {
return null;
}
}
abstract class Matcher {}

2
lib/Scope/Matchers/GroupMatcher.php

@ -16,7 +16,7 @@ class GroupMatcher extends Matcher {
}
public function matches(array $scopes): bool {
return $this->selector->matches($scope);
return $this->selector->matches($scopes);
}
public function getPrefix(array $scopes): string|null|false {

2
lib/Scope/Matchers/NegateMatcher.php

@ -17,7 +17,7 @@ class NegateMatcher extends Matcher {
return !($this->matcher->matches($scopes));
}
public function getPrefix(array $scopes): null {
public function getPrefix(array $scopes) {
return null;
}
}

2
lib/Scope/Matchers/ScopeMatcher.php

@ -17,7 +17,7 @@ class ScopeMatcher extends Matcher {
$lastDotIndex = 0;
$scopeLen = strlen($scope);
foreach ($this->segments as $index => $segment) {
if ($lastIndex > $scopeLen) {
if ($lastDotIndex > $scopeLen) {
break;
}

4
lib/Scope/Matchers/SegmentMatcher.php

@ -16,4 +16,8 @@ class SegmentMatcher extends Matcher {
public function matches(string $scope): bool {
return ($scope === $this->segment);
}
public function getPrefix(string $scope): string|null|false {
return null;
}
}

4
lib/Scope/Matchers/TrueMatcher.php

@ -16,4 +16,8 @@ class TrueMatcher extends Matcher {
public function matches(string $scope): bool {
return true;
}
public function getPrefix(string $scope): string|null|false {
return null;
}
}

5
lib/Scope/Parser.php

@ -131,6 +131,7 @@ class Parser {
$result = false;
$prefix = null;
$position = self::$instance->data->position;
$s2 = self::$instance->data->consumeIf('LRB');
if ($s2 === '' || $s2 === false) {
@ -167,6 +168,10 @@ class Parser {
self::fail('(');
}
if ($result === false) {
self::$instance->data->unconsumeTo($position);
}
if (self::$debug === true) {
self::debugResult($result);
}

Loading…
Cancel
Save