@@ -41,26 +41,32 @@ public function describeConfiguration(PluginConfigurationBuilderInterface $confi
4141        $ configOptionsBuilder
4242            ->describeStringListOption (
4343                'standard_paths ' ,
44-                 'Setting the installed standard paths as relative path to the project root dir. ' 
44+                 'Setting the installed standard paths as relative path to the project root dir. ' , 
4545            )
4646            ->isRequired ()
4747            ->withDefaultValue ([]);
4848        $ configOptionsBuilder
4949            ->describeBoolOption (
5050                'fix ' ,
51-                 'If given, the source will be fixed automatically with phpcbf ' 
51+                 'If given, the source will be fixed automatically with phpcbf ' , 
5252            )
5353            ->isRequired ()
5454            ->withDefaultValue (false );
5555        $ configOptionsBuilder
5656            ->describeStringListOption (
5757                'excluded ' ,
58-                 'List of excluded paths. ' 
58+                 'List of excluded paths. ' , 
5959            );
6060        $ configOptionsBuilder
6161            ->describeStringListOption (
6262                'excluded_sniffs ' ,
63-                 'List of excluded sniffs. ' 
63+                 'List of excluded sniffs. ' ,
64+             );
65+ 
66+         $ configOptionsBuilder
67+             ->describeStringListOption (
68+                 'autoload_paths ' ,
69+                 'List of files to autoload relative to project directory ' ,
6470            );
6571    }
6672
@@ -127,7 +133,7 @@ private function buildArguments(
127133                function  ($ pathuse  ($ projectPathstring  {
128134                    return  realpath ($ projectPath'/ '  . $ path
129135                },
130-                 $ standardPaths
136+                 $ standardPaths, 
131137            ));
132138        }
133139
@@ -137,6 +143,33 @@ function ($path) use ($projectPath): string {
137143            $ arguments'--report-file= '  . $ tempFile
138144        }
139145
146+         if  ($ confighas ('autoload_paths ' )) {
147+             $ template
148+ <?php  
149+ declare(strict_types=1); 
150+ 
151+ foreach (%s as $path) { 
152+     require_once $path; 
153+ } 
154+ PHP;
155+             $ tmpFile$ environmentgetUniqueTempFile ($ this 'phpcs.bootstrap.php ' );
156+             $ pathsarray_unique (
157+                 array_map (
158+                     function  (string  $ pathuse  ($ environmentstring  {
159+                         $ file$ environmentgetProjectConfiguration ()->getProjectRootPath () . '/ '  . $ path
160+                         if  (! file_exists ($ file
161+                             throw  new  RuntimeException ('Autoload file does not exist:  '  . $ file
162+                         }
163+ 
164+                         return  $ environmentgetProjectConfiguration ()->getProjectRootPath () . '/ '  . $ path
165+                     },
166+                     $ configgetStringList ('autoload_paths ' )
167+                 ),
168+             );
169+             file_put_contents ($ tmpFilesprintf ($ templatevar_export ($ pathstrue )));
170+             $ arguments'--bootstrap= '  . $ tmpFile
171+         }
172+ 
140173        return  array_merge ($ arguments$ configgetStringList ('directories ' ));
141174    }
142175
@@ -149,14 +182,14 @@ public function describeExecTask(
149182            'phpcs ' ,
150183            'PHP CodeSniffer by Squiz (http://www.squiz.net) ' ,
151184            $ definitionBuilder
152-             $ environment
185+             $ environment, 
153186        );
154187        $ this describeApplication (
155188            'phpcbf ' ,
156189            'PHP Code Beautifier and Fixer ' ,
157190            $ definitionBuilder
158191            $ environment
159-             'fix ' 
192+             'fix ' , 
160193        );
161194    }
162195
0 commit comments