| 4979 | } |
| 4980 | |
| 4981 | static bool php_vendor_extracted_sites(void) { |
| 4982 | for (int file = 3; file < PHP_VENDOR_FILE_COUNT; file++) { |
| 4983 | const char *source = k_php_vendor_files[file].src; |
| 4984 | CBMFileResult *r = |
| 4985 | cbm_extract_file(source, (int)strlen(source), CBM_LANG_PHP, "cbm_par_phpvendor", |
| 4986 | k_php_vendor_files[file].rel, 0, NULL, NULL); |
| 4987 | if (!r) |
| 4988 | return false; |
| 4989 | bool ok = r->defs.count > 0 && r->imports.count == 2; |
| 4990 | const char *core[] = {"validated", "makeIt", "go", "build", "get", "sendAsync"}; |
| 4991 | const char *service[] = {"get", "publish"}; |
| 4992 | const char *const *wanted = file == 3 ? core : service; |
| 4993 | int wanted_count = file == 3 ? 6 : 2; |
| 4994 | for (int i = 0; i < wanted_count; i++) { |
| 4995 | int count = 0; |
| 4996 | for (int j = 0; j < r->calls.count; j++) { |
| 4997 | const CBMCall *c = &r->calls.items[j]; |
| 4998 | if (!c->callee_name || !c->enclosing_func_qn || |
| 4999 | strcmp(cbm_pipeline_call_callee_leaf(c->callee_name), wanted[i]) != 0 || |
| 5000 | c->site_end_byte <= c->site_start_byte || c->site_end_byte > strlen(source)) |
| 5001 | continue; |
| 5002 | if (file == 4) { |
| 5003 | const char *arg = i == 0 ? "/api/vendor-health" : "vendor-orders"; |
| 5004 | const char *alias = i == 0 ? "GuzzleClient::" : "KafkaProducer::"; |
| 5005 | /* The extractor names a scoped call by its method alone |
| 5006 | * (it keeps only a literal `Route::` scope, #952), so the |
| 5007 | * aliased scope is proven on the occurrence text. */ |
| 5008 | if (!c->first_string_arg || strcmp(c->first_string_arg, arg) != 0 || |
| 5009 | strncmp(source + c->site_start_byte, alias, strlen(alias)) != 0) |
| 5010 | continue; |
| 5011 | } |
| 5012 | count++; |
| 5013 | } |
| 5014 | ok = count == 1 && ok; |
| 5015 | } |
| 5016 | cbm_free_result(r); |
| 5017 | if (!ok) |
| 5018 | return false; |
| 5019 | } |
| 5020 | return true; |
| 5021 | } |
| 5022 | |
| 5023 | static bool php_vendor_service_edge(const cbm_gbuf_t *gb, const char *type, const char *name) { |
| 5024 | const cbm_gbuf_node_t *source = find_unique_callable_node_by_tail(gb, "Clients.run"); |
no test coverage detected