@@ -279,45 +279,46 @@ public function required_with($str = null, ?string $fields = null, array $data =
279279 * required_without[id,email]
280280 *
281281 * @param string|null $str
282- * @param string|null $keyField This rule param fields aren't present, this field is required.
282+ * @param string|null $otherFields The param fields of required_without[].
283+ * @param string|null $field This rule param fields aren't present, this field is required.
283284 */
284- public function required_without ($ str = null , ?string $ fields = null , array $ data = [], ?string $ error = null , ?string $ keyField = null ): bool
285+ public function required_without ($ str = null , ?string $ otherFields = null , array $ data = [], ?string $ error = null , ?string $ field = null ): bool
285286 {
286- if ($ fields === null || empty ($ data )) {
287+ if ($ otherFields === null || empty ($ data )) {
287288 throw new InvalidArgumentException ('You must supply the parameters: fields, data. ' );
288289 }
289290
290291 // If the field is present we can safely assume that
291292 // the field is here, no matter whether the corresponding
292293 // search field is present or not.
293- $ fields = explode (', ' , $ fields );
294- $ present = $ this ->required ($ str ?? '' );
294+ $ otherFields = explode (', ' , $ otherFields );
295+ $ present = $ this ->required ($ str ?? '' );
295296
296297 if ($ present ) {
297298 return true ;
298299 }
299300
300- $ nowKeyField = 0 ;
301+ $ fieldIndex = 0 ;
301302
302303 // Still here? Then we fail this test if
303304 // any of the fields are not present in $data
304- foreach ($ fields as $ field ) {
305- if ((strpos ($ field , '. ' ) === false ) && (! array_key_exists ($ field , $ data ) || empty ($ data [$ field ]))) {
305+ foreach ($ otherFields as $ otherField ) {
306+ if ((strpos ($ otherField , '. ' ) === false ) && (! array_key_exists ($ otherField , $ data ) || empty ($ data [$ otherField ]))) {
306307 return false ;
307308 }
308- if (strpos ($ field , '. ' ) !== false ) {
309- if ($ keyField === null ) {
309+ if (strpos ($ otherField , '. ' ) !== false ) {
310+ if ($ field === null ) {
310311 throw new InvalidArgumentException ('You must supply the parameters: keyField. ' );
311312 }
312313
313- $ fieldData = dot_array_search ($ field , $ data );
314- $ keyFieldArray = explode ('. ' , $ keyField );
315- $ nowKeyField = $ keyFieldArray [1 ];
314+ $ fieldData = dot_array_search ($ otherField , $ data );
315+ $ fieldSplitArray = explode ('. ' , $ field );
316+ $ fieldIndex = $ fieldSplitArray [1 ];
316317
317318 if (is_array ($ fieldData )) {
318- return ! empty (dot_array_search ($ field , $ data )[$ nowKeyField ]);
319+ return ! empty (dot_array_search ($ otherField , $ data )[$ fieldIndex ]);
319320 }
320- $ nowField = str_replace ('* ' , $ nowKeyField , $ field );
321+ $ nowField = str_replace ('* ' , $ fieldIndex , $ otherField );
321322 $ nowFieldVaule = dot_array_search ($ nowField , $ data );
322323
323324 return null !== $ nowFieldVaule ;
0 commit comments