nhrrob/wp-fatal-tester
Composer 安装命令:
composer require --dev nhrrob/wp-fatal-tester
包简介
A comprehensive CLI tool to detect fatal PHP errors and compatibility issues in WordPress plugins and themes
README 文档
README
A comprehensive CLI tool to detect fatal PHP errors and compatibility issues in WordPress plugins and themes. This tool helps developers identify potential fatal errors before deploying to production by testing code against different PHP and WordPress version combinations.
Features
🔍 Comprehensive Error Detection
- Syntax Errors: Detects PHP syntax errors, missing semicolons, and bracket mismatches
- Undefined Functions: Identifies calls to undefined or removed functions
- Class Conflicts: Detects class redeclaration and undefined class usage
- PHP Version Compatibility: Tests against PHP 7.4, 8.0, 8.1, 8.2, and 8.3
- WordPress Compatibility: Tests against WordPress 6.0+ versions
- Deprecated Features: Warns about deprecated PHP and WordPress functions
📊 Detailed Reporting
- Color-coded error output with severity levels
- File location and line number information
- Contextual suggestions for fixing errors
- Comprehensive summary reports
- Version compatibility matrix
⚡ Smart Analysis
- Scans PHP files recursively
- Excludes common non-essential directories (node_modules, vendor, tests)
- Detects WordPress-specific patterns and functions
- Identifies version-specific syntax and features
🎯 Widget Exclusion System (New!)
- Reduces False Positives: Smart exclusion of widgets without "Load More" functionality
- AJAX Context Awareness: Detects template method context issues in AJAX operations
- Future-Proof Design: Temporary exclusions with review dates for evolving widgets
- Multiple Reporting Modes: Fatal-only, all-errors, and debug modes
- Configurable Rules: JSON-based configuration for easy customization
- CLI Integration: Command-line options for quick adjustments
Installation
composer require --dev nhrrob/wp-fatal-tester
Usage
Basic Usage
Test the current directory (auto-detects plugin name, shows fatal errors only):
vendor/bin/fataltest
Test a specific plugin (shows fatal errors only):
vendor/bin/fataltest my-plugin
Show all errors including warnings:
vendor/bin/fataltest --show-all-errors
Plugin Name Parameter
The plugin name parameter is optional when running the tool from within a WordPress plugin directory. The tool will automatically detect the current plugin name based on the directory structure. You only need to specify a plugin name when:
- Running from outside the plugin directory
- Testing a plugin located in a different path
- Overriding the auto-detected plugin name
Command Line Options
# Show help vendor/bin/fataltest --help # Test with all error types (including warnings) vendor/bin/fataltest my-plugin --show-all-errors # Test specific PHP and WordPress versions vendor/bin/fataltest my-plugin --php 8.0,8.1,8.2 --wp 6.3,6.4,6.5,6.6 # Custom severity filtering vendor/bin/fataltest my-plugin --severity error,warning # Disable colored output vendor/bin/fataltest my-plugin --no-colors
What It Tests
The tool automatically tests your code against all major PHP and WordPress versions:
- PHP Versions: 7.4, 8.0, 8.1, 8.2, 8.3 (configurable via
--phpoption) - WordPress Versions: 6.3, 6.4, 6.5, 6.6 (configurable via
--wpoption)
This comprehensive testing matrix ensures your plugin works across 20 different environment combinations by default, providing maximum compatibility coverage for WordPress plugins.
Default Behavior
By default, the tool shows only fatal errors to focus on critical issues that will break plugin functionality. This filtering approach helps developers concentrate on the most important issues first.
- Fatal errors (severity:
error) are issues that will prevent your plugin from working - Warnings (severity:
warning) are about deprecated features or potential future issues
Use --show-all-errors to see warnings and other non-fatal issues when needed.
Widget Exclusion System
The tool now includes a sophisticated widget exclusion system to reduce false positives, especially for AJAX "Load More" operations:
# Default behavior - automatically excludes widgets without load more functionality vendor/bin/fataltest my-plugin # Show all errors including excluded ones for debugging vendor/bin/fataltest my-plugin --widget-reporting-mode all_errors # Debug widget exclusion decisions vendor/bin/fataltest my-plugin --debug-widget-exclusions # Use custom widget configuration vendor/bin/fataltest my-plugin --widget-config-file ./my-config.json # Show exclusion statistics vendor/bin/fataltest my-plugin --show-exclusion-stats
Quick Start: If you're seeing many false positives from Elementor widgets, see QUICK_START_WIDGET_EXCLUSIONS.md for immediate solutions.
Tested with Essential Addons for Elementor
wp-fatal-tester has been extensively tested with the Essential Addons for Elementor free plugin and passes all compatibility tests across PHP 7.4-8.3 and WordPress 6.3-6.6. The tool includes smart ecosystem detection to prevent false positives for Elementor and WooCommerce dependencies.
See EA_TESTING_GUIDE.md for detailed testing instructions and integration examples.
Example Output
When you run vendor/bin/fataltest from within your plugin directory:
🚀 Running fatal test for plugin: my-awesome-plugin
PHP versions: 7.4, 8.0, 8.1, 8.2, 8.3
WP versions: 6.3, 6.4, 6.5, 6.6
Plugin path: /path/to/my-awesome-plugin
Filter: Fatal errors only (use --show-all-errors to see warnings)
▶️ Testing my-awesome-plugin on PHP 7.4, WP 6.3 (1/20)...
❌ Found 2 error(s) on PHP 8.1, WP 6.5 (15,847 total, filtered by severity)
📋 SYNTAX_ERROR (1 error(s)):
🔴 syntax error, unexpected identifier "create_function"
Location: plugin.php:25
💡 Suggestion: Fix the syntax error in the specified line
📋 REMOVED_PHP_FEATURE (1 error(s)):
🔴 create_function() was removed in PHP 8.0.0
Location: plugin.php:25
💡 Suggestion: Use anonymous functions instead
# Note: DEPRECATED_PHP_FEATURE warnings and undefined WordPress functions
# are filtered out by default. Use --show-all-errors to see them.
Notice: The example shows "15,847 total" errors but only 2 fatal errors are displayed. This demonstrates how the filtering helps you focus on critical issues while the high total count reflects WordPress function dependencies.
Quick Start Tips
- Install in your plugin directory:
composer require --dev nhrrob/wp-fatal-tester - Run from plugin root:
vendor/bin/fataltest(no plugin name needed) - Focus on fatal errors first: The default output shows only critical issues
- Don't worry about high error counts: Thousands of errors are normal due to WordPress dependencies
- Use
--show-all-errorssparingly: Only when you need to see warnings and deprecated features
Error Types Detected
🔴 Fatal Errors (Must Fix)
- SYNTAX_ERROR: PHP syntax errors that prevent code execution
- UNDEFINED_FUNCTION: Calls to functions that don't exist
- UNDEFINED_CLASS: Usage of classes that aren't defined
- REMOVED_PHP_FEATURE: Features removed in target PHP versions
- VERSION_REQUIREMENT: Features requiring newer PHP/WordPress versions
🟡 Warnings (Should Fix)
- DEPRECATED_PHP_FEATURE: PHP features deprecated in target versions
- DEPRECATED_FUNCTION: WordPress functions deprecated in target versions
- DEPRECATED_HOOK: WordPress hooks deprecated in target versions
- MISSING_SEMICOLON: Potential missing semicolons
- UNMATCHED_BRACKETS: Potential bracket mismatches
Supported Versions
PHP Versions
- ✅ PHP 7.4+
- ✅ PHP 8.0
- ✅ PHP 8.1
- ✅ PHP 8.2
- ✅ PHP 8.3
WordPress Versions
- ✅ WordPress 6.0+
- ✅ WordPress 6.1
- ✅ WordPress 6.2
- ✅ WordPress 6.3
- ✅ WordPress 6.4
- ✅ WordPress 6.5
- ✅ WordPress 6.6
Architecture
The tool is built with a modular architecture:
Core Components
- FatalTester: Main orchestrator class
- FileScanner: Scans and filters PHP files
- ErrorReporter: Formats and displays results
Error Detectors
- SyntaxErrorDetector: PHP syntax validation
- UndefinedFunctionDetector: Function existence checking
- ClassConflictDetector: Class definition validation
- PHPVersionCompatibilityDetector: PHP version compatibility
- WordPressCompatibilityDetector: WordPress compatibility
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE file for details.
Changelog
v1.0.0
- ✅ Complete rewrite with comprehensive error detection
- ✅ PHP 7.4+ and WordPress 6.0+ support
- ✅ Multi-version compatibility testing
- ✅ Detailed error reporting with suggestions
- ✅ Smart file scanning and filtering
- ✅ Color-coded terminal output
nhrrob/wp-fatal-tester 适用场景与选型建议
nhrrob/wp-fatal-tester 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cli」 「testing」 「plugin」 「theme」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nhrrob/wp-fatal-tester 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nhrrob/wp-fatal-tester 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nhrrob/wp-fatal-tester 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
The PHP SDK for Checkmango
Slim starter / Slim skeleton package to boost your development with Slim framework
Generates a trait to help ease the access of custom repo methods
Alfabank REST API integration
The testing extension of TYPO3voilà.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-17