Skip to content

Commit

Permalink
Inconsistent return types: mostly TODOs, some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tivnet committed Nov 29, 2013
1 parent 676330d commit 7b38c73
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions includes/abstracts/abstract-wc-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function is_available() {
if ( $this->enabled == "yes" ) {
return true;
}
/** @todo [tivnet] Rewrite as return( $this->enabled === 'yes' ) */
}

/**
Expand Down
4 changes: 4 additions & 0 deletions includes/abstracts/abstract-wc-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function get_total_stock() {
*/
public function set_stock( $amount = null ) {
if ( is_null( $amount ) ) {
/** @todo [tivnet] return 0; */
return;
}

Expand Down Expand Up @@ -184,6 +185,8 @@ public function set_stock( $amount = null ) {

return $this->get_stock_quantity();
}

/** @todo [tivnet] return 0; */
}

/**
Expand Down Expand Up @@ -1044,6 +1047,7 @@ public function get_rating_html( $rating = null ) {

return $rating_html;
}
/** @todo [tivnet] return ''; */
}


Expand Down
1 change: 1 addition & 0 deletions includes/admin/class-wc-admin-duplicate-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function dupe_link( $actions, $post ) {

/**
* Show the dupe product link in admin
* @todo [tivnet] $actions is undefined.
*/
public function dupe_button() {
global $post;
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/post-types/class-wc-admin-cpt-shop_order.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,12 @@ public function custom_shop_order_orderby( $vars ) {
*
* @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;

Expand Down
2 changes: 2 additions & 0 deletions includes/admin/reports/class-wc-report-customer-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ public function output_report() {
* @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 ) {
Expand Down
1 change: 1 addition & 0 deletions includes/admin/wc-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public function get_shipping() {
*
* @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' );
Expand Down
1 change: 1 addition & 0 deletions includes/class-wc-product-variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function __construct( $variation, $args = array() ) {
$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;

Expand Down
17 changes: 9 additions & 8 deletions includes/class-wc-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -106,7 +105,8 @@ public function add_endpoints() {
* 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 )
Expand Down Expand Up @@ -250,8 +250,8 @@ public function exclude_protected_products( $where ) {
* 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') );
Expand All @@ -262,7 +262,8 @@ public function wpseo_metadesc() {
* 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') );
Expand All @@ -273,9 +274,9 @@ public function wpseo_metakey() {
* 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
Expand Down
3 changes: 1 addition & 2 deletions includes/class-wc-shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ public function sort_shipping_methods() {
* 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;
Expand Down
1 change: 1 addition & 0 deletions includes/wc-coupon-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion includes/wc-order-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions includes/wc-page-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) );
Expand Down
8 changes: 5 additions & 3 deletions includes/wc-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ function woocommerce_product_reviews_tab() {
* 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;
Expand Down Expand Up @@ -1528,6 +1528,7 @@ function woocommerce_order_again_button( $order ) {
* @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(
Expand Down Expand Up @@ -1748,7 +1749,8 @@ function woocommerce_form_field( $key, $args, $value = null ) {
* @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' );
Expand Down

0 comments on commit 7b38c73

Please sign in to comment.