diff --git a/src/Analyzers/ConfigAnalyzer.php b/src/Analyzers/ConfigAnalyzer.php index e88b74d..cec46bf 100644 --- a/src/Analyzers/ConfigAnalyzer.php +++ b/src/Analyzers/ConfigAnalyzer.php @@ -264,7 +264,7 @@ protected function willClobberTheExistingArray(Array_ $node, ArrayItem $incoming $willWreckArray = true; foreach ($node->items as $item) { - if (! ($item instanceof ArrayItem && $item->value instanceof Array_)) { + if (!($item instanceof ArrayItem && $item->value instanceof Array_)) { $willWreckArray = false; break; } diff --git a/tests/MergeTest.php b/tests/MergeTest.php index 93418d4..af540d1 100644 --- a/tests/MergeTest.php +++ b/tests/MergeTest.php @@ -54,70 +54,70 @@ public function testMergeDoesNotFlattenValues() $updater->open(__DIR__.'/configs/issues/018.php'); $updater->update([ - 'forms' => [ - [ - 'id' => 'new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, - 'marketing_permissions_field_ids' => [ - [ - ], + 'forms' => [ + [ + 'id' => 'new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, + 'marketing_permissions_field_ids' => [ + [ + ], + ], + 'merge_fields' => [ + [ + 'id' => 'new2', + 'field_name' => 'first_name', + 'tag' => 'FNAME', ], - 'merge_fields' => [ - [ - 'id' => 'new2', - 'field_name' => 'first_name', - 'tag' => 'FNAME', - ], - [ - 'id' => 'new3', - 'field_name' => 'last_name', - 'tag' => 'LNAME', - ], - [ - 'id' => 'new4', - 'field_name' => 'company', - 'tag' => 'COMPANY', - ], + [ + 'id' => 'new3', + 'field_name' => 'last_name', + 'tag' => 'LNAME', + ], + [ + 'id' => 'new4', + 'field_name' => 'company', + 'tag' => 'COMPANY', ], - 'primary_email_field' => 'email', - 'audience_id' => 'new5', ], - [ - 'id' => 'b-new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, - 'marketing_permissions_field_ids' => [ - [ - ], + 'primary_email_field' => 'email', + 'audience_id' => 'new5', + ], + [ + 'id' => 'b-new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, + 'marketing_permissions_field_ids' => [ + [ + ], + ], + 'merge_fields' => [ + [ + 'id' => 'b-new2', + 'field_name' => 'first_name', + 'tag' => 'FNAME', + ], + [ + 'id' => 'b-new3', + 'field_name' => 'last_name', + 'tag' => 'LNAME', ], - 'merge_fields' => [ - [ - 'id' => 'b-new2', - 'field_name' => 'first_name', - 'tag' => 'FNAME', - ], - [ - 'id' => 'b-new3', - 'field_name' => 'last_name', - 'tag' => 'LNAME', - ], - [ - 'id' => 'b-new4', - 'field_name' => 'company', - 'tag' => 'COMPANY', - ], + [ + 'id' => 'b-new4', + 'field_name' => 'company', + 'tag' => 'COMPANY', ], - 'primary_email_field' => 'email', - 'audience_id' => 'b-new5', ], + 'primary_email_field' => 'email', + 'audience_id' => 'b-new5', + ], ], - ],true); + ], true); $expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018.php')); $this->assertSame($expected, $updater->getDocument()); @@ -126,74 +126,73 @@ public function testMergeDoesNotFlattenValues() $updater->open(__DIR__.'/expected/issues/018.php'); $updater->update([ - 'forms' => [ - [ - 'id' => 'c-new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, - 'marketing_permissions_field_ids' => [ - [ - ], + 'forms' => [ + [ + 'id' => 'c-new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, + 'marketing_permissions_field_ids' => [ + [ + ], + ], + 'merge_fields' => [ + [ + 'id' => 'c-new2', + 'field_name' => 'first_name', + 'tag' => 'FNAME', + ], + [ + 'id' => 'c-new3', + 'field_name' => 'last_name', + 'tag' => 'LNAME', ], - 'merge_fields' => [ - [ - 'id' => 'c-new2', - 'field_name' => 'first_name', - 'tag' => 'FNAME', - ], - [ - 'id' => 'c-new3', - 'field_name' => 'last_name', - 'tag' => 'LNAME', - ], - [ - 'id' => 'c-new4', - 'field_name' => 'company', - 'tag' => 'COMPANY', - ], + [ + 'id' => 'c-new4', + 'field_name' => 'company', + 'tag' => 'COMPANY', ], - 'primary_email_field' => 'email', - 'audience_id' => 'c-new5', ], - [ - 'id' => 'd-new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, - 'marketing_permissions_field_ids' => [ - [ - ], + 'primary_email_field' => 'email', + 'audience_id' => 'c-new5', + ], + [ + 'id' => 'd-new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, + 'marketing_permissions_field_ids' => [ + [ + ], + ], + 'merge_fields' => [ + [ + 'id' => 'd-new2', + 'field_name' => 'first_name', + 'tag' => 'FNAME', + ], + [ + 'id' => 'd-new3', + 'field_name' => 'last_name', + 'tag' => 'LNAME', ], - 'merge_fields' => [ - [ - 'id' => 'd-new2', - 'field_name' => 'first_name', - 'tag' => 'FNAME', - ], - [ - 'id' => 'd-new3', - 'field_name' => 'last_name', - 'tag' => 'LNAME', - ], - [ - 'id' => 'd-new4', - 'field_name' => 'company', - 'tag' => 'COMPANY', - ], + [ + 'id' => 'd-new4', + 'field_name' => 'company', + 'tag' => 'COMPANY', ], - 'primary_email_field' => 'email', - 'audience_id' => 'd-new5', ], + 'primary_email_field' => 'email', + 'audience_id' => 'd-new5', ], + ], - ],true); - - $expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018a.php')); - $this->assertSame($expected, $updater->getDocument()); + ], true); + $expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018a.php')); + $this->assertSame($expected, $updater->getDocument()); $updater = new ConfigUpdater(); $updater->open(__DIR__.'/expected/issues/018a.php'); @@ -201,71 +200,70 @@ public function testMergeDoesNotFlattenValues() $updater->update([ 'forms' => [ [ - 'id' => 'c-new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, + 'id' => 'c-new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, 'marketing_permissions_field_ids' => [ [ ], ], 'merge_fields' => [ [ - 'id' => 'c-new2', + 'id' => 'c-new2', 'field_name' => 'first_name', - 'tag' => 'FNAME', + 'tag' => 'FNAME', ], [ - 'id' => 'c-new3', + 'id' => 'c-new3', 'field_name' => 'last_name', - 'tag' => 'LNAME', + 'tag' => 'LNAME', ], [ - 'id' => 'c-new4', + 'id' => 'c-new4', 'field_name' => 'company', - 'tag' => 'COMPANY', + 'tag' => 'COMPANY', ], ], 'primary_email_field' => 'email', - 'audience_id' => 'c-new5', + 'audience_id' => 'c-new5', ], [ - 'id' => 'd-new1', - 'form' => 'contact', - 'check_consent' => true, - 'consent_field' => 'newsletter', - 'disable_opt_in' => false, + 'id' => 'd-new1', + 'form' => 'contact', + 'check_consent' => true, + 'consent_field' => 'newsletter', + 'disable_opt_in' => false, 'marketing_permissions_field_ids' => [ [ ], ], 'merge_fields' => [ [ - 'id' => 'd-new2', + 'id' => 'd-new2', 'field_name' => 'first_name', - 'tag' => 'FNAME', + 'tag' => 'FNAME', ], [ - 'id' => 'd-new3', + 'id' => 'd-new3', 'field_name' => 'last_name', - 'tag' => 'LNAME', + 'tag' => 'LNAME', ], [ - 'id' => 'd-new4', + 'id' => 'd-new4', 'field_name' => 'company', - 'tag' => 'COMPANY', + 'tag' => 'COMPANY', ], ], 'primary_email_field' => 'email', - 'audience_id' => 'd-new5', + 'audience_id' => 'd-new5', ], ], - ],false); - + ], false); $expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__.'/expected/issues/018b.php')); $this->assertSame($expected, $updater->getDocument()); - } + } }