Skip to content

\JsonSchema\Constraints\BaseConstraint::arrayToObjectRecursive() doesn't convert empty arrays to objects #407

Closed as not planned
@shtrom

Description

@shtrom

When an empty array is given to \JsonSchema\Constraints\BaseConstraint::arrayToObjectRecursive(), it is returned identical. This leads to issues later on when using a SchemaStorage to contain this schema. Such an empty schema is only really used for tests, but this currently requires workarounds.

The following example code

use \JsonSchema\Validator;
print_r(Validator::arrayToObjectRecursive([ "baz" => [ "bar" => "baz" ]  ])); 
print_r(Validator::arrayToObjectRecursive([]));

results in

stdClass Object
(
    [baz] => stdClass Object
        (
            [bar] => baz
        )

)
Array
(
)

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