1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Cubiche package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) Cubiche |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
namespace Cubiche\Core\Selector; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Selector Builder Class. |
15
|
|
|
* |
16
|
|
|
* @method static Selectors key(string $name) |
17
|
|
|
* @method static Selectors property(string $name) |
18
|
|
|
* @method static Selectors method(string $name) |
19
|
|
|
* @method static Selectors custom(callable $callable) |
20
|
|
|
* @method static Selectors value($value) |
21
|
|
|
* @method static Selectors count() |
22
|
|
|
* @method static Selectors composite(SelectorInterface $x, SelectorInterface $y) |
23
|
|
|
* @method static Selectors this() |
24
|
|
|
* |
25
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class Selectors extends Selector |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var SelectorFactoryInterface |
31
|
|
|
*/ |
32
|
|
|
protected static $factory; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var SelectorInterface |
36
|
|
|
*/ |
37
|
|
|
private $selector; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return \Cubiche\Core\Selector\SelectorFactoryInterface |
41
|
|
|
*/ |
42
|
|
|
protected static function factory() |
43
|
|
|
{ |
44
|
|
|
if (self::$factory === null) { |
45
|
|
|
self::setFactory(new SelectorFactory(__NAMESPACE__)); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return self::$factory; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param SelectorFactoryInterface $factory |
53
|
|
|
*/ |
54
|
|
|
public static function setFactory(SelectorFactoryInterface $factory) |
55
|
|
|
{ |
56
|
|
|
self::$factory = $factory; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string $selectorClass |
61
|
|
|
* @param string $selectorName |
62
|
|
|
*/ |
63
|
|
|
public static function addSelector($selectorClass, $selectorName = null) |
64
|
|
|
{ |
65
|
|
|
self::factory()->addSelector($selectorClass, $selectorName); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $namespace |
70
|
|
|
*/ |
71
|
|
|
public static function addNamespace($namespace) |
72
|
|
|
{ |
73
|
|
|
self::factory()->addNamespace($namespace); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param SelectorInterface $selector |
78
|
|
|
*/ |
79
|
|
|
protected function __construct(SelectorInterface $selector) |
80
|
|
|
{ |
81
|
|
|
$this->selector = $selector; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $method |
86
|
|
|
* @param array $arguments |
87
|
|
|
* |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
|
|
public static function __callStatic($method, $arguments) |
91
|
|
|
{ |
92
|
|
|
return new static(self::factory()->create($method, $arguments)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $method |
97
|
|
|
* @param array $args |
|
|
|
|
98
|
|
|
* |
99
|
|
|
* @return mixed |
100
|
|
|
*/ |
101
|
|
|
public function __call($method, $arguments) |
102
|
|
|
{ |
103
|
|
|
return $this->select(self::factory()->create($method, $arguments)); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritdoc} |
108
|
|
|
*/ |
109
|
|
|
public function apply($value) |
110
|
|
|
{ |
111
|
|
|
return $this->selector()->apply($value); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritdoc} |
116
|
|
|
*/ |
117
|
|
|
public function select(SelectorInterface $selector) |
118
|
|
|
{ |
119
|
|
|
$this->selector = $this->selector()->select($selector); |
120
|
|
|
|
121
|
|
|
return $this; |
|
|
|
|
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param SelectorVisitorInterface $visitor |
126
|
|
|
* |
127
|
|
|
* @return mixed |
128
|
|
|
*/ |
129
|
|
|
public function acceptSelectorVisitor(SelectorVisitorInterface $visitor) |
130
|
|
|
{ |
131
|
|
|
return $this->selector()->acceptSelectorVisitor($visitor); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return \Cubiche\Core\Selector\SelectorInterface |
136
|
|
|
*/ |
137
|
|
|
public function selector() |
138
|
|
|
{ |
139
|
|
|
return $this->selector; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.