master

laravel/framework

Last updated at: 29/12/2023 09:21

Arrayable.php

TLDR

This file contains the Arrayable interface, which defines a method toArray() that should be implemented by classes that want to be converted into an array.

Methods

toArray

This method should be implemented by a class that wants to be converted into an array. It returns an array with keys of type TKey and values of type TValue.

<?php

namespace Illuminate\Contracts\Support;

/**
 * @template TKey of array-key
 * @template TValue
 */
interface Arrayable
{
    /**
     * Get the instance as an array.
     *
     * @return array<TKey, TValue>
     */
    public function toArray();
}