Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check $patternData["lineages"] for being an array #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alamowo
Copy link

@alamowo alamowo commented Nov 12, 2018

If $patternData["lineages"] equals false, make it an empty array to prevent php warning:

Warning: count(): Parameter must be an array or an object that implements Countable in /.../pattern-lab/vendor/pattern-lab/plugin-data-inheritance/src/PatternLab/DataInheritance/PatternLabListener.php on line 43

@@ -40,6 +40,10 @@ public function inherit() {

foreach ($storePatternData as $patternStoreKey => $patternData) {

if ($patternData["lineages"] === false) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ($patternData["lineages"] === false) {

Copy link

Choose a reason for hiding this comment

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

This fails with PHP Notice: Undefined index: lineages

@@ -40,6 +40,10 @@ public function inherit() {

foreach ($storePatternData as $patternStoreKey => $patternData) {

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
Copy link

Choose a reason for hiding this comment

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

Suggested change
$patternData["lineages"] = array();

@@ -40,6 +40,10 @@ public function inherit() {

foreach ($storePatternData as $patternStoreKey => $patternData) {

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
}
Copy link

Choose a reason for hiding this comment

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

Suggested change
}

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
}

Copy link

Choose a reason for hiding this comment

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

Suggested change

if ($patternData["lineages"] === false) {
$patternData["lineages"] = array();
}

if (isset($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (isset($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {
if (isset($patternData["lineages"]) && is_array($patternData["lineages"]) && (count($patternData["lineages"]) > 0)) {

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