-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
2.0Types 2.0Types 2.0
Description
Extract values should be also possile from objects implementing ArrayAccess.
BC break: No
New feature: Yes
If you implement own collection or you want to extract values maybe from \Nette\Database\IRow. First you have to serialize object to array then you can extract values from array.
Example:
/** @var Nette\Database\Table\ActiveRow $databaseRow */
$databaseRow = $this->repository->fetch();
$array = iterator_to_array($databaseRow); // or $databaseRow->toArray()
$id = PrimitiveTypes::extractInt($array, 'id');should be simplified to:
/** @var Nette\Database\Table\ActiveRow $databaseRow */
$databaseRow = $this->repository->fetch();
$id = PrimitiveTypes::extractInt($databaseRow, 'id');So exract method should look like:
final public static function extractInt(array|ArrayAccess $data, string $key): int; // PHP 8.0 syntaxMetadata
Metadata
Assignees
Labels
2.0Types 2.0Types 2.0