code: public function findWith($with, &$models)
      {
          $primaryModel = reset($models);
          if (!$primaryModel instanceof ActiveRecordInterface) {
              /* @var $modelClass ActiveRecordInterface */
              $modelClass = $this->modelClass;
              $primaryModel = $modelClass::instance();
          }
          $relations = $this->normalizeRelations($primaryModel, $with);
          /* @var $relation ActiveQuery */
          foreach ($relations as $name => $relation) {
              if ($relation->asArray === null) {
                  // inherit asArray from primary query
                  $relation->asArray($this->asArray);
              }
              $relation->populateRelation($name, $models);
          }
      }
docs: Finds records corresponding to one or multiple relations and populates them into the primary models.
  @param array $with a list of relations that this query should be performed with. Please
  refer to [[with()]] for details about specifying this parameter.
  @param array|ActiveRecord[] $models the primary models (can be either AR instances or arrays)