-
Notifications
You must be signed in to change notification settings - Fork 463
fix: cleanup Model fields for better source-of-truth and type-safety. #3363
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
fix: cleanup Model fields for better source-of-truth and type-safety. #3363
Conversation
return 'revision' === $this->data->post_type; | ||
}, | ||
'isSticky' => function () { | ||
return is_sticky( $this->data->ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
return ! empty( $this->data->post_parent ) ? absint( $this->data->post_parent ) : null; | ||
}, | ||
'parentId' => function () { | ||
return ( ! empty( $this->data->post_type ) && ! empty( $this->parentDatabaseId ) ) ? Relay::toGlobalId( 'post', (string) $this->parentDatabaseId ) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
'pinged' => function () { | ||
$punged = get_pung( $this->data->ID ); | ||
|
||
return empty( $punged ) ? null : implode( ',', (array) $punged ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
return ! empty( $this->previewRevisionDatabaseId ) ? Relay::toGlobalId( 'post', (string) $this->previewRevisionDatabaseId ) : null; | ||
// Aliases. | ||
'ID' => function () { | ||
return $this->databaseId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
|
||
return false; | ||
'post_author' => function () { | ||
return $this->authorDatabaseId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
Code Climate has analyzed commit 13b15ca and detected 53 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
What does this implement/fix? Explain your changes.
This PR cleans up the existing WPGraphQL Models in the following ways:
@property
tags and sorts them.fields
(cosmetic, to make the diff's easier to read now and in the future)As a result, we're also able to begin enforcing traversable types on new code via PHPStan.
Additional benefits:
Important
This PR is based on #3362 which should be merged first.
Relevant diffs: