Inconsistent return types: mostly TODOs, some fixes

This commit is contained in:
Gregory K 2013-11-29 13:50:31 -05:00
parent 676330de2a
commit 7b38c7300b
14 changed files with 34 additions and 19 deletions

View File

@ -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' ) */
}
/**

View File

@ -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 ''; */
}

View File

@ -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;

View File

@ -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;

View File

@ -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 ) {

View File

@ -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;

View File

@ -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' );

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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' ) ) );

View File

@ -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' );