Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion codewiki/cli/utils/repo_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
'.cxx', # C++
'.hxx', # C++ headers
'.cs', # C#
'.php', # PHP
'.phtml', # PHP templates
'.inc', # PHP includes
}


Expand Down Expand Up @@ -57,7 +60,7 @@ def validate_repository(repo_path: Path) -> Tuple[Path, List[Tuple[str, int]]]:
if not languages:
raise RepositoryError(
f"No supported code files found in {repo_path}\n\n"
"CodeWiki supports: Python, Java, JavaScript, TypeScript, C, C++, C#\n\n"
"CodeWiki supports: Python, Java, JavaScript, TypeScript, C, C++, C#, PHP\n\n"
"Please navigate to a code repository or specify a custom directory:\n"
" cd /path/to/your/project\n"
" codewiki generate"
Expand Down
1 change: 1 addition & 0 deletions codewiki/cli/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def detect_supported_languages(directory: Path) -> List[Tuple[str, int]]:
'C': ['.c', '.h'],
'C++': ['.cpp', '.hpp', '.cc', '.hh', '.cxx', '.hxx'],
'C#': ['.cs'],
'PHP': ['.php', '.phtml', '.inc'],
}

# Directories to exclude from counting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,17 @@ def _filter_supported_languages(self, code_files: List[Dict]) -> List[Dict]:
"""
Filter code files to only include supported languages.

Supports Python, JavaScript, TypeScript, C, C++, Go, and Rust.
Supports Python, JavaScript, TypeScript, Java, C#, C, C++, PHP, Go, and Rust.
"""
supported_languages = {
"python",
"javascript",
"javascript",
"typescript",
"java",
"csharp",
"c",
"cpp",
"php",
"go",
"rust",
}
Expand All @@ -317,7 +318,7 @@ def _filter_supported_languages(self, code_files: List[Dict]) -> List[Dict]:

def _get_supported_languages(self) -> List[str]:
"""Get list of currently supported languages for analysis."""
return ["python", "javascript", "typescript", "java", "csharp", "c", "cpp"]
return ["python", "javascript", "typescript", "java", "csharp", "c", "cpp", "php"]

def _cleanup_repository(self, temp_dir: str):
"""Clean up cloned repository."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def _analyze_code_file(self, repo_dir: str, file_info: Dict):
self._analyze_c_file(file_path, content, repo_dir)
elif language == "cpp":
self._analyze_cpp_file(file_path, content, repo_dir)
elif language == "php":
self._analyze_php_file(file_path, content, repo_dir)
# else:
# logger.warning(
# f"Unsupported language for call graph analysis: {language} for file {file_path}"
Expand Down Expand Up @@ -298,6 +300,28 @@ def _analyze_csharp_file(self, file_path: str, content: str, repo_dir: str):
except Exception as e:
logger.error(f"Failed to analyze C# file {file_path}: {e}", exc_info=True)

def _analyze_php_file(self, file_path: str, content: str, repo_dir: str):
"""
Analyze PHP file using tree-sitter based analyzer.

Args:
file_path: Relative path to the PHP file
content: File content string
repo_dir: Repository base directory
"""
from codewiki.src.be.dependency_analyzer.analyzers.php import analyze_php_file

try:
functions, relationships = analyze_php_file(file_path, content, repo_path=repo_dir)

for func in functions:
func_id = func.id if func.id else f"{file_path}:{func.name}"
self.functions[func_id] = func

self.call_relationships.extend(relationships)
except Exception as e:
logger.error(f"Failed to analyze PHP file {file_path}: {e}", exc_info=True)

def _resolve_call_relationships(self):
"""
Resolve function call relationships across all languages.
Expand Down Expand Up @@ -382,6 +406,8 @@ def _generate_visualization_data(self) -> Dict:
node_classes.append("lang-c")
elif file_ext in [".cpp", ".cc", ".cxx", ".hpp", ".hxx"]:
node_classes.append("lang-cpp")
elif file_ext in [".php", ".phtml", ".inc"]:
node_classes.append("lang-php")

cytoscape_elements.append(
{
Expand Down
Loading