=== Eli's PHP Compatibility Scanner ===
Contributors: eliehanna
Donate link: 
Tags:  compatibility, testing, code-quality, phpcs, wordpress-development
Requires at least: 4.5
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A comprehensive WordPress plugin that scans your plugins and themes for PHP version compatibility issues using the  PHPCompatibility ruleset.

== Description ==

**⚠️ Important: Development Environment Only**

This plugin is designed for development environments like LocalWP, XAMPP, or self-hosted servers. It will **not work** on most managed hosting providers (WP Engine, Kinsta, SiteGround, etc.) due to security restrictions that disable the `exec()` function and limit access to PHP binaries.



**How It Works**

This plugin leverages [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) with the [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) standard to perform deep static analysis of your PHP code.

**Core Components:**

1. **Bundled Dependencies**: Includes PHP_CodeSniffer and PHPCompatibility ruleset
2. **Batch Processing**: Scans files in configurable batches (10-100 files) to manage memory usage
3. **Command Execution**: Executes PHPCS via PHP's `exec()` function with specific parameters
4. **Server-Side State**: Stores file lists in WordPress options to optimize AJAX requests
5. **Progressive UI**: Real-time batch results with stop/start controls

**How to Use:**

1. Navigate to **Tools → PHP Compatibility Scanner**
2. Review the **System Check** section to ensure your environment is compatible
3. Select the **plugins and/or themes** you want to scan by checking their boxes
4. Configure your scan options:
   - **Target PHP Version**: Choose the PHP version you want to test against (7.4 - 8.4)
   - **Batch Size**: Select how many files to process at once (default: 50 files)
   - **Skip Vendor Directory**: Keep checked to skip third-party dependencies
5. Click **Start Scan** to begin the compatibility check
6. View results in real-time as each plugin/theme is scanned
7. Review any **errors** (❌) or **warnings** (⚠️) found in your code
8. Click on any target to expand and see detailed compatibility issues

**Why It Requires Development Environments**

* **`exec()` Function**: Required to run PHPCS binary - disabled on managed hosts
* **PHP Binary Access**: Needs access to PHP executable - restricted on shared hosting
* **Composer Dependencies**: Requires vendor directory with PHPCS installation
* **File System Access**: Creates temporary files for batch processing
* **Memory/Time Limits**: Long-running scans need relaxed execution limits

**Supported Environments**

* **LocalWP** (recommended)
* **XAMPP/MAMP**
* **Docker WordPress** setups
* **Self-hosted** VPS/dedicated servers
* **Development** environments with shell access

**Unsupported Environments**

* **WP Engine** (exec() disabled)
* **Kinsta** (security restrictions)
* **SiteGround** (managed hosting limitations)
* **GoDaddy Managed WordPress** (function restrictions)
* **WordPress.com** (no plugin uploads)
* Most **shared hosting** providers

== Installation ==

**Prerequisites**

* **Development Environment**: LocalWP, XAMPP, MAMP, or self-hosted server
* **PHP 7.4+**: Required for plugin operation
* **WordPress 4.5+**: Minimum WordPress version

**Setup Instructions**

1. **Download/Install** the plugin to your `wp-content/plugins/` directory
2. **Activate Plugin** in WordPress Admin → Plugins
3. **Access Tool** via WordPress Admin → Tools → PHP Compatibility Scanner

**Note**: All required dependencies (PHP_CodeSniffer and PHPCompatibility) are included with the plugin - no additional setup required!

== Frequently Asked Questions ==

= What is this plugin for? =

This plugin helps WordPress developers check if their custom code (plugins and themes) will work with different PHP versions. It's especially useful when planning to upgrade PHP on production servers or when developing for clients with specific PHP version requirements.

= Why won't it work on my hosting provider? =

Most managed hosting providers (WP Engine, Kinsta, SiteGround, etc.) disable the `exec()` function for security reasons. This plugin needs to run PHP commands to analyze your code, which requires this function to be enabled.

= What PHP versions can I test against? =

The plugin can test your code against PHP versions 7.4 through 8.4, helping you identify compatibility issues before upgrading.

= How accurate are the results? =

Very accurate! The plugin uses the official PHPCompatibility ruleset, which is the industry standard for PHP version compatibility testing. It catches both deprecated features and breaking changes.

= Can I scan multiple plugins at once? =

Yes! You can select multiple plugins and themes to scan simultaneously. The plugin processes them in batches to manage memory usage efficiently.

= What if the scan takes too long? =

The plugin includes stop/resume functionality. You can cancel a long-running scan at any time and resume it later. You can also adjust batch sizes to optimize performance.

= Are my files modified during scanning? =

No, your files are never modified. The plugin only reads your code to analyze it. Any temporary files created during scanning are automatically cleaned up.

== Screenshots ==

1. Plugin dashboard displaying environment compatibility check results
2. Configuration panel with scan options and available plugins/themes selection
3. Scan results showing detected PHP compatibility errors in selected plugins
4. Clean scan results indicating no compatibility issues found

== Changelog ==

= 1.1.3 =
* Fix: "Unable to run phpcs --version with detected PHP binary" on LocalWP/macOS — PHP_BINARY pointed to php-fpm (a server SAPI that can't run CLI scripts); the scanner now resolves the CLI php binary from the same PHP install.
* Tested up to WordPress 7.0.

= 1.1.2 =
* Fix: Wrong php exec detected in some XAMPP environments

= 1.1.1 =
* Fix: scan overview tags no longer disappear after scan completes; selected targets and their results stay visible.

= 1.1.0 =
* Scan Overview UI Update

= 1.0.5 =
* Improved target selection: show Active badge for active plugins/theme; add Select All (toggle) and Select Active buttons.

= 1.0.4 =
* Fix "Namespace declaration statement has to be the very first statement" when running phpcs on some hosts (e.g. LiteSpeed): plugin now prefers the direct PHPCS script over the Composer proxy to avoid BOM/encoding issues in vendor/bin/phpcs.

= 1.0.3 =
* Fix "ERROR: The file 2>&1 does not exist" on macOS when PHPCS command runs without a shell (removed shell redirection from command string)
* Fix PHP 8.1+ deprecation: trim() null parameter in PHP_CodeSniffer vendor (Common.php)
* Tested on latest WordPress and WordPress Studio for Mac

= 1.0.2 =
* Updated plugin name to "Eli's PHP Compatibility Scanner" for WordPress.org compliance
* Improved documentation and usage instructions


= 1.0.0 =
* Initial release
* PHP compatibility scanning using PHPCompatibility standard
* Modern, responsive user interface
* Batch processing for large codebases
* Real-time progress updates
* Stop/resume functionality
* Vendor directory exclusion
* Support for PHP versions 7.4-8.4

== Upgrade Notice ==

= 1.1.3 =
Fixes "Unable to run phpcs --version" on LocalWP/macOS. Tested up to WordPress 7.0.

= 1.1.1 =
Fix: scan overview tags persist after scan completes.

= 1.1.0 =
Scan Overview UI Update

= 1.0.5 =
Improved target selection with Active indicators and Select All / Select Active buttons.

= 1.0.4 =
Fixes fatal error "Namespace declaration... very first statement" on some servers (e.g. LiteSpeed). Use Tools → PHP Compatibility Scanner after updating.

= 1.0.3 =
Fixes scan error on macOS and PHP 8.1+ deprecation. Tested on latest WordPress and WordPress Studio for Mac.

= 1.0.2 =
Important update with WordPress.org compliance fixes, and improved documentation.

= 1.0.0 =
Initial release with comprehensive PHP compatibility checking features. Perfect for WordPress developers working in development environments who need to ensure their code works across different PHP versions.

== Contributing ==

This plugin is actively developed for WordPress development environments. Contributions are welcome, especially:

* Additional PHP version compatibility rules
* Performance optimizations
* UI/UX improvements
* Hosted environment compatibility solutions

== Technical Details ==

**Dependencies**

* **PHP_CodeSniffer**: ^3.13 (static analysis engine)
* **PHPCompatibility**: dev-develop (compatibility ruleset)

**License**

GPLv2 or later - same as WordPress core.
