@@ -533,34 +533,51 @@ public function initStandard($standards, array $restrictions=array(), array $exc
533533 // be detected properly for files created on a Mac with the /r line ending.
534534 ini_set ('auto_detect_line_endings ' , true );
535535
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 ] );
539539 if ($ installed !== null ) {
540540 $ standard = $ installed ;
541541 } else {
542- $ standard = self ::realpath ($ standard );
542+ $ standard = self ::realpath ($ standards [ 0 ] );
543543 if (is_dir ($ standard ) === true
544544 && is_file (self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' )) === true
545545 ) {
546546 $ standard = self ::realpath ($ standard .DIRECTORY_SEPARATOR .'ruleset.xml ' );
547547 }
548548 }
549549
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+ }
554564 }
555565
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+ }
559576 }
560- }
561577
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
564581
565582 $ sniffRestrictions = array ();
566583 foreach ($ restrictions as $ sniffCode ) {
0 commit comments