1 | <?php |
||
22 | abstract class Node implements VisitableInterface, |
||
23 | GenerateCSSInterface, CompilableInterface |
||
24 | { |
||
25 | /** |
||
26 | * The value. |
||
27 | * |
||
28 | * @var Node|string |
||
29 | */ |
||
30 | public $value; |
||
31 | |||
32 | /** |
||
33 | * ILess\Debug information. |
||
34 | * |
||
35 | * @var DebugInfo |
||
36 | */ |
||
37 | public $debugInfo; |
||
38 | |||
39 | /** |
||
40 | * The node type. Each node should define the type. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $type; |
||
45 | |||
46 | /** |
||
47 | * Current file info. |
||
48 | * |
||
49 | * @var FileInfo |
||
50 | */ |
||
51 | public $currentFileInfo; |
||
52 | |||
53 | /** |
||
54 | * @var bool |
||
55 | */ |
||
56 | public $compileFirst = false; |
||
57 | |||
58 | /** |
||
59 | * Constructor. |
||
60 | * |
||
61 | * @param mixed $value |
||
62 | */ |
||
63 | public function __construct($value) |
||
67 | |||
68 | /** |
||
69 | * Returns the node type. |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getType() |
||
77 | |||
78 | /** |
||
79 | * Checks if given method exists. |
||
80 | * |
||
81 | * @param mixed $var The variable name |
||
82 | * @param string $methodName The method name |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | public static function methodExists($var, $methodName) |
||
90 | |||
91 | /** |
||
92 | * Checks if given property exists. |
||
93 | * |
||
94 | * @param mixed $var The variable to check |
||
95 | * @param string $property The property name |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | public static function propertyExists($var, $property) |
||
103 | |||
104 | /** |
||
105 | * Returns debug information for the node. |
||
106 | * |
||
107 | * @param Context $context The context |
||
108 | * @param Node $node The context node |
||
109 | * @param string $lineSeparator Line separator |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | public static function getDebugInfo(Context $context, Node $node, $lineSeparator = '') |
||
139 | |||
140 | /** |
||
141 | * Outputs the ruleset rules. |
||
142 | * |
||
143 | * @param Context $context |
||
144 | * @param OutputInterface $output |
||
145 | * @param array $rules |
||
146 | */ |
||
147 | public static function outputRuleset(Context $context, OutputInterface $output, array $rules) |
||
184 | |||
185 | /** |
||
186 | * Convert to string. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | public function toString() |
||
194 | |||
195 | /** |
||
196 | * Convert to string. |
||
197 | * |
||
198 | * @return string |
||
199 | */ |
||
200 | public function __toString() |
||
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | public function toCSS(Context $context) |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function accept(VisitorInterface $visitor) |
||
223 | |||
224 | /** |
||
225 | * Generate the CSS and put it in the output container. |
||
226 | * |
||
227 | * @param Context $context The context |
||
228 | * @param OutputInterface $output The output |
||
229 | */ |
||
230 | public function generateCSS(Context $context, OutputInterface $output) |
||
234 | |||
235 | /** |
||
236 | * Compiles the node. |
||
237 | * |
||
238 | * @param Context $context The context |
||
239 | * @param array|null $arguments Array of arguments |
||
240 | * @param bool|null $important Important flag |
||
241 | * |
||
242 | * @return Node |
||
243 | */ |
||
244 | public function compile(Context $context, $arguments = null, $important = null) |
||
248 | |||
249 | /** |
||
250 | * @return bool |
||
251 | */ |
||
252 | public function isRulesetLike() |
||
256 | |||
257 | /** |
||
258 | * @return bool |
||
259 | */ |
||
260 | public function compileFirst() |
||
264 | } |
||
265 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.