original_string: protected function _resolveJoins($associations, $matching = [])
      {
          $result = [];
          foreach ($matching as $table => $loadable) {
              $result[$table] = $loadable;
              $result += $this->_resolveJoins($loadable->associations(), []);
          }
          foreach ($associations as $table => $loadable) {
              $inMatching = isset($matching[$table]);
              if (!$inMatching && $loadable->canBeJoined()) {
                  $result[$table] = $loadable;
                  $result += $this->_resolveJoins($loadable->associations(), []);
                  continue;
              }
  
              if ($inMatching) {
                  $this->_correctStrategy($loadable);
              }
  
              $loadable->setCanBeJoined(false);
              $this->_loadExternal[] = $loadable;
          }
  
          return $result;
      }
code: protected function _resolveJoins($associations, $matching = [])
      {
          $result = [];
          foreach ($matching as $table => $loadable) {
              $result[$table] = $loadable;
              $result += $this->_resolveJoins($loadable->associations(), []);
          }
          foreach ($associations as $table => $loadable) {
              $inMatching = isset($matching[$table]);
              if (!$inMatching && $loadable->canBeJoined()) {
                  $result[$table] = $loadable;
                  $result += $this->_resolveJoins($loadable->associations(), []);
                  continue;
              }
  
              if ($inMatching) {
                  $this->_correctStrategy($loadable);
              }
  
              $loadable->setCanBeJoined(false);
              $this->_loadExternal[] = $loadable;
          }
  
          return $result;
      }
code_tokens: protected function _resolveJoins ( $ associations , $ matching = [ ] ) { $ result = [ ] ; foreach ( $ matching as $ table => $ loadable ) { $ result [ $ table ] = $ loadable ; $ result += $ this -> _resolveJoins ( $ loadable -> associations ( ) , [ ] ) ; } foreach ( $ associations as $ table => $ loadable ) { $ inMatching = isset ( $ matching [ $ table ] ) ; if ( ! $ inMatching && $ loadable -> canBeJoined ( ) ) { $ result [ $ table ] = $ loadable ; $ result += $ this -> _resolveJoins ( $ loadable -> associations ( ) , [ ] ) ; continue ; } if ( $ inMatching ) { $ this -> _correctStrategy ( $ loadable ) ; } $ loadable -> setCanBeJoined ( false ) ; $ this -> _loadExternal [ ] = $ loadable ; } return $ result ; }
docstring: Helper function used to compile a list of all associations that can be
  joined in the query.
  
  @param array $associations list of associations from which to obtain joins.
  @param array $matching list of associations that should be forcibly joined.
  @return array
docstring_tokens: Helper function used to compile a list of all associations that can be joined in the query .