diff --git a/joern-cli/frontends/php2cpg/src/main/scala/io/joern/php2cpg/astcreation/AstCreator.scala b/joern-cli/frontends/php2cpg/src/main/scala/io/joern/php2cpg/astcreation/AstCreator.scala index 03b6022e165d..4a1e04fad3a7 100644 --- a/joern-cli/frontends/php2cpg/src/main/scala/io/joern/php2cpg/astcreation/AstCreator.scala +++ b/joern-cli/frontends/php2cpg/src/main/scala/io/joern/php2cpg/astcreation/AstCreator.scala @@ -967,8 +967,10 @@ class AstCreator(filename: String, phpAst: PhpFile)(implicit withSchemaValidatio val fullName = call.target match { // Static method call with a known class name - case Some(nameExpr: PhpNameExpr) if call.isStatic => - s"${nameExpr.name}${StaticMethodDelimiter}$name" + case Some(nameExpr: PhpNameExpr) if call.isStatic => { + if (nameExpr.name == "self") composeMethodFullName(name, call.isStatic) + else s"${nameExpr.name}${StaticMethodDelimiter}$name" + } case Some(expr) => s"$UnresolvedNamespace\\$codePrefix" diff --git a/joern-cli/frontends/php2cpg/src/test/scala/io/joern/php2cpg/querying/CallTests.scala b/joern-cli/frontends/php2cpg/src/test/scala/io/joern/php2cpg/querying/CallTests.scala index b9ca7ca7bc37..057973414d71 100644 --- a/joern-cli/frontends/php2cpg/src/test/scala/io/joern/php2cpg/querying/CallTests.scala +++ b/joern-cli/frontends/php2cpg/src/test/scala/io/joern/php2cpg/querying/CallTests.scala @@ -84,6 +84,30 @@ class CallTests extends PhpCode2CpgFixture { } } + /* This possibly should exist in NamespaceTests.scala */ + "static method calls that refer to self" should { + val cpg = code(""" + |foo($x);")