Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

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

Open
alamowo wants to merge 1 commit into
pattern-lab:masterfrom
alamowo:patch-2
Open

Check $patternData["lineages"] for being an array#8
alamowo wants to merge 1 commit into
pattern-lab:masterfrom
alamowo:patch-2

Conversation

@alamowo
Copy link
Copy Markdown

@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


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

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

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
Copy Markdown

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

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

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

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();


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

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
Copy Markdown

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();
}

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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants