Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use array_key_exists
  • Loading branch information
fogelito committed Jul 28, 2025
commit 2d37031df8d939dee5d01815442c5efaf8f66d9d
12 changes: 10 additions & 2 deletions src/Database/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ class Document extends ArrayObject
*/
public function __construct(array $input = [])
{
if (isset($input['$id']) && !\is_string($input['$id'])) {
if (array_key_exists('$id', $input) && !\is_string($input['$id'])) {
throw new StructureException('$id must be of type string');
}

if (isset($input['$permissions']) && !is_array($input['$permissions'])) {
if (array_key_exists('$permissions', $input) && !is_array($input['$permissions'])) {
throw new StructureException('$permissions must be of type array');
}

// if (isset($input['$id']) && !\is_string($input['$id'])) {
// throw new StructureException('$id must be of type string');
// }
//
// if (isset($input['$permissions']) && !is_array($input['$permissions'])) {
// throw new StructureException('$permissions must be of type array');
// }
//
foreach ($input as $key => $value) {
if (!\is_array($value)) {
continue;
Expand Down