@@ -9659,6 +9659,163 @@ TEST(pipeline_python_receiver_suppresses_weak_method_edge) {
96599659 PASS();
96609660}
96619661
9662+ /* #606: a receiver typed as an unindexed (vendor/) class must not weakly bind a
9663+ * same-named project method. */
9664+ static void write_php_receiver_fixture(const char *tmp) {
9665+ write_temp_file(tmp, "src/Item.php",
9666+ "<?php\n"
9667+ "namespace App;\n"
9668+ "\n"
9669+ "class Item\n"
9670+ "{\n"
9671+ " public function getUid(): int\n"
9672+ " {\n"
9673+ " return 1;\n"
9674+ " }\n"
9675+ "}\n");
9676+ write_temp_file(tmp, "src/Domain/Repository.php",
9677+ "<?php\n"
9678+ "namespace App\\Domain;\n"
9679+ "\n"
9680+ "use App\\Item;\n"
9681+ "use Vendor\\Storage\\File;\n"
9682+ "\n"
9683+ "class Repository\n"
9684+ "{\n"
9685+ " public function findItem(): Item\n"
9686+ " {\n"
9687+ " return new Item();\n"
9688+ " }\n"
9689+ "\n"
9690+ " public function findFile(): File\n"
9691+ " {\n"
9692+ " return new File();\n"
9693+ " }\n"
9694+ "}\n");
9695+ write_temp_file(tmp, "src/Listener.php",
9696+ "<?php\n"
9697+ "namespace App;\n"
9698+ "\n"
9699+ "use Vendor\\Storage\\File;\n"
9700+ "use function sprintf;\n"
9701+ "\n"
9702+ "class Listener\n"
9703+ "{\n"
9704+ " public function vendorCall(File $file): int\n"
9705+ " {\n"
9706+ " return $file->getUid();\n"
9707+ " }\n"
9708+ "\n"
9709+ " public function selfCall(): int\n"
9710+ " {\n"
9711+ " return $this->localHelper();\n"
9712+ " }\n"
9713+ "\n"
9714+ " private function localHelper(): int\n"
9715+ " {\n"
9716+ " return 1;\n"
9717+ " }\n"
9718+ "}\n");
9719+ write_temp_file(tmp, "src/ChainListener.php",
9720+ "<?php\n"
9721+ "namespace App;\n"
9722+ "\n"
9723+ "use App\\Domain\\Repository;\n"
9724+ "\n"
9725+ "class ChainListener\n"
9726+ "{\n"
9727+ " public function chainedVendorCall(Repository $repository): int\n"
9728+ " {\n"
9729+ " return $repository->findFile()->getUid();\n"
9730+ " }\n"
9731+ "\n"
9732+ " public function projectCall(Repository $repository): Item\n"
9733+ " {\n"
9734+ " return $repository->findItem();\n"
9735+ " }\n"
9736+ "}\n");
9737+ }
9738+
9739+ /* Fewer than 50 files exercises pass_calls.c. */
9740+ TEST(pipeline_php_receiver_suppresses_weak_method_edge) {
9741+ char tmp[256];
9742+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_php_recv_XXXXXX");
9743+ if (!cbm_mkdtemp(tmp)) {
9744+ FAIL("tmpdir");
9745+ }
9746+ write_php_receiver_fixture(tmp);
9747+
9748+ char db_path[512];
9749+ snprintf(db_path, sizeof(db_path), "%s/php_recv.db", tmp);
9750+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
9751+ ASSERT_NOT_NULL(p);
9752+ ASSERT_EQ(cbm_pipeline_run(p), 0);
9753+ const char *project = cbm_pipeline_project_name(p);
9754+
9755+ cbm_store_t *s = cbm_store_open_path(db_path);
9756+ ASSERT_NOT_NULL(s);
9757+
9758+ ASSERT_GTE(fixture_node_count(s, project, "src/Item.php", "getUid", "Method"), 1);
9759+ ASSERT_FALSE(cross_file_call_exists(s, project, "vendorCall", "getUid"));
9760+ ASSERT_FALSE(cross_file_call_exists(s, project, "chainedVendorCall", "getUid"));
9761+ ASSERT_TRUE(cross_file_call_exists(s, project, "projectCall", "findItem"));
9762+ ASSERT_GTE(named_edge_count(s, project, "CALLS", "selfCall", "localHelper"), 1);
9763+
9764+ cbm_store_close(s);
9765+ cbm_pipeline_free(p);
9766+ th_rmtree(tmp);
9767+ PASS();
9768+ }
9769+
9770+ /* >= 50 files forces pass_parallel.c. */
9771+ TEST(pipeline_php_receiver_parallel_suppresses_weak_method_edge) {
9772+ char tmp[256];
9773+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_php_par_XXXXXX");
9774+ if (!cbm_mkdtemp(tmp)) {
9775+ FAIL("tmpdir");
9776+ }
9777+ write_php_receiver_fixture(tmp);
9778+ for (int i = 0; i < 52; i++) {
9779+ char name[64];
9780+ char body[128];
9781+ snprintf(name, sizeof(name), "src/Filler%d.php", i);
9782+ snprintf(body, sizeof(body), "<?php\nfunction filler%d(): int\n{\n return %d;\n}\n", i,
9783+ i);
9784+ write_temp_file(tmp, name, body);
9785+ }
9786+
9787+ char *old_workers = getenv("CBM_WORKERS");
9788+ char *saved = old_workers ? strdup(old_workers) : NULL;
9789+ cbm_setenv("CBM_WORKERS", "4", 1);
9790+
9791+ char db_path[512];
9792+ snprintf(db_path, sizeof(db_path), "%s/php_par.db", tmp);
9793+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
9794+ ASSERT_NOT_NULL(p);
9795+ ASSERT_EQ(cbm_pipeline_run(p), 0);
9796+ const char *project = cbm_pipeline_project_name(p);
9797+
9798+ cbm_store_t *s = cbm_store_open_path(db_path);
9799+ ASSERT_NOT_NULL(s);
9800+
9801+ ASSERT_GTE(fixture_node_count(s, project, "src/Item.php", "getUid", "Method"), 1);
9802+ ASSERT_FALSE(cross_file_call_exists(s, project, "vendorCall", "getUid"));
9803+ ASSERT_FALSE(cross_file_call_exists(s, project, "chainedVendorCall", "getUid"));
9804+ ASSERT_TRUE(cross_file_call_exists(s, project, "projectCall", "findItem"));
9805+ ASSERT_GTE(named_edge_count(s, project, "CALLS", "selfCall", "localHelper"), 1);
9806+
9807+ cbm_store_close(s);
9808+ cbm_pipeline_free(p);
9809+ if (saved) {
9810+ cbm_setenv("CBM_WORKERS", saved, 1);
9811+ free(saved);
9812+ } else {
9813+ cbm_unsetenv("CBM_WORKERS");
9814+ }
9815+ th_rmtree(tmp);
9816+ PASS();
9817+ }
9818+
96629819/* The member guard's one exemption (2026-09-16, v0.10.8 → v0.11.0 A/B on
96639820 * django/django): a member call whose receiver is an attribute chain rooted at
96649821 * self/cls, whose callee has exactly ONE definition in the project and is not a
@@ -27522,6 +27679,8 @@ SUITE(pipeline) {
2752227679 RUN_TEST(pipeline_ts_crossfile_new_instance_method_call_issue1354);
2752327680 RUN_TEST(pipeline_ts_param_property_injection_issue514);
2752427681 RUN_TEST(pipeline_python_receiver_suppresses_weak_method_edge);
27682+ RUN_TEST(pipeline_php_receiver_suppresses_weak_method_edge);
27683+ RUN_TEST(pipeline_php_receiver_parallel_suppresses_weak_method_edge);
2752527684 RUN_TEST(pipeline_python_receiver_keeps_specific_unique_name_member_call);
2752627685 RUN_TEST(pipeline_html_embedded_member_call_stays_unbound);
2752727686 RUN_TEST(pipeline_go_method_caller_keeps_lsp_join);
0 commit comments