Skip to content

Commit 652ffc6

Browse files
committed
chore(develop): safe unwrap of properties in responses
1 parent 0df1595 commit 652ffc6

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ composer.lock
44
*.DS_Store
55
examples/out
66
examples/models/2021-06-17
7+
examples/reference/Aryeo
78
.phpunit.result.cache

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Aryeo
3+
Copyright (c) 2024 Aryeo
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

app/Command/Report/SafeController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ public function checkEnumsChanged($last_open_api, $current_open_api)
497497
$errors[] = sprintf(
498498
'%s (%s): Enum removal detected at `%s` (%s).',
499499
PapiMethods::formatOperationKey($operation_key),
500-
'parameter::'.$parameter_in,
500+
'parameter::' . $parameter_in,
501501
$parameter_name,
502502
$difference
503503
);
@@ -546,7 +546,7 @@ public function checkResponsePropertyNowNullable($last_open_api, $current_open_a
546546
'',
547547
$property_key,
548548
$last_property,
549-
$current_operation_response_properties[$property_key]
549+
$current_operation_response_properties[$property_key] ?? []
550550
)
551551
);
552552
}
@@ -585,7 +585,7 @@ public function comparePropertySafeNullabilityRecursive($operation_key, $status_
585585
$this->comparePropertySafeNullabilityRecursive(
586586
$operation_key,
587587
$status_code,
588-
$property_key.'.',
588+
$property_key . '.',
589589
$next_property_key,
590590
$next_property,
591591
$property_two_properties[$next_property_key]
@@ -607,7 +607,7 @@ public function comparePropertySafeNullability($operation_key, $status_code, $pr
607607
'%s (%s): Property `%s` in the response changed from non-nullable to nullable.',
608608
PapiMethods::formatOperationKey($operation_key),
609609
$status_code,
610-
$property_key_prefix.$property_key
610+
$property_key_prefix . $property_key
611611
)];
612612
} else {
613613
return [];
@@ -692,12 +692,12 @@ public function schemaObjectPropertyMap($schema, $key = 'root', $map = [])
692692
$property_keys = array_keys($schema['properties'] ?? []);
693693
$map[$key] = $property_keys;
694694
foreach ($property_keys as $property_key) {
695-
$map = array_merge($map, $this->schemaObjectPropertyMap($schema['properties'][$property_key], $key.'.'.$property_key, $map));
695+
$map = array_merge($map, $this->schemaObjectPropertyMap($schema['properties'][$property_key], $key . '.' . $property_key, $map));
696696
}
697697

698698
return $map;
699699
} elseif ($schema['type'] === 'array') {
700-
return array_merge($map, $this->schemaObjectPropertyMap($schema['items'], $key.'.array[items]', $map));
700+
return array_merge($map, $this->schemaObjectPropertyMap($schema['items'], $key . '.array[items]', $map));
701701
} else {
702702
return $map;
703703
}
@@ -710,16 +710,16 @@ public function schemaPropertyTypeMap($schema, $key = 'root', $map = [])
710710
{
711711
if (isset($schema['type'])) {
712712
if ($schema['type'] === 'object') {
713-
$map[$key.'.title'] = $schema['title'] ?? '';
713+
$map[$key . '.title'] = $schema['title'] ?? '';
714714
$properties = $schema['properties'] ?? [];
715715

716716
foreach ($properties as $property_key => $property) {
717-
$map = array_merge($map, $this->schemaPropertyTypeMap($property, $key.'.'.$property_key, $map));
717+
$map = array_merge($map, $this->schemaPropertyTypeMap($property, $key . '.' . $property_key, $map));
718718
}
719719

720720
return $map;
721721
} elseif ($schema['type'] === 'array') {
722-
return array_merge($map, $this->schemaPropertyTypeMap($schema['items'], $key.'.array[items]', $map));
722+
return array_merge($map, $this->schemaPropertyTypeMap($schema['items'], $key . '.array[items]', $map));
723723
} else {
724724
$map[$key] = $schema['type'];
725725

@@ -739,13 +739,13 @@ public function schemaPropertyRequiredMap($schema, $key = 'root', $map = [])
739739

740740
if (isset($schema['properties'])) {
741741
foreach ($schema['properties'] as $property_key => $property) {
742-
$map = array_merge($map, $this->schemaPropertyRequiredMap($property, $key.'.'.$property_key, $map));
742+
$map = array_merge($map, $this->schemaPropertyRequiredMap($property, $key . '.' . $property_key, $map));
743743
}
744744
}
745745

746746
return $map;
747747
} elseif ($schema['type'] === 'array') {
748-
return array_merge($map, $this->schemaPropertyRequiredMap($schema['items'], $key.'.array[items]', $map));
748+
return array_merge($map, $this->schemaPropertyRequiredMap($schema['items'], $key . '.array[items]', $map));
749749
} else {
750750
return $map;
751751
}

0 commit comments

Comments
 (0)