Title: PHP Quality Analyzer User Guide
Version: 1.0
Date: December 2025
Author: Development Team
Audience: PHP Developers, Software Architects, Quality Assurance Engineers
Purpose: User guide for PHP Quality Analyzer plugin in SciTools Understand
- Introduction
- Concept of Operations
- Installation
- User Procedures
- Information for Uninstallation
- Troubleshooting
- Appendices
- Figure 1: IReport Interface
- Table 1: Configuration Options
- Table 2: Analysis Results Interpretation
- Table 3: Severity Levels
The PHP Quality Analyzer plugin for SciTools Understand provides comprehensive static code analysis for PHP projects. This user guide explains how to install, configure, and use the plugin to analyze PHP code quality, identify architectural smells, design issues, and implementation problems.
This document covers:
- Installation and setup procedures
- Configuration of analysis parameters
- Interpretation of analysis results
- Troubleshooting common issues
This guide is intended for:
- PHP developers
- Software architects
- Quality assurance engineers
- Project managers
- Bold text: UI elements, menu items, buttons
Monospace: Code examples, file paths, commands⚠️ Warning: Important notes about potential issues- 💡 Tip: Helpful suggestions for better usage
- 🔧 Note: Technical details or additional information
- SciTools Understand (with PHP language support)
- Windows/Linux/macOS operating system
- Minimum 4GB RAM recommended for large projects
The PHP Quality Analyzer operates as an IReport plugin within SciTools Understand, providing automated static analysis of PHP source code. The plugin analyzes the entire PHP project database to identify code quality issues across multiple dimensions.
The plugin identifies architectural issues that affect system maintainability and scalability:
- Unstable Dependency: Components depending on less stable components
- God Component: Excessively large components (high LOC or method count)
- Feature Concentration: Components implementing multiple architectural concerns
- Dense Structure: Components with excessive dependency density
Design-level issues violating object-oriented principles:
- Multifaceted Abstraction: Classes with multiple responsibilities
- Feature Envy: Methods accessing external class members excessively
- Insufficient Encapsulation: Members with overly permissive access
- Broken Modularization: Members scattered across abstractions
- Hub-like Modularization: Classes with excessive dependencies (>20)
- Wide/Deep Hierarchy: Inheritance hierarchies that are too wide or deep
Code-level issues affecting readability and maintainability:
- Complex Conditional: Conditions with high cyclomatic complexity
- Complex Method: Methods with high cyclomatic complexity
- Empty Catch Clause: Empty or comment-only catch blocks
- Long Identifiers: Identifiers exceeding 50 characters
- Long Methods: Methods exceeding 50 lines of code
- Long Parameter Lists: Methods with more than 7 parameters
Quantitative measures of code quality:
- LOC: Lines of Code
- CC: Cyclomatic Complexity
- PC: Parameter Count
- NOM/NOPM: Number of Methods/Public Methods
- LCOM: Lack of Cohesion in Methods
- FANIN/FANOUT: Dependency metrics
The plugin uses algorithmic analysis rather than keyword-based detection:
- Complexity Analysis: Methods are evaluated using the formula
complexity = LOC × CC + parameters - Cluster Analysis: Methods are grouped by complexity levels (high/medium/low)
- Pattern Recognition: Automated identification of problematic patterns
- Metric Calculation: Direct computation using Understand's built-in metrics
Results are presented in a structured HTML report with:
- Executive summary of findings
- Detailed issue descriptions with file locations
- Severity classifications (HIGH/MEDIUM/LOW)
- Refactoring recommendations
- Code quality statistics
- SciTools Understand installed with PHP language support
- Administrative privileges for plugin installation
- Valid Understand license
-
Locate the SciTools Understand plugins directory:
- Windows:
C:\Program Files\SciTools\plugins\ - Linux:
/opt/scitools/plugins/ - macOS:
/Applications/SciTools/plugins/
- Windows:
-
Copy the plugin files to the IReport subdirectory:
plugins/IReport/PHP_Quality_Analyzer/ ├── check.upy ├── README.md └── test files/ -
Verify the installation:
- Restart SciTools Understand
- Open Tools → Reports → IReport
- Confirm "PHP Quality Analyzer Report" appears in the list
- Launch SciTools Understand
- Create or open a PHP project
- Access IReport and select the PHP Quality Analyzer
- Run a test analysis on sample PHP files
- Launch SciTools Understand
- Select File → New Project or File → Open Project
- Add PHP source files to the project
- Ensure files are recognized as PHP language
- Build the project database (Project → Analyze)
- Select Tools → Reports → IReport from the main menu
- In the IReport dialog, select "PHP Quality Analyzer Report"
- Click Run Report
Configure which types of analysis to perform:
- ☑️ Analyze Architecture Smells: Detect architectural issues
- ☑️ Analyze Design Smells: Identify design problems
- ☑️ Analyze Implementation Smells: Find code-level issues
- ☑️ Calculate Code Metrics: Compute quality metrics
Architecture Smells:
- God Component LOC Threshold: Maximum lines of code (default: 2000)
- God Component Classes Threshold: Maximum class count (default: 50)
- Hub Dependencies Threshold: Maximum dependencies (default: 20)
- Feature Concentration Threshold: Minimum complexity clusters (default: 3)
Design Smells:
- Feature Envy Threshold: External access percentage (default: 70%)
- LCOM Threshold: Cohesion threshold (default: 80%)
Implementation Smells:
- Complex Method CC Threshold: Cyclomatic complexity (default: 15)
- Long Method LOC Threshold: Lines of code (default: 50)
- Long Identifier Threshold: Character length (default: 50)
- Long Parameter List Threshold: Parameter count (default: 7)
Configure result display limits:
- Max God Components to Show: Default 10
- Max Feature Concentration Issues to Show: Default 3
- Max Classes/Functions in Summary: Default 10
- Click Generate to start analysis
- Monitor progress in the status bar
- Review results in the report window
PHP Quality Analyzer Report
==================================================
🏗️ ARCHITECTURE SMELLS ANALYSIS
----------------------------------------
⚠️ God Components Found: 1
• ClassName in file.php:line (LOC: 1500, Methods: 45)
⚠️ Feature Concentration: 2
• ClassName in file.php:line
MEDIUM: 3 weakly cohesive method groups
• Cluster 1: 3 methods - high complexity methods
• method1 (complexity: 150)
• method2 (complexity: 120)
• Cluster 2: 4 methods - medium complexity methods
• method3 (complexity: 45)
• method4 (complexity: 38)
📊 CODE QUALITY METRICS
----------------------------------------
📈 Project Statistics:
• Classes: 25
• Methods/Functions: 180
• Total Lines of Code: 3500
- 🔴 HIGH: Critical architectural issues
- 🟡 MEDIUM: Design and implementation problems
- 🟢 LOW: Minor code quality issues
To remove the PHP Quality Analyzer plugin from SciTools Understand:
- Close SciTools Understand completely
- Navigate to the plugins directory:
- Windows:
C:\Program Files\SciTools\plugins\IReport\ - Linux:
/opt/scitools/plugins/IReport/ - macOS:
/Applications/SciTools/plugins/IReport/
- Windows:
- Delete the entire
PHP_Quality_Analyzerfolder - Restart SciTools Understand
The plugin does not create:
- Registry entries
- Configuration files outside the plugin directory
- Persistent user data
- Database modifications
No additional cleanup is required.
After uninstallation:
- "PHP Quality Analyzer Report" will no longer appear in IReport menu
- Existing project databases remain unaffected
- Other plugins continue to function normally
- No system performance impact
Symptoms:
- "PHP Quality Analyzer Report" not visible in IReport menu
Possible Causes and Solutions:
-
Incorrect Installation Path
- Solution: Verify plugin files are in
plugins/IReport/PHP_Quality_Analyzer/ - Action: Recopy files to correct location
- Solution: Verify plugin files are in
-
Missing check.upy File
- Solution: Ensure
check.upyexists in plugin directory - Action: Verify file integrity
- Solution: Ensure
-
Understand Not Restarted
- Solution: Restart SciTools Understand after installation
- Action: Complete application restart required
Symptoms:
- Report shows "No PHP files found"
- Missing analysis results
Possible Causes and Solutions:
-
No PHP Files in Project
- Solution: Add PHP source files to project
- Action: Use Project → Add Files
-
Files Not Recognized as PHP
- Solution: Check file language settings
- Action: Right-click files → Properties → Language
-
Database Not Analyzed
- Solution: Build project database
- Action: Project → Analyze
Symptoms:
- Analysis takes too long
- High memory usage
Possible Causes and Solutions:
-
Large Project Size
- Solution: Disable unnecessary analysis types
- Action: Uncheck analysis options in configuration
-
Low System Resources
- Solution: Increase memory allocation
- Action: Close other applications during analysis
Symptoms:
- Error messages during analysis
- Incomplete results
Possible Causes and Solutions:
-
Corrupted Project Database
- Solution: Rebuild project database
- Action: Project → Analyze (force rebuild)
-
Plugin Version Incompatibility
- Solution: Check Understand version compatibility
- Action: Verify minimum version requirements
If problems persist:
- Check SciTools Understand documentation
- Review plugin README for updates
- Contact technical support with:
- Understand version
- Operating system
- Error messages
- Project size information
- God Component LOC Threshold: Максимальна кількість рядків коду (за замовчуванням: 2000)
- God Component Classes Threshold: Максимальна кількість класів (за замовчуванням: 50)
- Hub Dependencies Threshold: Максимальна кількість залежностей (за замовчуванням: 20)
- Feature Concentration Threshold: Мінімальна кількість груп методів різної складності (за замовчуванням: 3)
- Dense Structure Density Threshold: Максимальна щільність залежностей (%) (за замовчуванням: 70)
- Wide Hierarchy Threshold: Максимальна кількість прямих підкласів (за замовчуванням: 10)
- Deep Hierarchy Threshold: Максимальна глибина наслідування (за замовчуванням: 6)
Плагін використовує алгоритмічний підхід замість жорстко заданих категорій:
Методика аналізу:
- Метричний аналіз складності: Кожен метод оцінюється за формулою:
складність = LOC × CC + кількість_параметрів - Кластеризація: Методи групуються за рівнями складності:
- Висока складність: > 50 (складні алгоритми, обробка даних)
- Середня складність: 20-50 (бізнес-логіка, валідація)
- Низька складність: < 20 (гетери, сетери, утиліти)
- Виявлення: Якщо клас має методи з 3+ різних груп складності - це Feature Concentration
Переваги:
- ✅ Алгоритмічний: Не залежить від жорстко заданих ключових слів
- ✅ Вимірюваний: Заснований на об'єктивних метриках коду
- ✅ Адаптивний: Працює з різними стилями програмування
- ✅ Точний: Використовує кількісні виміри складності
Configure result display limits:
- Max God Components to Show: Default 10
- Max Hub Classes to Show: Default 5
- Max Feature Concentration Issues to Show: Default 3
- Max Dense Structure Issues to Show: Default 5
- Max Multifaceted Abstractions to Show: Default 5
- Max Insufficient Modularization Issues to Show: Default 5
- Max Classes in Summary: Default 10
- Max Functions in Summary: Default 10
Design Smells:
- Feature Envy Threshold: External access percentage (default: 70%)
- LCOM Threshold: Cohesion threshold (default: 80%)
Implementation Smells:
- Complex Method CC Threshold: Cyclomatic complexity (default: 15)
- Long Method LOC Threshold: Lines of code (default: 50)
- Long Identifier Threshold: Character length (default: 50)
- Long Parameter List Threshold: Parameter count (default: 7)
- Long Statement Threshold: Expression length (default: 120)
- Complex Conditional CC: Condition complexity (default: 10)
The report includes the following sections:
- Statistics of detected "God Components"
- Hub-like modularization analysis
- Refactoring recommendations
- Multifaceted abstractions
- Insufficient modularization
- Inheritance hierarchy problems
- Complex methods and conditions
- Long identifiers and methods
- Parameter-related problems
- Overall project statistics
- Class metrics (LOC, NOM, NOF, DIT, LCOM)
- Method metrics (LOC, CC, PC)
- Average, minimum, and maximum values
The plugin includes comprehensive test files that demonstrate various code quality issues:
test_god_component.php: Demonstrates "God Component" smelltest_design_smells.php: Shows various design smellstest_implementation_smells.php: Contains implementation smell examplestest_metrics.php: Provides metric calculation examples
The plugin integrates with the IReport framework of SciTools Understand:
- Uses
name(),description(),tags()for report metadata - Provides
test_*()functions for filtering - Uses
init()for option settings - Implements
generate()for report creation
- Static Analysis: Uses AST and Understand's symbol table
- Metric Calculation: Uses Understand's built-in metrics
- Pattern Recognition: Implements custom heuristics for smell detection
- Configurable Thresholds: Allows sensitivity adjustment
- SciTools Understand (for PHP support)
- Python 3.x (for UPY plugin execution)
- No external Python libraries required
- Some complex smells require deeper semantic analysis
- Machine learning smells not fully implemented (PHP context limitations)
- Cross-file/project architectural analysis is simplified
- Some metrics may slightly differ from academic definitions
- Enhanced semantic analysis for more accurate smell detection
- Cross-project architecture analysis
- Integration with additional PHP quality tools
- Performance optimization for large codebases
- Additional configuration options
- DPy (Design Pattern detector) framework
- Refactoring for Software Design Smells (Mäntylä et al.)
- Object-Oriented Metrics in Practice (Lorenz and Kidd)
- Various scientific papers on code smells and metrics
The plugin has been fully updated for IReport API compatibility:
- API Options:
report.option()→report.options()(parentheses added) - API Database:
report.db→report.db()(parentheses added) - Full functionality tested
# Launch Understand
"C:\Program Files\SciTools\bin\pc-win64\ud.exe"- File → New Project (create new PHP project)
- File → Open Project (open existing .udb file)
- Add PHP files to project for analysis
- Tools → Reports → IReport (or
Ctrl+Shift+R) - In IReport window find "PHP Quality Analyzer Report"
- Click Run Report
In the settings dialog select:
Core Analysis Parameters:
- ☑️ Analyze Architecture Smells - Analyze architectural issues
- ☑️ Analyze Design Smells - Analyze design problems
- ☑️ Analyze Implementation Smells - Analyze implementation issues
- ☑️ Calculate Code Metrics - Calculate quality metrics
Architecture Smells Thresholds:
- God Component LOC Threshold: 2000 (maximum lines of code)
- God Component Classes Threshold: 50 (maximum classes)
- Hub Dependencies Threshold: 20 (maximum dependencies)
- Wide Hierarchy Threshold: 10 (maximum subclasses)
- Deep Hierarchy Threshold: 6 (maximum inheritance depth)
Design Smells Thresholds:
- Feature Envy Threshold: 70% (external access percentage)
- LCOM Threshold: 80% (cohesion threshold)
Implementation Smells Thresholds:
- Complex Method CC Threshold: 15 (cyclomatic complexity)
- Long Method LOC Threshold: 50 (lines of code)
- Long Identifier Length: 50 (identifier length)
- Long Parameter Count: 7 (parameter count)
- Long Statement Length: 120 (statement length)
- Complex Conditional CC: 10 (condition complexity)
- Click Generate to create report
- Wait for analysis completion (progress bar shown)
- IMPORTANT: Report analyzes ALL PHP files in project, not just selected file
- Review results in report window with file and line references for each issue
PHP Quality Analyzer Report
==================================================
🏗️ ARCHITECTURE SMELLS ANALYSIS
⚠️ God Components Found: 1
• GodComponent in test_god_component.php:8 (LOC: 2397, Methods: 2015, Fields: 21)
✅ No Hub-like modularization detected
⚠️ Feature Concentration: 1
• hKit in hkit.class.php:60
MEDIUM: 3 weakly cohesive method groups
Methods: 15 | Weak clusters: 3
• Cluster 1: 3 methods - very low cohesion, high complexity methods
• processnodes (complexity: 255)
• resolvepath (complexity: 93)
• parse (complexity: 85)
• Cluster 2: 5 methods - low cohesion, medium complexity methods
• find (complexity: 45)
• extract (complexity: 38)
• validate (complexity: 32)
• format (complexity: 28)
• convert (complexity: 25)
• Cluster 3: 7 methods - low cohesion, low complexity methods
• getName (complexity: 3)
• setValue (complexity: 4)
• isValid (complexity: 5)
• ... and 4 more methods
💡 Improve cohesion within clusters before splitting | Apply Single Responsibility Principle
... and X more (configure "Max Feature Concentration Issues to Show")
⚠️ Dense Structure: 1
• CentralManager in architecture_test.php:15 (85% density, 12 dependencies)
🎨 DESIGN SMELLS ANALYSIS
⚠️ Multifaceted Abstractions: 3
• GodComponent in test_god_component.php:8 (4 concerns)
• ReportGenerator in test_implementation_smells.php:8 (5 concerns)
• UtilityClass in test_design_smells.php:155 (4 concerns)
⚠️ Insufficient Modularization: 18
• GodComponent in test_god_component.php:8 (LCOM: 0.93)
• UserManager in test_design_smells.php:8 (LCOM: 1.00)
• ReportGenerator in test_implementation_smells.php:8 (LCOM: 1.00)
⚙️ IMPLEMENTATION SMELLS ANALYSIS
⚠️ Long Methods: 1
• DataProcessor::processdatawithcomplexlogic in test_implementation_smells.php:101 (68 lines)
⚠️ Long Identifiers: 5
• UserAuthenticationAndAuthorizationManagementService in test_implementation_smells.php:228 (51 chars)
• performuserauthenticationandauthorizationcheckingprocess in test_implementation_smells.php:260 (56 chars)
📊 CODE QUALITY METRICS
Project Statistics:
• Classes: 63
• Methods/Functions: 341
• Total Lines of Code: 958
Class Metrics:
• LOC: Avg=15.2, Min=0, Max=138
• NOM: Avg=2.7, Min=0, Max=27
• NOF: Avg=1.5, Min=0, Max=21
• DIT: Avg=0.0, Min=0, Max=0
• LCOM: Avg=0.4, Min=0.0, Max=1.0
Method Metrics:
• LOC: Avg=2.2, Min=0, Max=68
• CC: Avg=0.5, Min=0, Max=6
• PC: Avg=0.0, Min=0, Max=0
📋 Top 10 Classes by LOC (showing top 10):
• GodComponent - 2397 LOC, 2244 methods
• LargeClass - 850 LOC, 45 methods
• ComplexClass - 320 LOC, 28 methods
... and 7 more classes (configure "Max Classes in Summary")
📋 Top 10 Functions by LOC (showing top 10):
• processLargeData - 68 LOC, CC: 12
• complexCalculation - 45 LOC, CC: 8
• handleMultipleTasks - 38 LOC, CC: 6
... and 11 more functions (configure "Max Functions in Summary")
Plugin analyzes ALL PHP files in the project, regardless of the file selected in IReport. This provides a complete picture of the entire project's code quality.
- 🔴 HIGH: Architectural smells, complex methods
- 🟡 MEDIUM: Design smells, long methods
- 🟢 LOW: Implementation smells, metric warnings
Each issue now shows:
IssueName in file.php:line (details)
This allows quick navigation to problematic code in IDE.
🐘 God Component:
// BAD: One huge class
class UserManager {
// 2000+ lines of code, multiple responsibilities
}
// GOOD: Split into specialized classes
class UserRepository { /* data only */ }
class UserService { /* business logic only */ }
class UserValidator { /* validation only */ }🎭 Multifaceted Abstraction:
// BAD: Class with multiple responsibilities
class OrderProcessor {
public function validate() { /* validation */ }
public function save() { /* persistence */ }
public function sendEmail() { /* notifications */ }
public function calculateTax() { /* calculations */ }
}
// GOOD: Single Responsibility Principle
class OrderValidator { /* validation only */ }
class OrderRepository { /* persistence only */ }
class OrderNotifier { /* notifications only */ }
class TaxCalculator { /* calculations only */ }🌀 Complex Method:
// BAD: Complex method with high cyclomatic complexity
public function processOrder($orderData) {
if ($orderData['type'] == 'new') {
if ($orderData['payment'] == 'card') {
if ($orderData['amount'] > 100) {
// ... many nested conditions
}
}
}
}
// GOOD: Break into simple methods
public function processOrder($orderData) {
if (!$this->isValidOrder($orderData)) return false;
$this->processPayment($orderData);
$this->updateInventory($orderData);
$this->sendConfirmation($orderData);
}- LOC < 50: Excellent method
- CC < 10: Good complexity
- LCOM < 0.5: High cohesion
- DIT < 4: Acceptable inheritance depth
For automated analysis, use:
# In build script
ud -db project.udb -report "PHP Quality Analyzer Report" -output quality_report.htmlЧтобы добавить новые проверки:
# Добавить в check.upy
def analyze_custom_smell(entities):
"""Пользовательская проверка"""
custom_smells = []
for cls in entities['classes']:
# Ваша логика анализа
if some_condition(cls):
custom_smells.append({'name': cls.name(), 'issue': 'Custom Issue'})
return custom_smells
# Добавить вызов в generate()
def generate_custom_report(report, entities):
custom_issues = analyze_custom_smell(entities)
if custom_issues:
report.print(f"⚠️ Custom Issues: {len(custom_issues)}\n")
for issue in custom_issues:
report.print(f" • {issue['name']}: {issue['issue']}\n")- DPy Framework - Основа для анализа качества кода
- SOLID принципы - Основы объектно-ориентированного дизайна
- Clean Code (Robert Martin) - Стандарты чистого кода
- Refactoring (Martin Fowler) - Техники рефакторинга
- Check path:
IReport/PHP_Quality_Analyzer/check.upy - Restart Understand
- Verify
check.upyfile exists
- Ensure PHP files exist in project
- Check file language settings (should be PHP)
- Try analyzing individual files
- For large projects, disable some analysis types
- Increase thresholds to reduce detections
- Analyze individual packages/directories
PHP Quality Analyzer is a powerful tool for maintaining high PHP code quality. It combines proven analysis methodologies (DPy framework) with the convenient SciTools Understand interface.
Key Advantages:
- ✅ Comprehensive analysis of all code quality aspects
- ✅ Configurable thresholds to match your team's standards
- ✅ Detailed reports with refactoring recommendations
- ✅ IDE integration for ease of use
- ✅ Open source for extensions and modifications
Happy coding and quality analysis! 🎯
| Option | Default | Description |
|---|---|---|
| Analyze Architecture Smells | True | Enable architectural issue detection |
| Analyze Design Smells | True | Enable design problem detection |
| Analyze Implementation Smells | True | Enable code-level issue detection |
| Calculate Code Metrics | True | Enable quality metrics calculation |
| God Component LOC Threshold | 2000 | Maximum lines of code for God Component |
| God Component Classes Threshold | 50 | Maximum classes for God Component |
| Hub Dependencies Threshold | 20 | Maximum dependencies for hub detection |
| Feature Concentration Threshold | 3 | Minimum complexity clusters |
| Feature Envy Threshold | 70% | External access percentage threshold |
| LCOM Threshold | 80% | Lack of cohesion threshold |
| Complex Method CC Threshold | 15 | Cyclomatic complexity threshold |
| Long Method LOC Threshold | 50 | Lines of code threshold |
| Long Identifier Threshold | 50 | Character length threshold |
| Long Parameter List Threshold | 7 | Parameter count threshold |
| Severity | Description | Action Required |
|---|---|---|
| ?? HIGH | Critical architectural issues | Immediate refactoring required |
| ?? MEDIUM | Design and implementation problems | Plan refactoring in next sprint |
| ?? LOW | Minor code quality issues | Address during code review |
| Issue Type | Common Solution |
|---|---|
| God Component | Split into smaller, focused classes |
| Feature Concentration | Extract methods into separate classes |
| Multifaceted Abstraction | Apply Single Responsibility Principle |
| Long Method | Extract method or decompose functionality |
| High Complexity | Simplify logic, reduce nesting |
- Cyclomatic Complexity (CC): Measure of code complexity based on control flow
- Lack of Cohesion in Methods (LCOM): Measure of how closely related methods are within a class
- Feature Concentration: Architectural smell where a component handles multiple concerns
- God Component: Anti-pattern of a class that knows too much or does too much
- Refactoring: Improving code structure without changing its external behavior
- ISO/IEC/IEEE 26514:2018 - Systems and software engineering - User documentation standards
- DPy Framework - Design Pattern Detection Framework
- Martin, R. C. (2008). Clean Code: A Handbook of Agile Software Craftsmanship
- Fowler, M. (1999). Refactoring: Improving the Design of Existing Code
- Lorenz, M., & Kidd, J. (1994). Object-Oriented Software Metrics
- Version 1.0 (December 2025): Initial release with comprehensive PHP analysis
- Architecture, design, and implementation smell detection
- Code quality metrics calculation
- Algorithmic Feature Concentration analysis
- IReport integration