You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you encounter errors when running PHPUnit on PHP 8.x, try the following:
31
+
32
+
1. Make sure you're using the right PHPUnit version for your PHP version
33
+
2. Use the custom runner script: `php run-phpunit.php`
34
+
3. Ensure the file `tests/php8-compatibility.php` exists
35
+
4. Clear any cached files by running `rm -rf vendor && composer install`
36
+
37
+
## GitHub Actions
38
+
39
+
When running tests in GitHub Actions, the workflow will automatically detect the PHP version and use the appropriate PHPUnit version and execution method.
40
+
41
+
## Common Errors and Solutions
42
+
43
+
### Error: "Fatal error: Cannot use positional argument after named argument"
44
+
45
+
This occurs on PHP 8.0+ with older PHPUnit versions. Solution: Use PHPUnit 9.x.
46
+
47
+
### Error: "Fatal error: Cannot acquire reference to $GLOBALS"
48
+
49
+
This occurs on PHPUnit 7.x with PHP 8.1+. Solution: Use the custom runner script that includes compatibility fixes.
50
+
51
+
### Error: "--no-deprecations is not a recognized option"
52
+
53
+
This option doesn't exist in older PHPUnit versions. The custom runner script will avoid using this flag.
A lightweight WordPress plugin designed to optimize your website by removing unnecessary scripts, styles, and header elements that can slow down your site.
@@ -77,6 +77,20 @@ Yes, hiding the WordPress version can provide a minor security benefit by making
77
77
3. Set up the test environment: `bin/install-wp-tests.sh wordpress_test root '' localhost latest`
78
78
4. Run tests: `composer test`
79
79
80
+
### PHP 8.x Compatibility
81
+
82
+
This plugin is fully compatible with PHP versions 7.4 through 8.2. For testing with PHP 8.x, we provide a custom PHPUnit runner script that helps avoid common compatibility issues between PHPUnit and newer PHP versions:
83
+
84
+
```bash
85
+
# For PHP 7.4 (standard testing)
86
+
composer test
87
+
88
+
# For PHP 8.0, 8.1, and 8.2 (using the custom runner)
89
+
composer test:php8
90
+
```
91
+
92
+
The custom runner automatically detects your PHP version and applies the appropriate compatibility settings.
93
+
80
94
## Contributing
81
95
82
96
Contributions are welcome! Please feel free to submit a Pull Request.
0 commit comments