Skip to content

Util function to check if running plugin check command#161

Merged
felixarntz merged 5 commits into
trunkfrom
fix/111-add-util-function
May 15, 2023
Merged

Util function to check if running plugin check command#161
felixarntz merged 5 commits into
trunkfrom
fix/111-add-util-function

Conversation

@mukeshpanchal27
Copy link
Copy Markdown
Member

@mukeshpanchal27 mukeshpanchal27 commented May 10, 2023

Closes #111

Checklist:

@mukeshpanchal27 mukeshpanchal27 self-assigned this May 10, 2023
@mukeshpanchal27 mukeshpanchal27 marked this pull request as ready for review May 10, 2023 12:11
Comment thread cli.php Outdated
Comment on lines 54 to 56
} else {
return;
}
Copy link
Copy Markdown
Member

@spacedmonkey spacedmonkey May 10, 2023

Choose a reason for hiding this comment

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

There is no other code after this return. I am 99% sure that, this is not needed.

@spacedmonkey
Copy link
Copy Markdown
Member

@mukeshpanchal27 I played around with this ticket in https://github.com/10up/plugin-check/pull/152/files. I don't think the idea works, but it is still interesting to compare.

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@mukeshpanchal27 Looks good so far, though I think a cleaner solution would be to keep using the CLI_Runner method we already have for that purpose.

*
* @return bool Returns true if is a CLI request for the plugin check else false.
*/
public static function is_plugin_check() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of a new method in this general class (which is not specific to CLI at all), I suggest we use the CLI_Runner::is_plugin_check() method instead and make that static.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread includes/Checker/CLI_Runner.php Outdated
@@ -32,15 +33,7 @@ class CLI_Runner extends Abstract_Check_Runner {
* @return bool Returns true if is an CLI request for the plugin check else false.
*/
public function is_plugin_check() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my other comment, I think making this method static makes more sense than introducing a similar method somewhere else that is not specific to CLI.

It's perfectly reasonable for this method to be static since it only checks something in the global scope and has nothing to do with an instance of this class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mukeshpanchal27 @felixarntz should we also update the AJAX_Runner method to also be static for consistency? We would also need to update the Plugin_Request_Utility::initialize_runner method to use that static methods also.

Comment thread includes/Checker/CLI_Runner.php Outdated
@@ -32,15 +33,7 @@ class CLI_Runner extends Abstract_Check_Runner {
* @return bool Returns true if is an CLI request for the plugin check else false.
*/
public function is_plugin_check() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mukeshpanchal27 @felixarntz should we also update the AJAX_Runner method to also be static for consistency? We would also need to update the Plugin_Request_Utility::initialize_runner method to use that static methods also.

@spacedmonkey
Copy link
Copy Markdown
Member

Keep the static add back the public on the method.

@spacedmonkey
Copy link
Copy Markdown
Member

Another lint error.

Copy link
Copy Markdown
Contributor

@jjgrainger jjgrainger left a comment

Choose a reason for hiding this comment

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

Thanks @mukeshpanchal27 updates look good

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thanks @mukeshpanchal27, LGTM!

@felixarntz felixarntz merged commit 3f1c5c6 into trunk May 15, 2023
@felixarntz felixarntz deleted the fix/111-add-util-function branch May 15, 2023 16:43
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.

Create util function to check if running plugin check command

4 participants