-
-
Notifications
You must be signed in to change notification settings - Fork 23
Enhance PHP compatibility and structure for WP_REST_Blocks #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Update PHP requirement from 7.0 to 7.2 in composer.json - Add autoloading configuration in composer.json - Introduce Data, Posts, and Widgets classes for better organization - Implement REST API functionality for blocks in Posts and Widgets classes - Add coverage for block data handling in tests - Update PHPUnit configuration for coverage reporting - Add coverage-html directory to .gitignore
…ter compatibility
…azaliev/didom` for improved compatibility; refactor tests with data providers and enhance `.gitignore`
…y and maintainability
…roving Composer setup
…s and updating schema methods in Data, Posts, and Widgets classes
…and updating method names for clarity
…ethod for improved clarity and efficiency
…_editor for improved clarity
…elds for improved clarity and consistency
…ine nested foreach loop in Data.php for better readability
…arnings for improved output clarity
…de for PHPCS and PHPStan
…t.yml for cleaner output
…uests and enhance PHPCS/PHPStan commands for graceful warnings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR modernizes the WP REST Blocks plugin with significant improvements to PHP compatibility, code structure, development tooling, and CI/CD workflows. It updates the minimum PHP version, refactors the codebase to use modern OOP practices, and enhances the development and testing infrastructure.
🔄 Breaking Changes
PHP Version Requirements
Dependency Changes
tburry/pquerywithimangazaliev/didomfor better HTML parsing🏗️ Code Structure Improvements
Refactored to Object-Oriented Architecture
WP_REST_BlocksData- Core block data processing and attribute extractionPosts- REST API fields for post types with block editor supportWidgets- REST API fields for widgets with block contentcomposer.jsonFile Reorganization
src/data.php→src/Data.phpsrc/posts.php→src/Posts.phpsrc/widgets.php→src/Widgets.php🧪 Testing & Development Infrastructure
Modern Testing Environment
@wordpress/envfor local development.wp-env.jsonconfiguration filebin/install-wp-tests.shscript.nvmrc)Enhanced Test Configuration
phpunit.xml.distwith coverage reportingNew npm Scripts
npm run env:start- Start WordPress development environmentnpm run env:stop- Stop the environmentnpm run env:reset- Clean and restart environmentnpm run env:destroy- Completely remove environmentnpm run test:php- Run PHPUnit tests in wp-envnpm run test:php:multisite- Run multisite testsnpm run test:php:watch- Watch mode for testsnpm run make-pot- Generate translation filesnpm run wp/npm run wp:tests- Run WP-CLI commands🔍 Code Quality Tools
New Development Tools
phpstan.neon.distconfigurationszepeviktor/phpstan-wordpressphpmd.xml.distconfigurationcomposer.jsonformattingNew Composer Scripts
composer phpstan- Run static analysiscomposer phpmd- Run mess detectorcomposer normalize- Normalize composer.json🚀 CI/CD Workflow Improvements
New GitHub Actions Workflows
1. Reusable PHP Lint Workflow (
.github/workflows/reusable-php-lint.yml)2. Security Scanning (
.github/workflows/security.yml)3. Workflow Validation (
.github/workflows/validate-workflows.yml)actionlintUpdated Workflows
PHP Lint (
continuous-integration-lint-php.yml)Unit Tests (
test-unit-php.yml)npm run env:stopDeploy to WordPress.org (
deploytowp.yml)setup-php-composeractionUpload Release Assets (
upload-asset-on-release.yml)softprops/action-gh-release@v2fail_on_unmatched_filesUpdate Assets (
upateassets.yml)New Composite Action
.github/actions/setup-php-composer/action.ymlWorkflow Enhancements
concurrencygroups to prevent multiple runspermissionsdeclarations for securityactions/checkout@v4actions/cache@v4Dependabot Configuration
chore(deps)📚 Documentation
Updated README
🛠️ Composer Dependencies
Added Development Dependencies
ergebnis/composer-normalize^2.48imangazaliev/didom^2.0phpmd/phpmd^2.15phpstan/extension-installer^1.4phpstan/phpstan^2.1phpstan/phpstan-deprecation-rules^2.0phpstan/phpstan-strict-rules^2.0swissspidy/phpstan-no-private^1.0szepeviktor/phpstan-wordpress^2.0Updated Configuration
WP_REST_Blocksnamespace📦 Build & Distribution
Updated
.distignore.wp-env.json,.wp-env.override.json,.wp-env-homeUpdated
.gitignorecoverage-html/for PHPUnit coverage reports.wp-env-home/for local wp-env data.wp-env.override.jsonfor local overrides.phpunit.result.cachefor faster test runs🗑️ Removed Files
Gruntfile.js- Replaced with npm scripts and wp-envbin/install-wp-tests.sh- Replaced with wp-env🔧 Configuration Updates
PHPCS (
.phpcs.xml.dist)PHPUnit (
phpunit.xml.dist)📈 Impact Summary
🧪 Testing
All tests pass with the new structure: