Skip to content

Commit 1e888a0

Browse files
committed
fix: null as an array offset is deprecated, use an empty string instead
1 parent 59cbed5 commit 1e888a0

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

system/Autoloader/FileLocator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ public function __construct(Autoloader $autoloader)
4444
* Attempts to locate a file by examining the name for a namespace
4545
* and looking through the PSR-4 namespaced files that we know about.
4646
*
47-
* @param non-empty-string $file The relative file path or namespaced file to
48-
* locate. If not namespaced, search in the app
49-
* folder.
50-
* @param non-empty-string|null $folder The folder within the namespace that we should
51-
* look for the file. If $file does not contain
52-
* this value, it will be appended to the namespace
53-
* folder.
54-
* @param string $ext The file extension the file should have.
47+
* @param non-empty-string $file The relative file path or namespaced file to
48+
* locate. If not namespaced, search in the app
49+
* folder.
50+
* @param non-empty-string $folder The folder within the namespace that we should
51+
* look for the file. If $file does not contain
52+
* this value, it will be appended to the namespace
53+
* folder.
54+
* @param string $ext The file extension the file should have.
5555
*
5656
* @return false|non-empty-string The path to the file, or false if not found.
5757
*/
58-
public function locateFile(string $file, ?string $folder = null, string $ext = 'php')
58+
public function locateFile(string $file, string $folder = '', string $ext = 'php')
5959
{
6060
$file = $this->ensureExt($file, $ext);
6161

6262
// Clears the folder name if it is at the beginning of the filename
63-
if ($folder !== null && str_starts_with($file, $folder)) {
63+
if ($folder !== '' && str_starts_with($file, $folder)) {
6464
$file = substr($file, strlen($folder . '/'));
6565
}
6666

@@ -110,7 +110,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
110110
// If we have a folder name, then the calling function
111111
// expects this file to be within that folder, like 'Views',
112112
// or 'libraries'.
113-
if ($folder !== null && ! str_contains($path . $filename, '/' . $folder . '/')) {
113+
if ($folder !== '' && ! str_contains($path . $filename, '/' . $folder . '/')) {
114114
$path .= trim($folder, '/') . '/';
115115
}
116116

system/Autoloader/FileLocatorCached.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function listNamespaceFiles(string $prefix, string $path): array
161161
return $files;
162162
}
163163

164-
public function locateFile(string $file, ?string $folder = null, string $ext = 'php'): false|string
164+
public function locateFile(string $file, string $folder = '', string $ext = 'php'): false|string
165165
{
166166
if (isset($this->cache['locateFile'][$file][$folder][$ext])) {
167167
return $this->cache['locateFile'][$file][$folder][$ext];

system/Autoloader/FileLocatorInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ interface FileLocatorInterface
2323
* Attempts to locate a file by examining the name for a namespace
2424
* and looking through the PSR-4 namespaced files that we know about.
2525
*
26-
* @param non-empty-string $file The relative file path or namespaced file to
27-
* locate. If not namespaced, search in the app
28-
* folder.
29-
* @param non-empty-string|null $folder The folder within the namespace that we should
30-
* look for the file. If $file does not contain
31-
* this value, it will be appended to the namespace
32-
* folder.
33-
* @param string $ext The file extension the file should have.
26+
* @param non-empty-string $file The relative file path or namespaced file to
27+
* locate. If not namespaced, search in the app
28+
* folder.
29+
* @param non-empty-string $folder The folder within the namespace that we should
30+
* look for the file. If $file does not contain
31+
* this value, it will be appended to the namespace
32+
* folder.
33+
* @param string $ext The file extension the file should have.
3434
*
3535
* @return false|non-empty-string The path to the file, or false if not found.
3636
*/
37-
public function locateFile(string $file, ?string $folder = null, string $ext = 'php');
37+
public function locateFile(string $file, string $folder = '', string $ext = 'php');
3838

3939
/**
4040
* Examines a file and returns the fully qualified class name.

0 commit comments

Comments
 (0)