Skip to content
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

Introduce phpstan #5

Open
wants to merge 3 commits into
base: feat/source-wordpress-v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/wp-gatsby/lib/wp-settings-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function callback_textarea( $args ) {
*
* @param array $args settings field args
*
* @return string
* @return void
*/
function callback_html( $args ) {
echo $this->get_field_description( $args );
Expand Down
10 changes: 6 additions & 4 deletions packages/wp-gatsby/src/ActionMonitor/ActionMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function updateUserIsPublic( $post_id, $post ) {
? $current_user->data->user_nicename
: "User";

$relay_id = Relay::toGlobalId( 'user', $user_id );
$relay_id = Relay::toGlobalId( 'user', strval( $user_id ) );
Copy link
Author

@szepeviktor szepeviktor Apr 27, 2020

Choose a reason for hiding this comment

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

@TylerBarnes ID should be a string as it goes into base64_encode
See https://github.com/ivome/graphql-relay-php/blob/master/src/Relay.php#L188


$this->insertNewAction( [
'action_type' => $user_is_public ? 'CREATE' : 'DELETE',
Expand All @@ -322,10 +322,12 @@ function getTermInfo( $term_id, $taxonomy, $deleted_term = null ) {
return null;
}

/** @var string|null $graphql_single_name */
$graphql_single_name = $taxonomy_object->graphql_single_name ?? null;
/** @var string|null $graphql_plural_name */
$graphql_plural_name = $taxonomy_object->graphql_plural_name ?? null;

if ( ! $graphql_plural_name || ! $graphql_single_name ) {
if ( null === $graphql_plural_name || null === $graphql_single_name ) {
return null;
}

Expand Down Expand Up @@ -635,7 +637,7 @@ function savePost( $post_id, $post = null, $update_post_parent = true ) {
$global_relay_id = '';
$global_relay_id = Relay::toGlobalId(
$post_type_object->name,
absint( $post_id )
$post_id
);

$referenced_node_single_name
Expand Down Expand Up @@ -912,7 +914,7 @@ function initPostType() {
"description" => "Used to keep a log of actions in WordPress for cache invalidation in gatsby-source-wpgraphql.",
"public" => false,
"publicly_queryable" => false,
"show_ui" => defined( 'GRAPHQL_DEBUG' ) && GRAPHQL_DEBUG,
"show_ui" => defined( 'GRAPHQL_DEBUG' ) && true === GRAPHQL_DEBUG,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
Expand Down
6 changes: 3 additions & 3 deletions packages/wp-gatsby/src/ActionMonitor/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function __construct() {
}

/**
* @param $post_id int The ID of the Post being saved
* @param $post \WP_Post The Post Object being saved
* @param $update bool Whether this is an existing post being updated or not.
* @param int $post_id The ID of the Post being saved
* @param \WP_Post $post \WP_Post The Post Object being saved
* @param bool $update Whether this is an existing post being updated or not.
*/
public function queue_dispatch( $post_id, $post, $update ) {
$this->should_dispatch = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/wp-gatsby/src/Admin/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function post_to_preview_instance( $post_ID, $post ) {

$global_relay_id = Relay::toGlobalId(
$post_type_object->name,
absint( $original_post->ID ?? $post_ID )
$original_post->ID ?? $post_ID
);

$referenced_node_single_name
Expand Down
2 changes: 1 addition & 1 deletion packages/wp-gatsby/src/Admin/includes/preview-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

$global_relay_id = Relay::toGlobalId(
$post_type_object->name,
absint( $post_id )
$post_id
);

$referenced_node_single_name
Expand Down
4 changes: 2 additions & 2 deletions packages/wp-gatsby/wp-gatsby.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class WPGatsby {
/**
* Instance of the main WPGatsby class
*
* @var WPGatsby $instance
* @var WPGatsby|null $instance
*/
private static $instance;

Expand All @@ -42,7 +42,7 @@ public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPGatsby ) ) {
self::$instance = new WPGatsby();
self::$instance->setup_constants();
if ( WPGATSBY_AUTOLOAD ) {
if ( true === WPGATSBY_AUTOLOAD ) {
self::$instance->includes();
self::$instance->init();
}
Expand Down