bool TestDependGraph::TestFunctionCall() { // functions VD4(FunctionCall, "<?php include $_SERVER['PHP_ROOT'].'f2';\n test();", "<?php function test() {}", "test", "test()"); VD4(FunctionCall, "<?php test(); function test() {}", "", "test", "test()"); VD4(FunctionCall, "<?php function test() {} test();", "", "test", "test()"); // methods VD4(FunctionCall, "<?php include $_SERVER['PHP_ROOT'].'f2';\n" "function test() { $a = new C(); $a->test();}", "<?php class C { public function test() {}}", "c::test", "$a->test()"); VD4(FunctionCall, "<?php function test() { $a = new C(); $a->test();} " "class C { public function test() {}}", "", "c::test", "$a->test()"); VD4(FunctionCall, "<?php class C { public function test() {}} " "function test() { $a = new C(); $a->test();}", "", "c::test", "$a->test()"); #ifdef HPHP_NOTE // making sure a "MasterCopy" marked function will always be used for // dependency's parent { Option::IncludeRoots["$_SERVER['PHP_ROOT']"] = ""; AnalysisResultPtr ar(new AnalysisResult()); BuiltinSymbols::Load(ar); Parser::ParseString("<?php function test() {}", ar, "f1"); Parser::ParseString("<?php /*|MasterCopy|*/ function test() {}", ar, "f2"); ar->analyzeProgram(); ar->inferTypes(); DependencyGraphPtr dg = ar->getDependencyGraph(); ConstructPtr parent = dg->getParent(DependencyGraph::KindOfFunctionCall, "test"); if (!parent || strcmp(parent->getLocation()->file, "f2") != 0) { printf("%s:%d: incorrect parent found at %s:%d\n", __FILE__, __LINE__, parent ? parent->getLocation()->file : "", parent ? parent->getLocation()->line0 : 0); return false; } } #endif return true; }