Skip to content

Commit

Permalink
Fix linting errors in plugin files
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarssanchez committed Jan 17, 2025
1 parent b789ac0 commit 406fa44
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 49 deletions.
5 changes: 2 additions & 3 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,14 +1114,13 @@ private function maybe_change_host( $assoc_args ) {
if ( isset( $assoc_args['ep-host'] ) ) {
add_filter(
'ep_host',
function ( $host ) use ( $assoc_args ) {
function ( $host ) use ( $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
return $assoc_args['ep-host'];
}
);
}
}


/**
* maybe change index prefix on the fly
*
Expand All @@ -1133,7 +1132,7 @@ private function maybe_change_index_prefix( $assoc_args ) {
if ( isset( $assoc_args['ep-prefix'] ) ) {
add_filter(
'ep_index_prefix',
function ( $prefix ) use ( $assoc_args ) {
function ( $prefix ) use ( $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
return $assoc_args['ep-prefix'];
}
);
Expand Down
12 changes: 6 additions & 6 deletions includes/classes/Feature/RelatedPosts/RelatedPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ public function formatted_args( $formatted_args, $args ) {
* Search Elasticsearch for related content
*
* @param int $post_id Post ID
* @param int $return Return code
* @param int $post_return Number of posts to return
* @since 4.1.0
* @return WP_Query
*/
public function get_related_query( $post_id, $return = 5 ) {
public function get_related_query( $post_id, $post_return = 5 ) {
$args = array(
'more_like' => $post_id,
'posts_per_page' => $return,
'posts_per_page' => $post_return,
'ep_integrate' => true,
'ignore_sticky_posts' => true,
);
Expand All @@ -141,15 +141,15 @@ public function get_related_query( $post_id, $return = 5 ) {
* Search Elasticsearch for related content
*
* @param int $post_id Post ID
* @param int $return Return code
* @param int $post_return Number of posts to return
*
* @since 2.1
* @uses get_related_query
*
* @return array|bool
*/
public function find_related( $post_id, $return = 5 ) {
$query = $this->get_related_query( $post_id, $return );
public function find_related( $post_id, $post_return = 5 ) {
$query = $this->get_related_query( $post_id, $post_return );

if ( ! $query->have_posts() ) {
return false;
Expand Down
11 changes: 3 additions & 8 deletions includes/classes/Feature/Search/Weighting.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,9 @@ public function render_settings_page() {
/**
* Recursively renders each settings section and its children.
*
* @param string $post_type Current post type we're rendering
* @param array $field Current field to render
* @param array $current_values Current stored weighting values
* @deprecated
*/
public function render_settings_section( $post_type, $field, $current_values ) {
public function render_settings_section() {
_doing_it_wrong(
__METHOD__,
esc_html( 'Weighting sections display are now handled via React components.' ),
Expand All @@ -378,10 +375,9 @@ public function handle_save() {
/**
* We need this method to test handle_save properly.
*
* @param string $redirect_url Redirect URL.
* @deprecated
*/
protected function redirect( $redirect_url ) {
protected function redirect() {
_doing_it_wrong(
__METHOD__,
esc_html( 'Weighting settings are now updated using the REST API, and do not redirect server-side.' ),
Expand All @@ -392,12 +388,11 @@ protected function redirect( $redirect_url ) {
/**
* Save weighting configuration for each searchable post_type.
*
* @param array $settings weighting settings
* @return void
* @since 3.4.1
* @deprecated
*/
public function save_weighting_configuration( $settings ) {
public function save_weighting_configuration() {
_doing_it_wrong(
__METHOD__,
esc_html( 'Weighting sections display are now handled via React components.' ),
Expand Down
5 changes: 2 additions & 3 deletions includes/classes/Feature/WooCommerce/OrdersAutosuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function get_search_template() {

add_filter( 'ep_bypass_exclusion_from_search', '__return_true', 10 );
add_filter( 'ep_intercept_remote_request', '__return_true' );
add_filter( 'ep_do_intercept_request', [ $this, 'intercept_search_request' ], 10, 4 );
add_filter( 'ep_do_intercept_request', [ $this, 'intercept_search_request' ], 10, 3 );
add_filter( 'ep_is_integrated_request', [ $this, 'is_integrated_request' ], 10, 2 );

$query = new \WP_Query(
Expand Down Expand Up @@ -363,10 +363,9 @@ public function is_integrated_request( $is_integrated, $context ) {
* @param object $response Response
* @param array $query Query
* @param array $args WP_Query argument array
* @param int $failures Count of failures in request loop
* @return object $response Response
*/
public function intercept_search_request( $response, $query = [], $args = [], $failures = 0 ) {
public function intercept_search_request( $response, $query = [], $args = [] ) {
$this->search_template = $query['args']['body'];

return wp_remote_request( $query['url'], $args );
Expand Down
10 changes: 5 additions & 5 deletions includes/classes/IndexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,21 +1168,21 @@ public function get_last_sync(): array {
* We used to have two different filters for this (one for the dashboard, another for CLI),
* this method combines both.
*
* @param {stdClass} $object Object to be checked
* @param {stdClass} $indexable_object Object to be checked
* @param {Indexable} $indexable Indexable
* @return boolean
*/
protected function should_skip_object_index( $object, $indexable ) {
protected function should_skip_object_index( $indexable_object, $indexable ) {
/**
* Filter whether to not sync specific item in dashboard or not
*
* @since 2.1
* @hook ep_item_sync_kill
* @param {boolean} $kill False means dont sync
* @param {array} $object Object to sync
* @param {array} $indexable_object Object to sync
* @return {Indexable} Indexable that object belongs to
*/
$ep_item_sync_kill = apply_filters( 'ep_item_sync_kill', false, $object, $indexable );
$ep_item_sync_kill = apply_filters( 'ep_item_sync_kill', false, $indexable_object, $indexable );

/**
* Conditionally kill indexing for a post
Expand All @@ -1192,7 +1192,7 @@ protected function should_skip_object_index( $object, $indexable ) {
* @param {int} $object_id Object ID
* @return {bool} New value
*/
$ep_indexable_sync_kill = apply_filters( 'ep_' . $indexable->slug . '_index_kill', false, $object->ID );
$ep_indexable_sync_kill = apply_filters( 'ep_' . $indexable->slug . '_index_kill', false, $indexable_object->ID );

return $ep_item_sync_kill || $ep_indexable_sync_kill;
}
Expand Down
5 changes: 2 additions & 3 deletions includes/classes/Indexable/Post/QueryIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct( $indexable_slug = 'post' ) {
add_filter( 'posts_pre_query', array( $this, 'get_es_posts' ), 10, 2 );

// Properly restore blog if necessary
add_action( 'loop_end', array( $this, 'maybe_restore_blog' ), 10, 1 );
add_action( 'loop_end', array( $this, 'maybe_restore_blog' ), 10, 0 );

// Properly switch to blog if necessary
add_action( 'the_post', array( $this, 'maybe_switch_to_blog' ), 10, 2 );
Expand Down Expand Up @@ -194,10 +194,9 @@ public function maybe_switch_to_blog( $post, $query = null ) {
/**
* Make sure the correct blog is restored
*
* @param WP_Query $query WP_Query instance
* @since 0.9
*/
public function maybe_restore_blog( $query ) {
public function maybe_restore_blog() {
if ( ! is_multisite() ) {
// @codeCoverageIgnoreStart
return;
Expand Down
8 changes: 4 additions & 4 deletions includes/classes/Indexables.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,24 @@ public function is_active( string $slug ): bool {
/**
* Get all indexable instances
*
* @param boolean $global If true or false, will only get Indexables with that global property.
* @param boolean $global_property If true or false, will only get Indexables with that global property.
* @param boolean $slug_only True returns an array of only string slugs.
* @param string $status Whether to return active indexables or all registered.
* @since 3.0, 4.5.0 Added $status
* @return array
*/
public function get_all( $global = null, $slug_only = false, $status = 'active' ) {
public function get_all( $global_property = null, $slug_only = false, $status = 'active' ) {
$indexables = [];
$list = ( 'active' === $status ) ? $this->active_indexables : $this->registered_indexables;

foreach ( $list as $slug => $indexable ) {
if ( null === $global ) {
if ( null === $global_property ) {
if ( $slug_only ) {
$indexables[] = $slug;
} else {
$indexables[] = $indexable;
}
} elseif ( $global === $indexable->global ) {
} elseif ( $global_property === $indexable->global ) {
if ( $slug_only ) {
$indexables[] = $slug;
} else {
Expand Down
5 changes: 2 additions & 3 deletions includes/classes/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ class Installer {
*/
public function setup() {
add_action( 'admin_init', [ $this, 'calculate_install_status' ], 9 );
add_filter( 'admin_title', [ $this, 'filter_admin_title' ], 10, 2 );
add_filter( 'admin_title', [ $this, 'filter_admin_title' ], 10 );
}

/**
* Filter admin title for install page
*
* @param string $admin_title Current title
* @param string $title Original title
* @since 3.0
* @return string
*/
public function filter_admin_title( $admin_title, $title ) {
public function filter_admin_title( $admin_title ) {
if ( 'install' === Screen::factory()->get_current_screen() ) {
// translators: Site Name
return sprintf( esc_html__( 'ElasticPress Setup ‹ %s — WordPress', 'elasticpress' ), esc_html( get_bloginfo( 'name' ) ) );
Expand Down
3 changes: 1 addition & 2 deletions includes/classes/REST/MetaKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ public function check_permission() {
/**
* Get indexed meta keys.
*
* @param \WP_REST_Request $request Full details about the request.
* @return array
*/
public function get_meta_keys( \WP_REST_Request $request ) {
public function get_meta_keys() {
$post_indexable = Indexables::factory()->get( 'post' );

try {
Expand Down
6 changes: 2 additions & 4 deletions includes/classes/REST/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ public function output( array $message ) {
/**
* Get the status of a sync in progress.
*
* @param \WP_REST_Request $request Full details about the request.
* @return void
*/
public function get_sync_status( \WP_REST_Request $request ) {
public function get_sync_status() {
nocache_headers();

$index_meta = Utils\get_indexing_status();
Expand Down Expand Up @@ -211,10 +210,9 @@ public function get_sync_status( \WP_REST_Request $request ) {
/**
* Cancel a sync in progress.
*
* @param \WP_REST_Request $request Full details about the request.
* @return void
*/
public function cancel_sync( \WP_REST_Request $request ) {
public function cancel_sync() {
nocache_headers();

$index_meta = Utils\get_indexing_status();
Expand Down
3 changes: 1 addition & 2 deletions includes/classes/REST/Taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public function check_permission() {
/**
* Get filterable taxonomies.
*
* @param \WP_REST_Request $request Full details about the request.
* @return array
*/
public function get_taxonomies( \WP_REST_Request $request ) {
public function get_taxonomies() {
$filterable_taxonomies = Features::factory()->get_registered_feature( 'facets' )->types['taxonomy']->get_facetable_taxonomies();

$taxonomies = [];
Expand Down
3 changes: 1 addition & 2 deletions includes/classes/REST/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ public function get_token( \WP_REST_Request $request ) {
/**
* Refresh the temporary token.
*
* @param \WP_REST_Request $request Full details about the request.
* @return string|false
*/
public function refresh_token( \WP_REST_Request $request ) {
public function refresh_token() {
$user_id = get_current_user_id();

$endpoint = $this->get_token_endpoint();
Expand Down
6 changes: 3 additions & 3 deletions includes/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public function __construct( $code, $message = null ) {
* Search Elasticsearch for related content
*
* @param int $post_id Post ID
* @param int $return Number of posts to get
* @param int $post_return Number of posts to get
* @since 2.1
* @return array|bool
*/
function ep_find_related( $post_id, $return = 5 ) {
function ep_find_related( $post_id, $post_return = 5 ) {
_deprecated_function( __FUNCTION__, '3.0', 'ElasticPress\Features::factory()->get_registered_feature' );

$feature = \ElasticPress\Features::factory()->get_registered_feature( 'related_posts' );

return ( ! empty( $feature ) ) ? $feature->find_related( $post_id, $return ) : false;
return ( ! empty( $feature ) ) ? $feature->find_related( $post_id, $post_return ) : false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/screen/TestStatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testGetReportsFilter() {
public function testGetReportsSkipped() {
$status_report = new StatusReport();

parse_str( 'ep-skip-reports[]=wordpress&ep-skip-reports[]=indexable', $_GET ); // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
parse_str( 'ep-skip-reports[]=wordpress&ep-skip-reports[]=indexable', $_GET ); // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText

$reports = $status_report->get_reports();
$this->assertSame(
Expand Down

0 comments on commit 406fa44

Please sign in to comment.