Whilst working within Magento I have begun seeing a pattern throughout the core coding. However, it is something I have seen throughout many areas of PHP coding. When a variable is declared in a function, it can then be used. An example of this is within magento, whilst emulating the store there is this code:
public function startEnvironmentEmulation(
$storeId,
$area = Mage_Core_Model_App_Area::AREA_FRONTEND,
$emulateSroreInlineTranslation = false
) {
if (is_null($area)) {
$area = Mage_Core_Model_App_Area::AREA_FRONTEND;
}
...
...
You can see that $area
is defined, and then re-defined if it is found to be null.
Is it important to re declare the same variable if it is found to be null, as a kind of re-try? Or am I missing something?
Any help in understanding this would be appreciated!