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.
 
 

38 lines
911 B

<?php
/** @license MIT
* Copyright 2021 Dustin Wilson et al.
* See LICENSE file for details */
declare(strict_types=1);
namespace MensBeam\Lit\Scope;
class Selector extends Node {
protected array $_composites = [];
public function __construct(Composite ...$composites) {
$this->_composites = $composites;
}
public function getPrefix(array $scopes): ?int {
$matches = $this->matches($scopes, $match);
return ($matches) ? $match->getPrefix($scopes) : null;
}
public function matches(array $scopes, ?Composite &$match = null): bool {
foreach ($this->_composites as $composite) {
if ($composite->matches($scopes)) {
$match = $composite;
return true;
}
}
return false;
}
public function __toString(): string {
return implode(', ', $this->_composites);
}
}