Skip to content

Update CampaignCategory.php#8

Merged
stixx merged 3 commits into
stixx:masterfrom
lvdhoorn:master
Oct 4, 2019
Merged

Update CampaignCategory.php#8
stixx merged 3 commits into
stixx:masterfrom
lvdhoorn:master

Conversation

@lvdhoorn

@lvdhoorn lvdhoorn commented Oct 3, 2019

Copy link
Copy Markdown
Contributor

Removed array typecast on getCategories. If a category has no sub categories we where getting errors like this:
Symfony\Component\Debug\Exception\FatalThrowableError: Return value of Hypeit\TradeTracker\Model\CampaignCategory::getCategories() must be of the type array, null returned

Removed array typecast on getCategories. If a category has no sub categories we where getting errors like this:
Symfony\Component\Debug\Exception\FatalThrowableError: Return value of Hypeit\TradeTracker\Model\CampaignCategory::getCategories() must be of the type array, null returned
Make response getCategories backwards compatible
Comment thread src/Model/CampaignCategory.php Outdated
Comment on lines +65 to +67
public function getCategories()
{
return $this->categories;
return $this->categories ?? [];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave the return type restriction here if you force to always return an array. We can also set the default array type in the private property:

$this->categories = [];

@lvdhoorn lvdhoorn Oct 4, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is true, I will change it.

return type restriction on getCategories
@lvdhoorn
lvdhoorn requested a review from stixx October 4, 2019 15:51
@stixx
stixx merged commit 54ddea6 into stixx:master Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants