@@ -103,11 +103,11 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
103103 }
104104 }
105105 } else {
106- foreach ($ data as $ property => $ value ) {
106+ foreach ($ data as $ property => $ value ) {
107107 $ values [$ property ] = self ::sanitizeForSerialization ($ value );
108108 }
109109 }
110- return (object )$ values ;
110+ return (object ) $ values ;
111111 } else {
112112 return (string )$ data ;
113113 }
@@ -139,7 +139,9 @@ public static function sanitizeFilename($filename)
139139 */
140140 public static function sanitizeTimestamp ($ timestamp )
141141 {
142- if (!is_string ($ timestamp )) return $ timestamp ;
142+ if (!is_string ($ timestamp )) {
143+ return $ timestamp ;
144+ }
143145
144146 return preg_replace ('/(:\d{2}.\d{6})\d*/ ' , '$1 ' , $ timestamp );
145147 }
@@ -167,20 +169,20 @@ public static function toPathValue($value)
167169 */
168170 private static function isEmptyValue ($ value , string $ openApiType ): bool
169171 {
170- # If empty() returns false, it is not empty regardless of its type.
172+ // If empty() returns false, it is not empty regardless of its type.
171173 if (!empty ($ value )) {
172174 return false ;
173175 }
174176
175- # Null is always empty, as we cannot send a real "null" value in a query parameter.
177+ // Null is always empty, as we cannot send a real "null" value in a query parameter.
176178 if ($ value === null ) {
177179 return true ;
178180 }
179181
180182 switch ($ openApiType ) {
181- # For numeric values, false and '' are considered empty.
182- # This comparison is safe for floating point values, since the previous call to empty() will
183- # filter out values that don't match 0.
183+ // For numeric values, false and '' are considered empty.
184+ // This comparison is safe for floating point values, since the previous call to empty() will
185+ // filter out values that don't match 0.
184186 case 'int ' :
185187 case 'integer ' :
186188 return $ value !== 0 ;
@@ -189,16 +191,16 @@ private static function isEmptyValue($value, string $openApiType): bool
189191 case 'float ' :
190192 return $ value !== 0 && $ value !== 0.0 ;
191193
192- # For boolean values, '' is considered empty
194+ // For boolean values, '' is considered empty
193195 case 'bool ' :
194196 case 'boolean ' :
195197 return !in_array ($ value , [false , 0 ], true );
196198
197- # For string values, '' is considered empty.
199+ // For string values, '' is considered empty.
198200 case 'string ' :
199201 return $ value === '' ;
200202
201- # For all the other types, any value at this point can be considered empty.
203+ // For all the other types, any value at this point can be considered empty.
202204 default :
203205 return true ;
204206 }
@@ -226,10 +228,10 @@ public static function toQueryValue(
226228 bool $ required = true
227229 ): array {
228230
229- # Check if we should omit this parameter from the query. This should only happen when:
230- # - Parameter is NOT required; AND
231- # - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For
232- # example, 0 as "int" or "boolean" is NOT an empty value.
231+ // Check if we should omit this parameter from the query. This should only happen when:
232+ // - Parameter is NOT required; AND
233+ // - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For
234+ // example, 0 as "int" or "boolean" is NOT an empty value.
233235 if (self ::isEmptyValue ($ value , $ openApiType )) {
234236 if ($ required ) {
235237 return ["{$ paramName }" => '' ];
@@ -238,8 +240,8 @@ public static function toQueryValue(
238240 }
239241 }
240242
241- # Handle DateTime objects in query
242- if ($ openApiType === "\\DateTime " && $ value instanceof \DateTime) {
243+ // Handle DateTime objects in query
244+ if ($ openApiType === "\\DateTime " && $ value instanceof \DateTime) {
243245 return ["{$ paramName }" => $ value ->format (self ::$ dateTimeFormat )];
244246 }
245247
@@ -249,10 +251,12 @@ public static function toQueryValue(
249251 // since \GuzzleHttp\Psr7\Query::build fails with nested arrays
250252 // need to flatten array first
251253 $ flattenArray = function ($ arr , $ name , &$ result = []) use (&$ flattenArray , $ style , $ explode ) {
252- if (!is_array ($ arr )) return $ arr ;
254+ if (!is_array ($ arr )) {
255+ return $ arr ;
256+ }
253257
254258 foreach ($ arr as $ k => $ v ) {
255- $ prop = ($ style === 'deepObject ' ) ? $ prop = "{$ name }[ {$ k }] " : $ k ;
259+ $ prop = ($ style === 'deepObject ' ) ? "{$ name }[ {$ k }] " : $ k ;
256260
257261 if (is_array ($ v )) {
258262 $ flattenArray ($ v , $ prop , $ result );
@@ -497,7 +501,7 @@ public static function deserialize($data, $class, $httpHeaders = null)
497501 $ data = is_string ($ data ) ? json_decode ($ data ) : $ data ;
498502
499503 if (is_array ($ data )) {
500- $ data = (object )$ data ;
504+ $ data = (object ) $ data ;
501505 }
502506
503507 // If a discriminator is defined and points to a valid subclass, use it.
@@ -536,20 +540,20 @@ public static function deserialize($data, $class, $httpHeaders = null)
536540 }
537541
538542 /**
539- * Build a query string from an array of key value pairs.
540- *
541- * This function can use the return value of `parse()` to build a query
542- * string. This function does not modify the provided keys when an array is
543- * encountered (like `http_build_query()` would).
544- *
545- * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112
546- * with a modification which is described in https://github.com/guzzle/psr7/pull/603
547- *
548- * @param array $params Query string parameters.
549- * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
550- * to encode using RFC3986, or PHP_QUERY_RFC1738
551- * to encode using RFC1738.
552- */
543+ * Build a query string from an array of key value pairs.
544+ *
545+ * This function can use the return value of `parse()` to build a query
546+ * string. This function does not modify the provided keys when an array is
547+ * encountered (like `http_build_query()` would).
548+ *
549+ * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112
550+ * with a modification which is described in https://github.com/guzzle/psr7/pull/603
551+ *
552+ * @param array $params Query string parameters.
553+ * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
554+ * to encode using RFC3986, or PHP_QUERY_RFC1738
555+ * to encode using RFC1738.
556+ */
553557 public static function buildQuery (array $ params , $ encoding = PHP_QUERY_RFC3986 ): string
554558 {
555559 if (!$ params ) {
0 commit comments