Browse Source

Typing fixes in scope matchers

main
Dustin Wilson 3 years ago
parent
commit
dff3d622fe
  1. 10
      lib/Scope/Matchers/AndMatcher.php
  2. 8
      lib/Scope/Matchers/CompositeMatcher.php
  3. 8
      lib/Scope/Matchers/GroupMatcher.php
  4. 6
      lib/Scope/Matchers/NegateMatcher.php
  5. 8
      lib/Scope/Matchers/OrMatcher.php
  6. 4
      lib/Scope/Matchers/PathMatcher.php

10
lib/Scope/Matchers/AndMatcher.php

@ -15,13 +15,13 @@ class AndMatcher extends Matcher {
$this->right = $right;
}
public function matches(array $scopes): bool {
return ($this->left->matches($scopes) && $this->right->matches($scopes));
public function matches(string ...$scopes): bool {
return ($this->left->matches(...$scopes) && $this->right->matches(...$scopes));
}
public function getPrefix(array $scopes): string|null|false {
if ($this->left->matches($scopes) && $this->right->matches($scopes)) {
return $this->left->getPrefix($scopes);
public function getPrefix(string ...$scopes): string|null|false {
if ($this->left->matches(...$scopes) && $this->right->matches(...$scopes)) {
return $this->left->getPrefix(...$scopes);
}
}
}

8
lib/Scope/Matchers/CompositeMatcher.php

@ -23,11 +23,11 @@ class CompositeMatcher extends Matcher {
}
}
public function matches(array $scopes): bool {
return $this->matcher->matches($scopes);
public function matches(string ...$scopes): bool {
return $this->matcher->matches(...$scopes);
}
public function getPrefix(array $scopes): string|null|false {
return $this->matcher->getPrefix($scopes);
public function getPrefix(string ...$scopes): string|null|false {
return $this->matcher->getPrefix(...$scopes);
}
}

8
lib/Scope/Matchers/GroupMatcher.php

@ -15,12 +15,12 @@ class GroupMatcher extends Matcher {
$this->selector = $selector;
}
public function matches(array $scopes): bool {
return $this->selector->matches($scopes);
public function matches(string ...$scopes): bool {
return $this->selector->matches(...$scopes);
}
public function getPrefix(array $scopes): string|null|false {
if ($this->selector->matches($scopes)) {
public function getPrefix(string ...$scopes): string|null|false {
if ($this->selector->matches(...$scopes)) {
return $this->prefix;
}
}

6
lib/Scope/Matchers/NegateMatcher.php

@ -13,11 +13,11 @@ class NegateMatcher extends Matcher {
$this->matcher = $matcher;
}
public function matches(array $scopes): bool {
return !($this->matcher->matches($scopes));
public function matches(string ...$scopes): bool {
return !($this->matcher->matches(...$scopes));
}
public function getPrefix(array $scopes) {
public function getPrefix(string ...$scopes) {
return null;
}
}

8
lib/Scope/Matchers/OrMatcher.php

@ -15,11 +15,11 @@ class OrMatcher extends Matcher {
$this->right = $right;
}
public function matches(array $scopes): bool {
return ($this->left->matches($scopes) || $this->right->matches($scopes));
public function matches(string ...$scopes): bool {
return ($this->left->matches(...$scopes) || $this->right->matches(...$scopes));
}
public function getPrefix(array $scopes): string|null|false {
return $this->left->getPrefix($scopes) || $this->right->getPrefix($scopes);
public function getPrefix(string ...$scopes): string|null|false {
return $this->left->getPrefix(...$scopes) || $this->right->getPrefix(...$scopes);
}
}

4
lib/Scope/Matchers/PathMatcher.php

@ -15,7 +15,7 @@ class PathMatcher extends Matcher {
$this->matchers = $matchers;
}
public function matches(array $scopes): bool {
public function matches(string ...$scopes): bool {
$count = 0;
$matcher = $this->matchers[$count];
foreach ($scopes as $scope) {
@ -29,7 +29,7 @@ class PathMatcher extends Matcher {
return false;
}
public function getPrefix(array $scopes): string|null|false {
public function getPrefix(string ...$scopes): string|null|false {
if ($this->matches($scopes)) {
return $this->prefix;
}

Loading…
Cancel
Save