TextMate-style syntax highlighting in PHP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
846 B

<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE file for details */
declare(strict_types=1);
namespace dW\Lit\Scope;
class AndMatcher extends Matcher {
protected array $matchers = [];
public function __construct(Matcher ...$matchers) {
$this->matchers = $matchers;
}
public function add(Matcher $matcher) {
$this->matchers[] = $matcher;
}
public function matches(string ...$scopes): bool {
foreach ($this->matchers as $m) {
if (!$m->matches(...$scopes)) {
return false;
}
}
return true;
}
public function getPrefix(string ...$scopes): string|null|false {
if ($this->matches(...$scopes)) {
return $this->matches[0]->getPrefix(...$scopes);
}
return null;
}
}