| 1 | <?php |
| 2 | |
| 3 | namespace Cite; |
| 4 | |
| 5 | /** |
| 6 | * Internal data container for a single <ref> tag and all information about it. |
| 7 | * |
| 8 | * @license GPL-2.0-or-later |
| 9 | */ |
| 10 | class ReferenceStackItem { |
| 11 | /** |
| 12 | * @var int How often a reference footnote mark appears. Can be 0 in the case |
| 13 | * of not-yet-used or unused list-defined references, or sub-ref parents. |
| 14 | */ |
| 15 | public int $count = 0; |
| 16 | /** |
| 17 | * @var ?string Direction of the text. Should either be "ltr", "rtl" or null |
| 18 | * if unspecified. |
| 19 | */ |
| 20 | public ?string $dir = null; |
| 21 | /** |
| 22 | * @var ?string Marks a sub-reference. Points to the parent reference by name. |
| 23 | */ |
| 24 | public ?string $extends = null; |
| 25 | /** |
| 26 | * @var ?int Count how many subreferences point to a parent. Corresponds to |
| 27 | * the last {@see extendsIndex} but this field belongs to the parent. |
| 28 | */ |
| 29 | public ?int $extendsCount = null; |
| 30 | /** |
| 31 | * @var ?int Sequence number for sub-references with the same extends |
| 32 | * attribute value, starting from 1. {@see number} and this extends index are |
| 33 | * combined to render a footnote marker like "[1.1]". |
| 34 | */ |
| 35 | public ?int $extendsIndex = null; |
| 36 | /** |
| 37 | * @var ?string Marks a "follow" ref which continues the ref text from a |
| 38 | * previous page, e.g. in the Page:… namespace on Wikisource. |
| 39 | */ |
| 40 | public ?string $follow = null; |
| 41 | /** |
| 42 | * @var string Name of the group (or empty for the default group) which this ref |
| 43 | * belongs to. |
| 44 | */ |
| 45 | public string $group; |
| 46 | /** |
| 47 | * @var int Sequence number for all references, no matter which group, starting |
| 48 | * from 1. Used to generate IDs and anchors. |
| 49 | */ |
| 50 | public int $key; |
| 51 | /** |
| 52 | * @var ?string The original name attribute of a reference, or null for anonymous |
| 53 | * references. |
| 54 | */ |
| 55 | public ?string $name = null; |
| 56 | /** |
| 57 | * @var ?int Sequence number per {@see group}, starting from 1. To be used in the |
| 58 | * footnote marker, eg "[1]". |
| 59 | */ |
| 60 | public ?int $number = null; |
| 61 | /** |
| 62 | * @var bool Temporarily marks an incomplete parent ref referenced via |
| 63 | * {@see extends} before it exists. |
| 64 | */ |
| 65 | public bool $placeholder = false; |
| 66 | /** |
| 67 | * @var ?string The content inside the <ref>…</ref> tag. Null for a |
| 68 | * self-closing <ref /> without content. Also null for <ref></ref> without any |
| 69 | * non-whitespace content. |
| 70 | */ |
| 71 | public ?string $text = null; |
| 72 | /** |
| 73 | * @var array Error messages attached to this reference. |
| 74 | */ |
| 75 | public array $warnings = []; |
| 76 | } |