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
Apply Rector suggestions for PHP 8.1 #43233
Conversation
Test Results SummaryCommit SHA: 15641d1
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
d11830b
to
aa75d99
Compare
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.
Changes look good.
aa75d99
to
060d364
Compare
Hi @coreymckrill, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
@@ -192,7 +192,7 @@ public function get_item_schema() { | |||
* @return array | |||
*/ | |||
public function get_collection_params() { | |||
$params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); | |||
$params = [ 'context' => $this->get_context_param( array( 'default' => 'view' ) ) ]; |
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.
$params = [ 'context' => $this->get_context_param( array( 'default' => 'view' ) ) ]; | |
$params = array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ) ); |
In WP code style rules, the longform array
syntax is preferred to the shorter []
. In this case, I think it also makes it easier to understand.
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.
@coreymckrill I've fixed all PHP Lint issues 2355e20
060d364
to
2355e20
Compare
2355e20
to
15641d1
Compare
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.
👍 Looks good! Thanks @asumaran
* PHP8 fixes for src/Admin * Add changelog entry * Fix PHP Lint issues
@@ -165,7 +165,7 @@ protected function get_segments( $type, $query_params, $table_name ) { | |||
|
|||
$segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table ); | |||
} elseif ( 'variation' === $this->query_args['segmentby'] ) { | |||
if ( ! isset( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) { | |||
if ( ! isset( $this->query_args['product_includes'] ) || ! is_array( count( $this->query_args['product_includes'] ) ) || count( $this->query_args['product_includes'] ) !== 1 ) { |
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.
@asumaran it appears this change actually broke our Analytics view when comparing variation products within Analytics > Products and then selecting a variable product.
I assume this wasn't suppose to be wrapped in a count
method?
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.
I created a PR with a fix: #45939
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.
@louwie17 I'll give a look at the PR.
Submission Review Guidelines:
Changes proposed in this Pull Request:
Subset of WPCOM changes for PHP 8.1 compatibility based on the D128575-code diff.
Ref: p7H4VZ-4x1-p2
How to test the changes in this Pull Request:
The changes on this PR are based on changes currently made in WPCOM, As there are no logic changes, only compatibility with PHP 8.1, it was deemed unnecessary to include testing instructions. To put it simply, the current tests should be able to complete without any problems, and that should be sufficient.
In any case, I wanted to provide some basic testing steps in case we want to test some file changes:
plugins/woocommerce/src/Admin/API/OnboardingTasks.php
wp-admin/admin.php?page=wc-admin&task=products
plugins/woocommerce/src/Admin/API/Plugins.php
plugins/woocommerce/src/Admin/API/Reports/Categories/DataStore.php
plugins/woocommerce/src/Admin/API/Reports/Coupons/Stats/Segmenter.php
plugins/woocommerce/src/Admin/API/Reports/Orders/Stats/Segmenter.php
plugins/woocommerce/src/Admin/API/Reports/Products/Stats/Segmenter.php
plugins/woocommerce/src/Admin/API/Reports/Segmenter.php
count
plugins/woocommerce/src/Admin/API/Reports/Taxes/DataStore.php
plugins/woocommerce/src/Admin/API/Reports/Taxes/Stats/DataStore.php
plugins/woocommerce/src/Admin/API/Reports/TimeInterval.php
plugins/woocommerce/src/Admin/API/Reports/Variations/Stats/Segmenter.php
plugins/woocommerce/src/Admin/API/Themes.php
wc-admin/themes
REST route.plugins/woocommerce/src/Admin/PageController.php
plugins/woocommerce/src/Admin/RemoteInboxNotifications/PluginsActivatedRuleProcessor.php
count
plugins/woocommerce/src/Admin/RemoteInboxNotifications/RemoteInboxNotificationsEngine.php
count
plugins/woocommerce/src/Admin/RemoteInboxNotifications/SpecRunner.php
count
Changelog entry
Significance
Type
Message
Comment