MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / extract_psr4

Function extract_psr4

src/pipeline/pass_pkgmap.c:444–474  ·  view source on GitHub ↗

Extract PSR-4 autoload entries from composer.json root. */

Source from the content-addressed store, hash-verified

442
443/* Extract PSR-4 autoload entries from composer.json root. */
444static void extract_psr4(yyjson_val *root, const char *dir, cbm_pkg_entries_t *entries) {
445 yyjson_val *autoload = yyjson_obj_get(root, "autoload");
446 if (!yyjson_is_obj(autoload)) {
447 return;
448 }
449 yyjson_val *psr4 = yyjson_obj_get(autoload, "psr-4");
450 if (!yyjson_is_obj(psr4)) {
451 return;
452 }
453 yyjson_val *key = NULL;
454 yyjson_obj_iter iter = yyjson_obj_iter_with(psr4);
455 while ((key = yyjson_obj_iter_next(&iter)) != NULL) {
456 yyjson_val *val = yyjson_obj_iter_get_val(key);
457 if (!yyjson_is_str(key) || !yyjson_is_str(val)) {
458 continue;
459 }
460 const char *ns_prefix = yyjson_get_str(key);
461 const char *ns_dir = yyjson_get_str(val);
462 char ns_entry[PKGMAP_PATH_BUF];
463 if (dir[0]) {
464 snprintf(ns_entry, sizeof(ns_entry), "%s/%s", dir, ns_dir);
465 } else {
466 snprintf(ns_entry, sizeof(ns_entry), "%s", ns_dir);
467 }
468 size_t nelen = strlen(ns_entry);
469 if (nelen > 0 && ns_entry[nelen - SKIP_ONE] == '/') {
470 ns_entry[nelen - SKIP_ONE] = '\0';
471 }
472 pkg_entries_push(entries, strdup(ns_prefix), strdup(ns_entry));
473 }
474}
475
476/* PHP: composer.json — name + PSR-4 autoload */
477static void parse_composer_json(const char *source, int source_len, const char *rel_path,

Callers 1

parse_composer_jsonFunction · 0.85

Calls 1

pkg_entries_pushFunction · 0.85

Tested by

no test coverage detected