1 | <?php |
||
7 | namespace HDNET\OnpageIntegration\Controller; |
||
8 | |||
9 | use HDNET\OnpageIntegration\Domain\Repository\ConfigurationRepository; |
||
10 | use HDNET\OnpageIntegration\Utility\TitleUtility; |
||
11 | use HDNET\OnpageIntegration\Provider\MetaDataProvider; |
||
12 | use HDNET\OnpageIntegration\Utility\ArrayUtility; |
||
13 | |||
14 | use TYPO3\CMS\Extbase\Object\ObjectManager; |
||
15 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
||
16 | use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
||
17 | |||
18 | /** |
||
19 | * Class BackendController |
||
20 | */ |
||
21 | class BackendController extends ActionController |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var \HDNET\OnpageIntegration\Loader\ApiResultLoader |
||
26 | * @inject |
||
27 | */ |
||
28 | protected $loader; |
||
29 | |||
30 | /** |
||
31 | * Represent the index page |
||
32 | */ |
||
33 | public function indexAction() |
||
52 | |||
53 | /** |
||
54 | * Handle the detail pages |
||
55 | * |
||
56 | * @param string $section |
||
57 | * @param string $call |
||
58 | */ |
||
59 | public function detailAction($section, $call) |
||
77 | |||
78 | /** |
||
79 | * Empty Keyword Page |
||
80 | */ |
||
81 | public function keywordAction() |
||
87 | } |
||
88 |
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
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key 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.