This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Gwa\Wordpress\WpBridge; |
||
3 | |||
4 | use Gwa\Wordpress\WpBridge\Contracts\WpBridgeInterface; |
||
5 | use Mockery; |
||
6 | |||
7 | class MockeryWpBridge implements WpBridgeInterface |
||
8 | { |
||
9 | /** |
||
10 | * Mockery instance. |
||
11 | * |
||
12 | * @var \Mockery |
||
13 | */ |
||
14 | private $mock; |
||
15 | |||
16 | /** |
||
17 | * All shortcodes. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | private $shortcodes = []; |
||
22 | |||
23 | /** |
||
24 | * All filters. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | private $filters = []; |
||
29 | |||
30 | /** |
||
31 | * All actions. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | private $actions = []; |
||
36 | |||
37 | /** |
||
38 | * Add a shortcode. |
||
39 | * |
||
40 | * @param string $tag |
||
41 | * |
||
42 | * @param mixed $func |
||
43 | */ |
||
44 | public function addShortcode($tag, $func) |
||
45 | { |
||
46 | $this->shortcodes[$tag] = $func; |
||
47 | |||
48 | return $this; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Check if shortcode exist. |
||
53 | * |
||
54 | * @param string $tag |
||
55 | * |
||
56 | * @return boolean |
||
57 | */ |
||
58 | public function hasShortcode($tag) |
||
59 | { |
||
60 | return isset($this->shortcodes[$tag]); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Get a shortcode callback. |
||
65 | * |
||
66 | * @param string $tag |
||
67 | * |
||
68 | * @return mixed |
||
69 | */ |
||
70 | public function getShortcodeCallback($tag) |
||
71 | { |
||
72 | return isset($this->shortcodes[$tag]) ? $this->shortcodes[$tag] : null; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Combines shortcode attributes with known attributes and fills in defaults when needed. |
||
77 | * |
||
78 | * @param array $pairs |
||
79 | * @param array $atts |
||
80 | * @param string|null $shortcode |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | public function shortcodeAtts($pairs, $atts, $shortcode = null) |
||
0 ignored issues
–
show
|
|||
85 | { |
||
86 | return array_merge($pairs, $atts); |
||
87 | } |
||
88 | |||
89 | /* -------- */ |
||
90 | |||
91 | /** |
||
92 | * Wordpress mock on __() func. |
||
93 | * |
||
94 | * @param string $text |
||
95 | * @param string $domain |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | public function __($text, $domain) |
||
0 ignored issues
–
show
|
|||
100 | { |
||
101 | return $text; |
||
102 | } |
||
103 | |||
104 | /* -------- */ |
||
105 | |||
106 | /** |
||
107 | * Wordpress mock on add_filter func. |
||
108 | * |
||
109 | * @param string $filterName |
||
110 | * @param callback $filterCall |
||
111 | * @param int $prio |
||
112 | * @param int $numVars |
||
113 | * |
||
114 | * @return self |
||
115 | */ |
||
116 | public function addFilter($filterName, $filterCall, $prio, $numVars) |
||
117 | { |
||
118 | $this->filters[] = $this->add($filterName, $filterCall, $prio, $numVars); |
||
119 | |||
120 | return $this; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Get all added filters. |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | public function getAddedFilters() |
||
129 | { |
||
130 | return $this->filters; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Wordpress mock on add_action func. |
||
135 | * |
||
136 | * @param string $filterName |
||
137 | * @param callback $filterCall |
||
138 | * @param int $prio |
||
139 | * @param int $numVars |
||
140 | * |
||
141 | * @return self |
||
142 | */ |
||
143 | public function addAction($filterName, $filterCall, $prio, $numVars) |
||
144 | { |
||
145 | $this->actions[] = $this->add($filterName, $filterCall, $prio, $numVars); |
||
146 | |||
147 | return $this; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Get added actions |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | public function getAddedActions() |
||
156 | { |
||
157 | return $this->actions; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * add |
||
162 | * |
||
163 | * @param string $filterName |
||
164 | * @param callback $filterCall |
||
165 | * @param int $prio |
||
166 | * @param int $numVars |
||
167 | * |
||
168 | * @return \stdClass |
||
169 | */ |
||
170 | private function add($filterName, $filterCall, $prio, $numVars) |
||
171 | { |
||
172 | $data = new \stdClass(); |
||
173 | $data->filtername = $filterName; |
||
174 | $data->callback = $filterCall; |
||
175 | $data->prio = $prio; |
||
176 | $data->numvars = $numVars; |
||
177 | |||
178 | return $data; |
||
179 | } |
||
180 | |||
181 | public function __call($function, $args) |
||
182 | { |
||
183 | return call_user_func_array([$this->mock, $function], $args); |
||
184 | } |
||
185 | |||
186 | public function mock() |
||
187 | { |
||
188 | if (!isset($this->mock)) { |
||
189 | $this->mock = Mockery::mock('WpBridge'); |
||
190 | } |
||
191 | |||
192 | return $this->mock; |
||
193 | } |
||
194 | } |
||
195 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.