Returns the first item from the collection.

@return mixed|null
165111
public function first()
    {
        $this->executeBeforeCallback();

        return count($this->items) > 0 ? reset($this->items) : null;
    }
734979
public function first(): ?\stdClass
    {
        $pdoStatement = $this->provideStatement();
        $pdoStatement = $this->execute($pdoStatement);
        $row = $pdoStatement->fetch(\PDO::FETCH_OBJ);
        return (!empty($row)) ? $row : null;
    }
189487
public function first()
    {
        $sql = clone($this);
        $sql->limit(1);
        $collection = $this->query($sql);
        return $collection->isEmpty() ? null : $collection[0];
    }
36364
public function first()
    {
        $this->rewind();
        $document = $this->getCursor()->current();

        if (!$document) {
            return;
        }

        return $this->getAssembler()->assemble($document, $this->entitySchema);
    }
875818
public function first()
    {
        $oldLimit = $this->limit;
        $this->limit = 1;
        $rows = $this->get();
        $this->limit = $oldLimit;
        return isset($rows[0]) ? $rows[0] : null;
    }
229974
protected function NextItem()
	{
		while (true)
		{
			if ( ! $this->accept )
			{
				if ( ! $this->MoveNextIter() )
				{
					return null;
				}
				$this->first = true;
				if ( $this->matchSelf && $this->TestItem() )
				{
					$this->sequentialPosition++;
					return $this->curr;
				}
			}
			if ( $this->first)
			{
				$this->accept = $this->MoveToFirst( $this->curr );
				$this->first = false;
			}
			else
			{
				$this->accept = $this->MoveToNext( $this->curr );
			}
			if ( $this->accept )
			{
				if ( $this->TestItem() )
				{
					$this->sequentialPosition++;
					return $this->curr;
				}
			}
		}
	}
531569
public function first()
    {
        $this->limit(1);
        $result = $this->get();
        return empty($result) ? null : $result[0];
    }
1339849
public function first(callable $fn = null, $default = null)
    {
        if (is_null($fn)) {
            return count($this->items) > 0 ? reset($this->items) : $default;
        }

        foreach ($this->getIterator() as $value) {
            if (call_user_func($fn, $value)) {
                return $value;
            }
        }

        return $default;
    }
880175
public function first() : ?Post
    {
        $params = array_merge($this->getParameters(), [
            'limit' => 1,
        ]);

        $posts = Timber::get_posts($params, $this->postClass);

        if (!is_array($posts)) {
            return null;
        }

        return collect($posts)->first();
    }
808991
public static function first($value)
    {

        if (is_array($value) && $value) {
            reset($value);
            return current($value);
        }

        if (!$value) {
            return null;
        }

        if (is_string($value)) {
            return $value[0];
        }

        if (!is_object($value)) {
            return null;
        }

        if ($value instanceof ArrayAccess && isset($value[0])) {
            return $value[0];
        }

        if (!$value instanceof Traversable) {
            return null;
        }

        foreach ($value as $key=>$item) {
            return $item;
        }

        return null;

    }
1225745
public function getFirstToken()
    {
        if (! $this->_firstToken) {
            if (! $this->_tokens) {
                //No cache yet, but we might need all tokens later
                $this->getTokens();
            }
            $this->_firstToken = reset($this->_tokens);
        }

        return $this->_firstToken;
    }
1206836
public function first()
    {
        if ($this->isEmpty()) {
            return $this->makeItem(null);
        }

        $arResultIDList = $this->arElementIDList;

        $iElementID = array_shift($arResultIDList);

        return $this->makeItem($iElementID);
    }
68561
public function first($name)
    {
        if ($this->hasValue($name)) {
            return $this->getValue($name);
        }

        foreach ($this->getStructures() as $childStructure) {
            if ($result = $childStructure->first($name)) {
                return $result;
            }
        }

        return null;
    }
942795
public function first()
	{
		$result = $this->fetchFirst(PDO::FETCH_ASSOC);

		if($result !== false)
		{
			return $this->hydrateModelsAndLoadIncludes([$result])[0];
		}

		return false;
	}
387091
public function first()
    {
        $limit = $this->_limit;
        $offset = $this->_offset;
        $this->limit(1);
        $result = $this->all();

        $this->_limit  = $limit;
        $this->_offset = $offset;
        return is_bool($result) ? [] : reset($result);
    }
511308
public static function first($columns = [])
    {
        $model = static::getInstance();
        $item  = $model->getAll($columns, 1);

        return $item->first();
    }
505277
public function first()
    {
        $data = $this->getData();

        if (!$this->where) {
            return $data
                ? $this->convertItem(reset($data))
                : null;
        }

        foreach ($data as &$rs) {
            if ($this->matchWhere($rs)) {
                return $this->convertItem($rs);
            }
        }

        return null;
    }