1313
1414class Registry
1515{
16- /** @var string[] List of loaded registry names */
16+ /** @var array< string, Registry> List of loaded registries */
1717 private static array $ loaded_registries = [];
1818
19+ /** @var array<string, array{registry: string, config: string}> Maps of package and artifact names to their registry config file paths (for reverse lookup) */
20+ private static array $ package_reversed_registry_files = [];
21+ private static array $ artifact_reversed_registry_files = [];
22+
1923 /**
2024 * Load a registry from file path.
2125 * This method handles external registries that may not be in composer autoload.
@@ -85,9 +89,9 @@ public static function loadRegistry(string $registry_file, bool $auto_require =
8589 foreach ($ data ['package ' ]['config ' ] as $ path ) {
8690 $ path = self ::fullpath ($ path , dirname ($ registry_file ));
8791 if (is_file ($ path )) {
88- PackageConfig::loadFromFile ($ path );
92+ PackageConfig::loadFromFile ($ path, $ registry_name );
8993 } elseif (is_dir ($ path )) {
90- PackageConfig::loadFromDir ($ path );
94+ PackageConfig::loadFromDir ($ path, $ registry_name );
9195 }
9296 }
9397 }
@@ -97,9 +101,9 @@ public static function loadRegistry(string $registry_file, bool $auto_require =
97101 foreach ($ data ['artifact ' ]['config ' ] as $ path ) {
98102 $ path = self ::fullpath ($ path , dirname ($ registry_file ));
99103 if (is_file ($ path )) {
100- ArtifactConfig::loadFromFile ($ path );
104+ ArtifactConfig::loadFromFile ($ path, $ registry_name );
101105 } elseif (is_dir ($ path )) {
102- ArtifactConfig::loadFromDir ($ path );
106+ ArtifactConfig::loadFromDir ($ path, $ registry_name );
103107 }
104108 }
105109 }
@@ -187,7 +191,12 @@ public static function loadFromEnvOrOption(?string $registries = null): void
187191 }
188192 }
189193
190- public static function checkLoadedRegistries (): void
194+ /**
195+ * Resolve loaded registries.
196+ * This method finalizes the loading process by registering default stages
197+ * and validating stage events.
198+ */
199+ public static function resolve (): void
191200 {
192201 // Register default stages for all PhpExtensionPackage instances
193202 // This must be done after all registries are loaded to ensure custom stages take precedence
@@ -217,6 +226,42 @@ public static function reset(): void
217226 self ::$ loaded_registries = [];
218227 }
219228
229+ /**
230+ * Bind a package name to its registry config file for reverse lookup.
231+ *
232+ * @internal
233+ */
234+ public static function _bindPackageConfigFile (string $ package_name , string $ registry_name , string $ config_file ): void
235+ {
236+ self ::$ package_reversed_registry_files [$ package_name ] = [
237+ 'registry ' => $ registry_name ,
238+ 'config ' => $ config_file ,
239+ ];
240+ }
241+
242+ /**
243+ * Bind an artifact name to its registry config file for reverse lookup.
244+ *
245+ * @internal
246+ */
247+ public static function _bindArtifactConfigFile (string $ artifact_name , string $ registry_name , string $ config_file ): void
248+ {
249+ self ::$ artifact_reversed_registry_files [$ artifact_name ] = [
250+ 'registry ' => $ registry_name ,
251+ 'config ' => $ config_file ,
252+ ];
253+ }
254+
255+ public static function getPackageConfigInfo (string $ package_name ): ?array
256+ {
257+ return self ::$ package_reversed_registry_files [$ package_name ] ?? null ;
258+ }
259+
260+ public static function getArtifactConfigInfo (string $ artifact_name ): ?array
261+ {
262+ return self ::$ artifact_reversed_registry_files [$ artifact_name ] ?? null ;
263+ }
264+
220265 /**
221266 * Parse a class entry from the classes array.
222267 * Supports two formats:
0 commit comments