@@ -882,12 +882,7 @@ private function verifyTypes($type, $value, array &$invalidTypes)
882882 return true ;
883883 }
884884
885- $ invalidValues = array_filter ( // Filter out valid values, keeping invalid values in the resulting array
886- $ value ,
887- function ($ value ) use ($ type ) {
888- return !self ::isValueValidType ($ type , $ value );
889- }
890- );
885+ $ invalidValues = $ this ->getInvalidValues ($ value , $ type );
891886
892887 if (!$ invalidValues ) {
893888 return true ;
@@ -937,12 +932,7 @@ private function verifyArrayType($type, array $value, array &$invalidTypes)
937932 return $ success ;
938933 }
939934
940- $ invalid = array_filter ( // Filter out valid values, keeping invalid values in the resulting array
941- $ value ,
942- function ($ value ) use ($ type ) {
943- return !self ::isValueValidType ($ type , $ value );
944- }
945- );
935+ $ invalid = $ this ->getInvalidValues ($ value , $ type );
946936
947937 return !count ($ invalid );
948938 }
@@ -1118,4 +1108,22 @@ private static function isValueValidType($type, $value)
11181108 {
11191109 return (function_exists ($ isFunction = 'is_ ' .$ type ) && $ isFunction ($ value )) || $ value instanceof $ type ;
11201110 }
1111+
1112+ /**
1113+ * @param array $arrayValues
1114+ *
1115+ * @return array
1116+ */
1117+ private function getInvalidValues (array $ arrayValues , $ type )
1118+ {
1119+ $ invalidValues = array ();
1120+
1121+ foreach ($ arrayValues as $ key => $ value ) {
1122+ if (!self ::isValueValidType ($ type , $ value )) {
1123+ $ invalidValues [$ key ] = $ value ;
1124+ }
1125+ }
1126+
1127+ return $ invalidValues ;
1128+ }
11211129}
0 commit comments