1 | <?php |
||
22 | class DirectiveNode extends Node implements |
||
23 | MarkableAsReferencedInterface, ReferencedInterface |
||
24 | { |
||
25 | /** |
||
26 | * The type. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $type = 'Directive'; |
||
31 | |||
32 | /** |
||
33 | * The directive name. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | public $name; |
||
38 | |||
39 | /** |
||
40 | * Array of rules. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | public $rules = []; |
||
45 | |||
46 | /** |
||
47 | * Current index. |
||
48 | * |
||
49 | * @var int |
||
50 | */ |
||
51 | public $index = 0; |
||
52 | |||
53 | /** |
||
54 | * Array of variables. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $variables; |
||
59 | |||
60 | /** |
||
61 | * Is referenced? |
||
62 | * |
||
63 | * @var bool |
||
64 | */ |
||
65 | public $isReferenced = false; |
||
66 | |||
67 | /** |
||
68 | * @var bool |
||
69 | */ |
||
70 | public $isRooted = false; |
||
71 | |||
72 | /** |
||
73 | * @var array |
||
74 | */ |
||
75 | public $allExtends = []; |
||
76 | |||
77 | /** |
||
78 | * Constructor. |
||
79 | * |
||
80 | * @param string $name The name |
||
81 | * @param array|string $value The value |
||
82 | * @param RulesetNode|null|array $rules |
||
83 | * @param int $index The index |
||
84 | * @param FileInfo $currentFileInfo Current file info |
||
85 | * @param DebugInfo $debugInfo The debug information |
||
86 | * @param bool $isReferenced Is referenced? |
||
87 | * @param bool $isRooted Is rooted? |
||
88 | */ |
||
89 | public function __construct( |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function accept(VisitorInterface $visitor) |
||
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | public function generateCSS(Context $context, OutputInterface $output) |
||
161 | |||
162 | /** |
||
163 | * Compiles the node. |
||
164 | * |
||
165 | * @param Context $context The context |
||
166 | * @param array|null $arguments Array of arguments |
||
167 | * @param bool|null $important Important flag |
||
168 | * |
||
169 | * @return DirectiveNode |
||
170 | */ |
||
171 | public function compile(Context $context, $arguments = null, $important = null) |
||
199 | |||
200 | /** |
||
201 | * Returns the variable. |
||
202 | * |
||
203 | * @param string $name |
||
204 | * |
||
205 | * @return RuleNode|null |
||
206 | */ |
||
207 | public function variable($name) |
||
214 | |||
215 | /** |
||
216 | * Finds a selector. |
||
217 | * |
||
218 | * @param Node $selector |
||
219 | * @param Context $context |
||
220 | * @param null $filter |
||
221 | * |
||
222 | * @return mixed |
||
223 | */ |
||
224 | public function find(Node $selector, Context $context, $filter = null) |
||
231 | |||
232 | /** |
||
233 | * Returns the rulesets. |
||
234 | */ |
||
235 | public function rulesets() |
||
242 | |||
243 | /** |
||
244 | * Mark the directive as referenced. |
||
245 | */ |
||
246 | public function markReferenced() |
||
257 | |||
258 | /** |
||
259 | * Is the directive charset directive? |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | public function isCharset() |
||
267 | |||
268 | /** |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function isRulesetLike() |
||
275 | |||
276 | /** |
||
277 | * @return bool |
||
278 | */ |
||
279 | public function getIsReferenced() |
||
283 | } |
||
284 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: