66
77use Illuminate \Support \Collection ;
88use Illuminate \Support \Facades \Blade ;
9+ use Laravel \Roster \Enums \Packages ;
910use Laravel \Roster \Roster ;
1011use Symfony \Component \Finder \Exception \DirectoryNotFoundException ;
1112use Symfony \Component \Finder \Finder ;
@@ -21,6 +22,16 @@ class GuidelineComposer
2122
2223 protected GuidelineAssist $ guidelineAssist ;
2324
25+ /**
26+ * Package priority system to handle conflicts between packages.
27+ * When a higher-priority package is present, lower-priority packages are excluded from guidelines.
28+ *
29+ * @var array<string, string[]>
30+ */
31+ protected array $ packagePriorities = [
32+ Packages::PEST ->value => [Packages::PHPUNIT ->value ],
33+ ];
34+
2435 public function __construct (protected Roster $ roster , protected Herd $ herd )
2536 {
2637 $ this ->config = new GuidelineConfig ;
@@ -118,6 +129,11 @@ protected function find(): Collection
118129 // Add all core and version specific docs for Roster supported packages
119130 // We don't add guidelines for packages unsupported by Roster right now
120131 foreach ($ this ->roster ->packages () as $ package ) {
132+ // Skip packages that should be excluded due to priority rules
133+ if ($ this ->shouldExcludePackage ($ package ->package ()->value )) {
134+ continue ;
135+ }
136+
121137 $ guidelineDir = str_replace ('_ ' , '- ' , strtolower ($ package ->name ()));
122138
123139 $ guidelines ->put (
@@ -152,6 +168,23 @@ protected function find(): Collection
152168 ->where (fn (array $ guideline ) => ! empty (trim ($ guideline ['content ' ])));
153169 }
154170
171+ /**
172+ * Determines if a package should be excluded from guidelines based on priority rules.
173+ */
174+ protected function shouldExcludePackage (string $ packageName ): bool
175+ {
176+ foreach ($ this ->packagePriorities as $ priorityPackage => $ excludedPackages ) {
177+ if (in_array ($ packageName , $ excludedPackages )) {
178+ $ priorityEnum = Packages::from ($ priorityPackage );
179+ if ($ this ->roster ->uses ($ priorityEnum )) {
180+ return true ;
181+ }
182+ }
183+ }
184+
185+ return false ;
186+ }
187+
155188 /**
156189 * @param string $dirPath
157190 * @return array<array{content: string, name: string, path: ?string, custom: bool}>
0 commit comments