| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\RemexHtml\Tokenizer; |
| 4 |
|
| 5 |
/** |
| 6 |
* Interface for attributes emitted by the tokenizer |
| 7 |
*/ |
| 8 |
interface Attributes extends \ArrayAccess, \IteratorAggregate { |
| 9 |
/** |
| 10 |
* Get the attributes as a key/value array |
| 11 |
* @return string[] |
| 12 |
*/ |
| 13 |
public function getValues(); |
| 14 |
|
| 15 |
/** |
| 16 |
* Get the attributes as an array of Attribute objects |
| 17 |
* @return Attribute[] |
| 18 |
*/ |
| 19 |
public function getObjects(); |
| 20 |
|
| 21 |
/** |
| 22 |
* Get the number of attributes. This may include duplicates, and so may |
| 23 |
* be larger than count( $this->getValues() ). Including duplicates |
| 24 |
* gives us an efficient way to distinguish zero attributes from non-zero |
| 25 |
* but is not compliant with the spec, which states that duplicate |
| 26 |
* attributes must be removed. |
| 27 |
* |
| 28 |
* @return int |
| 29 |
*/ |
| 30 |
public function count(); |
| 31 |
|
| 32 |
/** |
| 33 |
* Add any attributes in the argument to $this, but if an attribute of the |
| 34 |
* same name already exists, do not overwrite it. |
| 35 |
* |
| 36 |
* @param Attributes $other |
| 37 |
*/ |
| 38 |
public function merge( Attributes $other ); |
| 39 |
|
| 40 |
/** |
| 41 |
* It's efficient to assume that attributes are immutable when cloning |
| 42 |
* nodes due to AFE reconstruction or AAA. So by default, this returns |
| 43 |
* $this. But users can override it if attribute cloning needs special |
| 44 |
* handling. |
| 45 |
* |
| 46 |
* @return Attributes |
| 47 |
*/ |
| 48 |
public function clone(); |
| 49 |
} |