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 | /** |
||
3 | * Main definition for Assertion. Define core methods and properties here. |
||
4 | */ |
||
5 | use Peridot\Leo\Assertion; |
||
6 | use Peridot\Leo\Matcher\EmptyMatcher; |
||
7 | use Peridot\Leo\Matcher\EqualMatcher; |
||
8 | use Peridot\Leo\Matcher\ExceptionMatcher; |
||
9 | use Peridot\Leo\Matcher\InclusionMatcher; |
||
10 | use Peridot\Leo\Matcher\InstanceofMatcher; |
||
11 | use Peridot\Leo\Matcher\KeysMatcher; |
||
12 | use Peridot\Leo\Matcher\LengthMatcher; |
||
13 | use Peridot\Leo\Matcher\NullMatcher; |
||
14 | use Peridot\Leo\Matcher\PatternMatcher; |
||
15 | use Peridot\Leo\Matcher\PredicateMatcher; |
||
16 | use Peridot\Leo\Matcher\PropertyMatcher; |
||
17 | use Peridot\Leo\Matcher\RangeMatcher; |
||
18 | use Peridot\Leo\Matcher\SameMatcher; |
||
19 | use Peridot\Leo\Matcher\SubStringMatcher; |
||
20 | use Peridot\Leo\Matcher\TrueMatcher; |
||
21 | use Peridot\Leo\Matcher\TruthyMatcher; |
||
22 | use Peridot\Leo\Matcher\TypeMatcher; |
||
23 | |||
24 | return function (Assertion $assertion) { |
||
25 | /* |
||
26 | * Default language chains. |
||
27 | */ |
||
28 | $chains = [ |
||
29 | 'to', 'be', 'been', |
||
30 | 'is', 'and', 'has', |
||
31 | 'have', 'with', 'that', |
||
32 | 'at', 'of', 'same', |
||
33 | 'an', 'a', |
||
34 | ]; |
||
35 | |||
36 | foreach ($chains as $chain) { |
||
37 | $assertion->addProperty($chain, function () { |
||
38 | return $this; |
||
0 ignored issues
–
show
|
|||
39 | }, true); |
||
40 | } |
||
41 | |||
42 | $assertion->addProperty('not', function () { |
||
43 | return $this->flag('not', true); |
||
0 ignored issues
–
show
|
|||
44 | }); |
||
45 | |||
46 | $assertion->addMethod('with', function () { |
||
47 | return $this->flag('arguments', func_get_args()); |
||
0 ignored issues
–
show
|
|||
48 | }); |
||
49 | |||
50 | $assertion->addProperty('loosely', function () { |
||
51 | return $this->flag('loosely', true); |
||
0 ignored issues
–
show
|
|||
52 | }); |
||
53 | |||
54 | $assertion->addMethod('equal', function ($expected, $message = '') { |
||
55 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
56 | if ($this->flag('loosely')) { |
||
57 | return new EqualMatcher($expected); |
||
58 | } |
||
59 | |||
60 | return new SameMatcher($expected); |
||
61 | }); |
||
62 | |||
63 | $assertion->addMethod('throw', function ($exceptionType, $exceptionMessage = '', $message = '') { |
||
64 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
65 | $matcher = new ExceptionMatcher($exceptionType); |
||
66 | $matcher->setExpectedMessage($exceptionMessage); |
||
67 | $matcher->setArguments($this->flag('arguments') ?: []); |
||
68 | |||
69 | return $matcher; |
||
70 | }); |
||
71 | |||
72 | $type = function ($expected, $message = '') { |
||
73 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
74 | |||
75 | return new TypeMatcher($expected); |
||
76 | }; |
||
77 | |||
78 | $assertion |
||
79 | ->addMethod('a', $type) |
||
80 | ->addMethod('an', $type); |
||
81 | |||
82 | $include = function ($expected, $message = '') { |
||
83 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
84 | |||
85 | return new InclusionMatcher($expected); |
||
86 | }; |
||
87 | |||
88 | $assertion |
||
89 | ->addMethod('include', $include) |
||
90 | ->addMethod('contain', $include); |
||
91 | |||
92 | $contain = function () { |
||
93 | return $this->flag('contain', true); |
||
0 ignored issues
–
show
|
|||
94 | }; |
||
95 | |||
96 | $assertion |
||
97 | ->addProperty('contain', $contain) |
||
98 | ->addProperty('include', $contain); |
||
99 | |||
100 | $truthy = function ($message = '') { |
||
101 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
102 | |||
103 | return new TruthyMatcher(); |
||
104 | }; |
||
105 | |||
106 | $assertion |
||
107 | ->addMethod('ok', $truthy) |
||
108 | ->addProperty('ok', $truthy); |
||
109 | |||
110 | $true = function ($message = '') { |
||
111 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
112 | |||
113 | return new TrueMatcher(); |
||
114 | }; |
||
115 | |||
116 | $assertion |
||
117 | ->addMethod('true', $true) |
||
118 | ->addProperty('true', $true); |
||
119 | |||
120 | $false = function ($message = '') { |
||
121 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
122 | $matcher = new TrueMatcher(); |
||
123 | |||
124 | return $matcher->invert(); |
||
125 | }; |
||
126 | |||
127 | $assertion |
||
128 | ->addMethod('false', $false) |
||
129 | ->addProperty('false', $false); |
||
130 | |||
131 | $null = function ($message = '') { |
||
132 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
133 | |||
134 | return new NullMatcher(); |
||
135 | }; |
||
136 | |||
137 | $assertion |
||
138 | ->addMethod('null', $null) |
||
139 | ->addProperty('null', $null); |
||
140 | |||
141 | $empty = function ($message = '') { |
||
142 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
143 | |||
144 | return new EmptyMatcher(); |
||
145 | }; |
||
146 | |||
147 | $assertion |
||
148 | ->addMethod('empty', $empty) |
||
149 | ->addProperty('empty', $empty); |
||
150 | |||
151 | $assertion->addProperty('length', function () { |
||
152 | return $this->flag('length', $this->getActual()); |
||
0 ignored issues
–
show
|
|||
153 | }); |
||
154 | |||
155 | /* |
||
156 | * Define a helper for creating countable matchers. A countable |
||
157 | * matcher is a matcher that matches against a single numeric |
||
158 | * value, or a value that can be reduced to a single numeric value |
||
159 | * via the count() function. |
||
160 | * |
||
161 | * @param $className |
||
162 | * @return callable |
||
163 | */ |
||
164 | $countable = function ($className) { |
||
165 | return function ($expected, $message = '') use ($className) { |
||
166 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
167 | $class = "Peridot\\Leo\\Matcher\\$className"; |
||
168 | $matcher = new $class($expected); |
||
169 | if ($countable = $this->flag('length')) { |
||
170 | $matcher->setCountable($countable); |
||
171 | } |
||
172 | |||
173 | return $matcher; |
||
174 | }; |
||
175 | }; |
||
176 | |||
177 | $assertion->addMethod('above', $countable('GreaterThanMatcher')); |
||
178 | $assertion->addMethod('least', $countable('GreaterThanOrEqualMatcher')); |
||
179 | $assertion->addMethod('below', $countable('LessThanMatcher')); |
||
180 | $assertion->addMethod('most', $countable('LessThanOrEqualMatcher')); |
||
181 | |||
182 | $assertion->addMethod('within', function ($lower, $upper, $message = '') { |
||
183 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
184 | $matcher = new RangeMatcher($lower, $upper); |
||
185 | if ($countable = $this->flag('length')) { |
||
186 | $matcher->setCountable($countable); |
||
187 | } |
||
188 | |||
189 | return $matcher; |
||
190 | }); |
||
191 | |||
192 | $assertion->addMethod('instanceof', function ($expected, $message = '') { |
||
193 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
194 | |||
195 | return new InstanceofMatcher($expected); |
||
196 | }); |
||
197 | |||
198 | $assertion->addProperty('deep', function () { |
||
199 | return $this->flag('deep', true); |
||
0 ignored issues
–
show
|
|||
200 | }); |
||
201 | |||
202 | $assertion->addMethod('property', function ($name, $value = '', $message = '') { |
||
203 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
204 | $matcher = new PropertyMatcher($name, $value); |
||
205 | $matcher->setAssertion($this); |
||
206 | |||
207 | return $matcher->setIsDeep($this->flag('deep')); |
||
208 | }); |
||
209 | |||
210 | $assertion->addMethod('length', function ($expected, $message = '') { |
||
211 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
212 | |||
213 | return new LengthMatcher($expected); |
||
214 | }); |
||
215 | |||
216 | $assertion->addMethod('match', function ($pattern, $message = '') { |
||
217 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
218 | |||
219 | return new PatternMatcher($pattern); |
||
220 | }); |
||
221 | |||
222 | $assertion->addMethod('string', function ($expected, $message = '') { |
||
223 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
224 | |||
225 | return new SubStringMatcher($expected); |
||
226 | }); |
||
227 | |||
228 | $assertion->addMethod('keys', function (array $keys, $message = '') { |
||
229 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
230 | |||
231 | return new KeysMatcher($keys); |
||
232 | }); |
||
233 | |||
234 | $assertion->addMethod('satisfy', function (callable $predicate, $message = '') { |
||
235 | $this->flag('message', $message); |
||
0 ignored issues
–
show
|
|||
236 | |||
237 | return new PredicateMatcher($predicate); |
||
238 | }); |
||
239 | }; |
||
240 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.