1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Lagdo\UiBuilder; |
4
|
|
|
|
5
|
|
|
use AvpLab\Element\Comment; |
6
|
|
|
use AvpLab\Element\Element as Block; |
7
|
|
|
use AvpLab\Element\Text; |
8
|
|
|
use Lagdo\UiBuilder\Builder\Html\AbstractElement; |
9
|
|
|
use Lagdo\UiBuilder\Builder\Html\Element; |
10
|
|
|
use Lagdo\UiBuilder\Builder\Html\ElementExprEach; |
11
|
|
|
use Lagdo\UiBuilder\Builder\Html\ElementExprList; |
12
|
|
|
use Lagdo\UiBuilder\Builder\Html\ElementExprWhen; |
13
|
|
|
use Lagdo\UiBuilder\Builder\Html\HtmlBuilder; |
14
|
|
|
use Lagdo\UiBuilder\Element\ElementInterface; |
15
|
|
|
use Lagdo\UiBuilder\Element\ColInterface; |
16
|
|
|
use Lagdo\UiBuilder\Element\RowInterface; |
17
|
|
|
use Closure; |
18
|
|
|
|
19
|
|
|
abstract class AbstractBuilder implements BuilderInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var HtmlBuilder |
23
|
|
|
*/ |
24
|
|
|
protected $builder; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The constructor |
28
|
|
|
*/ |
29
|
|
|
public function __construct() |
30
|
|
|
{ |
31
|
|
|
$this->builder = new HtmlBuilder(); |
32
|
|
|
$this->builder->addElementBuilder('form', function(Element|null $element, |
33
|
|
|
string $tagName, string $method, array $arguments) { |
34
|
|
|
return $this->createFormElement($tagName, $arguments); |
35
|
|
|
}); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param string $method |
40
|
|
|
* @param array $arguments |
41
|
|
|
* |
42
|
|
|
* @return ElementInterface |
43
|
|
|
*/ |
44
|
|
|
public function __call(string $method, array $arguments): mixed |
45
|
|
|
{ |
46
|
|
|
return $this->builder->make($method, $arguments); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string $tagPrefix |
51
|
|
|
* @param Closure $tagBuilder |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function addElementBuilder(string $tagPrefix, Closure $tagBuilder) |
56
|
|
|
{ |
57
|
|
|
$this->builder->addElementBuilder($tagPrefix, $tagBuilder); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param string $name |
62
|
|
|
* |
63
|
|
|
* @return ElementInterface |
64
|
|
|
*/ |
65
|
|
|
public function tag(string $name, ...$arguments): ElementInterface |
66
|
|
|
{ |
67
|
|
|
return $this->builder->createElement($name, $arguments); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Create an element of a given class name |
72
|
|
|
* |
73
|
|
|
* @template T of Element |
74
|
|
|
* @psalm-param class-string<T> $class |
75
|
|
|
* @param array $arguments |
76
|
|
|
* |
77
|
|
|
* @return T |
|
|
|
|
78
|
|
|
*/ |
79
|
|
|
protected function createElementOfClass(string $class, $arguments): Element |
80
|
|
|
{ |
81
|
|
|
return $this->builder->createElement($class::$tag, $arguments, $class); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $tagName |
86
|
|
|
* @param array $arguments |
87
|
|
|
* |
88
|
|
|
* @return ElementInterface |
89
|
|
|
*/ |
90
|
|
|
abstract protected function createFormElement(string $tagName, $arguments): ElementInterface; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @inheritDoc |
94
|
|
|
*/ |
95
|
|
|
public function formRow(...$arguments): RowInterface |
96
|
|
|
{ |
97
|
|
|
return $this->row(...$arguments); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @inheritDoc |
102
|
|
|
*/ |
103
|
|
|
public function formCol(...$arguments): ColInterface |
104
|
|
|
{ |
105
|
|
|
return $this->col(...$arguments); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param array $values |
110
|
|
|
* @param Closure $closure |
111
|
|
|
* |
112
|
|
|
* @return ElementExprEach |
113
|
|
|
*/ |
114
|
|
|
public function each(array $values, Closure $closure): AbstractElement |
115
|
|
|
{ |
116
|
|
|
return new ElementExprEach($values, $closure); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return AbstractElement |
121
|
|
|
*/ |
122
|
|
|
public function list(...$arguments): AbstractElement |
123
|
|
|
{ |
124
|
|
|
return new ElementExprList($arguments); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param bool $condition |
129
|
|
|
* @param Closure $closure |
130
|
|
|
* |
131
|
|
|
* @return AbstractElement |
132
|
|
|
*/ |
133
|
|
|
public function when(bool $condition, Closure $closure): AbstractElement |
134
|
|
|
{ |
135
|
|
|
return new ElementExprWhen($condition, $closure); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @inheritDoc |
140
|
|
|
*/ |
141
|
|
|
public function text(string $text): Block |
142
|
|
|
{ |
143
|
|
|
return new Text($text); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @inheritDoc |
148
|
|
|
*/ |
149
|
|
|
public function html(string $html): Block |
150
|
|
|
{ |
151
|
|
|
return new Text($html, false); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @inheritDoc |
156
|
|
|
*/ |
157
|
|
|
public function comment(string $comment): Block |
158
|
|
|
{ |
159
|
|
|
return new Comment($comment); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @inheritDoc |
164
|
|
|
*/ |
165
|
|
|
public function build(...$arguments): string |
166
|
|
|
{ |
167
|
|
|
return $this->builder->build($arguments); |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths