$properties was never initialized. Although not strictly required by PHP, it is generally a good practice to add $properties = array(); before regardless.
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:
foreach($collectionas$item){$myArray['foo']=$item->getFoo();if($item->hasBar()){$myArray['bar']=$item->getBar();}// do something with $myArray}
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 the
bar 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.
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: