Skip to content

Commit 614edb3

Browse files
committed
Rename all $dir to $directory.
1 parent 4d4a57a commit 614edb3

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

src/ClassFilesIA/ClassFilesIA.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
class ClassFilesIA {
1212

1313
/**
14-
* @param string $dir
14+
* @param string $directory
1515
* @param string $namespace
1616
*
1717
* @return \Ock\ClassFilesIterator\ClassFilesIA\ClassFilesIAInterface
1818
*/
19-
public static function psr4(string $dir, string $namespace): ClassFilesIAInterface {
19+
public static function psr4(string $directory, string $namespace): ClassFilesIAInterface {
2020
return new ClassFilesIA_Psr4(
21-
$dir,
21+
$directory,
2222
NsDirUtil::terminateNamespace($namespace),
2323
);
2424
}
2525

2626
/**
27-
* @param string $dir
27+
* @param string $directory
2828
* @param string $namespace
2929
* @param int $nLevelsUp
3030
*
3131
* @return \Ock\ClassFilesIterator\ClassFilesIA\ClassFilesIAInterface
3232
*/
33-
public static function psr4Up(string $dir, string $namespace, int $nLevelsUp = 0): ClassFilesIAInterface {
34-
return NamespaceDirectory::create($dir, $namespace)
33+
public static function psr4Up(string $directory, string $namespace, int $nLevelsUp = 0): ClassFilesIAInterface {
34+
return NamespaceDirectory::create($directory, $namespace)
3535
->requireParentN($nLevelsUp);
3636
}
3737

src/ClassFilesIA/ClassFilesIA_Psr4.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ public function __construct(
1717
) {}
1818

1919
/**
20-
* @param string $dir
20+
* @param string $directory
2121
* @param string $namespace
2222
*
2323
* @return self
2424
*/
25-
public static function create(string $dir, string $namespace): self {
25+
public static function create(string $directory, string $namespace): self {
2626
return new self(
27-
$dir,
27+
$directory,
2828
NsDirUtil::terminateNamespace($namespace),
2929
);
3030
}

src/DirectoryContents.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public function __construct(
3030
/**
3131
* Static factory which loads a directory.
3232
*
33-
* @param string $dir
33+
* @param string $directory
3434
* Directory path without trailing slash.
3535
*
3636
* @return static
3737
*/
38-
public static function load(string $dir): static {
39-
assert(!str_ends_with($dir, '/'));
40-
$iterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS|\FilesystemIterator::KEY_AS_FILENAME|\FilesystemIterator::CURRENT_AS_SELF);
38+
public static function load(string $directory): static {
39+
assert(!str_ends_with($directory, '/'));
40+
$iterator = new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS|\FilesystemIterator::KEY_AS_FILENAME|\FilesystemIterator::CURRENT_AS_SELF);
4141
$subdir_names = [];
4242
$file_names = [];
4343
foreach ($iterator as $name => $iterator_self) {

src/NsDirUtil.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,60 @@ public static function terminateNamespace(string $namespace): string {
2727
/**
2828
* Recursively iterates over class files.
2929
*
30-
* @param string $dir
30+
* @param string $directory
3131
* Directory without trailing slash.
3232
* @param string $terminatedNamespace
3333
* Namespace with trailing separator.
3434
*
3535
* @return \Iterator<string, class-string>
3636
* Format: $[$file] = $class
3737
*/
38-
public static function iterate(string $dir, string $terminatedNamespace): \Iterator {
39-
assert(!str_ends_with($dir, '/'));
38+
public static function iterate(string $directory, string $terminatedNamespace): \Iterator {
39+
assert(!str_ends_with($directory, '/'));
4040
assert(str_ends_with($terminatedNamespace, '\\') || $terminatedNamespace === '');
41-
self::assertReadableDirectory($dir);
42-
return self::doIterateRecursively($dir, $terminatedNamespace);
41+
self::assertReadableDirectory($directory);
42+
return self::doIterateRecursively($directory, $terminatedNamespace);
4343
}
4444

4545
/**
4646
* Asserts that a path is a readable directory.
4747
*
48-
* @param string $dir
48+
* @param string $directory
4949
* Directory path.
5050
*/
51-
public static function assertReadableDirectory(string $dir): void {
52-
if (!is_dir($dir)) {
53-
if (!file_exists($dir)) {
54-
throw new \RuntimeException("Directory '$dir' does not exist.");
51+
public static function assertReadableDirectory(string $directory): void {
52+
if (!is_dir($directory)) {
53+
if (!file_exists($directory)) {
54+
throw new \RuntimeException("Directory '$directory' does not exist.");
5555
}
56-
throw new \RuntimeException("Path '$dir' is not a directory.");
56+
throw new \RuntimeException("Path '$directory' is not a directory.");
5757
}
58-
if (!is_readable($dir)) {
59-
throw new \RuntimeException("Directory '$dir' is not readable.");
58+
if (!is_readable($directory)) {
59+
throw new \RuntimeException("Directory '$directory' is not readable.");
6060
}
6161
}
6262

6363
/**
6464
* Recursively iterates over class files.
6565
*
66-
* @param string $dir
66+
* @param string $directory
6767
* Directory without trailing slash.
6868
* @param string $terminatedNamespace
6969
* Namespace with trailing separator.
7070
*
7171
* @return \Iterator<string, class-string>
7272
* Format: $[$file] = $class
7373
*/
74-
private static function doIterateRecursively(string $dir, string $terminatedNamespace): \Iterator {
75-
$contents = DirectoryContents::load($dir);
74+
private static function doIterateRecursively(string $directory, string $terminatedNamespace): \Iterator {
75+
$contents = DirectoryContents::load($directory);
7676
foreach ($contents->iterateClassAndNamespaceMap() as $name => $is_namespace) {
7777
if (!$is_namespace) {
7878
// @phpstan-ignore generator.valueType
79-
yield $dir . '/' . $name . '.php' => $terminatedNamespace . $name;
79+
yield $directory . '/' . $name . '.php' => $terminatedNamespace . $name;
8080
}
8181
else {
8282
yield from self::doIterateRecursively(
83-
$dir . '/' . $name,
83+
$directory . '/' . $name,
8484
$terminatedNamespace . $name . '\\',
8585
);
8686
}

0 commit comments

Comments
 (0)