X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Futils%2FAutoloadGenerator.php;h=1415ea32b4ec60748155160dcbdac01b42613212;hb=39c9e5f98a7d641ef725bb4909a2de4dc618b230;hp=4f639c13fb145cb7f9e9bc8931a4bfdccf409415;hpb=d400024d28aba2fe50dfad64e38bc68f727bae63;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/utils/AutoloadGenerator.php b/includes/utils/AutoloadGenerator.php index 4f639c13fb..1415ea32b4 100644 --- a/includes/utils/AutoloadGenerator.php +++ b/includes/utils/AutoloadGenerator.php @@ -42,6 +42,13 @@ class AutoloadGenerator { */ protected $overrides = []; + /** + * Directories that should be excluded + * + * @var string[] + */ + protected $excludePaths = []; + /** * @param string $basepath Root path of the project being scanned for classes * @param array|string $flags @@ -60,6 +67,34 @@ class AutoloadGenerator { } } + /** + * Directories that should be excluded + * + * @since 1.31 + * @param string[] $paths + */ + public function setExcludePaths( array $paths ) { + foreach ( $paths as $path ) { + $this->excludePaths[] = self::normalizePathSeparator( $path ); + } + } + + /** + * Whether the file should be excluded + * + * @param string $path File path + * @return bool + */ + private function shouldExclude( $path ) { + foreach ( $this->excludePaths as $dir ) { + if ( strpos( $path, $dir ) === 0 ) { + return true; + } + } + + return false; + } + /** * Force a class to be autoloaded from a specific path, regardless of where * or if it was detected. @@ -94,6 +129,9 @@ class AutoloadGenerator { if ( substr( $inputPath, 0, $len ) !== $this->basepath ) { throw new \Exception( "Path is not within basepath: $inputPath" ); } + if ( $this->shouldExclude( $inputPath ) ) { + return; + } $result = $this->collector->getClasses( file_get_contents( $inputPath ) ); @@ -156,8 +194,8 @@ class AutoloadGenerator { /** * Generates a PHP file setting up autoload information. * - * @param {string} $commandName Command name to include in comment - * @param {string} $filename of PHP file to put autoload information in. + * @param string $commandName Command name to include in comment + * @param string $filename of PHP file to put autoload information in. * @return string */ protected function generatePHPAutoload( $commandName, $filename ) {