2222use Tempest \Reflection \ClassReflector ;
2323use Throwable ;
2424
25- use function Tempest \Support \Arr \contains ;
26-
2725/** @internal */
2826final 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