Skip to content

Quality + PHPcs + Not only Memcached#111

Open
herewithme wants to merge 6 commits intoAutomattic:masterfrom
BeAPI:quality
Open

Quality + PHPcs + Not only Memcached#111
herewithme wants to merge 6 commits intoAutomattic:masterfrom
BeAPI:quality

Conversation

@herewithme
Copy link

  • Code changes for PHPCS compliance: WordPress Coding Standards (WordPress-Extra, WordPress-Docs), formatting, PHPDoc, and targeted rule exclusions for drop-in layout

  • Add PHP quality tooling: Composer dev dependencies (WPCS, PHPCompatibility-WP, PHPStan with WordPress stubs), .phpcs.xml.dist, phpstan.neon, .editorconfig; composer lint, composer format, composer analyze

  • Development: add DDEV for local WordPress environment; add .ddev/config.yaml, .ddev/docker-compose.plugin.yaml (plugin mount at wp/wp-content/plugins/batcache)

  • Docs: add TESTING.md with DDEV one-time setup, manual testing steps, Redis/Memcached section; document Redis Object Cache installation via WP-CLI and wp-config (WP_REDIS_HOST, WP_CACHE)

  • Fix: in batcache.php, guard now checks isset( $wp_object_cache ) and is_object( $wp_object_cache ) before method_exists() to avoid PHP 8 TypeError when object cache is not available (e.g. CLI, headless)

  • Development: no automated tests (manual testing only)

  • Admin bar: add "Purge Batcache" button for users with manage_options; purges entire batcache group via wp_cache_flush_group() when the object cache supports it (e.g. Redis)

  • Document compatibility with any WordPress object cache API backend (Redis, Memcached, etc.), not only Memcached

  • Update code comments and docs to use "object cache" instead of "memcached" where generic

  • Readme: add Object cache backend section; cite Memcached as reference setup and original dependency

- Introduced .editorconfig to unify coding style across editors.
- Added .gitignore to exclude the vendor directory.
- Created .phpcs.xml.dist for custom PHP CodeSniffer ruleset.
- Updated composer.json to include development dependencies for PHP CodeSniffer and PHPStan.
- Added phpstan configuration files for static analysis.
- Enhanced readme.txt with development instructions for PHP quality tools.
- Updated function definitions and conditionals for better clarity and consistency.
- Enhanced comments for better understanding of functionality.
- Adjusted formatting and spacing for improved code style.
- Ensured compatibility with PHP 8.2 by declaring used properties and using modern syntax.
- Updated .phpcs.xml.dist to include additional rules and configurations for improved code quality checks.
- Added detailed comments and documentation in advanced-cache.php for better understanding of functionality and parameters.
- Adjusted minimum supported PHP and WordPress versions in the configuration to align with current standards.
- Changed references from Memcached to the WordPress object cache API in advanced-cache.php for clarity.
- Updated composer.json description to reflect support for various object cache backends.
- Revised readme.txt to emphasize compatibility with Redis and other object cache systems, enhancing installation instructions and usage guidelines.
- Increment stable tag to 1.6.
- Document compatibility with all WordPress object cache API backends, not just Memcached.
- Revise code comments and documentation to use "object cache" terminology.
- Add a section for Object cache backends in the readme, citing Memcached as a reference.
- Introduce PHP quality tooling with Composer dev dependencies and configuration files for code standards.
- Ensure code compliance with WordPress Coding Standards through formatting and PHPDoc updates.
- Added DDEV configuration files for local WordPress development.
- Updated .gitignore to exclude build and wp directories.
- Enhanced .phpcs.xml.dist to exclude additional patterns.
- Improved advanced-cache.php and batcache.php with detailed plugin metadata and new admin bar functionality for purging cache.
- Documented testing procedures and setup in TESTING.md, including Redis and Memcached integration.
- Revised readme.txt to reflect new features and installation instructions.
@tomjn
Copy link
Contributor

tomjn commented Mar 3, 2026

@herewithme this is a huge PR, can you split it out into separate topics? E.g. 1 for PHPCS etc 1 for CI additions, another for each bug fix, etc

Note that some of the additions, e.g. the admin bar purge button, would probably be rejected as this has direct impacts on a large number of hosts that use batcache internally. Likewise for memcached and other major refactors/features. I'd also question DDEV support, as valuable as it might be (and as much as I like DDEV) you might get an automattician wanting WP Env instead.

@herewithme
Copy link
Author

@herewithme this is a huge PR, can you split it out into separate topics? E.g. 1 for PHPCS etc 1 for CI additions, another for each bug fix, etc

Note that some of the additions, e.g. the admin bar purge button, would probably be rejected as this has direct impacts on a large number of hosts that use batcache internally. Likewise for memcached and other major refactors/features. I'd also question DDEV support, as valuable as it might be (and as much as I like DDEV) you might get an automattician wanting WP Env instead.

Too complex — bringing the codebase into PHPCS compliance would effectively require a very large rewrite: for styling, but also to apply changes like Yoda conditions, etc.

What could be removed is the flush button indeed.

Regarding wp-env, I considered it, but the lack of Redis/Memcached support makes it unsuitable.

Apart from checking whether a variable exists (which is more in the realm of code quality/static analysis, e.g., PHPStan), there are no other changes.

@tomjn
Copy link
Contributor

tomjn commented Mar 4, 2026

Too complex — bringing the codebase into PHPCS compliance would effectively require a very large rewrite: for styling, but also to apply changes like Yoda conditions, etc.

not bringing the entire codebase into compliance, just the PHPCS related changes in the PR you've already made

@herewithme
Copy link
Author

I’m not sure I understand — do you mean a PR that only adds the tooling, without aiming to make the whole codebase compliant?

And in that case, do you want it with or without the auto-fix corrections (formatting / PHPCS autofixes)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants