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 | namespace spec\Prophecy\Prophecy; |
||
4 | |||
5 | use PhpSpec\Exception\Example\SkippingException; |
||
6 | use PhpSpec\ObjectBehavior; |
||
7 | use Prophecy\Argument; |
||
8 | use Prophecy\Argument\ArgumentsWildcard; |
||
9 | use Prophecy\Call\Call; |
||
10 | use Prophecy\Prediction\PredictionInterface; |
||
11 | use Prophecy\Promise\CallbackPromise; |
||
12 | use Prophecy\Promise\PromiseInterface; |
||
13 | use Prophecy\Prophecy\ObjectProphecy; |
||
14 | use ReflectionClass; |
||
15 | use RuntimeException; |
||
16 | |||
17 | class MethodProphecySpec extends ObjectBehavior |
||
18 | { |
||
19 | function let(ObjectProphecy $objectProphecy, ReflectionClass $reflection) |
||
20 | { |
||
21 | $objectProphecy->reveal()->willReturn($reflection); |
||
22 | |||
23 | $this->beConstructedWith($objectProphecy, 'getName', null); |
||
24 | } |
||
25 | |||
26 | function it_is_initializable() |
||
27 | { |
||
28 | $this->shouldHaveType('Prophecy\Prophecy\MethodProphecy'); |
||
29 | } |
||
30 | |||
31 | function its_constructor_throws_MethodNotFoundException_for_unexisting_method( |
||
32 | ObjectProphecy $objectProphecy, |
||
33 | ObjectProphecy $objectProphecyInner, |
||
34 | ReflectionClass $reflection |
||
35 | ) { |
||
36 | $objectProphecy->reveal()->willReturn($objectProphecyInner); |
||
37 | $objectProphecyInner->reveal()->willReturn($reflection); |
||
38 | $this->beConstructedWith($objectProphecy, 'getUnexisting', null); |
||
39 | $this->shouldThrow('Prophecy\Exception\Doubler\MethodNotFoundException')->duringInstantiation(); |
||
40 | } |
||
41 | |||
42 | function its_constructor_throws_MethodProphecyException_for_final_methods( |
||
43 | ObjectProphecy $objectProphecy, |
||
44 | ObjectProphecy $objectProphecyInner, |
||
45 | ClassWithFinalMethod $subject |
||
46 | ) { |
||
47 | $objectProphecy->reveal()->willReturn($objectProphecyInner); |
||
48 | $objectProphecyInner->reveal()->willReturn($subject); |
||
49 | |||
50 | $this->shouldThrow('Prophecy\Exception\Prophecy\MethodProphecyException')->during( |
||
51 | '__construct', array($objectProphecy, 'finalMethod', null) |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | function its_constructor_transforms_array_passed_as_3rd_argument_to_ArgumentsWildcard( |
||
56 | ObjectProphecy $objectProphecy |
||
57 | ) { |
||
58 | $this->beConstructedWith($objectProphecy, 'getName', array(42, 33)); |
||
59 | |||
60 | $wildcard = $this->getArgumentsWildcard(); |
||
61 | $wildcard->shouldNotBe(null); |
||
62 | $wildcard->__toString()->shouldReturn('exact(42), exact(33)'); |
||
63 | } |
||
64 | |||
65 | function its_constructor_does_not_touch_third_argument_if_it_is_null(ObjectProphecy $objectProphecy) |
||
66 | { |
||
67 | $this->beConstructedWith($objectProphecy, 'getName', null); |
||
68 | |||
69 | $wildcard = $this->getArgumentsWildcard(); |
||
70 | $wildcard->shouldBe(null); |
||
71 | } |
||
72 | |||
73 | View Code Duplication | function its_constructor_records_default_callback_promise_for_return_type_hinted_methods( |
|
74 | ObjectProphecy $objectProphecy, |
||
75 | $subject |
||
76 | ) { |
||
77 | if (PHP_VERSION_ID < 70100) { |
||
78 | throw new SkippingException('Return void type hint language feature only introduced in >=7.1'); |
||
79 | } |
||
80 | |||
81 | $subject->beADoubleOf('spec\Prophecy\Prophecy\ClassWithVoidTypeHintedMethods'); |
||
82 | $objectProphecy->addMethodProphecy(Argument::cetera())->willReturn(null); |
||
83 | $objectProphecy->reveal()->willReturn($subject); |
||
84 | |||
85 | $this->beConstructedWith($objectProphecy, 'getVoid'); |
||
86 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\CallbackPromise'); |
||
87 | } |
||
88 | |||
89 | View Code Duplication | function its_constructor_records_promise_that_returns_null_for_void_type_hinted_methods( |
|
90 | ObjectProphecy $objectProphecy, |
||
91 | $subject |
||
92 | ) { |
||
93 | if (PHP_VERSION_ID < 70100) { |
||
94 | throw new SkippingException('Return void type hint language feature only introduced in >=7.1'); |
||
95 | } |
||
96 | |||
97 | $subject->beADoubleOf('spec\Prophecy\Prophecy\ClassWithVoidTypeHintedMethods'); |
||
98 | $objectProphecy->addMethodProphecy(Argument::cetera())->willReturn(null); |
||
99 | $objectProphecy->reveal()->willReturn($subject); |
||
100 | |||
101 | $this->beConstructedWith($objectProphecy, 'getVoid'); |
||
102 | $this->getPromise()->execute(array(), $objectProphecy, $this)->shouldBeNull(); |
||
103 | } |
||
104 | |||
105 | View Code Duplication | function its_constructor_adds_itself_to_ObjectProphecy_for_return_type_hinted_methods( |
|
106 | ObjectProphecy $objectProphecy, |
||
107 | $subject |
||
108 | ) { |
||
109 | if (PHP_VERSION_ID < 70100) { |
||
110 | throw new SkippingException('Return void type hint language feature only introduced in >=7.1'); |
||
111 | } |
||
112 | |||
113 | $subject->beADoubleOf('spec\Prophecy\Prophecy\ClassWithVoidTypeHintedMethods'); |
||
114 | $objectProphecy->addMethodProphecy(Argument::cetera())->willReturn(null); |
||
115 | $objectProphecy->reveal()->willReturn($subject); |
||
116 | |||
117 | $this->beConstructedWith($objectProphecy, 'getVoid'); |
||
118 | $objectProphecy->addMethodProphecy($this)->shouldHaveBeenCalled(); |
||
119 | } |
||
120 | |||
121 | function it_records_promise_through_will_method(PromiseInterface $promise, ObjectProphecy $objectProphecy) |
||
122 | { |
||
123 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
124 | |||
125 | $this->will($promise); |
||
126 | $this->getPromise()->shouldReturn($promise); |
||
127 | } |
||
128 | |||
129 | function it_adds_itself_to_ObjectProphecy_during_call_to_will( |
||
130 | ObjectProphecy $objectProphecy, |
||
131 | PromiseInterface $promise |
||
132 | ) { |
||
133 | $objectProphecy->addMethodProphecy($this)->shouldBeCalled(); |
||
134 | |||
135 | $this->will($promise); |
||
136 | } |
||
137 | |||
138 | function it_adds_ReturnPromise_during_willReturn_call(ObjectProphecy $objectProphecy) |
||
139 | { |
||
140 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
141 | |||
142 | $this->willReturn(42); |
||
143 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\ReturnPromise'); |
||
144 | } |
||
145 | |||
146 | function it_adds_CallbackPromise_during_willYield_call(ObjectProphecy $objectProphecy) |
||
147 | { |
||
148 | if (PHP_VERSION_ID < 50500) { |
||
149 | throw new SkippingException('Yield language feature was introduced in >=5.5'); |
||
150 | } |
||
151 | |||
152 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
153 | |||
154 | $this->willYield(array('foo', 'bar')); |
||
155 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\CallbackPromise'); |
||
156 | } |
||
157 | |||
158 | function it_yields_elements_configured_in_willYield(ObjectProphecy $objectProphecy) |
||
159 | { |
||
160 | if (PHP_VERSION_ID < 70000) { |
||
161 | throw new SkippingException('Yield language feature was introduced in >=5.5 but shouldYield matcher only available in >=7.0'); |
||
162 | } |
||
163 | |||
164 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
165 | |||
166 | $this->willYield(array('foo', 'bar')); |
||
167 | $this->getPromise()->execute(array(), $objectProphecy, $this)->shouldYield(array('foo', 'bar')); |
||
168 | } |
||
169 | |||
170 | function it_yields_key_value_pairs_configured_in_willYield(ObjectProphecy $objectProphecy) |
||
171 | { |
||
172 | if (PHP_VERSION_ID < 70000) { |
||
173 | throw new SkippingException('Yield language feature was introduced in >=5.5 but shouldYield matcher only available in >=7.0'); |
||
174 | } |
||
175 | |||
176 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
177 | |||
178 | $this->willYield(array(10 => 'foo', 11 => 'bar')); |
||
179 | $this->getPromise()->execute(array(), $objectProphecy, $this)->shouldYield(array(10 => 'foo', 11 => 'bar')); |
||
180 | } |
||
181 | |||
182 | function it_adds_ThrowPromise_during_willThrow_call(ObjectProphecy $objectProphecy) |
||
183 | { |
||
184 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
185 | |||
186 | $this->willThrow('RuntimeException'); |
||
187 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\ThrowPromise'); |
||
188 | } |
||
189 | |||
190 | function it_adds_ReturnArgumentPromise_during_willReturnArgument_call(ObjectProphecy $objectProphecy) |
||
191 | { |
||
192 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
193 | |||
194 | $this->willReturnArgument(); |
||
195 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\ReturnArgumentPromise'); |
||
196 | } |
||
197 | |||
198 | function it_adds_ReturnArgumentPromise_during_willReturnArgument_call_with_index_argument( |
||
199 | ObjectProphecy $objectProphecy |
||
200 | ) { |
||
201 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
202 | |||
203 | $this->willReturnArgument(1); |
||
204 | $promise = $this->getPromise(); |
||
205 | $promise->shouldBeAnInstanceOf('Prophecy\Promise\ReturnArgumentPromise'); |
||
206 | $promise->execute(array('one', 'two'), $objectProphecy, $this)->shouldReturn('two'); |
||
207 | } |
||
208 | |||
209 | function it_adds_CallbackPromise_during_will_call_with_callback_argument(ObjectProphecy $objectProphecy) |
||
210 | { |
||
211 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
212 | |||
213 | $callback = function () {}; |
||
214 | |||
215 | $this->will($callback); |
||
216 | $this->getPromise()->shouldBeAnInstanceOf('Prophecy\Promise\CallbackPromise'); |
||
217 | } |
||
218 | |||
219 | function it_records_prediction_through_should_method( |
||
220 | PredictionInterface $prediction, |
||
221 | ObjectProphecy $objectProphecy |
||
222 | ) { |
||
223 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
224 | |||
225 | $this->callOnWrappedObject('should', array($prediction)); |
||
226 | $this->getPrediction()->shouldReturn($prediction); |
||
227 | } |
||
228 | |||
229 | View Code Duplication | function it_adds_CallbackPrediction_during_should_call_with_callback_argument(ObjectProphecy $objectProphecy) |
|
230 | { |
||
231 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
232 | |||
233 | $callback = function () {}; |
||
234 | |||
235 | $this->callOnWrappedObject('should', array($callback)); |
||
236 | $this->getPrediction()->shouldBeAnInstanceOf('Prophecy\Prediction\CallbackPrediction'); |
||
237 | } |
||
238 | |||
239 | function it_adds_itself_to_ObjectProphecy_during_call_to_should( |
||
240 | ObjectProphecy $objectProphecy, |
||
241 | PredictionInterface $prediction |
||
242 | ) { |
||
243 | $objectProphecy->addMethodProphecy($this)->shouldBeCalled(); |
||
244 | |||
245 | $this->callOnWrappedObject('should', array($prediction)); |
||
246 | } |
||
247 | |||
248 | function it_adds_CallPrediction_during_shouldBeCalled_call($objectProphecy) |
||
249 | { |
||
250 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
251 | |||
252 | $this->callOnWrappedObject('shouldBeCalled', array()); |
||
253 | $this->getPrediction()->shouldBeAnInstanceOf('Prophecy\Prediction\CallPrediction'); |
||
254 | } |
||
255 | |||
256 | function it_adds_NoCallsPrediction_during_shouldNotBeCalled_call(ObjectProphecy $objectProphecy) |
||
257 | { |
||
258 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
259 | |||
260 | $this->callOnWrappedObject('shouldNotBeCalled', array()); |
||
261 | $this->getPrediction()->shouldBeAnInstanceOf('Prophecy\Prediction\NoCallsPrediction'); |
||
262 | } |
||
263 | |||
264 | View Code Duplication | function it_adds_CallTimesPrediction_during_shouldBeCalledTimes_call(ObjectProphecy $objectProphecy) |
|
265 | { |
||
266 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
267 | |||
268 | $this->callOnWrappedObject('shouldBeCalledTimes', array(5)); |
||
269 | $this->getPrediction()->shouldBeAnInstanceOf('Prophecy\Prediction\CallTimesPrediction'); |
||
270 | } |
||
271 | |||
272 | function it_adds_CallTimesPrediction_during_shouldBeCalledOnce_call(ObjectProphecy $objectProphecy) |
||
273 | { |
||
274 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
275 | |||
276 | $this->callOnWrappedObject('shouldBeCalledOnce'); |
||
277 | $this->getPrediction()->shouldBeAnInstanceOf('Prophecy\Prediction\CallTimesPrediction'); |
||
278 | } |
||
279 | |||
280 | function it_checks_prediction_via_shouldHave_method_call( |
||
281 | ObjectProphecy $objectProphecy, |
||
282 | ArgumentsWildcard $arguments, |
||
283 | PredictionInterface $prediction, |
||
284 | Call $call1, |
||
285 | Call $call2 |
||
286 | ) { |
||
287 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
288 | $prediction->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->shouldBeCalled(); |
||
289 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
290 | |||
291 | $this->withArguments($arguments); |
||
292 | $this->callOnWrappedObject('shouldHave', array($prediction)); |
||
293 | } |
||
294 | |||
295 | View Code Duplication | function it_sets_return_promise_during_shouldHave_call_if_none_was_set_before( |
|
0 ignored issues
–
show
|
|||
296 | ObjectProphecy $objectProphecy, |
||
297 | ArgumentsWildcard $arguments, |
||
298 | PredictionInterface $prediction, |
||
299 | Call $call1, |
||
300 | Call $call2 |
||
301 | ) { |
||
302 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
303 | $prediction->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->shouldBeCalled(); |
||
304 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
305 | |||
306 | $this->withArguments($arguments); |
||
307 | $this->callOnWrappedObject('shouldHave', array($prediction)); |
||
308 | |||
309 | $this->getPromise()->shouldReturnAnInstanceOf('Prophecy\Promise\ReturnPromise'); |
||
310 | } |
||
311 | |||
312 | View Code Duplication | function it_does_not_set_return_promise_during_shouldHave_call_if_it_was_set_before( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
313 | ObjectProphecy $objectProphecy, |
||
314 | ArgumentsWildcard $arguments, |
||
315 | PredictionInterface $prediction, |
||
316 | Call $call1, |
||
317 | Call $call2, |
||
318 | PromiseInterface $promise |
||
319 | ) { |
||
320 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
321 | $prediction->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->shouldBeCalled(); |
||
322 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
323 | |||
324 | $this->will($promise); |
||
325 | $this->withArguments($arguments); |
||
326 | $this->callOnWrappedObject('shouldHave', array($prediction)); |
||
327 | |||
328 | $this->getPromise()->shouldReturn($promise); |
||
329 | } |
||
330 | |||
331 | function it_records_checked_predictions( |
||
332 | ObjectProphecy $objectProphecy, |
||
333 | ArgumentsWildcard $arguments, |
||
334 | PredictionInterface $prediction1, |
||
335 | PredictionInterface $prediction2, |
||
336 | Call $call1, |
||
337 | Call $call2, |
||
338 | PromiseInterface $promise |
||
339 | ) { |
||
340 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
341 | $prediction1->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->willReturn(); |
||
342 | $prediction2->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->willReturn(); |
||
343 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
344 | |||
345 | $this->will($promise); |
||
346 | $this->withArguments($arguments); |
||
347 | $this->callOnWrappedObject('shouldHave', array($prediction1)); |
||
348 | $this->callOnWrappedObject('shouldHave', array($prediction2)); |
||
349 | |||
350 | $this->getCheckedPredictions()->shouldReturn(array($prediction1, $prediction2)); |
||
351 | } |
||
352 | |||
353 | View Code Duplication | function it_records_even_failed_checked_predictions( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
354 | ObjectProphecy $objectProphecy, |
||
355 | ArgumentsWildcard $arguments, |
||
356 | PredictionInterface $prediction, |
||
357 | Call $call1, |
||
358 | Call $call2, |
||
359 | PromiseInterface $promise |
||
360 | ) { |
||
361 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
362 | $prediction->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->willThrow(new RuntimeException()); |
||
363 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
364 | |||
365 | $this->will($promise); |
||
366 | $this->withArguments($arguments); |
||
367 | |||
368 | try { |
||
369 | $this->callOnWrappedObject('shouldHave', array($prediction)); |
||
370 | } catch (\Exception $e) {} |
||
371 | |||
372 | $this->getCheckedPredictions()->shouldReturn(array($prediction)); |
||
373 | } |
||
374 | |||
375 | function it_checks_prediction_via_shouldHave_method_call_with_callback( |
||
376 | ObjectProphecy $objectProphecy, |
||
377 | ArgumentsWildcard $arguments, |
||
378 | Call $call1, |
||
379 | Call $call2 |
||
380 | ) { |
||
381 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
382 | $callback = function ($calls, $object, $method) { |
||
383 | throw new RuntimeException; |
||
384 | }; |
||
385 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
386 | |||
387 | $this->withArguments($arguments); |
||
388 | $this->shouldThrow('RuntimeException')->duringShouldHave($callback); |
||
389 | } |
||
390 | |||
391 | function it_does_nothing_during_checkPrediction_if_no_prediction_set() |
||
392 | { |
||
393 | $this->checkPrediction()->shouldReturn(null); |
||
394 | } |
||
395 | |||
396 | function it_checks_set_prediction_during_checkPrediction( |
||
397 | ObjectProphecy $objectProphecy, |
||
398 | ArgumentsWildcard $arguments, |
||
399 | PredictionInterface $prediction, |
||
400 | Call $call1, |
||
401 | Call $call2 |
||
402 | ) { |
||
403 | $prediction->check(array($call1, $call2), $objectProphecy->getWrappedObject(), $this)->shouldBeCalled(); |
||
404 | $objectProphecy->findProphecyMethodCalls('getName', $arguments)->willReturn(array($call1, $call2)); |
||
405 | $objectProphecy->addMethodProphecy($this)->willReturn(null); |
||
406 | |||
407 | $this->withArguments($arguments); |
||
408 | $this->callOnWrappedObject('should', array($prediction)); |
||
409 | $this->checkPrediction(); |
||
410 | } |
||
411 | |||
412 | function it_links_back_to_ObjectProphecy_through_getter(ObjectProphecy $objectProphecy) |
||
413 | { |
||
414 | $this->getObjectProphecy()->shouldReturn($objectProphecy); |
||
415 | } |
||
416 | |||
417 | function it_has_MethodName() |
||
418 | { |
||
419 | $this->getMethodName()->shouldReturn('getName'); |
||
420 | } |
||
421 | |||
422 | function it_contains_ArgumentsWildcard_it_was_constructed_with( |
||
423 | ObjectProphecy $objectProphecy, |
||
424 | ArgumentsWildcard $wildcard |
||
425 | ) { |
||
426 | $this->beConstructedWith($objectProphecy, 'getName', $wildcard); |
||
427 | |||
428 | $this->getArgumentsWildcard()->shouldReturn($wildcard); |
||
429 | } |
||
430 | |||
431 | function its_ArgumentWildcard_is_mutable_through_setter(ArgumentsWildcard $wildcard) |
||
432 | { |
||
433 | $this->withArguments($wildcard); |
||
434 | |||
435 | $this->getArgumentsWildcard()->shouldReturn($wildcard); |
||
436 | } |
||
437 | |||
438 | function its_withArguments_transforms_passed_array_into_ArgumentsWildcard() |
||
439 | { |
||
440 | $this->withArguments(array(42, 33)); |
||
441 | |||
442 | $wildcard = $this->getArgumentsWildcard(); |
||
443 | $wildcard->shouldNotBe(null); |
||
444 | $wildcard->__toString()->shouldReturn('exact(42), exact(33)'); |
||
445 | } |
||
446 | |||
447 | function its_withArguments_throws_exception_if_wrong_arguments_provided() |
||
448 | { |
||
449 | $this->shouldThrow('Prophecy\Exception\InvalidArgumentException')->duringWithArguments(42); |
||
450 | } |
||
451 | } |
||
452 | |||
453 | class ClassWithFinalMethod |
||
454 | { |
||
455 | final public function finalMethod() {} |
||
456 | } |
||
457 | |||
458 | // Return void type hint language feature only introduced in >=7.1 |
||
459 | if (PHP_VERSION_ID >= 70100) { |
||
460 | require_once __DIR__ . DIRECTORY_SEPARATOR . 'ClassWithVoidTypeHintedMethods.php'; |
||
461 | } |
||
462 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.