@@ -143,7 +143,7 @@ public static function composeDataSets(array $files)
143
143
{
144
144
$ result = [];
145
145
foreach ($ files as $ file ) {
146
- $ key = str_replace (BP . '/ ' , '' , $ file );
146
+ $ key = $ file !== null ? str_replace (BP . '/ ' , '' , $ file ) : '' ;
147
147
$ result [$ key ] = [$ file ];
148
148
}
149
149
return $ result ;
@@ -640,9 +640,10 @@ private function collectModuleLayoutFiles(array $params, $location)
640
640
);
641
641
if ($ params ['with_metainfo ' ]) {
642
642
foreach ($ moduleFiles as $ moduleFile ) {
643
- $ modulePath = str_replace (DIRECTORY_SEPARATOR , '/ ' , preg_quote ($ moduleDir , '# ' ));
643
+ $ modulePath = $ moduleDir !== null ?
644
+ str_replace (DIRECTORY_SEPARATOR , '/ ' , preg_quote ($ moduleDir , '# ' )) : '' ;
644
645
$ regex = '#^ ' . $ modulePath . '/view/(?P<area>[a-z]+)/layout/(?P<path>.+)$#i ' ;
645
- if (preg_match ($ regex , $ moduleFile , $ matches )) {
646
+ if ($ moduleFile && preg_match ($ regex , $ moduleFile , $ matches )) {
646
647
$ files [] = [
647
648
[$ matches ['area ' ], '' , $ moduleName , $ matches ['path ' ], $ moduleFile ]
648
649
];
@@ -673,7 +674,8 @@ private function collectThemeLayoutFiles(array $params, $location)
673
674
$ requiredModuleName = $ params ['namespace ' ] . '_ ' . $ params ['module ' ];
674
675
$ themePath = $ params ['theme_path ' ];
675
676
foreach ($ this ->themePackageList ->getThemes () as $ theme ) {
676
- $ currentThemePath = str_replace (DIRECTORY_SEPARATOR , '/ ' , $ theme ->getPath ());
677
+ $ currentThemePath = $ theme ->getPath () !== null ?
678
+ str_replace (DIRECTORY_SEPARATOR , '/ ' , $ theme ->getPath ()) : '' ;
677
679
$ currentThemeCode = $ theme ->getVendor () . '/ ' . $ theme ->getName ();
678
680
if (($ area == '* ' || $ theme ->getArea () === $ area )
679
681
&& ($ themePath == '* ' || $ themePath == '*/* ' || $ themePath == $ currentThemeCode )
@@ -712,7 +714,7 @@ private function parseThemeFiles($themeFiles, $currentThemePath, $theme)
712
714
. '/(?P<module>[a-z\d]+_[a-z\d]+)/layout/(override/((base/)|(theme/[a-z\d_]+/[a-z\d_]+/)))? '
713
715
. '(?P<path>.+)$#i ' ;
714
716
foreach ($ themeFiles as $ themeFile ) {
715
- if (preg_match ($ regex , $ themeFile , $ matches )) {
717
+ if ($ themeFile && preg_match ($ regex , $ themeFile , $ matches )) {
716
718
$ files [] = [
717
719
$ theme ->getArea (),
718
720
$ theme ->getVendor () . '/ ' . $ theme ->getName (),
@@ -927,7 +929,8 @@ private function accumulateThemeStaticFiles($area, $locale, $filePattern, &$resu
927
929
$ themeArea = $ themePackage ->getArea ();
928
930
if ($ area == '* ' || $ area == $ themeArea ) {
929
931
$ files = [];
930
- $ themePath = str_replace (DIRECTORY_SEPARATOR , '/ ' , $ themePackage ->getPath ());
932
+ $ themePath = $ themePackage ->getPath () !== null ?
933
+ str_replace (DIRECTORY_SEPARATOR , '/ ' , $ themePackage ->getPath ()) : '' ;
931
934
$ paths = [
932
935
$ themePath . "/web " ,
933
936
$ themePath . "/*_*/web " ,
@@ -938,7 +941,7 @@ private function accumulateThemeStaticFiles($area, $locale, $filePattern, &$resu
938
941
$ regex = '#^ ' . $ themePath .
939
942
'/((?P<module>[a-z\d]+_[a-z_\d]+)/)?web/(i18n/(?P<locale>[a-z_]+)/)?(?P<path>.+)$#i ' ;
940
943
foreach ($ files as $ file ) {
941
- if (preg_match ($ regex , $ file , $ matches )) {
944
+ if ($ file && preg_match ($ regex , $ file , $ matches )) {
942
945
$ result [] = [
943
946
$ themeArea ,
944
947
$ themePackage ->getVendor () . '/ ' . $ themePackage ->getName (),
@@ -1004,7 +1007,7 @@ protected function _accumulateFilesByPatterns(array $patterns, $filePattern, arr
1004
1007
{
1005
1008
$ path = str_replace (DIRECTORY_SEPARATOR , '/ ' , BP );
1006
1009
foreach (self ::getFiles ($ patterns , $ filePattern ) as $ file ) {
1007
- $ file = str_replace (DIRECTORY_SEPARATOR , '/ ' , $ file );
1010
+ $ file = $ file !== null ? str_replace (DIRECTORY_SEPARATOR , '/ ' , $ file ) : '' ;
1008
1011
if ($ subroutine ) {
1009
1012
$ result [] = $ this ->$ subroutine ($ file , $ path );
1010
1013
} else {
@@ -1024,7 +1027,7 @@ protected function _accumulateFilesByPatterns(array $patterns, $filePattern, arr
1024
1027
protected function _parseModuleStatic ($ file )
1025
1028
{
1026
1029
foreach ($ this ->componentRegistrar ->getPaths (ComponentRegistrar::MODULE ) as $ moduleName => $ modulePath ) {
1027
- if (preg_match (
1030
+ if ($ file && preg_match (
1028
1031
'/^ ' . preg_quote ("{$ modulePath }/ " , '/ ' ) . 'view\/([a-z]+)\/web\/(.+)$/i ' ,
1029
1032
$ file ,
1030
1033
$ matches
@@ -1051,7 +1054,7 @@ private function accumulateStaticFiles($area, $filePattern, array &$result)
1051
1054
$ moduleWebPath = $ moduleDir . "/view/ {$ area }/web " ;
1052
1055
1053
1056
foreach (self ::getFiles ([$ moduleWebPath ], $ filePattern ) as $ absolutePath ) {
1054
- $ localPath = substr ($ absolutePath , strlen ($ moduleDir ) + 1 );
1057
+ $ localPath = $ absolutePath !== null ? substr ($ absolutePath , strlen ($ moduleDir ?? '' ) + 1 ) : '' ;
1055
1058
if (preg_match ('/^view\/([a-z]+)\/web\/(.+)$/i ' , $ localPath , $ matches ) === 1 ) {
1056
1059
list (, $ parsedArea , $ parsedPath ) = $ matches ;
1057
1060
$ result [] = [$ parsedArea , '' , '' , $ moduleName , $ parsedPath , $ absolutePath ];
@@ -1070,7 +1073,8 @@ protected function _parseModuleLocaleStatic($file)
1070
1073
{
1071
1074
foreach ($ this ->componentRegistrar ->getPaths (ComponentRegistrar::MODULE ) as $ moduleName => $ modulePath ) {
1072
1075
$ appCode = preg_quote ("{$ modulePath }/ " , '/ ' );
1073
- if (preg_match ('/^ ' . $ appCode . 'view\/([a-z]+)\/web\/i18n\/([a-z_]+)\/(.+)$/i ' , $ file , $ matches ) === 1 ) {
1076
+ if ($ file &&
1077
+ preg_match ('/^ ' . $ appCode . 'view\/([a-z]+)\/web\/i18n\/([a-z_]+)\/(.+)$/i ' , $ file , $ matches ) === 1 ) {
1074
1078
list (, $ area , $ locale , $ filePath ) = $ matches ;
1075
1079
return [$ area , '' , $ locale , $ moduleName , $ filePath , $ file ];
1076
1080
}
@@ -1191,10 +1195,10 @@ private function accumulateThemeTemplateFiles($withMetaInfo, array &$result)
1191
1195
$ files
1192
1196
);
1193
1197
if ($ withMetaInfo ) {
1194
- $ regex = ' #^ ' . str_replace (DIRECTORY_SEPARATOR , '/ ' , $ theme ->getPath ())
1195
- . '/(?P<module>[a-z\d]+_[a-z\d]+)/templates/(?P<path>.+)$#i ' ;
1198
+ $ themePath = $ theme -> getPath () !== null ? str_replace (DIRECTORY_SEPARATOR , '/ ' , $ theme ->getPath ()) : '' ;
1199
+ $ regex = ' #^ ' . $ themePath . '/(?P<module>[a-z\d]+_[a-z\d]+)/templates/(?P<path>.+)$#i ' ;
1196
1200
foreach ($ files as $ file ) {
1197
- if (preg_match ($ regex , $ file , $ matches )) {
1201
+ if ($ file && preg_match ($ regex , $ file , $ matches )) {
1198
1202
$ result [] = [
1199
1203
$ theme ->getArea (),
1200
1204
$ theme ->getVendor () . '/ ' . $ theme ->getName (),
@@ -1230,10 +1234,11 @@ private function accumulateModuleTemplateFiles($withMetaInfo, array &$result)
1230
1234
$ files
1231
1235
);
1232
1236
if ($ withMetaInfo ) {
1233
- $ modulePath = str_replace (DIRECTORY_SEPARATOR , '/ ' , preg_quote ($ moduleDir , '# ' ));
1237
+ $ modulePath = $ moduleDir !== null ?
1238
+ str_replace (DIRECTORY_SEPARATOR , '/ ' , preg_quote ($ moduleDir , '# ' )) : '' ;
1234
1239
$ regex = '#^ ' . $ modulePath . '/view/(?P<area>[a-z]+)/templates/(?P<path>.+)$#i ' ;
1235
1240
foreach ($ files as $ file ) {
1236
- if (preg_match ($ regex , $ file , $ matches )) {
1241
+ if ($ file && preg_match ($ regex , $ file , $ matches )) {
1237
1242
$ result [] = [
1238
1243
$ matches ['area ' ],
1239
1244
'' ,
@@ -1320,7 +1325,7 @@ public static function getFiles(array $dirPatterns, $fileNamePattern, $recursive
1320
1325
{
1321
1326
$ result = [];
1322
1327
foreach ($ dirPatterns as $ oneDirPattern ) {
1323
- $ oneDirPattern = str_replace ('\\' , '/ ' , $ oneDirPattern );
1328
+ $ oneDirPattern = $ oneDirPattern !== null ? str_replace ('\\' , '/ ' , $ oneDirPattern ) : '' ;
1324
1329
$ entriesInDir = Glob::glob ("{$ oneDirPattern }/ {$ fileNamePattern }" , Glob::GLOB_NOSORT | Glob::GLOB_BRACE );
1325
1330
$ subDirs = Glob::glob ("{$ oneDirPattern }/* " , Glob::GLOB_ONLYDIR | Glob::GLOB_NOSORT | Glob::GLOB_BRACE );
1326
1331
$ filesInDir = array_diff ($ entriesInDir , $ subDirs );
@@ -1389,6 +1394,8 @@ private function getPaths()
1389
1394
*/
1390
1395
public function classFileExists ($ class , &$ path = '' )
1391
1396
{
1397
+ $ class = $ class ?: '' ;
1398
+
1392
1399
if ($ class [0 ] == '\\' ) {
1393
1400
$ class = substr ($ class , 1 );
1394
1401
}
@@ -1459,7 +1466,7 @@ private function classFileExistsCheckContent($fullPath, $namespace, $className)
1459
1466
* Note that realpath() automatically changes directory separator to the OS-native
1460
1467
* Since realpath won't work with symlinks we also check file_exists if realpath failed
1461
1468
*/
1462
- if (realpath ($ fullPath ) == str_replace (['/ ' , '\\' ], DIRECTORY_SEPARATOR , $ fullPath )
1469
+ if ($ fullPath && realpath ($ fullPath ) == str_replace (['/ ' , '\\' ], DIRECTORY_SEPARATOR , $ fullPath )
1463
1470
|| file_exists ($ fullPath )
1464
1471
) {
1465
1472
$ fileContent = file_get_contents ($ fullPath );
@@ -1582,10 +1589,13 @@ public function readLists($globPattern)
1582
1589
$ result = [];
1583
1590
$ incorrectPatterns = [];
1584
1591
foreach ($ patterns as $ pattern ) {
1592
+ $ pattern = $ pattern ?? '' ;
1593
+
1585
1594
if (0 === strpos ($ pattern , '# ' )) {
1586
1595
continue ;
1587
1596
}
1588
1597
$ patternParts = explode (' ' , $ pattern );
1598
+
1589
1599
if (count ($ patternParts ) == 3 ) {
1590
1600
list ($ componentType , $ componentName , $ pathPattern ) = $ patternParts ;
1591
1601
$ files = $ this ->getPathByComponentPattern ($ componentType , $ componentName , $ pathPattern );
0 commit comments