@@ -44,12 +44,12 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
4444 $ file = $ this ->ensureExt ($ file , $ ext );
4545
4646 // Clears the folder name if it is at the beginning of the filename
47- if (! empty ($ folder ) && strpos ($ file , $ folder ) === 0 ) {
47+ if (! empty ($ folder ) && str_starts_with ($ file , $ folder )) {
4848 $ file = substr ($ file , strlen ($ folder . '/ ' ));
4949 }
5050
5151 // Is not namespaced? Try the application folder.
52- if (strpos ($ file , '\\' ) === false ) {
52+ if (! str_contains ($ file , '\\' )) {
5353 return $ this ->legacyLocate ($ file , $ folder );
5454 }
5555
@@ -71,7 +71,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
7171 $ namespaces = $ this ->autoloader ->getNamespace ();
7272
7373 foreach (array_keys ($ namespaces ) as $ namespace ) {
74- if (substr ($ file , 0 , strlen ( $ namespace )) === $ namespace ) {
74+ if (str_starts_with ($ file , $ namespace )) {
7575 // There may be sub-namespaces of the same vendor,
7676 // so overwrite them with namespaces found later.
7777 $ paths = $ namespaces [$ namespace ];
@@ -94,7 +94,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
9494 // If we have a folder name, then the calling function
9595 // expects this file to be within that folder, like 'Views',
9696 // or 'libraries'.
97- if (! empty ($ folder ) && strpos ($ path . $ filename , '/ ' . $ folder . '/ ' ) === false ) {
97+ if (! empty ($ folder ) && ! str_contains ($ path . $ filename , '/ ' . $ folder . '/ ' )) {
9898 $ path .= trim ($ folder , '/ ' ) . '/ ' ;
9999 }
100100
@@ -177,7 +177,7 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
177177
178178 if ($ prioritizeApp ) {
179179 $ foundPaths [] = $ fullPath ;
180- } elseif (strpos ($ fullPath , APPPATH ) === 0 ) {
180+ } elseif (str_starts_with ($ fullPath , APPPATH )) {
181181 $ appPaths [] = $ fullPath ;
182182 } else {
183183 $ foundPaths [] = $ fullPath ;
@@ -201,7 +201,7 @@ protected function ensureExt(string $path, string $ext): string
201201 if ($ ext ) {
202202 $ ext = '. ' . $ ext ;
203203
204- if (substr ($ path , - strlen ( $ ext )) !== $ ext ) {
204+ if (! str_ends_with ($ path , $ ext )) {
205205 $ path .= $ ext ;
206206 }
207207 }
0 commit comments