original_string: protected function _assertFieldsPresent($fetchQuery, $key)
      {
          $select = $fetchQuery->aliasFields($fetchQuery->clause('select'));
          if (empty($select)) {
              return;
          }
          $missingKey = function ($fieldList, $key) {
              foreach ($key as $keyField) {
                  if (!in_array($keyField, $fieldList, true)) {
                      return true;
                  }
              }
  
              return false;
          };
  
          $missingFields = $missingKey($select, $key);
          if ($missingFields) {
              $driver = $fetchQuery->getConnection()->getDriver();
              $quoted = array_map([$driver, 'quoteIdentifier'], $key);
              $missingFields = $missingKey($select, $quoted);
          }
  
          if ($missingFields) {
              throw new InvalidArgumentException(
                  sprintf(
                      'You are required to select the "%s" field(s)',
                      implode(', ', (array)$key)
                  )
              );
          }
      }
code: protected function _assertFieldsPresent($fetchQuery, $key)
      {
          $select = $fetchQuery->aliasFields($fetchQuery->clause('select'));
          if (empty($select)) {
              return;
          }
          $missingKey = function ($fieldList, $key) {
              foreach ($key as $keyField) {
                  if (!in_array($keyField, $fieldList, true)) {
                      return true;
                  }
              }
  
              return false;
          };
  
          $missingFields = $missingKey($select, $key);
          if ($missingFields) {
              $driver = $fetchQuery->getConnection()->getDriver();
              $quoted = array_map([$driver, 'quoteIdentifier'], $key);
              $missingFields = $missingKey($select, $quoted);
          }
  
          if ($missingFields) {
              throw new InvalidArgumentException(
                  sprintf(
                      'You are required to select the "%s" field(s)',
                      implode(', ', (array)$key)
                  )
              );
          }
      }
code_tokens: protected function _assertFieldsPresent ( $ fetchQuery , $ key ) { $ select = $ fetchQuery -> aliasFields ( $ fetchQuery -> clause ( 'select' ) ) ; if ( empty ( $ select ) ) { return ; } $ missingKey = function ( $ fieldList , $ key ) { foreach ( $ key as $ keyField ) { if ( ! in_array ( $ keyField , $ fieldList , true ) ) { return true ; } } return false ; } ; $ missingFields = $ missingKey ( $ select , $ key ) ; if ( $ missingFields ) { $ driver = $ fetchQuery -> getConnection ( ) -> getDriver ( ) ; $ quoted = array_map ( [ $ driver , 'quoteIdentifier' ] , $ key ) ; $ missingFields = $ missingKey ( $ select , $ quoted ) ; } if ( $ missingFields ) { throw new InvalidArgumentException ( sprintf ( 'You are required to select the "%s" field(s)' , implode ( ', ' , ( array ) $ key ) ) ) ; } }
docstring: Checks that the fetching query either has auto fields on or
  has the foreignKey fields selected.
  If the required fields are missing, throws an exception.
  
  @param \Cake\ORM\Query $fetchQuery The association fetching query
  @param array $key The foreign key fields to check
  @return void
  @throws \InvalidArgumentException
docstring_tokens: Checks that the fetching query either has auto fields on or has the foreignKey fields selected . If the required fields are missing throws an exception .