@@ -533,34 +533,51 @@ public function initStandard($standards, array $restrictions=array(), array $exc
533
533
// be detected properly for files created on a Mac with the /r line ending.
534
534
ini_set ('auto_detect_line_endings ' , true );
535
535
536
- $ sniffs = array ();
537
- foreach ( $ standards as $ standard) {
538
- $ installed = $ this ->getInstalledStandardPath ($ standard );
536
+ if ( defined ( ' PHP_CODESNIFFER_IN_TESTS ' ) === true ) {
537
+ // Should be one standard and one sniff being tested at a time.
538
+ $ installed = $ this ->getInstalledStandardPath ($ standards [ 0 ] );
539
539
if ($ installed !== null ) {
540
540
$ standard = $ installed ;
541
541
} else {
542
- $ standard = self ::realpath ($ standard );
542
+ $ standard = self ::realpath ($ standards [ 0 ] );
543
543
if (is_dir ($ standard ) === true
544
544
&& is_file (self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' )) === true
545
545
) {
546
546
$ standard = self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' );
547
547
}
548
548
}
549
549
550
- if (PHP_CODESNIFFER_VERBOSITY === 1 ) {
551
- $ ruleset = simplexml_load_string (file_get_contents ($ standard ));
552
- if ($ ruleset !== false ) {
553
- $ standardName = (string ) $ ruleset ['name ' ];
550
+ $ sniffs = $ this ->_expandRulesetReference ($ restrictions [0 ], dirname ($ standard ));
551
+ } else {
552
+ $ sniffs = array ();
553
+ foreach ($ standards as $ standard ) {
554
+ $ installed = $ this ->getInstalledStandardPath ($ standard );
555
+ if ($ installed !== null ) {
556
+ $ standard = $ installed ;
557
+ } else {
558
+ $ standard = self ::realpath ($ standard );
559
+ if (is_dir ($ standard ) === true
560
+ && is_file (self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' )) === true
561
+ ) {
562
+ $ standard = self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' );
563
+ }
554
564
}
555
565
556
- echo "Registering sniffs in the $ standardName standard... " ;
557
- if (count ($ standards ) > 1 || PHP_CODESNIFFER_VERBOSITY > 2 ) {
558
- echo PHP_EOL ;
566
+ if (PHP_CODESNIFFER_VERBOSITY === 1 ) {
567
+ $ ruleset = simplexml_load_string (file_get_contents ($ standard ));
568
+ if ($ ruleset !== false ) {
569
+ $ standardName = (string ) $ ruleset ['name ' ];
570
+ }
571
+
572
+ echo "Registering sniffs in the $ standardName standard... " ;
573
+ if (count ($ standards ) > 1 || PHP_CODESNIFFER_VERBOSITY > 2 ) {
574
+ echo PHP_EOL ;
575
+ }
559
576
}
560
- }
561
577
562
- $ sniffs = array_merge ($ sniffs , $ this ->processRuleset ($ standard ));
563
- }//end foreach
578
+ $ sniffs = array_merge ($ sniffs , $ this ->processRuleset ($ standard ));
579
+ }//end foreach
580
+ }//end if
564
581
565
582
$ sniffRestrictions = array ();
566
583
foreach ($ restrictions as $ sniffCode ) {
0 commit comments