Добавлены нулевые привязки по СБП Добавлена причина отмены возвратов `payment_expired`
13 KiB
YooKassa API SDK
Class: \YooKassa\Common\ListObject
Namespace: \YooKassa\Common
Summary:
Класс, представляющий модель ListObject.
Description:
Коллекция объектов AbstractObject.
Examples
Работа с коллекциями объектов
require_once '../vendor/autoload.php';
// Создание коллекции
$collection = new \YooKassa\Common\ListObject(\YooKassa\Request\Payments\Airline::class, [
[
'booking_reference' => 'IIIKRV',
'ticket_number' => '12342123413',
'passengers' => [
[
'first_name' => 'SERGEI',
'last_name' => 'IVANOV',
],
],
'legs' => [
[
'departure_airport' => 'LED',
'destination_airport' => 'AMS',
'departure_date' => '2023-01-20',
],
],
],
]);
var_dump([$collection->count(), $collection->toArray(), json_encode($collection->toArray())]);
// Чтобы сменить тип объекта коллекции, необходимо сначала очистить коллекцию. В случае попытки изменить тип объекта в заполненной коллекции, будет получено исключение
try {
$collection->setType(\YooKassa\Request\Payments\Leg::class);
} catch (Exception $exception) {
print_r($exception);
exit();
}
// Очищает коллекцию и устанавливает тип объекта в коллекцию
$collection->clear()->setType(\YooKassa\Request\Payments\Passenger::class);
// Добавляет объект в коллекцию
$collection->add(new \YooKassa\Request\Payments\Passenger(['first_name' => 'Sergei', 'last_name' => 'Ivanov']));
var_dump([$collection->count(), $collection->toArray(), json_encode($collection->toArray())]);
// Получить массив объектов
var_dump($collection->getItems()->toArray());
// Для добавления объектов в коллекцию можно использовать []
$collection[] = ['first_name' => 'Ivan', 'last_name' => 'Ivanov'];
// Можно удалить объект из коллекции по индексу
$collection->remove(1);
var_dump([$collection->count(), $collection->toArray(), json_encode($collection->toArray())]);
// Можно добавить массив объектов в коллекцию. Если тип коллекции интерфейс или абстрактный класс, то добавить массив не получится.
$collection->merge([
['first_name' => 'Michail', 'last_name' => 'Sidorov'],
new \YooKassa\Request\Payments\Passenger(['first_name' => 'Alex', 'last_name' => 'Lutor']),
]);
// Можно получить объект коллекции по индексу
var_dump([$collection[0]?->toArray(), $collection->get(1)?->toArray()]);
Constants
- No constants found
Methods
| Visibility | Name | Flag | Summary |
|---|---|---|---|
| public | __construct() | ||
| public | add() | Добавляет объект в коллекцию | |
| public | clear() | Очищает коллекцию | |
| public | count() | Возвращает количество объектов в коллекции | |
| public | get() | Возвращает объект коллекции по индексу | |
| public | getItems() | Возвращает коллекцию | |
| public | getIterator() | ||
| public | getType() | Возвращает тип объектов в коллекции | |
| public | isEmpty() | Проверка на пустую коллекцию | |
| public | jsonSerialize() | Возвращает коллекцию в виде массива | |
| public | merge() | Добавляет массив объектов в коллекцию | |
| public | offsetExists() | ||
| public | offsetGet() | ||
| public | offsetSet() | ||
| public | offsetUnset() | ||
| public | remove() | Удаляет объект из коллекции по индексу | |
| public | setType() | Устанавливает тип объектов в коллекции | |
| public | toArray() | Возвращает коллекцию в виде массива |
Details
-
Package: YooKassa
-
Class Hierarchy:
- \YooKassa\Common\ListObject
-
Implements:
-
See Also:
Tags
| Tag | Version | Description |
|---|---|---|
| category | Class | |
| author | cms@yoomoney.ru |
Methods
public __construct() : mixed
public __construct(string $type, array|null $data = []) : mixed
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
string |
type | Тип хранимых объектов |
array OR null |
data | Массив данных |
Returns: mixed -
public add() : $this
public add(mixed $item) : $this
Summary
Добавляет объект в коллекцию
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
mixed |
item |
Returns: $this -
public clear() : $this
public clear() : $this
Summary
Очищает коллекцию
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: $this -
public count() : int
public count() : int
Summary
Возвращает количество объектов в коллекции
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: int -
public get() : \YooKassa\Common\AbstractObject
public get(int $index) : \YooKassa\Common\AbstractObject
Summary
Возвращает объект коллекции по индексу
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
int |
index |
Returns: \YooKassa\Common\AbstractObject -
public getItems() : \Ds\Vector
public getItems() : \Ds\Vector
Summary
Возвращает коллекцию
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: \Ds\Vector -
public getIterator() : \Ds\Vector
public getIterator() : \Ds\Vector
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: \Ds\Vector -
public getType() : string
public getType() : string
Summary
Возвращает тип объектов в коллекции
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: string -
public isEmpty() : bool
public isEmpty() : bool
Summary
Проверка на пустую коллекцию
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: bool -
public jsonSerialize() : array
public jsonSerialize() : array
Summary
Возвращает коллекцию в виде массива
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: array -
public merge() : $this
public merge(iterable $data) : $this
Summary
Добавляет массив объектов в коллекцию
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
iterable |
data |
Returns: $this -
public offsetExists() : mixed
public offsetExists(mixed $offset) : mixed
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
mixed |
offset |
Returns: mixed -
public offsetGet() : mixed
public offsetGet(mixed $offset) : mixed
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
mixed |
offset |
Returns: mixed -
public offsetSet() : mixed
public offsetSet(mixed $offset, mixed $value) : mixed
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
mixed |
offset | |
mixed |
value |
Returns: mixed -
public offsetUnset() : mixed
public offsetUnset(mixed $offset) : mixed
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
mixed |
offset |
Returns: mixed -
public remove() : $this
public remove(int $index) : $this
Summary
Удаляет объект из коллекции по индексу
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
int |
index |
Returns: $this -
public setType() : $this
public setType(string $type) : $this
Summary
Устанавливает тип объектов в коллекции
Details:
- Inherited From: \YooKassa\Common\ListObject
Parameters:
| Type | Name | Description |
|---|---|---|
string |
type |
Returns: $this -
public toArray() : array
public toArray() : array
Summary
Возвращает коллекцию в виде массива
Details:
- Inherited From: \YooKassa\Common\ListObject
Returns: array -
Top Namespaces
Reports
This document was automatically generated from source code comments on 2026-06-29 using phpDocumentor
© 2026 YooMoney