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

Fixes for PHP8 and static analysis #1006

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

prettyboymp
Copy link
Contributor

This makes some improvements to docblock comments to improve static analysis and fixes some issues found by verifying PHP8 compatibility.

This makes some improvements to docblock comments to improve static analysis and fixes some issues found by verifying PHP8 compatibility.
@prettyboymp prettyboymp requested review from a team and jorgeatorres and removed request for a team October 25, 2023 12:51
Copy link
Member

@jorgeatorres jorgeatorres left a comment

Choose a reason for hiding this comment

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

Hey @prettyboymp!

Thanks for submitting these fixes. Overall this looks good, but I left some questions/comments. Please let me know what you think.

@@ -711,7 +711,7 @@ protected function bulk_cancel_actions( $query_args ) {

while ( $action_ids ) {
$action_ids = $this->query_actions( $query_args );
if ( empty( $action_ids ) ) {
if ( empty( $action_ids ) || ! is_countable( $action_ids ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think query_actions() can return anything other than an array. Is this check really needed here?

@@ -142,6 +142,7 @@ private function init_logging() {
WP_CLI::debug( 'Beginning migration of batch: ' . print_r( $batch, true ) );
}, 10, 1 );
add_action( 'action_scheduler/migration_batch_complete', function ( $batch ) {
/** @var array $batch */
Copy link
Member

Choose a reason for hiding this comment

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

Does this truly have any effect at this location in the code?

@@ -94,7 +94,8 @@ public function __construct($expression, CronExpression_FieldFactory $fieldFacto
*/
public function setExpression($value)
{
$this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
$cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
$this->cronParts = is_array($cronParts) ? $cronParts : [];
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with WP coding standards:

Suggested change
$this->cronParts = is_array($cronParts) ? $cronParts : [];
$this->cronParts = is_array( $cronParts ) ? $cronParts : array();

@jorgeatorres jorgeatorres added has feedback Issues for which we requested feedback from the author and received it. needs feedback The issue/PR needs a response from any of the parties involved in the issue. and removed has feedback Issues for which we requested feedback from the author and received it. labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs feedback The issue/PR needs a response from any of the parties involved in the issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants