@@ -79,7 +79,7 @@ public function getExAppTaskProcessingProvider(string $appId, string $name): ?Ta
7979 }
8080 }
8181
82- private function everyElementHasKeys (array |null $ array , array $ keys ): bool {
82+ private function everyElementHasKeys (array |null $ array , array $ keys, bool $ properties_have_array = true ): bool {
8383 if (!is_array ($ array )) {
8484 return false ;
8585 }
@@ -88,12 +88,20 @@ private function everyElementHasKeys(array|null $array, array $keys): bool {
8888 if (!is_string ($ propertyName ) || !is_array ($ properties )) {
8989 return false ;
9090 }
91- foreach ($ properties as $ property ) {
92- if (!is_array ($ property )) {
93- return false ;
91+ if ($ properties_have_array ) {
92+ foreach ($ properties as $ property ) {
93+ if (!is_array ($ property )) {
94+ return false ;
95+ }
96+ foreach ($ keys as $ key ) {
97+ if (!array_key_exists ($ key , $ property )) {
98+ return false ;
99+ }
100+ }
94101 }
102+ } else {
95103 foreach ($ keys as $ key ) {
96- if (!array_key_exists ($ key , $ property )) {
104+ if (!array_key_exists ($ key , $ properties )) {
97105 return false ;
98106 }
99107 }
@@ -116,10 +124,10 @@ private function validateTaskProcessingProvider(array $provider): void {
116124 if (!isset ($ provider ['expected_runtime ' ]) || !is_int ($ provider ['expected_runtime ' ])) {
117125 throw new Exception ('"expected_runtime" key must be an integer ' );
118126 }
119- if (!$ this ->everyElementHasKeys ($ provider ['optional_input_shape ' ], ['name ' , 'description ' , 'shape_type ' ])) {
127+ if (!$ this ->everyElementHasKeys ($ provider ['optional_input_shape ' ], ['name ' , 'description ' , 'shape_type ' ], false )) {
120128 throw new Exception ('"optional_input_shape" should be an array and must have "name", "description" and "shape_type" keys ' );
121129 }
122- if (!$ this ->everyElementHasKeys ($ provider ['optional_output_shape ' ], ['name ' , 'description ' , 'shape_type ' ])) {
130+ if (!$ this ->everyElementHasKeys ($ provider ['optional_output_shape ' ], ['name ' , 'description ' , 'shape_type ' ], false )) {
123131 throw new Exception ('"optional_output_shape" should be an array and must have "name", "description" and "shape_type" keys ' );
124132 }
125133 if (!$ this ->everyElementHasKeys ($ provider ['input_shape_enum_values ' ], ['name ' , 'value ' ])) {
0 commit comments