File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
52
52
-- If ommitted, the namespace is assumed to be the same as the directory name containing the ruleset.xml file
53
53
-- The namespace is set in the ruleset tag of the ruleset.xml file
54
54
-- e.g., ruleset name="My Coding Standard" namespace="MyProject\CS\Standard"
55
+ - Rulesets can now specify custom autoloaders using the new autoload tag
56
+ -- Autloaders are included while the ruleset is being processed and before any custom sniffs are included
57
+ -- Allows for very custom autoloading of helper classes well before the boostrap files are included
55
58
- Fixed a problem where excluding a message from a custom standard's own sniff would exclude the whole sniff
56
59
-- This caused some PSR2 errors to be under-reported
57
60
- Fixed bug #1442 : T_NULLABLE detection not working for nullable parameters and return type hints in some cases
Original file line number Diff line number Diff line change @@ -326,6 +326,30 @@ public function processRuleset($rulesetPath, $depth=0)
326
326
$ ownSniffs = $ this ->expandSniffDirectory ($ sniffDir , $ depth );
327
327
}
328
328
329
+ // Included custom autoloaders.
330
+ foreach ($ ruleset ->{'autoload ' } as $ autoload ) {
331
+ if ($ this ->shouldProcessElement ($ autoload ) === false ) {
332
+ continue ;
333
+ }
334
+
335
+ $ autoloadPath = (string ) $ autoload ;
336
+ if (is_file ($ autoloadPath ) === false ) {
337
+ $ autoloadPath = Util \Common::realPath (dirname ($ rulesetPath ).DIRECTORY_SEPARATOR .$ autoloadPath );
338
+ }
339
+
340
+ if ($ autoloadPath === false ) {
341
+ echo 'ERROR: The specified autoload file " ' .$ autoload .'" does not exist ' .PHP_EOL .PHP_EOL ;
342
+ exit (3 );
343
+ }
344
+
345
+ include $ autoloadPath ;
346
+
347
+ if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
348
+ echo str_repeat ("\t" , $ depth );
349
+ echo "\t=> included autoloader $ autoloadPath " .PHP_EOL ;
350
+ }
351
+ }//end foreach
352
+
329
353
// Process custom sniff config settings.
330
354
foreach ($ ruleset ->{'config ' } as $ config ) {
331
355
if ($ this ->shouldProcessElement ($ config ) === false ) {
You can’t perform that action at this time.
0 commit comments