Skip to content

Commit 3723575

Browse files
committed
minor #1791 EnumHelper.php : Fix Windows behaviour (tcoch)
This PR was squashed before being merged into the 1.x branch. Discussion ---------- `EnumHelper.php` : Fix Windows behaviour Behaviour is OK on Linux, but tests have been failing on Windows Usage of `DIRECTORY_SEPARATOR` in `EnumHelper.php` fixes this. Commits ------- 2e0a903 `EnumHelper.php` : Fix Windows behaviour
2 parents a3d616e + 2e0a903 commit 3723575

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Util/EnumHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function __construct(
2323
private string $directory,
2424
private string $namespace = 'App',
2525
) {
26+
$this->directory = str_replace(['/', '\\'], \DIRECTORY_SEPARATOR, $directory);
2627
}
2728

2829
public function getAllEnums(): array
@@ -40,7 +41,7 @@ public function getAllEnums(): array
4041
}
4142

4243
foreach ($finder as $file) {
43-
$relativePath = str_replace([$this->directory.'/', '.php'], ['', ''], $file->getRealPath());
44+
$relativePath = str_replace([$this->directory.\DIRECTORY_SEPARATOR, '.php'], ['', ''], $file->getRealPath());
4445
$className = $this->namespace.'\\'.str_replace('/', '\\', $relativePath);
4546

4647
if (enum_exists($className)) {

0 commit comments

Comments
 (0)