| Conditions | 7 | 
| Paths | 6 | 
| Total Lines | 34 | 
| Code Lines | 26 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 8 |     public function __construct() { | 
            ||
| 9 | global $ACT;  | 
            ||
| 10 | global $INFO;  | 
            ||
| 11 | global $REV;  | 
            ||
| 12 | |||
| 13 | parent::__construct();  | 
            ||
| 14 | |||
| 15 |         if($ACT == 'show' || $ACT == 'search') { | 
            ||
| 16 | $this->method = 'post';  | 
            ||
| 17 |             if($INFO['writable']) { | 
            ||
| 18 | $this->accesskey = 'e';  | 
            ||
| 19 |                 if(!empty($INFO['draft'])) { | 
            ||
| 20 | $this->type = 'draft';  | 
            ||
| 21 | $this->params['do'] = 'draft';  | 
            ||
| 22 |                 } else { | 
            ||
| 23 | $this->params['rev'] = $REV;  | 
            ||
| 24 |                     if(!$INFO['exists']) { | 
            ||
| 25 | $this->type = 'create';  | 
            ||
| 26 | }  | 
            ||
| 27 | }  | 
            ||
| 28 |             } else { | 
            ||
| 29 |                 if(!actionOK($this->type)) throw new \RuntimeException("action disabled: source"); | 
            ||
| 30 | $params['rev'] = $REV;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 31 | $this->type = 'source';  | 
            ||
| 32 | $this->accesskey = 'v';  | 
            ||
| 33 | }  | 
            ||
| 34 |         } else { | 
            ||
| 35 |             $this->params = array('do' => ''); | 
            ||
| 36 | $this->type = 'show';  | 
            ||
| 37 | $this->accesskey = 'v';  | 
            ||
| 38 | }  | 
            ||
| 39 | |||
| 40 | $this->setIcon();  | 
            ||
| 41 | }  | 
            ||
| 42 | |||
| 60 | 
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.