Skip to content

Support for @type being an array #10

Description

@louist7

There's a bug in the Brick\StructuredData\Reader\JsonLdReader at 151-159:

  } elseif (is_array($type)) {
      $types = array_map(
          fn($type) => is_string($type) ? $this->resolveTerm($type, $vocabulary) : null,
          $types,                          // ← BUG: should be $type, not $types
      );
      $types = array_filter($types);
      $types = array_values($types);
  }

When @type is an array, array_map iterates over $types (the empty array initialised on line 143) instead of $type (the actual array value from the JSON). So every type gets silently dropped.

Suggested fix:

$types = array_map(
      fn($t) => is_string($t) ? $this->resolveTerm($t, $vocabulary) : null,
      $type,   // was $types
  );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions