@@ -825,21 +825,6 @@ public function process($values=array())
825
825
exit (0 );
826
826
}
827
827
828
- $ fileContents = '' ;
829
- if (empty ($ values ['files ' ]) === true ) {
830
- // Check if they are passing in the file contents.
831
- $ handle = fopen ('php://stdin ' , 'r ' );
832
- $ fileContents = stream_get_contents ($ handle );
833
- fclose ($ handle );
834
-
835
- if ($ fileContents === '' ) {
836
- // No files and no content passed in.
837
- echo 'ERROR: You must supply at least one file or directory to process. ' .PHP_EOL .PHP_EOL ;
838
- $ this ->printUsage ();
839
- exit (2 );
840
- }
841
- }
842
-
843
828
$ phpcs = new PHP_CodeSniffer ($ values ['verbosity ' ], null , null , null );
844
829
$ phpcs ->setCli ($ this );
845
830
$ phpcs ->initStandard ($ values ['standard ' ], $ values ['sniffs ' ]);
@@ -880,8 +865,22 @@ public function process($values=array())
880
865
881
866
$ phpcs ->processFiles ($ values ['files ' ], $ values ['local ' ]);
882
867
883
- if ($ fileContents !== '' ) {
884
- $ phpcs ->processFile ('STDIN ' , $ fileContents );
868
+ if (empty ($ values ['files ' ]) === true ) {
869
+ // Check if they are passing in the file contents.
870
+ $ handle = fopen ('php://stdin ' , 'r ' );
871
+ $ fileContents = stream_get_contents ($ handle );
872
+ fclose ($ handle );
873
+
874
+ if ($ fileContents === '' ) {
875
+ // No files and no content passed in.
876
+ echo 'ERROR: You must supply at least one file or directory to process. ' .PHP_EOL .PHP_EOL ;
877
+ $ this ->printUsage ();
878
+ exit (2 );
879
+ } else {
880
+ if ($ fileContents !== '' ) {
881
+ $ phpcs ->processFile ('STDIN ' , $ fileContents );
882
+ }
883
+ }
885
884
}
886
885
887
886
// Interactive runs don't require a final report and it doesn't really
@@ -997,6 +996,14 @@ public function validateStandard($standards)
997
996
{
998
997
if ($ standards === null ) {
999
998
// They did not supply a standard to use.
999
+ // Looks for a ruleset in the current directory.
1000
+ if (empty ($ this ->values ['files ' ]) === true ) {
1001
+ $ default = getcwd ().DIRECTORY_SEPARATOR .'ruleset.xml ' ;
1002
+ if (is_file ($ default ) === true ) {
1003
+ return array ($ default );
1004
+ }
1005
+ }
1006
+
1000
1007
// Try to get the default from the config system.
1001
1008
$ standard = PHP_CodeSniffer::getConfigData ('default_standard ' );
1002
1009
if ($ standard === null ) {
0 commit comments