1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @file |
||
5 | * Contains SetXMLPropertyTask. |
||
6 | */ |
||
7 | |||
8 | require_once 'phing/Task.php'; |
||
9 | |||
10 | /** |
||
11 | * A Phing task to set the value of an XML element attribute. |
||
12 | */ |
||
13 | class SetXMLPropertyTask extends Task { |
||
0 ignored issues
–
show
|
|||
14 | |||
15 | /** |
||
16 | * The XML file path. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $file; |
||
21 | |||
22 | /** |
||
23 | * The XPath query for the element to change. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $element; |
||
28 | |||
29 | /** |
||
30 | * The attribute to change. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $attribute; |
||
35 | |||
36 | /** |
||
37 | * The value to set. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $value; |
||
42 | |||
43 | /** |
||
44 | * Sets the XML file path. |
||
45 | * |
||
46 | * @param string $file |
||
47 | * The XML file path. |
||
48 | */ |
||
49 | public function setFile($file) { |
||
50 | $this->file = $file; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Sets the XPath element query. |
||
55 | * |
||
56 | * @param string $element |
||
57 | * The XPath element query. |
||
58 | */ |
||
59 | public function setElement($element) { |
||
60 | $this->element = $element; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Sets the attribute to change. |
||
65 | * |
||
66 | * @param string $attribute |
||
67 | * The attribute to change. |
||
68 | */ |
||
69 | public function setAttribute($attribute) { |
||
70 | $this->attribute = $attribute; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Sets the value to set. |
||
75 | * |
||
76 | * @param string $value |
||
77 | * The value to set. |
||
78 | */ |
||
79 | public function setValue($value) { |
||
80 | $this->value = $value; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function main() { |
||
87 | $doc = new DOMDocument(); |
||
88 | $doc->load($this->file); |
||
89 | |||
90 | (new DOMXPath($doc)) |
||
91 | ->query($this->element) |
||
92 | ->item(0) |
||
93 | ->setAttribute($this->attribute, $this->value); |
||
94 | |||
95 | $doc->save($this->file); |
||
96 | } |
||
97 | |||
98 | } |
||
99 |
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