Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Remove unnecessary condition #632

Merged
merged 1 commit into from Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ For a full diff see [`2.0.0...2.1.0`][2.0.0...2.1.0].
### Changed

- Adjusted `SchemaNormalizer` to support `anyOf` ([#623]), by [@localheinz]
- Stopped checking whether `type` property in schema is set to `array` or `object` ([#632]), by [@localheinz]

## [`2.0.0`][2.0.0]

Expand Down Expand Up @@ -461,6 +462,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#618]: https://github.com/ergebnis/json-normalizer/pull/618
[#619]: https://github.com/ergebnis/json-normalizer/pull/619
[#623]: https://github.com/ergebnis/json-normalizer/pull/623
[#632]: https://github.com/ergebnis/json-normalizer/pull/632

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
32 changes: 0 additions & 32 deletions src/SchemaNormalizer.php
Expand Up @@ -131,13 +131,6 @@ private function normalizeArray(
$schema,
);

/**
* @see https://json-schema.org/understanding-json-schema/reference/array.html
*/
if (!self::describesType('array', $schema)) {
return $data;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/array.html#items
*/
Expand Down Expand Up @@ -179,13 +172,6 @@ private function normalizeObject(
$schema,
);

/**
* @see https://json-schema.org/understanding-json-schema/reference/object.html
*/
if (!self::describesType('object', $schema)) {
return $data;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/object.html#properties
*/
Expand Down Expand Up @@ -298,22 +284,4 @@ private function resolveSchema(

return $schema;
}

/**
* @see https://json-schema.org/understanding-json-schema/reference/type.html
*/
private static function describesType(
string $type,
\stdClass $schema
): bool {
if (!\property_exists($schema, 'type')) {
return false;
}

if ($schema->type === $type) {
return true;
}

return \is_array($schema->type) && \in_array($type, $schema->type, true);
}
}