original_string: protected function _subqueryFields($query)
      {
          $keys = (array)$this->bindingKey;
  
          if ($this->associationType === Association::MANY_TO_ONE) {
              $keys = (array)$this->foreignKey;
          }
  
          $fields = $query->aliasFields($keys, $this->sourceAlias);
          $group = $fields = array_values($fields);
  
          $order = $query->clause('order');
          if ($order) {
              $columns = $query->clause('select');
              $order->iterateParts(function ($direction, $field) use (&$fields, $columns) {
                  if (isset($columns[$field])) {
                      $fields[$field] = $columns[$field];
                  }
              });
          }
  
          return ['select' => $fields, 'group' => $group];
      }
code: protected function _subqueryFields($query)
      {
          $keys = (array)$this->bindingKey;
  
          if ($this->associationType === Association::MANY_TO_ONE) {
              $keys = (array)$this->foreignKey;
          }
  
          $fields = $query->aliasFields($keys, $this->sourceAlias);
          $group = $fields = array_values($fields);
  
          $order = $query->clause('order');
          if ($order) {
              $columns = $query->clause('select');
              $order->iterateParts(function ($direction, $field) use (&$fields, $columns) {
                  if (isset($columns[$field])) {
                      $fields[$field] = $columns[$field];
                  }
              });
          }
  
          return ['select' => $fields, 'group' => $group];
      }
code_tokens: protected function _subqueryFields ( $ query ) { $ keys = ( array ) $ this -> bindingKey ; if ( $ this -> associationType === Association :: MANY_TO_ONE ) { $ keys = ( array ) $ this -> foreignKey ; } $ fields = $ query -> aliasFields ( $ keys , $ this -> sourceAlias ) ; $ group = $ fields = array_values ( $ fields ) ; $ order = $ query -> clause ( 'order' ) ; if ( $ order ) { $ columns = $ query -> clause ( 'select' ) ; $ order -> iterateParts ( function ( $ direction , $ field ) use ( & $ fields , $ columns ) { if ( isset ( $ columns [ $ field ] ) ) { $ fields [ $ field ] = $ columns [ $ field ] ; } } ) ; } return [ 'select' => $ fields , 'group' => $ group ] ; }
docstring: Calculate the fields that need to participate in a subquery.
  
  Normally this includes the binding key columns. If there is a an ORDER BY,
  those columns are also included as the fields may be calculated or constant values,
  that need to be present to ensure the correct association data is loaded.
  
  @param \Cake\ORM\Query $query The query to get fields from.
  @return array The list of fields for the subquery.
docstring_tokens: Calculate the fields that need to participate in a subquery .