Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Property/Selector/SelectorComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Sabberworm\CSS\Property\Selector;

/**
* This interface is for a class that represents a part of a selector which is either a compound selector (or a simple
* selector, which is effectively a compound selector without any compounding) or a selector combinator.
*
* It allows a selector to be represented as an array of objects that implement this interface.
* This is the formal definition:
* selector = compound-selector [combinator, compound-selector]*
*
* The selector is comprised of an array of alternating types that can't be easily represented in a type-safe manner
* without this.
*
* 'Selector component' is not a known grammar in the spec, but a convenience for the implementation.
*
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Selectors/Selector_structure
* @see https://www.w3.org/TR/selectors-4/#structure
*/
interface SelectorComponent
Comment thread
oliverklee marked this conversation as resolved.
{
/**
* @return non-empty-string
*/
public function getValue(): string;

/**
* @param non-empty-string $value
*/
public function setValue(string $value): void;

/**
* @return int<0, max>
*/
public function getSpecificity(): int;
}