1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /** |
||
6 | * TaskScheduler |
||
7 | * |
||
8 | * @author Raffael Sahli <[email protected]> |
||
9 | * @copyright Copryright (c) 2017-2019 gyselroth GmbH (https://gyselroth.com) |
||
10 | * @license MIT https://opensource.org/licenses/MIT |
||
11 | */ |
||
12 | |||
13 | namespace TaskScheduler; |
||
14 | |||
15 | trait InjectTrait |
||
16 | { |
||
17 | /** |
||
18 | * This method may seem useless but is actually very useful to mock the loop. |
||
19 | */ |
||
20 | protected function loop(): bool |
||
21 | { |
||
22 | return true; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * This method may seem useless but is actually very useful to mock exits. |
||
27 | */ |
||
28 | protected function exit(): bool |
||
29 | { |
||
30 | exit(); |
||
0 ignored issues
–
show
In this branch, the function will implicitly return
null which is incompatible with the type-hinted return boolean . Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: interface ReturnsInt {
public function returnsIntHinted(): int;
}
class MyClass implements ReturnsInt {
public function returnsIntHinted(): int
{
if (foo()) {
return 123;
}
// here: null is implicitly returned
}
}
![]() |
|||
31 | } |
||
32 | } |
||
33 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.