From 7b38c7300b1f94edd660f5789e391b0bcdc78dc4 Mon Sep 17 00:00:00 2001 From: Gregory K Date: Fri, 29 Nov 2013 13:50:31 -0500 Subject: [PATCH] Inconsistent return types: mostly TODOs, some fixes --- .../abstracts/abstract-wc-payment-gateway.php | 1 + includes/abstracts/abstract-wc-product.php | 4 ++++ .../admin/class-wc-admin-duplicate-product.php | 1 + .../class-wc-admin-cpt-shop_order.php | 4 ++-- .../reports/class-wc-report-customer-list.php | 2 ++ includes/admin/wc-admin-functions.php | 1 + includes/class-wc-order.php | 2 +- includes/class-wc-product-variation.php | 1 + includes/class-wc-query.php | 17 +++++++++-------- includes/class-wc-shipping.php | 3 +-- includes/wc-coupon-functions.php | 1 + includes/wc-order-functions.php | 3 ++- includes/wc-page-functions.php | 5 +++-- includes/wc-template-functions.php | 8 +++++--- 14 files changed, 34 insertions(+), 19 deletions(-) diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index 222023841bb..9f81081d22d 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -77,6 +77,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { if ( $this->enabled == "yes" ) { return true; } + /** @todo [tivnet] Rewrite as return( $this->enabled === 'yes' ) */ } /** diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 37b308ecbd6..65633e02796 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -157,6 +157,7 @@ class WC_Product { */ public function set_stock( $amount = null ) { if ( is_null( $amount ) ) { + /** @todo [tivnet] return 0; */ return; } @@ -184,6 +185,8 @@ class WC_Product { return $this->get_stock_quantity(); } + + /** @todo [tivnet] return 0; */ } /** @@ -1044,6 +1047,7 @@ class WC_Product { return $rating_html; } + /** @todo [tivnet] return ''; */ } diff --git a/includes/admin/class-wc-admin-duplicate-product.php b/includes/admin/class-wc-admin-duplicate-product.php index d8be4cbd31e..4345c24a83b 100644 --- a/includes/admin/class-wc-admin-duplicate-product.php +++ b/includes/admin/class-wc-admin-duplicate-product.php @@ -48,6 +48,7 @@ class WC_Admin_Duplicate_Product { /** * Show the dupe product link in admin + * @todo [tivnet] $actions is undefined. */ public function dupe_button() { global $post; diff --git a/includes/admin/post-types/class-wc-admin-cpt-shop_order.php b/includes/admin/post-types/class-wc-admin-cpt-shop_order.php index c461bb00c9b..80565a896ce 100644 --- a/includes/admin/post-types/class-wc-admin-cpt-shop_order.php +++ b/includes/admin/post-types/class-wc-admin-cpt-shop_order.php @@ -509,12 +509,12 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT { * * @access public * @param WP_Query $wp - * @return WP_Query - * @todo Note: this is called via do_action_ref_array, so return $wp is probably wrong. + * @return void */ public function shop_order_search_custom_fields( $wp ) { global $pagenow, $wpdb; + /** @todo [tivnet] Note: this is called via do_action_ref_array, so return $wp is wrong. */ if ( 'edit.php' != $pagenow || empty( $wp->query_vars['s'] ) || $wp->query_vars['post_type'] != 'shop_order' ) return $wp; diff --git a/includes/admin/reports/class-wc-report-customer-list.php b/includes/admin/reports/class-wc-report-customer-list.php index 90dbf1a7013..dfd099e5819 100644 --- a/includes/admin/reports/class-wc-report-customer-list.php +++ b/includes/admin/reports/class-wc-report-customer-list.php @@ -61,8 +61,10 @@ class WC_Report_Customer_List extends WP_List_Table { * @param mixed $user * @param string $column_name * @return int|string + * @todo [tivnet] Inconsistent return types, and void return at the end */ function column_default( $user, $column_name ) { + /** @todo [tivnet] Remove $woocommerce */ global $woocommerce, $wpdb; switch( $column_name ) { diff --git a/includes/admin/wc-admin-functions.php b/includes/admin/wc-admin-functions.php index f51d4dc3d44..464219f5ce7 100644 --- a/includes/admin/wc-admin-functions.php +++ b/includes/admin/wc-admin-functions.php @@ -47,6 +47,7 @@ function wc_get_screen_ids() { * @param string $page_content (default: '') Content for the new page * @param int $post_parent (default: 0) Parent for the new page * @return int page ID + * @todo [tivnet] return; is wrong here. int expected. return 0; instead ? */ function wc_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { global $wpdb; diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index 9dce6830b19..b44178c5650 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -612,7 +612,7 @@ class WC_Order { * * @deprecated As of 2.1, use of get_total() is preferred * @access public - * @return void + * @return float */ public function get_order_total() { _deprecated_function( 'get_order_total', '2.1', 'get_total' ); diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index b25ff626884..39487b5f8db 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -76,6 +76,7 @@ class WC_Product_Variation extends WC_Product { $this->id = ! empty( $args['parent_id'] ) ? intval( $args['parent_id'] ) : wp_get_post_parent_id( $this->variation_id ); // The post doesn't have a parent id, therefore its invalid. + /** @todo [tivnet] This is a void function. Just return; */ if ( empty( $this->id ) ) return false; diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index 457918f46dd..77b9d73887e 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -46,7 +46,6 @@ class WC_Query { * Constructor for the query class. Hooks in methods. * * @access public - * @return void */ public function __construct() { add_action( 'init', array( $this, 'add_endpoints' ) ); @@ -106,7 +105,8 @@ class WC_Query { * add_query_vars function. * * @access public - * @return void + * @param array $vars + * @return array */ public function add_query_vars( $vars ) { foreach ( $this->query_vars as $key => $var ) @@ -250,8 +250,8 @@ class WC_Query { * wpseo_metadesc function. * * @access public - * @param mixed $meta - * @return void + * @return string + * @todo [tivnet] Need to check if ( function_exists( 'wpseo_get_value' ) ), and if not then return '' */ public function wpseo_metadesc() { return wpseo_get_value( 'metadesc', wc_get_page_id('shop') ); @@ -262,7 +262,8 @@ class WC_Query { * wpseo_metakey function. * * @access public - * @return void + * @return string + * @todo [tivnet] Need to check if ( function_exists( 'wpseo_get_value' ) ), and if not then return '' */ public function wpseo_metakey() { return wpseo_get_value( 'metakey', wc_get_page_id('shop') ); @@ -273,9 +274,9 @@ class WC_Query { * Hook into the_posts to do the main product query if needed - relevanssi compatibility * * @access public - * @param mixed $posts - * @param bool $query (default: false) - * @return void + * @param array $posts + * @param WP_Query|bool $query (default: false) + * @return array */ public function the_posts( $posts, $query = false ) { // Abort if there's no query diff --git a/includes/class-wc-shipping.php b/includes/class-wc-shipping.php index 12579a4df5e..a6f82756959 100644 --- a/includes/class-wc-shipping.php +++ b/includes/class-wc-shipping.php @@ -201,8 +201,7 @@ class WC_Shipping { * Returns all registered shipping methods for usage. * * @access public - * @param mixed $package - * @return void + * @return array */ public function get_shipping_methods() { return $this->shipping_methods; diff --git a/includes/wc-coupon-functions.php b/includes/wc-coupon-functions.php index 05b8cf6c301..9df7724f90b 100644 --- a/includes/wc-coupon-functions.php +++ b/includes/wc-coupon-functions.php @@ -31,6 +31,7 @@ function wc_get_coupon_types() { * * @param string $type (default: '') * @return string + * @todo [tivnet] Return empty string at the end of function */ function wc_get_coupon_type( $type = '' ) { $types = wc_get_coupon_types(); diff --git a/includes/wc-order-functions.php b/includes/wc-order-functions.php index 0f09b7f1018..176db75f6a3 100644 --- a/includes/wc-order-functions.php +++ b/includes/wc-order-functions.php @@ -35,11 +35,12 @@ function wc_get_order_id_by_order_key( $order_key ) { * @param string $download_id file identifier * @param int $product_id product identifier * @param WC_Order $order the order - * @return int insert id | bool false on failure + * @return int|bool insert id or false on failure */ function wc_downloadable_file_permission( $download_id, $product_id, $order ) { global $wpdb; + /** @todo [tivnet] return false; */ if ( $order->status == 'processing' && get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'no' ) return; diff --git a/includes/wc-page-functions.php b/includes/wc-page-functions.php index 004b814478a..b83e51ca531 100644 --- a/includes/wc-page-functions.php +++ b/includes/wc-page-functions.php @@ -61,8 +61,9 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { * Returns the url to the lost password endpoint url * * @access public - * @param mixed $url - * @return void + * @param string $url + * @return string + * @todo [tivnet] $url is unused. Remove it and add ...10, 0); to the add_filter */ function wc_lostpassword_url( $url ) { return wc_get_endpoint_url( 'lost-password', '', get_permalink( wc_get_page_id( 'myaccount' ) ) ); diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 135f98fdc41..dd229ed0e2a 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -953,8 +953,8 @@ if ( ! function_exists( 'woocommerce_default_product_tabs' ) ) { * Add default product tabs to product pages. * * @access public - * @param mixed $tabs - * @return void + * @param array $tabs + * @return array */ function woocommerce_default_product_tabs( $tabs = array() ) { global $product, $post; @@ -1528,6 +1528,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) { * @param mixed $args * @param string $value (default: null) * @return void + * @todo [tivnet] Set ob_start at the beginning and return ob_get_clean at the end if $args['return'] or echo if not */ function woocommerce_form_field( $key, $args, $value = null ) { $defaults = array( @@ -1748,7 +1749,8 @@ if ( ! function_exists( 'get_product_search_form' ) ) { * @access public * @subpackage Forms * @param bool $echo (default: true) - * @return void + * @return string + * @todo [tivnet] Return '' for consistency, or always echo */ function get_product_search_form( $echo = true ) { do_action( 'get_product_search_form' );