Skip to content

Commit 70ca497

Browse files
committed
modify: change variable name.
1 parent d42087b commit 70ca497

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

system/Validation/Rules.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function required_with($str = null, ?string $fields = null, array $data =
285285
public function required_without($str = null, ?string $otherFields = null, array $data = [], ?string $error = null, ?string $field = null): bool
286286
{
287287
if ($otherFields === null || empty($data)) {
288-
throw new InvalidArgumentException('You must supply the parameters: fields, data.');
288+
throw new InvalidArgumentException('You must supply the parameters: otherFields, data.');
289289
}
290290

291291
// If the field is present we can safely assume that
@@ -298,27 +298,25 @@ public function required_without($str = null, ?string $otherFields = null, array
298298
return true;
299299
}
300300

301-
$fieldIndex = 0;
302-
303301
// Still here? Then we fail this test if
304302
// any of the fields are not present in $data
305303
foreach ($otherFields as $otherField) {
306304
if ((strpos($otherField, '.') === false) && (! array_key_exists($otherField, $data) || empty($data[$otherField]))) {
307305
return false;
308306
}
309307
if (strpos($otherField, '.') !== false) {
310-
if ($field === null) {
308+
if ($otherField === null) {
311309
throw new InvalidArgumentException('You must supply the parameters: keyField.');
312310
}
313311

314312
$fieldData = dot_array_search($otherField, $data);
315313
$fieldSplitArray = explode('.', $field);
316-
$fieldIndex = $fieldSplitArray[1];
314+
$fieldKey = $fieldSplitArray[1];
317315

318316
if (is_array($fieldData)) {
319-
return ! empty(dot_array_search($otherField, $data)[$fieldIndex]);
317+
return ! empty(dot_array_search($otherField, $data)[$fieldKey]);
320318
}
321-
$nowField = str_replace('*', $fieldIndex, $otherField);
319+
$nowField = str_replace('*', $fieldKey, $otherField);
322320
$nowFieldVaule = dot_array_search($nowField, $data);
323321

324322
return null !== $nowFieldVaule;

0 commit comments

Comments
 (0)