Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename variable for clarity
  • Loading branch information
swissspidy committed May 14, 2020
commit 119fcf053e3e308532641ba43d82a420b4cae162
16 changes: 8 additions & 8 deletions src/IterableCodeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ trait IterableCodeExtractor {
/**
* Extract the translations from a file.
*
* @param array|string $file A path of a file or files
* @param Translations $translations The translations instance to append the new translations.
* @param array|string $file_or_files A path of a file or files
* @param Translations $translations The translations instance to append the new translations.
* @param array $options {
* Optional. An array of options passed down to static::fromString()
*
Expand All @@ -28,25 +28,25 @@ trait IterableCodeExtractor {
* }
* @return null
*/
public static function fromFile( $file, Translations $translations, array $options = [] ) {
foreach ( static::getFiles( $file ) as $f ) {
public static function fromFile( $file_or_files, Translations $translations, array $options = [] ) {
foreach ( static::getFiles( $file_or_files ) as $file ) {
if ( ! empty( $options['restrictFileNames'] ) ) {
$basename = Utils\basename( $f );
$basename = Utils\basename( $file );
if ( ! in_array( $basename, $options['restrictFileNames'], true ) ) {
continue;
}
}

// Make sure a relative file path is added as a comment.
$options['file'] = ltrim( str_replace( static::$dir, '', Utils\normalize_path( $f ) ), '/' );
$options['file'] = ltrim( str_replace( static::$dir, '', Utils\normalize_path( $file ) ), '/' );

$string = file_get_contents( $f );
$string = file_get_contents( $file );

if ( ! $string ) {
WP_CLI::debug(
sprintf(
'Could not load file %1s',
$f
$file
)
);

Expand Down