Skip to content

Commit

Permalink
Rename includ/exclude parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Aug 30, 2023
1 parent dcc8979 commit e3610e1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/IterableCodeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,29 +225,29 @@ protected static function containsMatchingChildren( SplFileInfo $dir, array $mat
* Recursively gets all PHP files within a directory.
*
* @param string $dir A path of a directory.
* @param array $include List of files and directories to include.
* @param array $exclude List of files and directories to skip.
* @param array $includes List of files and directories to include.
* @param array $excludes List of files and directories to skip.
* @param array $extensions List of filename extensions to process.
*
* @return array File list.
*/
public static function getFilesFromDirectory( $dir, array $include = [], array $exclude = [], $extensions = [] ) {
public static function getFilesFromDirectory( $dir, array $includes = [], array $excludes = [], $extensions = [] ) {
$filtered_files = [];

$files = new RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::UNIX_PATHS | RecursiveDirectoryIterator::FOLLOW_SYMLINKS ),
static function ( $file, $key, $iterator ) use ( $include, $exclude, $extensions ) {
static function ( $file, $key, $iterator ) use ( $includes, $excludes, $extensions ) {
/** @var RecursiveCallbackFilterIterator $iterator */
/** @var SplFileInfo $file */

// Normalize include and exclude paths.
$include = array_map( self::class . '::trim_leading_slash', $include );
$exclude = array_map( self::class . '::trim_leading_slash', $exclude );
$includes = array_map( self::class . '::trim_leading_slash', $includes );
$excludes = array_map( self::class . '::trim_leading_slash', $excludes );

// If no $include is passed everything gets the weakest possible matching score.
$inclusion_score = empty( $include ) ? 0.1 : static::calculateMatchScore( $file, $include );
$exclusion_score = static::calculateMatchScore( $file, $exclude );
// If no $includes is passed everything gets the weakest possible matching score.
$inclusion_score = empty( $includes ) ? 0.1 : static::calculateMatchScore( $file, $includes );
$exclusion_score = static::calculateMatchScore( $file, $excludes );

// Always include directories that aren't excluded.
if ( 0 === $exclusion_score && $iterator->hasChildren() ) {
Expand All @@ -256,7 +256,7 @@ static function ( $file, $key, $iterator ) use ( $include, $exclude, $extensions

if ( ( 0 === $inclusion_score || $exclusion_score > $inclusion_score ) && $iterator->hasChildren() ) {
// Always include directories that may have matching children even if they are excluded.
return static::containsMatchingChildren( $file, $include );
return static::containsMatchingChildren( $file, $includes );
}

// Include directories that are excluded but include score is higher.
Expand Down

0 comments on commit e3610e1

Please sign in to comment.