| 1 | <?php |
||
| 5 | class Rover |
||
| 6 | { |
||
| 7 | private $map; |
||
| 8 | private $position; |
||
| 9 | private $orientation; |
||
| 10 | private $collissions; |
||
| 11 | |||
| 12 | 2 | public function __construct(Map $a_map, Position $a_position, Orientation $an_orientation) |
|
| 20 | |||
| 21 | 2 | public function commands(string ...$movements): void |
|
| 28 | |||
| 29 | 2 | private function move(string $movement_string): void |
|
| 59 | |||
| 60 | 2 | private static function validate(): void |
|
| 64 | |||
| 65 | 2 | public function position(): Position |
|
| 69 | |||
| 70 | /** @return Position[] */ |
||
| 71 | public function detectedCollisions(): array |
||
| 80 | } |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: