lib-array2xml icon indicating copy to clipboard operation
lib-array2xml copied to clipboard

Fix reusage of reference for unknown nodes

Open dgrothaus-ku opened this issue 4 years ago • 0 comments

The reference to $output was overwritten by nodes not covered by the switch construct.

Example to test:

<root>
  <Nodes>
    <Node One="1" Two="2" />
    <Node Two="2" Three="3" />
            <!-- Content omitted -->
    <Node Three="3" Four="4" />
  </Nodes>
</root>

Array without patch:

[
  'root' => [
    'Nodes' => [
      'Node' => [
        '@value'    => '',
        '@attributes' => [
          'Three' => '3',
          'Four'  => '4',
        ],
      ],
    ],
  ],
];

Array with patch:

[
  'root' => [
    'Nodes' => [
      'Node' => [
        0 => [
          '@value'    => '',
          '@attributes' => [
            'One' => '1',
            'Two' => '2',
          ],
        ],
        1 => [
          '@value'    => '',
          '@attributes' => [
            'Two'   => '2',
            'Three' => '3',
          ],
        ],
        2 => [
          '@value'    => '',
          '@attributes' => [
            'Three' => '3',
            'Four'  => '4',
          ],
        ],
      ],
    ],
  ],
];

dgrothaus-ku avatar Mar 10 '20 08:03 dgrothaus-ku