File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 5252 * @property string $generator The documentation generator to use.
5353 * @property string $filter The filter to use for the run.
5454 * @property string[] $bootstrap One of more files to include before the run begins.
55+ * @property string $localFile The LocalFile object to use in FileList.
5556 * @property int|string $reportWidth The maximum number of columns that reports should use for output.
5657 * Set to "auto" for have this value changed to the width of the terminal.
5758 * @property int $errorSeverity The minimum severity an error must have to be displayed.
@@ -138,6 +139,7 @@ class Config
138139 'generator ' => null ,
139140 'filter ' => null ,
140141 'bootstrap ' => null ,
142+ 'localFile ' => null ,
141143 'reports ' => null ,
142144 'basepath ' => null ,
143145 'reportWidth ' => null ,
@@ -540,6 +542,7 @@ public function restoreDefaults()
540542 $ this ->generator = null ;
541543 $ this ->filter = null ;
542544 $ this ->bootstrap = [];
545+ $ this ->localFile = null ;
543546 $ this ->basepath = null ;
544547 $ this ->reports = ['full ' => null ];
545548 $ this ->reportWidth = 'auto ' ;
Original file line number Diff line number Diff line change 1717use PHP_CodeSniffer \Autoload ;
1818use PHP_CodeSniffer \Config ;
1919use PHP_CodeSniffer \Exceptions \DeepExitException ;
20+ use PHP_CodeSniffer \Exceptions \RuntimeException ;
2021use PHP_CodeSniffer \Ruleset ;
2122use PHP_CodeSniffer \Util \Common ;
2223use RecursiveArrayIterator ;
@@ -194,7 +195,16 @@ public function current()
194195 {
195196 $ path = key ($ this ->files );
196197 if (isset ($ this ->files [$ path ]) === false ) {
197- $ this ->files [$ path ] = new LocalFile ($ path , $ this ->ruleset , $ this ->config );
198+ if ($ this ->config ->localFile === null ) {
199+ $ this ->files [$ path ] = new LocalFile ($ path , $ this ->ruleset , $ this ->config );
200+ } else {
201+ $ localFileClass = $ this ->config ->localFile ;
202+ if (is_a ($ localFileClass , '\PHP_CodeSniffer\Files\LocalFile ' , true ) === false ) {
203+ throw new RuntimeException ('Custom LocalFile class ' .$ localFileClass .' is not a subtype of PHP_CodeSniffer\Files\LocalFile. ' );
204+ }
205+
206+ $ this ->files [$ path ] = new $ localFileClass ($ path , $ this ->ruleset , $ this ->config );
207+ }
198208 }
199209
200210 return $ this ->files [$ path ];
You can’t perform that action at this time.
0 commit comments