Skip to content

Commit 08bc0f8

Browse files
michalsnddevsr
andauthored
fix: null as an array offset is deprecated, use an empty string instead (#9849)
* fix: null as an array offset is deprecated, use an empty string instead Co-authored-by: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> * update tests signature --------- Co-authored-by: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com>
1 parent 59cbed5 commit 08bc0f8

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

system/Autoloader/FileLocatorCached.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,16 @@ public function listNamespaceFiles(string $prefix, string $path): array
163163

164164
public function locateFile(string $file, ?string $folder = null, string $ext = 'php'): false|string
165165
{
166-
if (isset($this->cache['locateFile'][$file][$folder][$ext])) {
167-
return $this->cache['locateFile'][$file][$folder][$ext];
166+
$folderKey = $folder ?? '';
167+
168+
if (isset($this->cache['locateFile'][$file][$folderKey][$ext])) {
169+
return $this->cache['locateFile'][$file][$folderKey][$ext];
168170
}
169171

170172
$files = $this->locator->locateFile($file, $folder, $ext);
171173

172-
$this->cache['locateFile'][$file][$folder][$ext] = $files;
173-
$this->cacheUpdated = true;
174+
$this->cache['locateFile'][$file][$folderKey][$ext] = $files;
175+
$this->cacheUpdated = true;
174176

175177
return $files;
176178
}

tests/system/Validation/RulesTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public static function provideInList(): iterable
669669
}
670670

671671
#[DataProvider('provideRequiredWith')]
672-
public function testRequiredWith(?string $field, ?string $check, bool $expected): void
672+
public function testRequiredWith(string $field, ?string $check, bool $expected): void
673673
{
674674
$data = [
675675
'foo' => 'bar',
@@ -693,8 +693,8 @@ public static function provideRequiredWith(): iterable
693693
['nope', 'bar', false],
694694
['foo', 'bar', true],
695695
['nope', 'baz', true],
696-
[null, null, true],
697-
[null, 'foo', false],
696+
['', null, true],
697+
['', 'foo', false],
698698
['foo', null, true],
699699
[
700700
'array.emptyField1',
@@ -779,7 +779,7 @@ public static function provideRequiredWithAndOtherRuleWithValueZero(): iterable
779779
}
780780

781781
#[DataProvider('provideRequiredWithout')]
782-
public function testRequiredWithout(?string $field, ?string $check, bool $expected): void
782+
public function testRequiredWithout(string $field, ?string $check, bool $expected): void
783783
{
784784
$data = [
785785
'foo' => 'bar',
@@ -802,8 +802,8 @@ public static function provideRequiredWithout(): iterable
802802
yield from [
803803
['nope', 'bars', false],
804804
['foo', 'nope', true],
805-
[null, null, false],
806-
[null, 'foo', true],
805+
['', null, false],
806+
['', 'foo', true],
807807
['foo', null, true],
808808
[
809809
'array.emptyField1',

0 commit comments

Comments
 (0)