1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ILess |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace ILess\Node; |
11
|
|
|
|
12
|
|
|
use ILess\Context; |
13
|
|
|
use ILess\Node; |
14
|
|
|
use ILess\Output\OutputInterface; |
15
|
|
|
use ILess\Visitor\VisitorInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Value. |
19
|
|
|
*/ |
20
|
|
|
class ValueNode extends Node |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Node type. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $type = 'Value'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Constructor. |
31
|
|
|
* |
32
|
|
|
* @param array $value Array of value |
33
|
|
|
*/ |
34
|
|
|
public function __construct(array $value) |
35
|
|
|
{ |
36
|
|
|
parent::__construct($value); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function accept(VisitorInterface $visitor) |
43
|
|
|
{ |
44
|
|
|
$this->value = $visitor->visitArray($this->value); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Compiles the node. |
49
|
|
|
* |
50
|
|
|
* @param Context $context The context |
51
|
|
|
* @param array|null $arguments Array of arguments |
52
|
|
|
* @param bool|null $important Important flag |
53
|
|
|
* |
54
|
|
|
* @return ValueNode |
55
|
|
|
*/ |
56
|
|
|
public function compile(Context $context, $arguments = null, $important = null) |
57
|
|
|
{ |
58
|
|
|
if (count($this->value) == 1) { |
59
|
|
|
return $this->value[0]->compile($context); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$return = []; |
63
|
|
|
foreach ($this->value as $v) { |
|
|
|
|
64
|
|
|
$return[] = $v->compile($context); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return new self($return); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public function generateCSS(Context $context, OutputInterface $output) |
74
|
|
|
{ |
75
|
|
|
for ($i = 0, $count = count($this->value); $i < $count; ++$i) { |
76
|
|
|
$this->value[$i]->generateCSS($context, $output); |
77
|
|
|
if ($i + 1 < $count) { |
78
|
|
|
$output->add($context->compress ? ',' : ', '); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: