Skip to content

Commit 6748cc7

Browse files
committed
wip
1 parent 464bbfd commit 6748cc7

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

packages/core/src/DiscoveryConfig.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,4 @@ final class DiscoveryConfig
77
public function __construct(
88
public array $skipDiscovery = [],
99
) {}
10-
11-
public function shouldBeSkipped(string $pathOrClassName): bool
12-
{
13-
return in_array($pathOrClassName, $this->skipDiscovery);
14-
}
1510
}

packages/core/src/Kernel/LoadDiscoveryClasses.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
use Tempest\Reflection\ClassReflector;
2323
use Throwable;
2424

25-
use function Tempest\Support\Arr\contains;
26-
2725
/** @internal */
2826
final class LoadDiscoveryClasses
2927
{
@@ -104,6 +102,7 @@ private function buildDiscovery(string $discoveryClass): Discovery
104102
/** @var SplFileInfo $file */
105103
foreach ($files as $file) {
106104
$fileName = $file->getFilename();
105+
107106
if ($fileName === '') {
108107
continue;
109108
}
@@ -118,7 +117,7 @@ private function buildDiscovery(string $discoveryClass): Discovery
118117

119118
$input = $file->getPathname();
120119

121-
if ($this->discoveryConfig->shouldBeSkipped($input)) {
120+
if ($this->shouldSkipBasedOnConfig($fileName)) {
122121
continue;
123122
}
124123

@@ -139,6 +138,10 @@ private function buildDiscovery(string $discoveryClass): Discovery
139138
}
140139
}
141140

141+
if ($this->shouldSkipBasedOnConfig($input)) {
142+
continue;
143+
}
144+
142145
if ($input instanceof ClassReflector) {
143146
// If the input is a class, we'll call `discover`
144147
if (! $this->shouldSkipDiscoveryForClass($discovery, $input)) {
@@ -168,15 +171,21 @@ private function applyDiscovery(Discovery $discovery): void
168171
$this->appliedDiscovery[$discovery::class] = true;
169172
}
170173

174+
private function shouldSkipBasedOnConfig(ClassReflector|string $input): bool
175+
{
176+
return false;
177+
if ($input instanceof ClassReflector) {
178+
$input = $input->getName();
179+
}
180+
181+
return in_array($input, $this->discoveryConfig->skipDiscovery, strict: true);
182+
}
183+
171184
/**
172185
* Check whether discovery for a specific class should be skipped based on the #[SkipDiscovery] attribute
173186
*/
174187
private function shouldSkipDiscoveryForClass(Discovery $discovery, ClassReflector $input): bool
175188
{
176-
if ($this->discoveryConfig->shouldBeSkipped($input->getName())) {
177-
return true;
178-
}
179-
180189
$attribute = $input->getAttribute(SkipDiscovery::class);
181190

182191
if ($attribute === null) {

0 commit comments

Comments
 (0)