@@ -322,12 +322,10 @@ public function getGetterReturnType($methodReflection)
322
322
if (preg_match ("/.* \\@return \\s+( {$ escapedReturnType }).*/i " , $ methodDocBlock ->getContents (), $ matches )) {
323
323
$ returnType = $ matches [1 ];
324
324
}
325
- $ isRequired = preg_match ("/.*\@return\s+\S+\|null.*/i " , $ methodDocBlock ->getContents (), $ matches )
326
- ? false
327
- : true ;
325
+ $ isNotRequired = (bool )preg_match ("/.*\@return\s+\S+\|null.*/i " , $ methodDocBlock ->getContents (), $ matches );
328
326
return [
329
327
'type ' => $ returnType ,
330
- 'isRequired ' => $ isRequired ,
328
+ 'isRequired ' => ! $ isNotRequired ,
331
329
'description ' => $ returnAnnotation ->getDescription (),
332
330
'parameterCount ' => $ methodReflection ->getNumberOfRequiredParameters ()
333
331
];
@@ -385,13 +383,8 @@ public function normalizeType($type)
385
383
*/
386
384
public function isTypeSimple ($ type )
387
385
{
388
- $ type = $ this ->normalizeType ($ type );
389
- if ($ this ->isArrayType ($ type )) {
390
- $ type = $ this ->getArrayItemType ($ type );
391
- }
392
-
393
386
return in_array (
394
- $ type ,
387
+ $ this -> getNormalizedType ( $ type) ,
395
388
[
396
389
self ::NORMALIZED_STRING_TYPE ,
397
390
self ::NORMALIZED_INT_TYPE ,
@@ -410,12 +403,7 @@ public function isTypeSimple($type)
410
403
*/
411
404
public function isTypeAny ($ type )
412
405
{
413
- $ type = $ this ->normalizeType ($ type );
414
- if ($ this ->isArrayType ($ type )) {
415
- $ type = $ this ->getArrayItemType ($ type );
416
- }
417
-
418
- return ($ type == self ::NORMALIZED_ANY_TYPE );
406
+ return ($ this ->getNormalizedType ($ type ) == self ::NORMALIZED_ANY_TYPE );
419
407
}
420
408
421
409
/**
@@ -623,11 +611,13 @@ protected function setType(&$value, $type)
623
611
{
624
612
// settype doesn't work for boolean string values.
625
613
// ex: custom_attributes passed from SOAP client can have boolean values as string
626
- if ($ type == 'bool ' || $ type == 'boolean ' ) {
614
+ $ booleanTypes = ['bool ' , 'boolean ' ];
615
+ if (in_array ($ type , $ booleanTypes )) {
627
616
$ value = filter_var ($ value , FILTER_VALIDATE_BOOLEAN );
628
617
return true ;
629
618
}
630
- if (($ type == 'int ' || $ type == 'float ' ) && !is_numeric ($ value )) {
619
+ $ numType = ['int ' , 'float ' ];
620
+ if (in_array ($ type , $ numType ) && !is_numeric ($ value )) {
631
621
return false ;
632
622
}
633
623
return settype ($ value , $ type );
@@ -731,4 +721,19 @@ public function getOperationName($serviceName, $methodName)
731
721
{
732
722
return $ serviceName . ucfirst ($ methodName );
733
723
}
724
+
725
+ /**
726
+ * Get normalized type
727
+ *
728
+ * @param string $type
729
+ * @return string
730
+ */
731
+ private function getNormalizedType ($ type )
732
+ {
733
+ $ type = $ this ->normalizeType ($ type );
734
+ if ($ this ->isArrayType ($ type )) {
735
+ $ type = $ this ->getArrayItemType ($ type );
736
+ }
737
+ return $ type ;
738
+ }
734
739
}
0 commit comments