Modernise PHP codebase to PHP 7.4 - #780
Open
abhijitb wants to merge 16 commits into
Open
Conversation
Align tooling to PHP 7.4, adopt short arrays and null coalescing, add native types to helpers/utilities, and document the remaining phased plan. Co-authored-by: Cursor <cursoragent@cursor.com>
Safely read nested PayPal attribution headers, clarify short-array PHPCS rules, and restore HTTPS VCS source URLs in composer.lock. Co-authored-by: Cursor <cursoragent@cursor.com>
Phase 4 of the PHP 7.4 modernization: type Admin and SitePreview methods without changing hook registration behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Phase 5: type non-override REST methods only; leave WP_REST_Controller overrides untyped to avoid PHP fatals. Co-authored-by: Cursor <cursoragent@cursor.com>
Phase 6: typed properties/methods on early-load compat checks, updates helpers, bootstrap activation hooks, and AutoIncrement::$wpdb. Co-authored-by: Cursor <cursoragent@cursor.com>
Defer PHPStan until stubs/CI are owned separately; lock PHPCS exclusions and contributor rules for first-party PHP 7.4 code. Co-authored-by: Cursor <cursoragent@cursor.com>
AI code review✅ Strengths
|
Use fully qualified \wpdb under the Web namespace, and correct strpos so the brand footer only runs on web plugin admin pages. Co-authored-by: Cursor <cursoragent@cursor.com>
Documents PHP load order, Newfold module system, PHP typing standard, and common build/lint/test commands for future Claude Code sessions.
- Admin::add_to_runtime() coerces non-array filter values instead of hard-failing with a TypeError. - Admin::__construct() drops the redundant $_GET isset check now that filter_input() is used directly, removing the phpcs:ignore. - Admin::assets() falls back to empty dependencies/current version when the build manifest is missing, instead of leaving $asset undefined. - base.php explicitly casts both operands before subtracting timestamps. - tests/phpunit/bootstrap.php now loads the plugin via muplugins_loaded so plugin classes are available to PHPUnit tests. - Add lightweight integration tests for the settings/caching REST controllers, the Admin asset fallback, and the NFD compat-check deactivation paths.
- Add phpunit/phpunit and yoast/phpunit-polyfills as dev dependencies, plus composer scripts (`composer run test`, `test:install-phpunit`) that run the suite via a downloaded tools/phpunit.phar. - tests/phpunit/bootstrap.php no longer eagerly requires vendor/autoload.php: doing so runs every Newfold module's Composer `autoload.files` bootstrap.php before ABSPATH is defined, which silently no-ops their ABSPATH guards and leaves services like `comingSoon`/`cachePurger` unregistered in the container. vendor/bin/phpunit is now documented as broken for this repo since it triggers that same autoload before our --bootstrap file ever runs; the phar avoids it entirely. - Add tests/phpunit/wp-tests-config-sample.php as the template for the gitignored, machine-local wp-tests-config.php. - Fix CachingController::purge_all(), which called the cache purging service's purgeAll() — a method that doesn't exist on NewfoldLabs\WP\Module\Performance\Cache\CachePurgingService (only purge_all() does). This fatally errored on every real DELETE /web/v1/caching request; caught by the new REST integration tests once the container was wired up correctly.
CachingController::purge_all() still calls the non-existent purgeAll() on CachePurgingService (only purge_all() exists, per usage elsewhere in wp-module-performance and wp-module-onboarding). Confirmed the route's only frontend caller, webPurgeCacheApiFetch in src/app/util/helpers.js, is currently unused/unwired, so this route isn't reachable from the UI today. Leaving the bug in place per decision; the corresponding integration test is now skipped with a comment explaining why, so the suite stays green without hiding the issue.
web/v1/caching (CachingController::purge_all()) had no live caller:
its only frontend consumer, webPurgeCacheApiFetch in
src/app/util/helpers.js, was itself never imported or invoked
anywhere. History confirms this was intentional fallout from an
incomplete migration ("Remove: caching controller and cacheLevel
option usage, both things are now managed at module level") to
wp-module-performance's own cache REST controller
(newfold-performance/v1/cache), which is what the admin UI's "Clear
Cache" action actually calls today.
Removes inc/RestApi/CachingController.php, its require in
bootstrap.php, its entry in rest-api.php's controller list, the
orphaned webPurgeCacheApiFetch export, and the corresponding
(skipped) test.
abhijitb
requested review from
ajayadav09,
diwanshuster and
ramyakrishnai
and removed request for
ramyakrishnai
August 5, 2026 05:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Type of Change
Production
Development
Visual
Checklist
Further comments