@@ -221,6 +221,7 @@ protected static function _initThemes()
221
221
$ defaultThemes = [];
222
222
foreach (self ::$ _listConfigXml as $ file ) {
223
223
$ config = simplexml_load_file ($ file );
224
+ //phpcs:ignore Generic.PHP.NoSilencedErrors
224
225
$ nodes = @($ config ->xpath ("/config/*/design/theme/full_name " ) ?: []);
225
226
foreach ($ nodes as $ node ) {
226
227
$ defaultThemes [] = (string )$ node ;
@@ -237,6 +238,7 @@ protected static function _initRules()
237
238
$ replaceFilePattern = str_replace ('\\' , '/ ' , realpath (__DIR__ )) . '/_files/dependency_test/tables_*.php ' ;
238
239
$ dbRuleTables = [];
239
240
foreach (glob ($ replaceFilePattern ) as $ fileName ) {
241
+ //phpcs:ignore Generic.PHP.NoSilencedErrors
240
242
$ dbRuleTables = array_merge ($ dbRuleTables , @include $ fileName );
241
243
}
242
244
self ::$ _rulesInstances = [
@@ -339,12 +341,12 @@ function ($fileType, $file) {
339
341
$ result = [];
340
342
foreach ($ undeclaredDependency as $ type => $ modules ) {
341
343
$ modules = array_unique ($ modules );
342
- if (! count ($ modules )) {
344
+ if (empty ($ modules )) {
343
345
continue ;
344
346
}
345
347
$ result [] = sprintf ("%s [%s] " , $ type , implode (', ' , $ modules ));
346
348
}
347
- if (count ($ result )) {
349
+ if (! empty ($ result )) {
348
350
$ this ->fail ('Module ' . $ module . ' has undeclared dependencies: ' . implode (', ' , $ result ));
349
351
}
350
352
},
@@ -473,7 +475,7 @@ public function testRedundant()
473
475
foreach (array_keys (self ::$ mapDependencies ) as $ module ) {
474
476
$ result = [];
475
477
$ redundant = $ this ->_getDependencies ($ module , self ::TYPE_HARD , self ::MAP_TYPE_REDUNDANT );
476
- if (count ($ redundant )) {
478
+ if (! empty ($ redundant )) {
477
479
$ result [] = sprintf (
478
480
"\r\nModule %s: %s [%s] " ,
479
481
$ module ,
@@ -482,11 +484,11 @@ public function testRedundant()
482
484
);
483
485
}
484
486
485
- if (count ($ result )) {
487
+ if (! empty ($ result )) {
486
488
$ output [] = implode (', ' , $ result );
487
489
}
488
490
}
489
- if (count ($ output )) {
491
+ if (! empty ($ output )) {
490
492
$ this ->fail ("Redundant dependencies found! \r\n" . implode (' ' , $ output ));
491
493
}
492
494
}
@@ -654,7 +656,7 @@ protected static function _prepareMapLayoutBlocks()
654
656
$ area = 'default ' ;
655
657
if (preg_match ('/[\/](?<area>adminhtml|frontend)[\/]/ ' , $ file , $ matches )) {
656
658
$ area = $ matches ['area ' ];
657
- self ::$ _mapLayoutBlocks [$ area ] = @( self ::$ _mapLayoutBlocks [$ area ] ?: []) ;
659
+ self ::$ _mapLayoutBlocks [$ area ] = self ::$ _mapLayoutBlocks [$ area ] ?? [];
658
660
}
659
661
if (preg_match ('/(?<namespace>[A-Z][a-z]+)[_\/ \\\\](?<module>[A-Z][a-zA-Z]+)/ ' , $ file , $ matches )) {
660
662
$ module = $ matches ['namespace ' ] . '\\' . $ matches ['module ' ];
@@ -664,7 +666,7 @@ protected static function _prepareMapLayoutBlocks()
664
666
$ attributes = $ element ->attributes ();
665
667
$ block = (string )$ attributes ->name ;
666
668
if (!empty ($ block )) {
667
- self ::$ _mapLayoutBlocks [$ area ][$ block ] = @( self ::$ _mapLayoutBlocks [$ area ][$ block ] ?: []) ;
669
+ self ::$ _mapLayoutBlocks [$ area ][$ block ] = self ::$ _mapLayoutBlocks [$ area ][$ block ] ?? [];
668
670
self ::$ _mapLayoutBlocks [$ area ][$ block ][$ module ] = $ module ;
669
671
}
670
672
}
@@ -682,7 +684,7 @@ protected static function _prepareMapLayoutHandles()
682
684
$ area = 'default ' ;
683
685
if (preg_match ('/\/(?<area>adminhtml|frontend)\// ' , $ file , $ matches )) {
684
686
$ area = $ matches ['area ' ];
685
- self ::$ _mapLayoutHandles [$ area ] = @( self ::$ _mapLayoutHandles [$ area ] ?: []) ;
687
+ self ::$ _mapLayoutHandles [$ area ] = self ::$ _mapLayoutHandles [$ area ] ?? [];
686
688
}
687
689
if (preg_match ('/app\/code\/(?<namespace>[A-Z][a-z]+)[_\/ \\\\](?<module>[A-Z][a-zA-Z]+)/ ' , $ file , $ matches )
688
690
) {
@@ -691,7 +693,7 @@ protected static function _prepareMapLayoutHandles()
691
693
foreach ((array )$ xml ->xpath ('/layout/child::* ' ) as $ element ) {
692
694
/** @var \SimpleXMLElement $element */
693
695
$ handle = $ element ->getName ();
694
- self ::$ _mapLayoutHandles [$ area ][$ handle ] = @( self ::$ _mapLayoutHandles [$ area ][$ handle ] ?: []) ;
696
+ self ::$ _mapLayoutHandles [$ area ][$ handle ] = self ::$ _mapLayoutHandles [$ area ][$ handle ] ?? [];
695
697
self ::$ _mapLayoutHandles [$ area ][$ handle ][$ module ] = $ module ;
696
698
}
697
699
}
@@ -751,6 +753,7 @@ protected static function _initDependencies()
751
753
$ contents = file_get_contents ($ file );
752
754
$ decodedJson = json_decode ($ contents );
753
755
if (null == $ decodedJson ) {
756
+ //phpcs:ignore Magento2.Exceptions.DirectThrow
754
757
throw new \Exception ("Invalid Json: $ file " );
755
758
}
756
759
$ json = new \Magento \Framework \Config \Composer \Package (json_decode ($ contents ));
@@ -839,6 +842,7 @@ private static function getPackageModuleMapping(): array
839
842
$ contents = file_get_contents ($ file );
840
843
$ composerJson = json_decode ($ contents );
841
844
if (null == $ composerJson ) {
845
+ //phpcs:ignore Magento2.Exceptions.DirectThrow
842
846
throw new \Exception ("Invalid Json: $ file " );
843
847
}
844
848
$ moduleXml = simplexml_load_file (dirname ($ file ) . '/etc/module.xml ' );
0 commit comments