Skip to content

fix: reconcile WordPress DTO field coverage#11

Merged
soulevilx merged 1 commit into
developfrom
fix/reconcile-dto-field-coverage
May 17, 2026
Merged

fix: reconcile WordPress DTO field coverage#11
soulevilx merged 1 commit into
developfrom
fix/reconcile-dto-field-coverage

Conversation

@soulevilx
Copy link
Copy Markdown
Contributor

@soulevilx soulevilx commented May 17, 2026

WHAT changed

  • Added additive DTO fields that are present in WordPress REST API response schemas:
    • Comment: meta
    • PostType: description, rest_namespace, labels, supports, taxonomies
    • Taxonomy: description, rest_namespace, labels
  • Updated DataModelsTest coverage for constructor storage and DTO normalization via toArray().

WHY changed

The preserved local backup contained a few useful DTO field coverage improvements mixed into an outdated branch. These fields are valid WordPress REST response fields and current DTOs were dropping them.

HOW implemented

  • Ported only minimal additive constructor parameters with default values.
  • Appended new parameters after existing optional parameters to preserve current positional constructor compatibility.
  • Preserved existing fields including PostType::viewable, PostType::rest_base, Taxonomy::types, and Taxonomy::rest_base.

Candidate fields checked

  • Comment meta: ADD, present in WordPress comment schema and missing locally.
  • PostType description: ADD, present in WordPress type schema and missing locally.
  • PostType rest_namespace: ADD, present in WordPress type schema and missing locally.
  • PostType labels: ADD, present in WordPress type schema and missing locally.
  • PostType supports: ADD, present in WordPress type schema and missing locally.
  • PostType taxonomies: ADD, present in WordPress type schema and missing locally.
  • PostType rest_base: SKIP_ALREADY_PRESENT.
  • PostType hierarchical: SKIP_ALREADY_PRESENT.
  • PostType viewable: SKIP_ALREADY_PRESENT and explicitly preserved.
  • Taxonomy description: ADD, present in WordPress taxonomy schema/controller response and missing locally.
  • Taxonomy rest_namespace: ADD, present in WordPress taxonomy schema/controller response and missing locally.
  • Taxonomy labels: ADD, present in WordPress taxonomy schema/controller response and missing locally.
  • Taxonomy types: SKIP_ALREADY_PRESENT.
  • Taxonomy rest_base: SKIP_ALREADY_PRESENT.
  • Taxonomy hierarchical: SKIP_ALREADY_PRESENT.

Fields skipped and why

  • No backup deletions were ported.
  • No type narrowing or nullable rest_base changes were ported because that would alter the existing public contract.
  • No PostType viewable removal was ported.
  • No content-template code was reintroduced into SDK core.

Validation

  • composer validate: passed
  • composer lint: passed after adding a targeted PHPMD suppression for the expanded PostType DTO constructor
  • composer test: passed, 180 tests / 627 assertions
  • composer security: passed, no advisories
  • composer quality: passed
  • composer test:coverage: passed, 97.0% statements, coverage gate passed
  • composer test:integration: exited successfully with no tests executed in this local invocation
  • pre-commit hook: pint --test, phpstan, phpcs passed
  • pre-push hook: unit tests and composer audit passed

Risk / impact

Low. Changes are additive DTO field coverage only. Existing constructor fields were not removed, renamed, reordered before current optional arguments, or narrowed.

Summary by CodeRabbit

  • New Features
    • Extended data models to support additional WordPress metadata and configuration fields: comment metadata storage, post type descriptions and labels, REST API namespace configuration, feature support declarations, and taxonomy associations. Enhanced the SDK's ability to preserve and manage an expanded range of WordPress schema properties for improved platform compatibility and schema coverage.

Review Change Stack

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ea59ea0-dc9e-485a-99c5-c142de87d765

📥 Commits

Reviewing files that changed from the base of the PR and between c38b0bd and 76a5856.

📒 Files selected for processing (4)
  • src/Data/Comment.php
  • src/Data/PostType.php
  • src/Data/Taxonomy.php
  • tests/Unit/Data/DataModelsTest.php

📝 Walkthrough

Walkthrough

The PR extends the WordPress SDK's core data model classes (Comment, Taxonomy, PostType) to support additional optional metadata and schema fields in their constructor contracts. Each model gains new public readonly properties with sensible defaults, backed by PHPDoc type annotations. Corresponding unit tests are added or updated to verify that these fields are properly constructed and serialized via toArray().

Changes

Data Model Constructor Extensions

Layer / File(s) Summary
Comment metadata extension
src/Data/Comment.php, tests/Unit/Data/DataModelsTest.php
Comment constructor gains a new $meta array parameter (default empty array) to store comment metadata. Docblock and promoted property document and initialize the field, and test assertions verify preservation via both direct property access and toArray()['meta'] output.
Taxonomy schema fields extension
src/Data/Taxonomy.php, tests/Unit/Data/DataModelsTest.php
Taxonomy constructor is extended with three optional parameters: $description, $rest_namespace, and $labels (typed as array<string, mixed>). Updated tests verify default values for these fields and their preservation in serialized output.
PostType schema fields extension
src/Data/PostType.php, tests/Unit/Data/DataModelsTest.php
PostType constructor adds five optional parameters: $description, $rest_namespace, $labels, $supports, $taxonomies. Prior viewability test is replaced with comprehensive assertions for schema field preservation and toArray()['rest_namespace'] mapping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Three data models stand up tall,
With metadata now in the fall,
Comment's meta, Taxonomy's rest,
PostType's fields put to the test—
Each one passing, verified right,
WordPress SDK shines so bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: reconcile WordPress DTO field coverage' clearly and specifically describes the main change: adding missing WordPress REST API fields to Data Transfer Objects.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reconcile-dto-field-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands WordPress REST DTO field coverage so SDK data models preserve additional schema fields instead of dropping them during construction/normalization.

Changes:

  • Added additive fields to Comment, PostType, and Taxonomy DTOs.
  • Added PHPDoc array shape annotations for the new DTO array fields.
  • Updated unit coverage for constructor storage and selected toArray() normalization.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Data/Comment.php Adds meta field support for comment DTOs.
src/Data/PostType.php Adds additional post type schema fields including description, namespace, labels, supports, and taxonomies.
src/Data/Taxonomy.php Adds taxonomy description, REST namespace, and labels support.
tests/Unit/Data/DataModelsTest.php Covers the new DTO fields and default values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soulevilx soulevilx merged commit 646f9d0 into develop May 17, 2026
9 checks passed
@soulevilx soulevilx deleted the fix/reconcile-dto-field-coverage branch May 17, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants