| Conditions | 1 |
| Paths | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function testMainFunctionality() |
||
| 12 | { |
||
| 13 | $count = 0; |
||
| 14 | $it = new CallbackIterator(function() use(&$count) { $count += 1; }); |
||
| 15 | |||
| 16 | $it->rewind(); |
||
| 17 | $it->valid(); |
||
|
|
|||
| 18 | $it->current(); |
||
| 19 | $it->valid(); |
||
| 20 | $it->next(); |
||
| 21 | $it->current(); |
||
| 22 | $it->current(); |
||
| 23 | $it->current(); |
||
| 24 | $it->valid(); |
||
| 25 | $it->next(); |
||
| 26 | $it->current(); |
||
| 27 | |||
| 28 | $this->assertEquals(3, $count); |
||
| 29 | } |
||
| 30 | |||
| 39 |
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: