Apply Rector suggestions for PHP 8.1 (#43229)
* Apply Rector suggestions * Add changelog entry * Update changelog entry * Fix PHP Lint errors
This commit is contained in:
parent
32282a00ce
commit
5b6897e690
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Apply type checks and instantiate arrays before assignment
|
|
@ -180,15 +180,15 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
|
||||||
$limit = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
|
$limit = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
||||||
if ( ! empty( $items['create'] ) ) {
|
if ( ! empty( $items['create'] ) && is_countable( $items['create'] ) ) {
|
||||||
$total += count( $items['create'] );
|
$total += count( $items['create'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $items['update'] ) ) {
|
if ( ! empty( $items['update'] ) && is_countable( $items['update'] ) ) {
|
||||||
$total += count( $items['update'] );
|
$total += count( $items['update'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $items['delete'] ) ) {
|
if ( ! empty( $items['delete'] ) && is_countable( $items['delete'] ) ) {
|
||||||
$total += count( $items['delete'] );
|
$total += count( $items['delete'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
||||||
*/
|
*/
|
||||||
public function get_items( $request ) {
|
public function get_items( $request ) {
|
||||||
$currencies = get_woocommerce_currencies();
|
$currencies = get_woocommerce_currencies();
|
||||||
|
$data = array();
|
||||||
foreach ( array_keys( $currencies ) as $code ) {
|
foreach ( array_keys( $currencies ) as $code ) {
|
||||||
$currency = $this->get_currency( $code, $request );
|
$currency = $this->get_currency( $code, $request );
|
||||||
$response = $this->prepare_item_for_response( $currency, $request );
|
$response = $this->prepare_item_for_response( $currency, $request );
|
||||||
|
|
|
@ -735,6 +735,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
||||||
* @return array|WP_Error $prepared_review
|
* @return array|WP_Error $prepared_review
|
||||||
*/
|
*/
|
||||||
protected function prepare_item_for_database( $request ) {
|
protected function prepare_item_for_database( $request ) {
|
||||||
|
$prepared_review = array();
|
||||||
if ( isset( $request['id'] ) ) {
|
if ( isset( $request['id'] ) ) {
|
||||||
$prepared_review['comment_ID'] = (int) $request['id'];
|
$prepared_review['comment_ID'] = (int) $request['id'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue