src/Db/Orm/ActiveQuery.php
public function one($db = null)
    {
        if ($this->emulateExecution) {
            return reject(false);
        }

        return $this->createCommand($db)->thenLazy(
            function(CommandInterface $command) {
                return $command->queryOne();
            }
        )->thenLazy(
            function($row) {
                if ($row !== false) {
                    return $this->populate([$row]);
                }
                return reject(null);
            }
        )->thenLazy(
            function($models) {
                return reset($models) ?: reject(null);
            }
        );
    }
public function one($db = null)
    {
        if ($this->emulateExecution) {
            return reject(false);
        }

        return $this->createCommand($db)->thenLazy(
            function(CommandInterface $command) {
                return $command->queryOne();
            }
        )->thenLazy(
            function($row) {
                if ($row !== false) {
                    return $this->populate([$row]);
                }
                return reject(null);
            }
        )->thenLazy(
            function($models) {
                return reset($models) ?: reject(null);
            }
        );
    }
Executes query and returns a single row of result.
@param DatabaseInterface|DbConnectionGetterInterface|null $db the DB connection used to create the DB command.
If `null`, the DB connection returned by [[modelClass]] will be used.
@return ExtendedPromiseInterface with ActiveRecordInterface|array|null a single row of query result. Depending on the setting of [[asArray]],
the query result may be either an array or an ActiveRecord object. `null` will be returned
if the query results in nothing.