Various actions possible here, mostly for compatibility with SQLs.

@param Model  $m
@param string $type
@param array  $args

@return mixed
166053
public function action($m, $type, $args = [])
    {
        if (!is_array($args)) {
            throw new Exception([
                '$args must be an array',
                'args' => $args,
            ]);
        }

        $action = $this->initAction($m, isset($args[0]) ? $args[0] : null);

        $this->applyConditions($m, $action);
        $this->setLimitOrder($m, $action);

        switch ($type) {
            case 'select':

                return $action;

            case 'count':

                return $action->count();

            /* These are not implemented yet
            case 'field':

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];

                return $action->filterField($field->short_name);

            case 'fx':
            case 'fx0':

                return $action->aggregate($field->short_name, $fx);
            */

            default:
                throw new Exception([
                    'Unsupported action mode',
                    'type' => $type,
                ]);
        }
    }
769738
protected function _setQuery(string $type, $args): self
    {
        if (!\is_array($args) && !($args instanceof AbstractSpanQuery)) {
            throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractSpanQuery');
        }

        return $this->setParam($type, $args);
    }
610879
public function get(...$args)
    {
        $record = $this->fetchSingle($args);
        if (!$record)
            return null;
        $obj = new $this->model_class;
        $obj->assignRecord($record, $this->db);
        return $obj;
    }
760379
protected function addCheck($name, $type, $args)
    {
        $func = $type.'Check';

        if (method_exists($this, $func)) {
            $type = strtolower(str_replace($type, '', $name));
            $this->$func($type, $name, $args);
        } else {
          throw new \InvalidArgumentException('Invalid check type: '.$type);
        }
    }
715162
public function getRegister($type, array $args = [])
    {
        $chain = clone $this->chain;
        while ($chain) {
            /** @var TypeResolverInterface $resolver */
            $resolver = $chain->current();
            try {
                $register = $resolver->getRegister($type, $args);
                if ($register instanceof RegisterInterface) {
                    return $register;
                }
            } catch (\Exception $e) {
                if (!$this->getFlagIgnoreException()) {
                    throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e);
                }
            }
            $chain->next();
        }

        $errMsg = sprintf('Register for type %s not found', $type);
        throw new Exception\ResultNotFoundException($errMsg);
    }
358161
public function typecastLoadRow(Model $m, $row)
    {
        $id = null;
        if (isset($row[$m->id_field])) {
            // temporary remove id field
            $id = $row[$m->id_field];
            unset($row[$m->id_field]);
        } else {
            $id = null;
        }
        $row = array_combine($this->header, $row);
        if (isset($id)) {
            $row[$m->id_field] = $id;
        }

        foreach ($row as $key => &$value) {
            if ($value === null) {
                continue;
            }

            if ($f = $m->hasField($key)) {
                $value = $this->typecastLoadField($f, $value);
            }
        }

        return $row;
    }
93273
private function createArgumentDescriptorForMagicMethod(string $name, Type $type): ArgumentDescriptor
    {
        $argumentDescriptor = new ArgumentDescriptor();
        $argumentDescriptor->setType(AssemblerAbstract::deduplicateTypes($type));
        $argumentDescriptor->setName($name);

        return $argumentDescriptor;
    }
827638
public function insert($args) {
        if (empty($args)) {
            Garp_Cli::errorOut('Please provide a model');
            return false;
        }

        $className = "Model_{$args[0]}";
        $model = new $className();
        $fields = $model->getConfiguration('fields');
        $fields = array_filter($fields, not(propertyEquals('name', 'id')));

        $mode = $this->_getInsertionMode();
        if ($mode === 'g') {
            $newData = $this->_createGibberish($fields);
        } else {
            $newData = array_reduce(
                $fields,
                function ($acc, $cur) {
                    $acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
                    return $acc;
                },
                array()
            );
        }

        $id = $model->insert($newData);
        Garp_Cli::lineOut("Record created: #{$id}");
        return true;
    }
967411
protected function _preCall(&$name, array &$args) {
        if (!method_exists($this, $name)) {
            $settings = $this->getCachedSettings($name);
            if (array_key_exists('reference', $settings['attrs']) || $settings['type'] == 'ReferenceMany') {
                $modelTable = array_key_exists('model', $settings['attrs']) ?
                        $settings['attrs']['model'] :
                        $settings['attrs']['reference']['model'];
                $columnValue = is_object($this->$name) ? $this->$name->getArrayCopy() : $this->$name;
                $nam = !is_array($columnValue) ? explode('__:DS:__', $columnValue) : $columnValue;
                $column = array_key_exists('column', $settings['attrs']) ?
                        $settings['attrs']['column'] :
                        $settings['attrs']['reference']['column'];
                $args['relateWhere'] = array();
                foreach ($nam as $val) {
                        $args['relateWhere'][] = array($column => $val);
                }
            }
            if ($modelTable || (!$modelTable && $modelTable = self::getModelTable(Util::camelTo_($name)))) {
                $model = is_array($modelTable) ?
                        new $modelTable[count($modelTable) - 1] :
                        new $modelTable;

                $name = $model->getTableName();
                if (!isset($args[0]['returnType']) || $args[0]['returnType'] == Table::RETURN_MODEL){
                    $relTable = $this->getConnection()->table($name);

                    $model->setConnection($this->getConnection());
                    $model->init($relTable);
                    $args['model'] = $model;
                }
            }
        }
    }
38880
public function expr(Model $m, $expr, $args = [])
    {
        if (!is_string($expr)) {
            return $this->connection->expr($expr, $args);
        }
        preg_replace_callback(
            '/\[[a-z0-9_]*\]|{[a-z0-9_]*}/i',
            function ($matches) use (&$args, $m) {
                $identifier = substr($matches[0], 1, -1);
                if ($identifier && !isset($args[$identifier])) {
                    $args[$identifier] = $m->getField($identifier);
                }

                return $matches[0];
            },
            $expr
        );

        return $this->connection->expr($expr, $args);
    }
597979
public function tryLoad(Model $m, $id, $table = null)
    {
        if (!isset($table)) {
            $table = $m->table;
        }

        if (!isset($this->data[$table][$id])) {
            return false; // no record with such id in table
        }

        return $this->typecastLoadRow($m, $this->data[$table][$id]);
    }
30971
private function getTypeObject($type, $args)
    {
        /* @var AbstractType $object */
        if ($type instanceof AbstractType) {
            $object = $type;
        } else {
            $class = $this->getTypeClass($type);

            if (!\class_exists($class)) {
                $class = TextType::class;
            }

            $object = new $class($args, $this);
        }

        return $object;
    }
608442
public function getRegister($type, array $args = [])
    {
        try {
            $wrapper = $this->wrapperFactory($type, $args, ServiceTypeResolver\RegisterWrapper::class);
        } catch (\Exception $e) {
            throw new Exception\ErrorCreatingRegisterException($e->getMessage(), $e->getCode(), $e);
        }
        return $wrapper;
    }
900388
public function getArg(string $name, string $type = null, $default = null)
    {
        if ($this->method == 'POST') {
            return $this->getPost($name, $type, $default);
        } else {
            return $this->getQuery($name, $type, $default);
        }
    }
276274
public function getCondition($type, array $args = [])
    {
        try {
            $wrapper = $this->wrapperFactory($type, $args, ServiceTypeResolver\ConditionWrapper::class);
        } catch (\Exception $e) {
            throw new Exception\ErrorCreatingConditionException($e->getMessage(), $e->getCode(), $e);
        }
        return $wrapper;
    }
36230
public static function is_type( $mf, $type ) {
		return is_array( $mf ) && ! empty( $mf['type'] ) && is_array( $mf['type'] ) && in_array( $type, $mf['type'], true );
	}
364157
public function setModel(\atk4\data\Model $model, $method = null, $args = [])
    {
        $this->runMethod($model, $method, $args);

        return $model;
    }