debug("Config cache hit: {$file}"); } else { $data = match (pathinfo($file, PATHINFO_EXTENSION)) { 'json' => json_decode($content, true), 'yml', 'yaml' => extension_loaded('yaml') ? yaml_parse($content) : Yaml::parse($content), default => throw new WrongUsageException("Unsupported artifact config file format: {$file}"), }; if (!is_array($data)) { throw new WrongUsageException("Invalid JSON format in artifact config file: {$file}"); } ConfigCache::set($content, $data); } ConfigValidator::validateAndLintArtifacts(basename($file), $data); foreach ($data as $artifact_name => $config) { self::$artifact_configs[$artifact_name] = $config; Registry::_bindArtifactConfigFile($artifact_name, $registry_name, $file); } return $file; } /** * Get all loaded artifact configurations. * * @return array an associative array of artifact configurations */ public static function getAll(): array { return self::$artifact_configs; } /** * Restore artifact configs from cache without re-parsing YAML files. * * @internal used by Registry cache layer only */ public static function _restoreFromCache(array $configs): void { self::$artifact_configs = array_merge(self::$artifact_configs, $configs); } /** * Get the configuration for a specific artifact by name. * * @param string $artifact_name the name of the artifact * @return null|array the configuration array for the specified artifact, or null if not found */ public static function get(string $artifact_name): ?array { return self::$artifact_configs[$artifact_name] ?? null; } /** * Register an inline artifact configuration. * Used when artifact is defined inline within a package configuration. * * @param string $artifact_name Artifact name (usually same as package name) * @param array $config Artifact configuration * @param string $registry_name Registry name * @param string $source_info Source info for debugging */ public static function registerInlineArtifact(string $artifact_name, array $config, string $registry_name, string $source_info = 'inline'): void { self::$artifact_configs[$artifact_name] = $config; Registry::_bindArtifactConfigFile($artifact_name, $registry_name, $source_info); } }