Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 3.576 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
17 | function datetimeinterface_to_datetimeimmutable(\DateTimeInterface $dateTime): \DateTimeImmutable |
||
18 | { |
||
19 | 6 | if ($dateTime instanceof \DateTimeImmutable) { |
|
20 | return $dateTime; |
||
21 | } |
||
22 | |||
23 | 6 | if ($dateTime instanceof \DateTime) { |
|
24 | 6 | return \DateTimeImmutable::createFromMutable($dateTime); |
|
25 | } |
||
26 | |||
27 | return \DateTimeImmutable::createFromFormat('u U', $dateTime->format('u U')); |
||
28 | } |
||
29 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.