Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php /** @return non-empty-array<int, array<string, scalar>> */ function process(mixed $inputArray): array { // Must be non-empty-array if (!is_array($inputArray) || empty($inputArray)) { throw new Exception(); } foreach ($inputArray as $rowKey => $rowData) { if (!is_string($rowKey)) { throw new Exception(); } // Must be non-empty-array on 2nd level if (!is_array($rowData) || empty($rowData)) { throw new Exception(); } foreach ($rowData as $columnName => $columnValue) { // String keys if (!is_string($columnName)) { throw new Exception(); } // Scalar values if (!is_scalar($columnValue)) { throw new Exception(); } } } return $inputArray; }
Snippet created on May 26 2023 at 08:48 UTC
Settings
Get link