1 | <?php |
||
18 | class Proxy extends \ArrayObject implements DOMElement, SimpleXMLElement { |
||
19 | |||
20 | use \arc\traits\Proxy { |
||
21 | \arc\traits\Proxy::__construct as private ProxyConstruct; |
||
22 | \arc\traits\Proxy::__call as private ProxyCall; |
||
23 | } |
||
24 | |||
25 | private $parser = null; |
||
26 | |||
27 | 16 | public function __construct( $node, $parser) { |
|
31 | |||
32 | 2 | public function __toString() { |
|
35 | |||
36 | 8 | private function _isDomProperty( $name ) { |
|
45 | |||
46 | 8 | private function _getTargetProperty($name) { |
|
47 | 8 | $value = null; |
|
48 | 8 | if ( $name[0] == '{' ) { |
|
49 | 2 | list($ns, $name) = explode('}', $name); |
|
50 | 2 | $ns = substr($ns, 1); |
|
|
|||
51 | 2 | $value = $this->target->children($ns, false)->{$name}; |
|
52 | 8 | } else if ( strpos($name, ':') !== false ) { |
|
53 | 2 | list ($ns, $name) = explode(':', $name); |
|
54 | 2 | if ( isset($this->parser->namespaces[$ns]) ) { |
|
55 | 2 | $ns = $this->parser->namespaces[$ns]; |
|
56 | 2 | $prefix = false; |
|
57 | 1 | } else { |
|
58 | $prefix = true; |
||
59 | } |
||
60 | 2 | $value = $this->target->children($ns, $prefix)->{$name}; |
|
61 | 8 | } else if ( !$this->_isDomProperty($name) ) { |
|
62 | 8 | $value = $this->target->{$name}; |
|
63 | 4 | } else { |
|
64 | 2 | $dom = dom_import_simplexml($this->target); |
|
65 | 2 | if ( isset($dom) ) { |
|
66 | 2 | $value = $dom->{$name}; |
|
67 | 1 | } |
|
68 | } |
||
69 | 8 | return $value; |
|
70 | } |
||
71 | |||
72 | 16 | private function _proxyResult( $value ) { |
|
91 | |||
92 | 14 | public function __get( $name) { |
|
98 | |||
99 | 4 | private function _domCall( $name, $args ) { |
|
120 | |||
121 | 4 | public function __call( $name, $args ) { |
|
128 | |||
129 | /** |
||
130 | * Search through the XML DOM with a single CSS selector |
||
131 | * @param string $query the CSS selector, most CSS 2 selectors work |
||
132 | * @return Proxy |
||
133 | */ |
||
134 | 8 | public function find( $query) { |
|
138 | |||
139 | /** |
||
140 | * Searches through the subtree for an element with the given id and returns it |
||
141 | * @param string $id |
||
142 | * @return Proxy |
||
143 | */ |
||
144 | 2 | public function getElementById( $id ) { |
|
147 | |||
148 | /** |
||
149 | * Register a namespace alias and URI to use in xpath and find |
||
150 | * @param string $prefix the alias for this namespace |
||
151 | * @param string $ns the URI for this namespace |
||
152 | */ |
||
153 | 2 | public function registerNamespace( $prefix, $ns ) { |
|
159 | |||
160 | 4 | public function offsetGet( $offset ) |
|
164 | |||
165 | 2 | public function offsetSet( $offset, $value ) |
|
169 | |||
170 | public function offsetUnset( $offset ) |
||
174 | } |
||
175 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.