From 1a9c502d8c672fbe9d71e0f6542d9bba912277ca Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 27 Jun 2024 06:45:05 +0200 Subject: [PATCH] Handle anonymous classes (#3399) --- CodeLite/PHPSourceFile.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CodeLite/PHPSourceFile.cpp b/CodeLite/PHPSourceFile.cpp index 3a6176deac..05d56760a6 100644 --- a/CodeLite/PHPSourceFile.cpp +++ b/CodeLite/PHPSourceFile.cpp @@ -774,14 +774,17 @@ void PHPSourceFile::OnClass(const phpLexerToken& tok) bool isAbstractClass = LookBackTokensContains(kPHP_T_ABSTRACT); // Read until we get the class name + wxString name; phpLexerToken token; while(NextToken(token)) { if(token.IsAnyComment()) continue; if(token.type != kPHP_T_IDENTIFIER) { - // expecting the class name - return; + // Anonymous classes + name = "@anonymous/" + m_filename.GetFullPath() + "/" + wxString::Format(wxT("%i"), token.lineNumber); + break; } + name = PrependCurrentScope(token.Text()); break; } @@ -796,7 +799,7 @@ void PHPSourceFile::OnClass(const phpLexerToken& tok) pClass->SetIsInterface(tok.type == kPHP_T_INTERFACE); pClass->SetIsAbstractClass(isAbstractClass); pClass->SetIsTrait(tok.type == kPHP_T_TRAIT); - pClass->SetFullName(PrependCurrentScope(token.Text())); + pClass->SetFullName(name); pClass->SetLine(token.lineNumber); if (tok.type == kPHP_T_ENUM) {