Skip to content

Conversation

@justlevine
Copy link
Collaborator

What does this implement/fix? Explain your changes.

This PR:

  • Inlines all (backwards-compatible) PHPDoc types into their native PHP types
  • Replaces the use of mixed with the specific array shape (where possible)
  • Adds type-narrowing to WPGraphQL::get_allowed_post_types() and ::get_allowed_taxonomies(), so the correct traversable type of the array is hinted correctly.

References to these functions have been cleaned up accordingly (usually just by removing a /** @var {...} */ typehint.

There are no breaking changes in this PR.

Does this close any currently open issues?

Any other comments?

@coveralls
Copy link

coveralls commented Apr 25, 2025

Coverage Status

coverage: 82.661% (-0.01%) from 82.671%
when pulling faa1353 on justlevine:chore/WPGraphQL-type-safety
into e2c4442 on wp-graphql:develop.

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit faa1353 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

View more on Code Climate.

@justlevine justlevine changed the title chore: improve type-safety for `WPGraphQL class chore: improve type-safety for WPGraphQL class Apr 25, 2025
@justlevine justlevine added status: in review Awaiting review before merging or closing needs: reviewer response This needs the attention of a codeowner or maintainer labels Apr 25, 2025
@justlevine justlevine requested a review from jasonbahl April 25, 2025 20:54
@justlevine justlevine added type: chore Maintenance tasks, refactoring, and other non-functional changes scope: code quality Refactoring, linting, and enforcing coding standards labels Apr 25, 2025
@jasonbahl jasonbahl merged commit 6d241b3 into wp-graphql:develop Apr 28, 2025
36 of 39 checks passed
jasonbahl pushed a commit to justlevine/wp-graphql that referenced this pull request Apr 28, 2025
@justlevine justlevine deleted the chore/WPGraphQL-type-safety branch April 29, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: reviewer response This needs the attention of a codeowner or maintainer scope: code quality Refactoring, linting, and enforcing coding standards status: in review Awaiting review before merging or closing type: chore Maintenance tasks, refactoring, and other non-functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants