original_string: private function handleUpgrade(array $node, NodePath $nodePath, string $newType)
      {
          if ((($node['nodeType'] == 'array') || ($newType == 'array')) && $this->autoUpgradeToArray) {
              $this->checkArrayUpgrade($node, $nodePath, $newType);
              // copy all properties to the array
              if (!empty($node[self::ARRAY_NAME])) {
                  foreach ($node[self::ARRAY_NAME] as $key => $value) {
                      $newNode[self::ARRAY_NAME][$key] = $value;
                  }
              }
              foreach ($node as $key => $value) {
                  if (is_array($value) && ($key != self::ARRAY_NAME)) {
                      $newNode[self::ARRAY_NAME][$key] = $value;
                  }
              }
              if ($newType != 'array') {
                  $newNode[self::ARRAY_NAME]['nodeType'] = $newType;
              } else {
                  $newNode[self::ARRAY_NAME]['nodeType'] = $node['nodeType'];
              }
              $newNode['nodeType'] = 'array';
              if (!empty($node['headerNames'])) {
                  $newNode[self::ARRAY_NAME]['headerNames'] = self::DATA_COLUMN;
                  $newNode['headerNames'] = $node['headerNames'];
              }
              $this->data = $this->storeNode($nodePath, $this->data, $newNode);
          } elseif (($node['nodeType'] != 'null') && ($newType == 'null')) {
              // do nothing, old type is fine
          } elseif (($node['nodeType'] == 'null') && ($newType != 'null')) {
              $newNode = $this->getNode($nodePath);
              $newNode['nodeType'] = $newType;
              $this->data = $this->storeNode($nodePath, $this->data, $newNode);
          } else {
              throw new JsonParserException(
                  'Unhandled nodeType change from "' . $node['nodeType'] .
                  '" to "' . $newType . '" in "' . $nodePath->__toString() . '"'
              );
          }
      }
code: private function handleUpgrade(array $node, NodePath $nodePath, string $newType)
      {
          if ((($node['nodeType'] == 'array') || ($newType == 'array')) && $this->autoUpgradeToArray) {
              $this->checkArrayUpgrade($node, $nodePath, $newType);
              // copy all properties to the array
              if (!empty($node[self::ARRAY_NAME])) {
                  foreach ($node[self::ARRAY_NAME] as $key => $value) {
                      $newNode[self::ARRAY_NAME][$key] = $value;
                  }
              }
              foreach ($node as $key => $value) {
                  if (is_array($value) && ($key != self::ARRAY_NAME)) {
                      $newNode[self::ARRAY_NAME][$key] = $value;
                  }
              }
              if ($newType != 'array') {
                  $newNode[self::ARRAY_NAME]['nodeType'] = $newType;
              } else {
                  $newNode[self::ARRAY_NAME]['nodeType'] = $node['nodeType'];
              }
              $newNode['nodeType'] = 'array';
              if (!empty($node['headerNames'])) {
                  $newNode[self::ARRAY_NAME]['headerNames'] = self::DATA_COLUMN;
                  $newNode['headerNames'] = $node['headerNames'];
              }
              $this->data = $this->storeNode($nodePath, $this->data, $newNode);
          } elseif (($node['nodeType'] != 'null') && ($newType == 'null')) {
              // do nothing, old type is fine
          } elseif (($node['nodeType'] == 'null') && ($newType != 'null')) {
              $newNode = $this->getNode($nodePath);
              $newNode['nodeType'] = $newType;
              $this->data = $this->storeNode($nodePath, $this->data, $newNode);
          } else {
              throw new JsonParserException(
                  'Unhandled nodeType change from "' . $node['nodeType'] .
                  '" to "' . $newType . '" in "' . $nodePath->__toString() . '"'
              );
          }
      }
code_tokens: private function handleUpgrade ( array $ node , NodePath $ nodePath , string $ newType ) { if ( ( ( $ node [ 'nodeType' ] == 'array' ) || ( $ newType == 'array' ) ) && $ this -> autoUpgradeToArray ) { $ this -> checkArrayUpgrade ( $ node , $ nodePath , $ newType ) ; // copy all properties to the array if ( ! empty ( $ node [ self :: ARRAY_NAME ] ) ) { foreach ( $ node [ self :: ARRAY_NAME ] as $ key => $ value ) { $ newNode [ self :: ARRAY_NAME ] [ $ key ] = $ value ; } } foreach ( $ node as $ key => $ value ) { if ( is_array ( $ value ) && ( $ key != self :: ARRAY_NAME ) ) { $ newNode [ self :: ARRAY_NAME ] [ $ key ] = $ value ; } } if ( $ newType != 'array' ) { $ newNode [ self :: ARRAY_NAME ] [ 'nodeType' ] = $ newType ; } else { $ newNode [ self :: ARRAY_NAME ] [ 'nodeType' ] = $ node [ 'nodeType' ] ; } $ newNode [ 'nodeType' ] = 'array' ; if ( ! empty ( $ node [ 'headerNames' ] ) ) { $ newNode [ self :: ARRAY_NAME ] [ 'headerNames' ] = self :: DATA_COLUMN ; $ newNode [ 'headerNames' ] = $ node [ 'headerNames' ] ; } $ this -> data = $ this -> storeNode ( $ nodePath , $ this -> data , $ newNode ) ; } elseif ( ( $ node [ 'nodeType' ] != 'null' ) && ( $ newType == 'null' ) ) { // do nothing, old type is fine } elseif ( ( $ node [ 'nodeType' ] == 'null' ) && ( $ newType != 'null' ) ) { $ newNode = $ this -> getNode ( $ nodePath ) ; $ newNode [ 'nodeType' ] = $ newType ; $ this -> data = $ this -> storeNode ( $ nodePath , $ this -> data , $ newNode ) ; } else { throw new JsonParserException ( 'Unhandled nodeType change from "' . $ node [ 'nodeType' ] . '" to "' . $ newType . '" in "' . $ nodePath -> __toString ( ) . '"' ) ; } }
docstring: Upgrade a node to array
  @param array $node
  @param NodePath $nodePath
  @param string $newType
  @throws JsonParserException
docstring_tokens: Upgrade a node to array