Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exclude paths option #87

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/AopKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ abstract class AopKernel extends CodeTransformerKernel
*/
protected ?string $cacheDir = null;

/**
* The exclude paths. Paths/directories in this array will be excluded
*
* @var array
*/
protected array $excludePaths = [];

// endregion

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Core/AutoloadInterceptor/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function findFile($namespacedClass): false|string

$filePath = Path::resolve($filePath);

foreach ($this->options->getExcludePaths() as $path) {
if (str_starts_with($filePath, $path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the same, Path::resolve($path), so that relative paths and slight differences in paths match.

return $filePath;
}
}

// Query cache state
$cacheState = $this->cacheStateManager->queryCacheState($filePath);
Expand Down