commit 557657344d9da8fff8f1b53909a7aa54e686b13d Author: Keith Solomon Date: Sun Apr 26 12:44:16 2026 -0500 feat: scaffold plugin foundation diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cde4a4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +/.phpunit.result.cache +/.vscode/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f12bafc --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "ksolo/wp-content-sync", + "description": "Bidirectional WordPress content synchronization plugin.", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "require": { + "php": ">=7.4" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-stubs/wordpress-stubs": "^6.8", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.9", + "wp-coding-standards/wpcs": "^3.0" + }, + "autoload": { + "psr-4": { + "WPContentSync\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "WPContentSync\\Tests\\": "tests/" + } + }, + "scripts": { + "validate": "composer validate --strict", + "lint": "phpcs", + "lint:fix": "phpcbf", + "stan": "phpstan analyse", + "test": "phpunit" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..bd6402f --- /dev/null +++ b/composer.lock @@ -0,0 +1,2339 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "43a8823d91f91a72bc9bfdfbbb57962d", + "packages": [], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1", + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.2", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "^2.2", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-11T04:32:07+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.7.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" + }, + "time": "2025-12-06T11:56:16+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.9.1", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "f12220f303e0d7c0844c0e5e957b0c3cee48d2f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/f12220f303e0d7c0844c0e5e957b0c3cee48d2f7", + "reference": "f12220f303e0d7c0844c0e5e957b0c3cee48d2f7", + "shasum": "" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "5.6.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^5.5", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^6.0", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^9.5", + "symfony/polyfill-php80": "*", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.9.1" + }, + "time": "2026-02-03T19:29:21+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "b598aa890815b8df16363271b659d73280129101" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/b598aa890815b8df16363271b659d73280129101", + "reference": "b598aa890815b8df16363271b659d73280129101", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.2.0", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-12T23:06:57+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-12-08T14:27:58+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.12.33", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", + "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2026-02-28T20:30:03+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.32", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:23:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.34", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "b36f02317466907a230d3aa1d34467041271ef4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b36f02317466907a230d3aa1d34467041271ef4a", + "reference": "b36f02317466907a230d3aa1d34467041271ef4a", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.10", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.8", + "sebastian/global-state": "^5.0.8", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.34" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2026-01-27T05:45:00+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.10", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "e4df00b9b3571187db2831ae9aada2c6efbd715d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e4df00b9b3571187db2831ae9aada2c6efbd715d", + "reference": "e4df00b9b3571187db2831ae9aada2c6efbd715d", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.10" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2026-01-24T09:22:56+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:03:27+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/global-state", + "type": "tidelift" + } + ], + "time": "2025-08-10T07:10:35+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:57:39+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-14T16:00:52+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.13.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-04T16:30:35+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2025-11-17T20:03:58+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.3.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", + "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.0", + "phpcsstandards/phpcsutils": "^1.1.0", + "squizlabs/php_codesniffer": "^3.13.4" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2025-11-25T12:08:04+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.4" + }, + "platform-dev": {}, + "plugin-api-version": "2.9.0" +} diff --git a/docs/superpowers/plans/2026-04-26-wordpress-content-sync-foundation.md b/docs/superpowers/plans/2026-04-26-wordpress-content-sync-foundation.md new file mode 100644 index 0000000..168265a --- /dev/null +++ b/docs/superpowers/plans/2026-04-26-wordpress-content-sync-foundation.md @@ -0,0 +1,1261 @@ +# WordPress Content Sync Foundation Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Build the loadable WordPress plugin foundation for WP Content Sync with tooling, bootstrap, settings, logging, and an admin dashboard shell. + +**Architecture:** The foundation uses a small bootstrap file at the plugin root and focused PHP classes under `src/`. A service container wires settings, logging, activation hooks, and admin screens while keeping WordPress calls at clear boundaries so unit tests can cover the domain behavior without a full WordPress runtime. + +**Tech Stack:** PHP 7.4+, WordPress 5.6+, Composer, PHPUnit, PHPStan level 6+, PHP_CodeSniffer with the project `phpcs.xml`, WordPress Coding Standards. + +--- + +## File Structure + +- Create: `wp-content-sync.php` as the WordPress plugin entrypoint. +- Create: `composer.json` for autoloading, dev dependencies, and scripts. +- Create: `phpcs.xml` for WordPress-oriented coding standards. +- Create: `phpstan.neon` for level 6 static analysis. +- Create: `phpunit.xml.dist` for unit test configuration. +- Create: `src/Plugin.php` as the lifecycle coordinator. +- Create: `src/Container.php` as the lightweight service registry. +- Create: `src/Activator.php` to install default options on activation. +- Create: `src/Deactivator.php` to perform safe deactivation cleanup. +- Create: `src/Settings/Settings.php` as a typed settings value object. +- Create: `src/Settings/SettingsRepository.php` as the WordPress option boundary. +- Create: `src/Logging/LoggerInterface.php` as the logging boundary. +- Create: `src/Logging/OptionLogger.php` as the initial bounded option-backed logger. +- Create: `src/Admin/AdminPage.php` as the admin dashboard controller. +- Create: `templates/admin/dashboard.php` as the escaped dashboard view. +- Create: `tests/bootstrap.php` for PHPUnit bootstrap and WordPress function stubs. +- Create: `tests/Unit/SettingsTest.php` for settings defaults and sanitization behavior. +- Create: `tests/Unit/ContainerTest.php` for service registration behavior. +- Create: `tests/Unit/OptionLoggerTest.php` for log redaction and retention behavior. + +## Task 1: Add Composer and Quality Tooling + +**Files:** +- Create: `composer.json` +- Create: `phpcs.xml` +- Create: `phpstan.neon` +- Create: `phpunit.xml.dist` + +- [ ] **Step 1: Create Composer metadata and scripts** + +Create `composer.json`: + +```json +{ + "name": "ksolo/wp-content-sync", + "description": "Bidirectional WordPress content synchronization plugin.", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "require": { + "php": ">=7.4" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.9", + "wp-coding-standards/wpcs": "^3.0" + }, + "autoload": { + "psr-4": { + "WPContentSync\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "WPContentSync\\Tests\\": "tests/" + } + }, + "scripts": { + "validate": "composer validate --strict", + "lint": "phpcs", + "lint:fix": "phpcbf", + "stan": "phpstan analyse", + "test": "phpunit" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true + } +} +``` + +- [ ] **Step 2: Create PHPCS rules** + +Create `phpcs.xml`: + +```xml + + + Custom coding standards for WP Content Sync. + + + + wp-content-sync.php + src + tests + + + + + + + + + vendor/* + +``` + +- [ ] **Step 3: Create PHPStan configuration** + +Create `phpstan.neon`: + +```neon +parameters: + level: 6 + paths: + - src + - wp-content-sync.php + scanFiles: + - tests/bootstrap.php + bootstrapFiles: + - tests/bootstrap.php +``` + +- [ ] **Step 4: Create PHPUnit configuration** + +Create `phpunit.xml.dist`: + +```xml + + + + + tests/Unit + + + +``` + +- [ ] **Step 5: Install dependencies** + +Run: `composer install` + +Expected: Composer installs dev dependencies and generates `vendor/autoload.php`. + +- [ ] **Step 6: Validate Composer metadata** + +Run: `composer validate --strict` + +Expected: PASS with no schema or lock warnings after `composer install`. + +- [ ] **Step 7: Commit** + +```bash +git add composer.json composer.lock phpcs.xml phpstan.neon phpunit.xml.dist +git commit -m "chore: add php quality tooling" +``` + +## Task 2: Add PHPUnit Bootstrap and Core Test Scaffolding + +**Files:** +- Create: `tests/bootstrap.php` +- Create: `tests/Unit/ContainerTest.php` +- Create: `src/Container.php` + +- [ ] **Step 1: Write the failing container tests** + +Create `tests/Unit/ContainerTest.php`: + +```php +set( 'example', $service ); + + self::assertSame( $service, $container->get( 'example' ) ); + } + + public function test_it_reuses_factory_result(): void { + $container = new Container(); + $calls = 0; + + $container->factory( + 'example', + static function () use ( &$calls ): \stdClass { + ++$calls; + return new \stdClass(); + } + ); + + $first = $container->get( 'example' ); + $second = $container->get( 'example' ); + + self::assertSame( $first, $second ); + self::assertSame( 1, $calls ); + } + + public function test_it_throws_for_unknown_service(): void { + $container = new Container(); + + $this->expectException( \InvalidArgumentException::class ); + $this->expectExceptionMessage( 'Service "missing" is not registered.' ); + + $container->get( 'missing' ); + } +} +``` + +- [ ] **Step 2: Add test bootstrap with WordPress stubs** + +Create `tests/bootstrap.php`: + +```php + + */ + private array $services = array(); + + /** + * @var array + */ + private array $factories = array(); + + public function set( string $id, $service ): void { + $this->services[ $id ] = $service; + } + + /** + * @param callable(): mixed $factory + */ + public function factory( string $id, callable $factory ): void { + $this->factories[ $id ] = $factory; + } + + public function get( string $id ) { + if ( array_key_exists( $id, $this->services ) ) { + return $this->services[ $id ]; + } + + if ( array_key_exists( $id, $this->factories ) ) { + $this->services[ $id ] = $this->factories[ $id ](); + return $this->services[ $id ]; + } + + throw new \InvalidArgumentException( sprintf( 'Service "%s" is not registered.', $id ) ); + } +} +``` + +- [ ] **Step 5: Run test to verify it passes** + +Run: `composer test -- --filter ContainerTest` + +Expected: PASS with 3 tests. + +- [ ] **Step 6: Commit** + +```bash +git add src/Container.php tests/bootstrap.php tests/Unit/ContainerTest.php +git commit -m "test: add service container coverage" +``` + +## Task 3: Add Settings Value Object and Repository + +**Files:** +- Create: `src/Settings/Settings.php` +- Create: `src/Settings/SettingsRepository.php` +- Create: `tests/Unit/SettingsTest.php` + +- [ ] **Step 1: Write failing settings tests** + +Create `tests/Unit/SettingsTest.php`: + +```php +syncPairs() ); + self::assertSame( 'warning', $settings->loggingLevel() ); + self::assertTrue( $settings->automaticUrlReplacementEnabled() ); + self::assertSame( 'last_write_wins', $settings->conflictStrategy() ); + } + + public function test_it_sanitizes_scalar_settings(): void { + $settings = Settings::fromArray( + array( + 'logging_level' => 'debug', + 'conflict_strategy' => "manual_review\n", + 'automatic_url_replacement' => false, + ) + ); + + self::assertSame( 'debug', $settings->loggingLevel() ); + self::assertSame( 'manual_review', $settings->conflictStrategy() ); + self::assertFalse( $settings->automaticUrlReplacementEnabled() ); + } + + public function test_it_rejects_unknown_logging_level(): void { + $settings = Settings::fromArray( + array( + 'logging_level' => 'verbose', + ) + ); + + self::assertSame( 'warning', $settings->loggingLevel() ); + } + + public function test_it_serializes_to_array(): void { + $settings = Settings::fromArray( + array( + 'sync_pairs' => array( + array( + 'name' => 'Staging', + 'source_url' => 'https://example.test', + 'destination_url' => 'https://staging.example.test', + ), + ), + ) + ); + + self::assertSame( + array( + 'sync_pairs' => array( + array( + 'name' => 'Staging', + 'source_url' => 'https://example.test', + 'destination_url' => 'https://staging.example.test', + ), + ), + 'logging_level' => 'warning', + 'automatic_url_replacement' => true, + 'conflict_strategy' => 'last_write_wins', + ), + $settings->toArray() + ); + } +} +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `composer test -- --filter SettingsTest` + +Expected: FAIL because class `WPContentSync\Settings\Settings` does not exist. + +- [ ] **Step 3: Implement settings value object** + +Create `src/Settings/Settings.php`: + +```php + + */ + private array $sync_pairs; + + private string $logging_level; + private bool $automatic_url_replacement; + private string $conflict_strategy; + + /** + * @param array $sync_pairs + */ + private function __construct( + array $sync_pairs, + string $logging_level, + bool $automatic_url_replacement, + string $conflict_strategy + ) { + $this->sync_pairs = $sync_pairs; + $this->logging_level = $logging_level; + $this->automatic_url_replacement = $automatic_url_replacement; + $this->conflict_strategy = $conflict_strategy; + } + + /** + * @param array $data + */ + public static function fromArray( array $data ): self { + $logging_level = self::sanitizeChoice( + $data['logging_level'] ?? 'warning', + self::LOGGING_LEVELS, + 'warning' + ); + + $conflict_strategy = self::sanitizeChoice( + $data['conflict_strategy'] ?? 'last_write_wins', + self::CONFLICT_STRATEGIES, + 'last_write_wins' + ); + + $automatic_url_replacement = array_key_exists( 'automatic_url_replacement', $data ) + ? (bool) $data['automatic_url_replacement'] + : true; + + return new self( + self::sanitizeSyncPairs( $data['sync_pairs'] ?? array() ), + $logging_level, + $automatic_url_replacement, + $conflict_strategy + ); + } + + /** + * @return array + */ + public function syncPairs(): array { + return $this->sync_pairs; + } + + public function loggingLevel(): string { + return $this->logging_level; + } + + public function automaticUrlReplacementEnabled(): bool { + return $this->automatic_url_replacement; + } + + public function conflictStrategy(): string { + return $this->conflict_strategy; + } + + /** + * @return array + */ + public function toArray(): array { + return array( + 'sync_pairs' => $this->sync_pairs, + 'logging_level' => $this->logging_level, + 'automatic_url_replacement' => $this->automatic_url_replacement, + 'conflict_strategy' => $this->conflict_strategy, + ); + } + + /** + * @param mixed $value + * @param array $allowed + */ + private static function sanitizeChoice( $value, array $allowed, string $fallback ): string { + $sanitized = sanitize_text_field( (string) $value ); + + return in_array( $sanitized, $allowed, true ) ? $sanitized : $fallback; + } + + /** + * @param mixed $pairs + * @return array + */ + private static function sanitizeSyncPairs( $pairs ): array { + if ( ! is_array( $pairs ) ) { + return array(); + } + + $sanitized = array(); + + foreach ( $pairs as $pair ) { + if ( ! is_array( $pair ) ) { + continue; + } + + $name = sanitize_text_field( (string) ( $pair['name'] ?? '' ) ); + $source_url = esc_url( (string) ( $pair['source_url'] ?? '' ) ); + $destination_url = esc_url( (string) ( $pair['destination_url'] ?? '' ) ); + + if ( '' === $name || '' === $source_url || '' === $destination_url ) { + continue; + } + + $sanitized[] = array( + 'name' => $name, + 'source_url' => $source_url, + 'destination_url' => $destination_url, + ); + } + + return $sanitized; + } +} +``` + +- [ ] **Step 4: Implement settings repository** + +Create `src/Settings/SettingsRepository.php`: + +```php +toArray(), false ); + } + + /** + * @param mixed $value + * @return array + */ + public function sanitizeOption( $value ): array { + return Settings::fromArray( is_array( $value ) ? $value : array() )->toArray(); + } +} +``` + +- [ ] **Step 5: Run tests to verify they pass** + +Run: `composer test -- --filter SettingsTest` + +Expected: PASS with 4 tests. + +- [ ] **Step 6: Commit** + +```bash +git add src/Settings/Settings.php src/Settings/SettingsRepository.php tests/Unit/SettingsTest.php +git commit -m "feat: add typed plugin settings" +``` + +## Task 4: Add Option-Backed Logger + +**Files:** +- Create: `src/Logging/LoggerInterface.php` +- Create: `src/Logging/OptionLogger.php` +- Create: `tests/Unit/OptionLoggerTest.php` + +- [ ] **Step 1: Write failing logger tests** + +Create `tests/Unit/OptionLoggerTest.php`: + +```php +warning( 'Connection failed.', array( 'url' => 'https://example.test' ) ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertCount( 1, $entries ); + self::assertSame( 'warning', $entries[0]['level'] ); + self::assertSame( 'Connection failed.', $entries[0]['message'] ); + self::assertSame( 'https://example.test', $entries[0]['context']['url'] ); + } + + public function test_it_redacts_sensitive_context_values(): void { + $logger = new OptionLogger( 10 ); + + $logger->error( + 'Authentication failed.', + array( + 'application_password' => 'secret-value', + 'token' => 'token-value', + 'username' => 'admin', + ) + ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertSame( '[redacted]', $entries[0]['context']['application_password'] ); + self::assertSame( '[redacted]', $entries[0]['context']['token'] ); + self::assertSame( 'admin', $entries[0]['context']['username'] ); + } + + public function test_it_limits_retained_entries(): void { + $logger = new OptionLogger( 2 ); + + $logger->info( 'First' ); + $logger->info( 'Second' ); + $logger->info( 'Third' ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertCount( 2, $entries ); + self::assertSame( 'Second', $entries[0]['message'] ); + self::assertSame( 'Third', $entries[1]['message'] ); + } +} +``` + +- [ ] **Step 2: Add option stubs to test bootstrap** + +Modify `tests/bootstrap.php` by appending: + +```php +if ( ! function_exists( 'get_option' ) ) { + function get_option( $name, $default = false ) { + return $GLOBALS['wpcs_test_options'][ $name ] ?? $default; + } +} + +if ( ! function_exists( 'update_option' ) ) { + function update_option( $name, $value, $autoload = null ) { + $GLOBALS['wpcs_test_options'][ $name ] = $value; + return true; + } +} +``` + +- [ ] **Step 3: Run test to verify it fails** + +Run: `composer test -- --filter OptionLoggerTest` + +Expected: FAIL because class `WPContentSync\Logging\OptionLogger` does not exist. + +- [ ] **Step 4: Implement logger interface** + +Create `src/Logging/LoggerInterface.php`: + +```php + $context + */ + public function error( string $message, array $context = array() ): void; + + /** + * @param array $context + */ + public function warning( string $message, array $context = array() ): void; + + /** + * @param array $context + */ + public function info( string $message, array $context = array() ): void; + + /** + * @param array $context + */ + public function debug( string $message, array $context = array() ): void; +} +``` + +- [ ] **Step 5: Implement option logger** + +Create `src/Logging/OptionLogger.php`: + +```php +max_entries = max( 1, $max_entries ); + } + + public function error( string $message, array $context = array() ): void { + $this->log( 'error', $message, $context ); + } + + public function warning( string $message, array $context = array() ): void { + $this->log( 'warning', $message, $context ); + } + + public function info( string $message, array $context = array() ): void { + $this->log( 'info', $message, $context ); + } + + public function debug( string $message, array $context = array() ): void { + $this->log( 'debug', $message, $context ); + } + + /** + * @param array $context + */ + private function log( string $level, string $message, array $context ): void { + $entries = get_option( self::OPTION_NAME, array() ); + $entries = is_array( $entries ) ? $entries : array(); + + $entries[] = array( + 'timestamp' => gmdate( 'c' ), + 'level' => $level, + 'message' => sanitize_text_field( $message ), + 'context' => $this->redactContext( $context ), + ); + + if ( count( $entries ) > $this->max_entries ) { + $entries = array_slice( $entries, -1 * $this->max_entries ); + } + + update_option( self::OPTION_NAME, $entries, false ); + } + + /** + * @param array $context + * @return array + */ + private function redactContext( array $context ): array { + $redacted = array(); + + foreach ( $context as $key => $value ) { + $normalized_key = strtolower( (string) $key ); + $redacted[ $key ] = in_array( $normalized_key, self::SENSITIVE_KEYS, true ) + ? '[redacted]' + : $value; + } + + return $redacted; + } +} +``` + +- [ ] **Step 6: Run tests to verify they pass** + +Run: `composer test -- --filter OptionLoggerTest` + +Expected: PASS with 3 tests. + +- [ ] **Step 7: Commit** + +```bash +git add src/Logging/LoggerInterface.php src/Logging/OptionLogger.php tests/Unit/OptionLoggerTest.php tests/bootstrap.php +git commit -m "feat: add bounded option logger" +``` + +## Task 5: Add Plugin Bootstrap and Lifecycle Hooks + +**Files:** +- Create: `wp-content-sync.php` +- Create: `src/Plugin.php` +- Create: `src/Activator.php` +- Create: `src/Deactivator.php` + +- [ ] **Step 1: Create the plugin entrypoint** + +Create `wp-content-sync.php`: + +```php +register(); + } +); +``` + +- [ ] **Step 2: Implement activator** + +Create `src/Activator.php`: + +```php +toArray(), false ); + } + } +} +``` + +- [ ] **Step 3: Implement deactivator** + +Create `src/Deactivator.php`: + +```php +container = $container; + } + + public static function create(): self { + $container = new Container(); + + $container->factory( + SettingsRepository::class, + static function (): SettingsRepository { + return new SettingsRepository(); + } + ); + + $container->factory( + LoggerInterface::class, + static function (): LoggerInterface { + return new OptionLogger(); + } + ); + + $container->factory( + AdminPage::class, + static function () use ( $container ): AdminPage { + return new AdminPage( + $container->get( SettingsRepository::class ), + $container->get( LoggerInterface::class ) + ); + } + ); + + return new self( $container ); + } + + public function register(): void { + $this->container->get( AdminPage::class )->register(); + } +} +``` + +- [ ] **Step 5: Add missing transient stub to test bootstrap** + +Modify `tests/bootstrap.php` by appending: + +```php +if ( ! function_exists( 'delete_transient' ) ) { + function delete_transient( $name ) { + unset( $GLOBALS['wpcs_test_transients'][ $name ] ); + return true; + } +} +``` + +- [ ] **Step 6: Run static checks for lifecycle files** + +Run: `composer stan` + +Expected: PASS with no PHPStan errors for `src` and `wp-content-sync.php`. + +- [ ] **Step 7: Commit** + +```bash +git add wp-content-sync.php src/Plugin.php src/Activator.php src/Deactivator.php tests/bootstrap.php +git commit -m "feat: add plugin bootstrap lifecycle" +``` + +## Task 6: Add Admin Dashboard Shell + +**Files:** +- Create: `src/Admin/AdminPage.php` +- Create: `templates/admin/dashboard.php` +- Modify: `src/Plugin.php` +- Modify: `tests/bootstrap.php` + +- [ ] **Step 1: Implement admin page controller** + +Create `src/Admin/AdminPage.php`: + +```php +settings_repository = $settings_repository; + $this->logger = $logger; + } + + public function register(): void { + add_action( 'admin_menu', array( $this, 'registerMenu' ) ); + add_action( 'admin_init', array( $this, 'registerSettings' ) ); + } + + public function registerMenu(): void { + add_management_page( + __( 'WP Content Sync', 'wp-content-sync' ), + __( 'Content Sync', 'wp-content-sync' ), + 'manage_options', + 'wp-content-sync', + array( $this, 'render' ) + ); + } + + public function registerSettings(): void { + register_setting( + 'wpcs_settings', + SettingsRepository::OPTION_NAME, + array( + 'type' => 'array', + 'sanitize_callback' => array( $this->settings_repository, 'sanitizeOption' ), + 'default' => $this->settings_repository->get()->toArray(), + ) + ); + } + + public function render(): void { + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( esc_html__( 'You do not have permission to access WP Content Sync.', 'wp-content-sync' ) ); + } + + $settings = $this->settings_repository->get(); + $this->logger->debug( 'Admin dashboard viewed.' ); + + include WPCS_PLUGIN_DIR . 'templates/admin/dashboard.php'; + } +} +``` + +- [ ] **Step 2: Create escaped dashboard template** + +Create `templates/admin/dashboard.php`: + +```php + +
+

+

+ +
+

+ +

+
+ +

+ + + + + + + + + + + + + + + + + + + +
syncPairs() ) ); ?>
loggingLevel() ); ?>
+ automaticUrlReplacementEnabled() + ? __( 'Enabled', 'wp-content-sync' ) + : __( 'Disabled', 'wp-content-sync' ) + ); + ?> +
conflictStrategy() ); ?>
+
+``` + +- [ ] **Step 3: Add admin WordPress stubs for static/unit runs** + +Modify `tests/bootstrap.php` by appending: + +```php +if ( ! function_exists( '__' ) ) { + function __( $text, $domain = 'default' ) { + return $text; + } +} + +if ( ! function_exists( 'esc_html__' ) ) { + function esc_html__( $text, $domain = 'default' ) { + return esc_html( $text ); + } +} + +if ( ! function_exists( 'add_action' ) ) { + function add_action( $hook_name, $callback ) { + $GLOBALS['wpcs_test_actions'][ $hook_name ][] = $callback; + return true; + } +} + +if ( ! function_exists( 'add_management_page' ) ) { + function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback ) { + $GLOBALS['wpcs_test_admin_pages'][ $menu_slug ] = compact( 'page_title', 'menu_title', 'capability', 'callback' ); + return $menu_slug; + } +} + +if ( ! function_exists( 'register_setting' ) ) { + function register_setting( $option_group, $option_name, $args = array() ) { + $GLOBALS['wpcs_test_registered_settings'][ $option_name ] = compact( 'option_group', 'args' ); + return true; + } +} + +if ( ! function_exists( 'current_user_can' ) ) { + function current_user_can( $capability ) { + return 'manage_options' === $capability; + } +} + +if ( ! function_exists( 'wp_die' ) ) { + function wp_die( $message ) { + throw new \RuntimeException( (string) $message ); + } +} +``` + +- [ ] **Step 4: Run lint and static analysis** + +Run: `composer lint` + +Expected: PASS with no PHPCS violations. + +Run: `composer stan` + +Expected: PASS with no PHPStan errors. + +- [ ] **Step 5: Commit** + +```bash +git add src/Admin/AdminPage.php templates/admin/dashboard.php tests/bootstrap.php +git commit -m "feat: add admin dashboard shell" +``` + +## Task 7: Run Full Foundation Verification + +**Files:** +- Verify all files created in Tasks 1-6. + +- [ ] **Step 1: Run Composer validation** + +Run: `composer validate --strict` + +Expected: PASS. + +- [ ] **Step 2: Run PHPCS** + +Run: `composer lint` + +Expected: PASS. + +- [ ] **Step 3: Run PHPStan** + +Run: `composer stan` + +Expected: PASS. + +- [ ] **Step 4: Run PHPUnit** + +Run: `composer test` + +Expected: PASS with all unit tests. + +- [ ] **Step 5: Perform manual WordPress smoke test** + +Install the plugin directory into a WordPress 5.6+ site and activate WP Content Sync from the Plugins screen. + +Expected: +- Activation completes without fatal errors. +- A `Content Sync` item appears under `Tools`. +- Opening `Tools > Content Sync` shows the dashboard shell. +- The dashboard shows `Configured Sync Pairs` as `0`, `Logging Level` as `warning`, `URL Replacement` as `Enabled`, and `Conflict Strategy` as `last_write_wins`. + +- [ ] **Step 6: Commit final verification note if code changed during fixes** + +```bash +git status --short +git add . +git commit -m "chore: verify plugin foundation" +``` + +## Self-Review + +**Spec coverage in this foundation plan:** +- Covers initial admin interface shell, settings persistence, secure defaults, logging boundary, plugin lifecycle, and project tooling. +- Defers sync engine, content handlers, URL transformation, REST transport, file transport, conflict resolution, and background progress to later roadmap phases. +- Security requirements begin here through capability checks, escaped admin output, sanitized settings, and log redaction. + +**Placeholder scan:** This plan intentionally avoids placeholder implementation steps. Deferred product areas are listed in the roadmap as later plans rather than vague steps inside this plan. + +**Type consistency:** `SettingsRepository`, `Settings`, `LoggerInterface`, `OptionLogger`, `AdminPage`, `Container`, `Activator`, `Deactivator`, and `Plugin` names are consistent across tasks. diff --git a/docs/superpowers/plans/2026-04-26-wordpress-content-sync-implementation-roadmap.md b/docs/superpowers/plans/2026-04-26-wordpress-content-sync-implementation-roadmap.md new file mode 100644 index 0000000..b826f73 --- /dev/null +++ b/docs/superpowers/plans/2026-04-26-wordpress-content-sync-implementation-roadmap.md @@ -0,0 +1,95 @@ +# WordPress Content Sync Implementation Roadmap + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement the linked plans task-by-task. + +**Source Spec:** `docs/superpowers/specs/2026-04-25-wordpress-content-sync-design.md` + +**Purpose:** Break the approved product design into independently shippable implementation plans. + +## Delivery Strategy + +Build the plugin in small vertical slices. Each slice must leave the repository in a working, testable state and must preserve the project agreements: PHPCS using `phpcs.xml`, PHPStan level 6 or higher, PHPUnit, secure nonce checks, sanitized input, escaped output, and no direct reliance on git or WP-CLI at runtime. + +## Phase 1: Plugin Foundation + +**Plan:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-foundation.md` + +Creates the WordPress plugin skeleton, Composer/dev tooling, bootstrap loader, activation/deactivation hooks, service container, admin shell, settings persistence, logging, and initial PHPUnit coverage. + +**Exit Criteria:** +- WordPress can load the plugin without fatal errors. +- Composer scripts exist for `lint`, `stan`, `test`, and `validate`. +- Admin menu renders a dashboard shell for users with `manage_options`. +- Plugin settings can be registered and read through a typed settings object. +- Unit tests pass for settings defaults, service registration, and logger behavior. + +## Phase 2: URL Transformation + +**Plan to create after Phase 1:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-url-transformer.md` + +Adds domain mapping, URL replacement in post content, URL replacement inside serialized metadata, and GUID/permalink transformation rules. + +**Exit Criteria:** +- Plain text URLs, HTML attributes, JSON strings, and serialized PHP arrays are transformed safely. +- Serialized data remains valid after replacement. +- Mapping supports multiple source/destination pairs. +- Tests cover escaped URLs, protocol-relative URLs, and nested metadata. + +## Phase 3: Content Package Schema and File Transport + +**Plan to create after Phase 2:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-file-transport.md` + +Defines the sync package schema and implements export/import through JSON files for posts, pages, taxonomies, media metadata, and custom post type records. + +**Exit Criteria:** +- Export produces a versioned JSON package with manifest, content records, taxonomy records, media records, and checksum metadata. +- Import validates schema before mutating data. +- Invalid files produce actionable admin errors without partial writes. +- File import uses WordPress nonce and capability checks. + +## Phase 4: REST Transport + +**Plan to create after Phase 3:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-rest-transport.md` + +Adds authenticated REST endpoints and REST client support using WordPress application passwords. + +**Exit Criteria:** +- Destination exposes secure receive/status endpoints. +- Source can test connection and send packages. +- REST failures surface typed errors and can fall back to file transport. +- Endpoint mutations validate permissions and request shape. + +## Phase 5: Sync Engine and Content Handlers + +**Plan to create after Phase 4:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-engine-handlers.md` + +Implements orchestration, content extraction/import handlers, conflict detection, retries, progress state, and operation logs. + +**Exit Criteria:** +- Push and pull operations can sync posts, pages, custom post types, taxonomies, metadata, and media records. +- Last-write-wins conflict behavior is logged. +- Partial failures preserve operation state. +- Long-running work is chunked to avoid memory exhaustion. + +## Phase 6: Admin Workflow and Hardening + +**Plan to create after Phase 5:** `docs/superpowers/plans/2026-04-26-wordpress-content-sync-admin-hardening.md` + +Completes the admin UI, connection diagnostics, operation history, import/export screens, user-facing errors, debug logging controls, and smoke/integration tests. + +**Exit Criteria:** +- Users can configure sync pairs, credentials, URL mappings, content type selection, and sync direction. +- Every state-changing admin action verifies nonce and capability. +- Output is escaped and input is sanitized. +- Manual smoke checklist covers production-to-staging, staging-to-production, REST, and file fallback. + +## Cross-Phase Standards + +- Keep implementation files under `src/` with namespace `WPContentSync`. +- Keep tests under `tests/Unit` and `tests/Integration`. +- Keep admin templates under `templates/admin`. +- Use `wpcs_` as the option/transient/action prefix for this plugin. +- Prefer interfaces at boundaries: settings storage, logger, transport, handlers, package validation. +- Never store raw application passwords in logs. +- Never mutate WordPress content from an unauthenticated request. +- Every plan should include test-first steps and exact verification commands. diff --git a/docs/superpowers/specs/2026-04-25-wordpress-content-sync-design.md b/docs/superpowers/specs/2026-04-25-wordpress-content-sync-design.md new file mode 100644 index 0000000..e238e98 --- /dev/null +++ b/docs/superpowers/specs/2026-04-25-wordpress-content-sync-design.md @@ -0,0 +1,293 @@ +# WordPress Content Sync Plugin Design + +**Date:** 2026-04-25 +**Type:** Feature Design +**Status:** Approved + +## Overview + +A WordPress plugin that enables bidirectional content synchronization between two WordPress instances, supporting both REST API and file-based transfer methods. The plugin handles all content types including posts, pages, custom post types, taxonomies, and media, with automatic URL rewriting for domain changes. + +## Use Case + +Primary use case is syncing content between production and staging/development environments for developers building and maintaining WordPress sites. The plugin must work with instances that are not publicly accessible and where git or wp-cli are unavailable. + +## Architecture + +### Core Layers + +**Core Sync Engine** +- Orchestrates sync operations between instances +- Manages both REST API and file transfer methods +- Coordinates source and destination operations +- Handles error recovery and retry logic + +**Content Handlers** +- Separate modules for different content types +- Each handler extracts, transforms, and restores specific content +- Supports posts, pages, media, custom post types, taxonomies, metadata + +**URL Transformation Layer** +- Handles all URL rewriting during sync operations +- Supports automatic domain mapping and manual overrides +- Processes content links, image paths, and custom field URLs + +**Transport Layer** +- Abstracts communication method between instances +- REST API implementation with application password authentication +- File transfer implementation as fallback + +**Admin Interface** +- WordPress admin pages for configuration +- Sync operation management and monitoring +- Status reporting and error handling + +## Core Components + +### Sync Manager +Central orchestrator responsible for: +- Managing sync configuration (instance pairs, credentials, URL mappings) +- Determining transport method (REST API vs file transfer) +- Coordinating content handlers during sync operations +- Handling error recovery and retry logic +- Providing sync status and progress reporting + +### Content Handlers +Specialized processors for different content types: + +**Posts/Pages Handler** +- Standard WordPress content with revisions +- Handles post content, excerpts, titles, and status +- Manages post relationships and hierarchy + +**Media Handler** +- File uploads and attachments +- URL rewriting for media references +- Handles image sizes and metadata + +**Custom Post Types Handler** +- Dynamic CPT support +- Respects CPT registration and capabilities +- Handles CPT-specific metadata + +**Taxonomies Handler** +- Categories, tags, and custom taxonomies +- Term relationships and hierarchies +- Term metadata and descriptions + +**Metadata Handler** +- Post meta, user meta, and options +- Serialized data handling +- Custom field URL scanning + +**Users Handler** (Optional) +- User accounts and roles +- User capabilities and permissions +- User metadata + +### URL Transformer +Handles URL transformation during sync: +- Domain mapping configuration (source → destination URLs) +- Content body URL replacement (links, images, embedded content) +- GUID and permalink updates +- Custom field URL scanning +- Serialized data URL replacement + +### Transport Abstraction +Two implementation strategies: + +**REST API Transport** +- Uses WordPress REST API endpoints +- Application password authentication +- Automatic when instances can communicate +- Supports real-time sync operations + +**File Transport** +- Generates JSON packages with all content data +- Manual file transfer between instances +- Fallback when REST API unavailable +- Supports offline sync scenarios + +## Data Flow + +### Push Operation (Source → Destination) +1. User initiates push from source instance admin +2. Sync Manager validates destination connection +3. Content handlers extract data from source database +4. URL Transformer rewrites source URLs to destination URLs +5. Transport layer sends data (REST API or generates file) +6. Destination receives and processes data +7. Content handlers import/merge data on destination +8. Sync Manager reports completion status + +### Pull Operation (Destination ← Source) +1. User initiates pull from destination instance admin +2. Destination connects to source instance +3. Source extracts and transforms data +4. Source sends data to destination +5. Destination processes and imports data +6. Sync Manager reports completion status + +### File Transfer Flow +1. Source instance exports data to JSON file +2. User manually transfers file between instances +3. Destination instance imports JSON file +4. Same processing as REST API flow + +### Conflict Resolution +- Last-write-wins strategy for content conflicts +- Optional merge strategies for specific content types +- Conflict log for review after sync operations +- User notification of conflicts requiring manual resolution + +## Error Handling + +### Connection Errors +- Automatic retry with exponential backoff for REST API failures +- Graceful fallback to file transfer if REST API unavailable +- Clear error messages with troubleshooting steps +- Connection timeout handling + +### Data Validation +- Schema validation for imported JSON files +- Content integrity checks during sync operations +- Validation of required fields and relationships +- Data type and format verification + +### Partial Failure Recovery +- Transaction-based sync operations with rollback on failure +- Progress tracking for resumable sync operations +- Detailed error logs with context for debugging +- State preservation for interrupted operations + +### User-Facing Error Messages +- Specific error types (connection, authentication, data, transport) +- Actionable suggestions for each error type +- Error severity levels (warning, error, critical) +- Contextual help and documentation links + +### Logging and Debugging +- Detailed sync operation logs +- Performance metrics for optimization +- Optional debug mode for troubleshooting +- Log rotation and management + +## Admin Interface + +### Main Dashboard +- List of configured sync pairs (source/destination instances) +- Quick sync status indicators (last sync time, success/failure) +- Push/Pull action buttons for each sync pair +- Sync history and logs viewer +- Overall system health indicators + +### Configuration Pages + +**Sync Pair Setup** +- Add/edit source and destination instances +- Instance naming and identification +- Connection details and credentials + +**Connection Test** +- Verify REST API connectivity +- Test authentication credentials +- Validate URL mappings +- Network diagnostics + +**URL Mapping Configuration** +- Define source/destination domain mappings +- Multiple domain support +- URL pattern matching +- Custom replacement rules + +**Content Type Selection** +- Choose which content types to sync +- Individual content type toggles +- Bulk selection options +- Custom post type detection + +**Authentication Setup** +- Application passwords and credentials +- Secure credential storage +- Credential rotation support +- Permission verification + +### Sync Operation Interface +- Progress bar with real-time status updates +- Content type breakdown (posts, media, etc.) +- Error/warning notifications during sync +- Cancel operation support +- Detailed results summary after completion + +### Settings and Preferences +- Default sync direction preferences +- Conflict resolution strategy selection +- Automatic URL replacement toggle +- Logging level configuration +- Performance tuning options + +## Testing Strategy + +### Unit Testing +- Content handler tests for each content type +- URL transformer tests with various URL patterns +- Transport layer tests for both REST API and file methods +- Sync manager orchestration tests +- Individual component isolation tests + +### Integration Testing +- End-to-end sync operations between test instances +- REST API authentication and communication +- File export/import functionality +- URL rewriting accuracy across different content types +- Multi-instance sync scenarios + +### Edge Case Testing +- Large content sets (performance testing) +- Special characters and encoding issues +- Custom post types and taxonomies +- Plugin/theme compatibility +- Network connectivity issues +- Concurrent sync operations + +### Manual Testing Scenarios +- Production to staging sync +- Staging to production sync +- File transfer fallback +- URL replacement accuracy +- Conflict resolution behavior +- Error recovery procedures + +## Technical Requirements + +### WordPress Compatibility +- Minimum WordPress version: 5.6+ +- PHP version: 7.4+ +- REST API support required +- Application passwords feature required for REST API method + +### Performance Considerations +- Support for large content sets (1000+ posts) +- Efficient memory usage during sync operations +- Background processing for long-running operations +- Progress tracking for user feedback + +### Security Considerations +- Secure credential storage +- Application password authentication +- Data encryption for file transfers +- Permission validation +- Audit logging for sync operations + +## Success Criteria + +1. Successfully sync all content types between two WordPress instances +2. Handle URL rewriting accurately for domain changes +3. Support both REST API and file transfer methods +4. Provide clear error messages and recovery options +5. Work with non-publicly accessible instances +6. Function without git or wp-cli dependencies +7. Support bidirectional sync with push/pull operations +8. Handle custom post types and taxonomies dynamically +9. Provide comprehensive admin interface for configuration +10. Include robust error handling and logging \ No newline at end of file diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..877bd7a --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,33 @@ + + + Custom coding standards for WP Content Sync. + + + + wp-content-sync.php + src + tests + + + + + + + + + + + + + + + + + + + + + + + vendor/* + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..6083b80 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + level: 6 + paths: + - src + - wp-content-sync.php + scanFiles: + - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + - tests/bootstrap.php + bootstrapFiles: + - tests/bootstrap.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..e102570 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + tests/Unit + + + diff --git a/src/Activator.php b/src/Activator.php new file mode 100644 index 0000000..4c8bd5e --- /dev/null +++ b/src/Activator.php @@ -0,0 +1,19 @@ +toArray(), false ); + } + } +} diff --git a/src/Admin/AdminPage.php b/src/Admin/AdminPage.php new file mode 100644 index 0000000..0d5abca --- /dev/null +++ b/src/Admin/AdminPage.php @@ -0,0 +1,93 @@ +settings_repository = $settings_repository; + $this->logger = $logger; + } + + /** + * Registers admin hooks. + */ + public function register(): void { + add_action( 'admin_menu', array( $this, 'registerMenu' ) ); + add_action( 'admin_init', array( $this, 'registerSettings' ) ); + } + + /** + * Registers the Tools menu page. + */ + // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid + public function registerMenu(): void { + add_management_page( + __( 'WP Content Sync', 'wp-content-sync' ), + __( 'Content Sync', 'wp-content-sync' ), + 'manage_options', + 'wp-content-sync', + array( $this, 'render' ) + ); + } + + /** + * Registers the plugin settings option. + */ + // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid + public function registerSettings(): void { + register_setting( + 'wpcs_settings', + SettingsRepository::OPTION_NAME, + array( + 'type' => 'array', + 'sanitize_callback' => array( $this->settings_repository, 'sanitizeOption' ), + 'default' => $this->settings_repository->get()->toArray(), + ) + ); + } + + /** + * Renders the admin dashboard. + */ + public function render(): void { + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( esc_html__( 'You do not have permission to access WP Content Sync.', 'wp-content-sync' ) ); + } + + $settings = $this->settings_repository->get(); + $this->logger->debug( 'Admin dashboard viewed.' ); + + include WPCS_PLUGIN_DIR . 'templates/admin/dashboard.php'; + } +} diff --git a/src/Container.php b/src/Container.php new file mode 100644 index 0000000..6e6c059 --- /dev/null +++ b/src/Container.php @@ -0,0 +1,45 @@ + + */ + private array $services = array(); + + /** + * @var array + */ + private array $factories = array(); + + /** + * @param mixed $service Service instance or value. + */ + public function set( string $id, $service ): void { + $this->services[ $id ] = $service; + } + + /** + * @param callable(): mixed $factory + */ + public function factory( string $id, callable $factory ): void { + $this->factories[ $id ] = $factory; + } + + /** + * @return mixed + */ + public function get( string $id ) { + if ( array_key_exists( $id, $this->services ) ) { + return $this->services[ $id ]; + } + + if ( array_key_exists( $id, $this->factories ) ) { + $this->services[ $id ] = $this->factories[ $id ](); + return $this->services[ $id ]; + } + + throw new \InvalidArgumentException( sprintf( 'Service "%s" is not registered.', $id ) ); + } +} diff --git a/src/Deactivator.php b/src/Deactivator.php new file mode 100644 index 0000000..331298f --- /dev/null +++ b/src/Deactivator.php @@ -0,0 +1,14 @@ + $context Log context. + */ + public function error( string $message, array $context = array() ): void; + + /** + * @param array $context Log context. + */ + public function warning( string $message, array $context = array() ): void; + + /** + * @param array $context Log context. + */ + public function info( string $message, array $context = array() ): void; + + /** + * @param array $context Log context. + */ + public function debug( string $message, array $context = array() ): void; +} diff --git a/src/Logging/OptionLogger.php b/src/Logging/OptionLogger.php new file mode 100644 index 0000000..10b3436 --- /dev/null +++ b/src/Logging/OptionLogger.php @@ -0,0 +1,106 @@ +max_entries = max( 1, $max_entries ); + } + + /** + * @param array $context Log context. + */ + public function error( string $message, array $context = array() ): void { + $this->log( 'error', $message, $context ); + } + + /** + * @param array $context Log context. + */ + public function warning( string $message, array $context = array() ): void { + $this->log( 'warning', $message, $context ); + } + + /** + * @param array $context Log context. + */ + public function info( string $message, array $context = array() ): void { + $this->log( 'info', $message, $context ); + } + + /** + * @param array $context Log context. + */ + public function debug( string $message, array $context = array() ): void { + $this->log( 'debug', $message, $context ); + } + + /** + * @param array $context Log context. + */ + private function log( string $level, string $message, array $context ): void { + $entries = get_option( self::OPTION_NAME, array() ); + $entries = is_array( $entries ) ? $entries : array(); + + $entries[] = array( + 'timestamp' => gmdate( 'c' ), + 'level' => $level, + 'message' => sanitize_text_field( $message ), + 'context' => $this->redactContext( $context ), + ); + + if ( count( $entries ) > $this->max_entries ) { + $entries = array_slice( $entries, -1 * $this->max_entries ); + } + + update_option( self::OPTION_NAME, $entries, false ); + } + + /** + * @param array $context Log context. + * @return array + */ + private function redactContext( array $context ): array { + $redacted = array(); + + foreach ( $context as $key => $value ) { + $redacted[ $key ] = $this->isSensitiveKey( (string) $key ) + ? '[redacted]' + : $this->redactValue( $value ); + } + + return $redacted; + } + + private function isSensitiveKey( string $key ): bool { + $normalized_key = strtolower( $key ); + + foreach ( self::SENSITIVE_KEYS as $sensitive_key ) { + if ( false !== strpos( $normalized_key, $sensitive_key ) ) { + return true; + } + } + + return false; + } + + /** + * @param mixed $value Context value. + * @return mixed + */ + private function redactValue( $value ) { + return is_array( $value ) ? $this->redactContext( $value ) : $value; + } +} diff --git a/src/Plugin.php b/src/Plugin.php new file mode 100644 index 0000000..36c9e4e --- /dev/null +++ b/src/Plugin.php @@ -0,0 +1,58 @@ +container = $container; + } + + public static function create(): self { + $container = new Container(); + + $container->factory( + SettingsRepository::class, + static function (): SettingsRepository { + return new SettingsRepository(); + } + ); + + $container->factory( + LoggerInterface::class, + static function (): LoggerInterface { + return new OptionLogger(); + } + ); + + $container->factory( + AdminPage::class, + static function () use ( $container ): AdminPage { + return new AdminPage( + $container->get( SettingsRepository::class ), + $container->get( LoggerInterface::class ) + ); + } + ); + + return new self( $container ); + } + + public function register(): void { + /** @var AdminPage $admin_page */ + $admin_page = $this->container->get( AdminPage::class ); + + $admin_page->register(); + } +} diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php new file mode 100644 index 0000000..846bda0 --- /dev/null +++ b/src/Settings/Settings.php @@ -0,0 +1,148 @@ + + */ + private array $sync_pairs; + + private string $logging_level; + private bool $automatic_url_replacement; + private string $conflict_strategy; + + /** + * @param array $sync_pairs Sync pairs. + */ + private function __construct( + array $sync_pairs, + string $logging_level, + bool $automatic_url_replacement, + string $conflict_strategy + ) { + $this->sync_pairs = $sync_pairs; + $this->logging_level = $logging_level; + $this->automatic_url_replacement = $automatic_url_replacement; + $this->conflict_strategy = $conflict_strategy; + } + + /** + * @param array $data Raw settings data. + */ + public static function fromArray( array $data ): self { + $logging_level = self::sanitizeChoice( + $data['logging_level'] ?? 'warning', + self::LOGGING_LEVELS, + 'warning' + ); + + $conflict_strategy = self::sanitizeChoice( + $data['conflict_strategy'] ?? 'last_write_wins', + self::CONFLICT_STRATEGIES, + 'last_write_wins' + ); + + $automatic_url_replacement = array_key_exists( 'automatic_url_replacement', $data ) + ? self::sanitizeBoolean( $data['automatic_url_replacement'] ) + : true; + + return new self( + self::sanitizeSyncPairs( $data['sync_pairs'] ?? array() ), + $logging_level, + $automatic_url_replacement, + $conflict_strategy + ); + } + + /** + * @return array + */ + public function syncPairs(): array { + return $this->sync_pairs; + } + + public function loggingLevel(): string { + return $this->logging_level; + } + + public function automaticUrlReplacementEnabled(): bool { + return $this->automatic_url_replacement; + } + + public function conflictStrategy(): string { + return $this->conflict_strategy; + } + + /** + * @return array + */ + public function toArray(): array { + return array( + 'sync_pairs' => $this->sync_pairs, + 'logging_level' => $this->logging_level, + 'automatic_url_replacement' => $this->automatic_url_replacement, + 'conflict_strategy' => $this->conflict_strategy, + ); + } + + /** + * @param mixed $value Value to sanitize. + * @param array $allowed Allowed values. + */ + private static function sanitizeChoice( $value, array $allowed, string $fallback ): string { + $sanitized = sanitize_text_field( (string) $value ); + + return in_array( $sanitized, $allowed, true ) ? $sanitized : $fallback; + } + + /** + * @param mixed $value Value to normalize. + */ + private static function sanitizeBoolean( $value ): bool { + if ( is_bool( $value ) ) { + return $value; + } + + $normalized = strtolower( sanitize_text_field( (string) $value ) ); + + return in_array( $normalized, array( '1', 'true', 'yes', 'on' ), true ); + } + + /** + * @param mixed $pairs Raw sync pairs. + * @return array + */ + private static function sanitizeSyncPairs( $pairs ): array { + if ( ! is_array( $pairs ) ) { + return array(); + } + + $sanitized = array(); + + foreach ( $pairs as $pair ) { + if ( ! is_array( $pair ) ) { + continue; + } + + $name = sanitize_text_field( (string) ( $pair['name'] ?? '' ) ); + $source_url = esc_url_raw( (string) ( $pair['source_url'] ?? '' ) ); + $destination_url = esc_url_raw( (string) ( $pair['destination_url'] ?? '' ) ); + + if ( '' === $name || '' === $source_url || '' === $destination_url ) { + continue; + } + + $sanitized[] = array( + 'name' => $name, + 'source_url' => $source_url, + 'destination_url' => $destination_url, + ); + } + + return $sanitized; + } +} diff --git a/src/Settings/SettingsRepository.php b/src/Settings/SettingsRepository.php new file mode 100644 index 0000000..0e0932b --- /dev/null +++ b/src/Settings/SettingsRepository.php @@ -0,0 +1,25 @@ +toArray(), false ); + } + + /** + * @param mixed $value Value to sanitize. + * @return array + */ + public function sanitizeOption( $value ): array { + return Settings::fromArray( is_array( $value ) ? $value : array() )->toArray(); + } +} diff --git a/templates/admin/dashboard.php b/templates/admin/dashboard.php new file mode 100644 index 0000000..98dfb66 --- /dev/null +++ b/templates/admin/dashboard.php @@ -0,0 +1,58 @@ + +
+

+

+ +
+

+ +

+
+ +

+ + + + + + + + + + + + + + + + + + + +
syncPairs() ) ); ?>
loggingLevel() ); ?>
+ automaticUrlReplacementEnabled() + ? __( 'Enabled', 'wp-content-sync' ) + : __( 'Disabled', 'wp-content-sync' ) + ); + ?> +
conflictStrategy() ); ?>
+
diff --git a/tests/Unit/ContainerTest.php b/tests/Unit/ContainerTest.php new file mode 100644 index 0000000..a4cc9f2 --- /dev/null +++ b/tests/Unit/ContainerTest.php @@ -0,0 +1,45 @@ +set( 'example', $service ); + + self::assertSame( $service, $container->get( 'example' ) ); + } + + public function test_it_reuses_factory_result(): void { + $container = new Container(); + $calls = 0; + + $container->factory( + 'example', + static function () use ( &$calls ): \stdClass { + ++$calls; + return new \stdClass(); + } + ); + + $first = $container->get( 'example' ); + $second = $container->get( 'example' ); + + self::assertSame( $first, $second ); + self::assertSame( 1, $calls ); + } + + public function test_it_throws_for_unknown_service(): void { + $container = new Container(); + + $this->expectException( \InvalidArgumentException::class ); + $this->expectExceptionMessage( 'Service "missing" is not registered.' ); + + $container->get( 'missing' ); + } +} diff --git a/tests/Unit/OptionLoggerTest.php b/tests/Unit/OptionLoggerTest.php new file mode 100644 index 0000000..4d86f24 --- /dev/null +++ b/tests/Unit/OptionLoggerTest.php @@ -0,0 +1,65 @@ +warning( 'Connection failed.', array( 'url' => 'https://example.test' ) ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertCount( 1, $entries ); + self::assertSame( 'warning', $entries[0]['level'] ); + self::assertSame( 'Connection failed.', $entries[0]['message'] ); + self::assertSame( 'https://example.test', $entries[0]['context']['url'] ); + self::assertArrayHasKey( 'timestamp', $entries[0] ); + } + + public function test_it_redacts_sensitive_context_values(): void { + $logger = new OptionLogger( 10 ); + + $logger->error( + 'Authentication failed.', + array( + 'application_password' => 'secret-value', + 'client_secret' => 'client-secret-value', + 'headers' => array( + 'Authorization' => 'Bearer nested-token', + ), + 'token' => 'token-value', + 'username' => 'admin', + ) + ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertSame( '[redacted]', $entries[0]['context']['application_password'] ); + self::assertSame( '[redacted]', $entries[0]['context']['client_secret'] ); + self::assertSame( '[redacted]', $entries[0]['context']['headers']['Authorization'] ); + self::assertSame( '[redacted]', $entries[0]['context']['token'] ); + self::assertSame( 'admin', $entries[0]['context']['username'] ); + } + + public function test_it_limits_retained_entries(): void { + $logger = new OptionLogger( 2 ); + + $logger->info( 'First' ); + $logger->info( 'Second' ); + $logger->info( 'Third' ); + + $entries = get_option( OptionLogger::OPTION_NAME, array() ); + + self::assertCount( 2, $entries ); + self::assertSame( 'Second', $entries[0]['message'] ); + self::assertSame( 'Third', $entries[1]['message'] ); + } +} diff --git a/tests/Unit/SettingsTest.php b/tests/Unit/SettingsTest.php new file mode 100644 index 0000000..cd02848 --- /dev/null +++ b/tests/Unit/SettingsTest.php @@ -0,0 +1,89 @@ +syncPairs() ); + self::assertSame( 'warning', $settings->loggingLevel() ); + self::assertTrue( $settings->automaticUrlReplacementEnabled() ); + self::assertSame( 'last_write_wins', $settings->conflictStrategy() ); + } + + public function test_it_sanitizes_scalar_settings(): void { + $settings = Settings::fromArray( + array( + 'logging_level' => 'debug', + 'conflict_strategy' => "manual_review\n", + 'automatic_url_replacement' => false, + ) + ); + + self::assertSame( 'debug', $settings->loggingLevel() ); + self::assertSame( 'manual_review', $settings->conflictStrategy() ); + self::assertFalse( $settings->automaticUrlReplacementEnabled() ); + } + + public function test_it_rejects_unknown_logging_level(): void { + $settings = Settings::fromArray( + array( + 'logging_level' => 'verbose', + ) + ); + + self::assertSame( 'warning', $settings->loggingLevel() ); + } + + public function test_it_normalizes_string_boolean_values(): void { + $settings = Settings::fromArray( + array( + 'automatic_url_replacement' => 'false', + ) + ); + + self::assertFalse( $settings->automaticUrlReplacementEnabled() ); + + $settings = Settings::fromArray( + array( + 'automatic_url_replacement' => '1', + ) + ); + + self::assertTrue( $settings->automaticUrlReplacementEnabled() ); + } + + public function test_it_serializes_to_array(): void { + $settings = Settings::fromArray( + array( + 'sync_pairs' => array( + array( + 'name' => 'Staging', + 'source_url' => 'https://example.test', + 'destination_url' => 'https://staging.example.test', + ), + ), + ) + ); + + self::assertSame( + array( + 'sync_pairs' => array( + array( + 'name' => 'Staging', + 'source_url' => 'https://example.test', + 'destination_url' => 'https://staging.example.test', + ), + ), + 'logging_level' => 'warning', + 'automatic_url_replacement' => true, + 'conflict_strategy' => 'last_write_wins', + ), + $settings->toArray() + ); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..dbea835 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,315 @@ +]*>/', '', $value ); + } +} + +if ( ! function_exists( 'esc_html' ) ) { + /** + * Minimal HTML escaper for unit tests. + * + * @param mixed $value Value to escape. + * @return string + */ + function esc_html( $value ) { + return htmlspecialchars( (string) $value, ENT_QUOTES, 'UTF-8' ); + } +} + +if ( ! function_exists( '__' ) ) { + /** + * Minimal translation helper for unit tests. + * + * @param string $text Text to translate. + * @param string $domain Text domain. + * @return string + */ + function __( $text, $domain = 'default' ) { + $GLOBALS['wpcs_test_text_domain'] = $domain; + + return $text; + } +} + +if ( ! function_exists( 'esc_html__' ) ) { + /** + * Minimal translated HTML escaper for unit tests. + * + * @param string $text Text to translate and escape. + * @param string $domain Text domain. + * @return string + */ + function esc_html__( $text, $domain = 'default' ) { + $GLOBALS['wpcs_test_text_domain'] = $domain; + + return esc_html( $text ); + } +} + +if ( ! function_exists( 'esc_attr' ) ) { + /** + * Minimal attribute escaper for unit tests. + * + * @param mixed $value Value to escape. + * @return string + */ + function esc_attr( $value ) { + return htmlspecialchars( (string) $value, ENT_QUOTES, 'UTF-8' ); + } +} + +if ( ! function_exists( 'esc_url' ) ) { + /** + * Minimal URL sanitizer for unit tests. + * + * @param mixed $value Value to sanitize. + * @return string + */ + function esc_url( $value ) { + return filter_var( (string) $value, FILTER_SANITIZE_URL ); + } +} + +if ( ! function_exists( 'esc_url_raw' ) ) { + /** + * Minimal raw URL sanitizer for unit tests. + * + * @param mixed $value Value to sanitize. + * @return string + */ + function esc_url_raw( $value ) { + return filter_var( (string) $value, FILTER_SANITIZE_URL ); + } +} + +if ( ! function_exists( 'get_option' ) ) { + /** + * Minimal WordPress option reader for unit tests. + * + * @param string $name Option name. + * @param mixed $default_value Default value. + * @return mixed + */ + function get_option( $name, $default_value = false ) { + return $GLOBALS['wpcs_test_options'][ $name ] ?? $default_value; + } +} + +if ( ! function_exists( 'update_option' ) ) { + /** + * Minimal WordPress option writer for unit tests. + * + * @param string $name Option name. + * @param mixed $value Option value. + * @param mixed $autoload Autoload flag. + * @return bool + */ + function update_option( $name, $value, $autoload = null ) { + $GLOBALS['wpcs_test_options'][ $name ] = $value; + $GLOBALS['wpcs_test_option_autoloads'][ $name ] = $autoload; + + return true; + } +} + +if ( ! function_exists( 'delete_transient' ) ) { + /** + * Minimal WordPress transient deleter for unit tests. + * + * @param string $name Transient name. + * @return bool + */ + function delete_transient( $name ) { + unset( $GLOBALS['wpcs_test_transients'][ $name ] ); + + return true; + } +} + +if ( ! function_exists( 'plugin_dir_path' ) ) { + /** + * Minimal plugin path helper for static analysis. + * + * @param string $file Plugin file. + * @return string + */ + function plugin_dir_path( $file ) { + return trailingslashit( dirname( $file ) ); + } +} + +if ( ! function_exists( 'plugin_dir_url' ) ) { + /** + * Minimal plugin URL helper for static analysis. + * + * @param string $file Plugin file. + * @return string + */ + function plugin_dir_url( $file ) { + return 'http://example.org/wp-content/plugins/' . basename( dirname( $file ) ) . '/'; + } +} + +if ( ! function_exists( 'trailingslashit' ) ) { + /** + * Minimal trailing slash helper for static analysis. + * + * @param string $value Value to slash. + * @return string + */ + function trailingslashit( $value ) { + return rtrim( $value, '/\\' ) . DIRECTORY_SEPARATOR; + } +} + +if ( ! function_exists( 'register_activation_hook' ) ) { + /** + * Minimal activation hook registrar for static analysis. + * + * @param string $file Plugin file. + * @param callable $callback Activation callback. + * @return void + */ + function register_activation_hook( $file, $callback ) { + $GLOBALS['wpcs_test_activation_hooks'][ $file ] = $callback; + } +} + +if ( ! function_exists( 'register_deactivation_hook' ) ) { + /** + * Minimal deactivation hook registrar for static analysis. + * + * @param string $file Plugin file. + * @param callable $callback Deactivation callback. + * @return void + */ + function register_deactivation_hook( $file, $callback ) { + $GLOBALS['wpcs_test_deactivation_hooks'][ $file ] = $callback; + } +} + +if ( ! function_exists( 'add_action' ) ) { + /** + * Minimal action registrar for static analysis. + * + * @param string $hook_name Hook name. + * @param callable $callback Hook callback. + * @return bool + */ + function add_action( $hook_name, $callback ) { + $GLOBALS['wpcs_test_actions'][ $hook_name ][] = $callback; + + return true; + } +} + +if ( ! function_exists( 'add_management_page' ) ) { + /** + * Minimal management page registrar for static analysis. + * + * @param string $page_title Page title. + * @param string $menu_title Menu title. + * @param string $capability Capability required. + * @param string $menu_slug Menu slug. + * @param callable $callback Page callback. + * @return string + */ + function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback ) { + $GLOBALS['wpcs_test_admin_pages'][ $menu_slug ] = array( + 'page_title' => $page_title, + 'menu_title' => $menu_title, + 'capability' => $capability, + 'callback' => $callback, + ); + + return $menu_slug; + } +} + +if ( ! function_exists( 'register_setting' ) ) { + /** + * Minimal setting registrar for static analysis. + * + * @param string $option_group Option group. + * @param string $option_name Option name. + * @param array $args Setting arguments. + * @return bool + */ + function register_setting( $option_group, $option_name, $args = array() ) { + $GLOBALS['wpcs_test_registered_settings'][ $option_name ] = array( + 'option_group' => $option_group, + 'args' => $args, + ); + + return true; + } +} + +if ( ! function_exists( 'current_user_can' ) ) { + /** + * Minimal capability checker for static analysis. + * + * @param string $capability Capability to check. + * @return bool + */ + function current_user_can( $capability ) { + return 'manage_options' === $capability; + } +} + +if ( ! function_exists( 'wp_die' ) ) { + /** + * Minimal WordPress die handler for unit tests. + * + * @param mixed $message Message to die with. + * @return void + * + * @throws \RuntimeException Always throws with the provided message. + */ + function wp_die( $message ) { + throw new \RuntimeException( esc_html( $message ) ); + } +} diff --git a/wp-content-sync.php b/wp-content-sync.php new file mode 100644 index 0000000..ae267e5 --- /dev/null +++ b/wp-content-sync.php @@ -0,0 +1,51 @@ +

%s

', + esc_html__( 'WP Content Sync dependencies are missing. Run composer install before activating the plugin.', 'wp-content-sync' ) + ); + } + ); + + return; +} + +require_once $wpcs_autoload; + +register_activation_hook( __FILE__, array( \WPContentSync\Activator::class, 'activate' ) ); +register_deactivation_hook( __FILE__, array( \WPContentSync\Deactivator::class, 'deactivate' ) ); + +add_action( + 'plugins_loaded', + static function (): void { + $plugin = \WPContentSync\Plugin::create(); + $plugin->register(); + } +);