Merge pull request #4252 from tivnet/master

Inconsistent return types: mostly TODOs, some fixes
This commit is contained in:
Coen Jacobs 2013-12-02 03:06:03 -08:00
commit 39592c1c5c
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" ) { if ( $this->enabled == "yes" ) {
return true; 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 ) { public function set_stock( $amount = null ) {
if ( is_null( $amount ) ) { if ( is_null( $amount ) ) {
/** @todo [tivnet] return 0; */
return; return;
} }
@ -184,6 +185,8 @@ class WC_Product {
return $this->get_stock_quantity(); return $this->get_stock_quantity();
} }
/** @todo [tivnet] return 0; */
} }
/** /**
@ -1044,6 +1047,7 @@ class WC_Product {
return $rating_html; return $rating_html;
} }
/** @todo [tivnet] return ''; */
} }

View File

@ -48,6 +48,7 @@ class WC_Admin_Duplicate_Product {
/** /**
* Show the dupe product link in admin * Show the dupe product link in admin
* @todo [tivnet] $actions is undefined.
*/ */
public function dupe_button() { public function dupe_button() {
global $post; global $post;

View File

@ -509,12 +509,12 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT {
* *
* @access public * @access public
* @param WP_Query $wp * @param WP_Query $wp
* @return WP_Query * @return void
* @todo Note: this is called via do_action_ref_array, so return $wp is probably wrong.
*/ */
public function shop_order_search_custom_fields( $wp ) { public function shop_order_search_custom_fields( $wp ) {
global $pagenow, $wpdb; 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' ) if ( 'edit.php' != $pagenow || empty( $wp->query_vars['s'] ) || $wp->query_vars['post_type'] != 'shop_order' )
return $wp; return $wp;

View File

@ -61,8 +61,10 @@ class WC_Report_Customer_List extends WP_List_Table {
* @param mixed $user * @param mixed $user
* @param string $column_name * @param string $column_name
* @return int|string * @return int|string
* @todo [tivnet] Inconsistent return types, and void return at the end
*/ */
function column_default( $user, $column_name ) { function column_default( $user, $column_name ) {
/** @todo [tivnet] Remove $woocommerce */
global $woocommerce, $wpdb; global $woocommerce, $wpdb;
switch( $column_name ) { 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 string $page_content (default: '') Content for the new page
* @param int $post_parent (default: 0) Parent for the new page * @param int $post_parent (default: 0) Parent for the new page
* @return int page ID * @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 ) { function wc_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
global $wpdb; global $wpdb;

View File

@ -612,7 +612,7 @@ class WC_Order {
* *
* @deprecated As of 2.1, use of get_total() is preferred * @deprecated As of 2.1, use of get_total() is preferred
* @access public * @access public
* @return void * @return float
*/ */
public function get_order_total() { public function get_order_total() {
_deprecated_function( 'get_order_total', '2.1', 'get_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 ); $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. // The post doesn't have a parent id, therefore its invalid.
/** @todo [tivnet] This is a void function. Just return; */
if ( empty( $this->id ) ) if ( empty( $this->id ) )
return false; return false;

View File

@ -46,7 +46,6 @@ class WC_Query {
* Constructor for the query class. Hooks in methods. * Constructor for the query class. Hooks in methods.
* *
* @access public * @access public
* @return void
*/ */
public function __construct() { public function __construct() {
add_action( 'init', array( $this, 'add_endpoints' ) ); add_action( 'init', array( $this, 'add_endpoints' ) );
@ -106,7 +105,8 @@ class WC_Query {
* add_query_vars function. * add_query_vars function.
* *
* @access public * @access public
* @return void * @param array $vars
* @return array
*/ */
public function add_query_vars( $vars ) { public function add_query_vars( $vars ) {
foreach ( $this->query_vars as $key => $var ) foreach ( $this->query_vars as $key => $var )
@ -250,8 +250,8 @@ class WC_Query {
* wpseo_metadesc function. * wpseo_metadesc function.
* *
* @access public * @access public
* @param mixed $meta * @return string
* @return void * @todo [tivnet] Need to check if ( function_exists( 'wpseo_get_value' ) ), and if not then return ''
*/ */
public function wpseo_metadesc() { public function wpseo_metadesc() {
return wpseo_get_value( 'metadesc', wc_get_page_id('shop') ); return wpseo_get_value( 'metadesc', wc_get_page_id('shop') );
@ -262,7 +262,8 @@ class WC_Query {
* wpseo_metakey function. * wpseo_metakey function.
* *
* @access public * @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() { public function wpseo_metakey() {
return wpseo_get_value( 'metakey', wc_get_page_id('shop') ); 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 * Hook into the_posts to do the main product query if needed - relevanssi compatibility
* *
* @access public * @access public
* @param mixed $posts * @param array $posts
* @param bool $query (default: false) * @param WP_Query|bool $query (default: false)
* @return void * @return array
*/ */
public function the_posts( $posts, $query = false ) { public function the_posts( $posts, $query = false ) {
// Abort if there's no query // Abort if there's no query

View File

@ -201,8 +201,7 @@ class WC_Shipping {
* Returns all registered shipping methods for usage. * Returns all registered shipping methods for usage.
* *
* @access public * @access public
* @param mixed $package * @return array
* @return void
*/ */
public function get_shipping_methods() { public function get_shipping_methods() {
return $this->shipping_methods; return $this->shipping_methods;

View File

@ -31,6 +31,7 @@ function wc_get_coupon_types() {
* *
* @param string $type (default: '') * @param string $type (default: '')
* @return string * @return string
* @todo [tivnet] Return empty string at the end of function
*/ */
function wc_get_coupon_type( $type = '' ) { function wc_get_coupon_type( $type = '' ) {
$types = wc_get_coupon_types(); $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 string $download_id file identifier
* @param int $product_id product identifier * @param int $product_id product identifier
* @param WC_Order $order the order * @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 ) { function wc_downloadable_file_permission( $download_id, $product_id, $order ) {
global $wpdb; global $wpdb;
/** @todo [tivnet] return false; */
if ( $order->status == 'processing' && get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'no' ) if ( $order->status == 'processing' && get_option( 'woocommerce_downloads_grant_access_after_payment' ) == 'no' )
return; return;

View File

@ -61,8 +61,9 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
* Returns the url to the lost password endpoint url * Returns the url to the lost password endpoint url
* *
* @access public * @access public
* @param mixed $url * @param string $url
* @return void * @return string
* @todo [tivnet] $url is unused. Remove it and add ...10, 0); to the add_filter
*/ */
function wc_lostpassword_url( $url ) { function wc_lostpassword_url( $url ) {
return wc_get_endpoint_url( 'lost-password', '', get_permalink( wc_get_page_id( 'myaccount' ) ) ); 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. * Add default product tabs to product pages.
* *
* @access public * @access public
* @param mixed $tabs * @param array $tabs
* @return void * @return array
*/ */
function woocommerce_default_product_tabs( $tabs = array() ) { function woocommerce_default_product_tabs( $tabs = array() ) {
global $product, $post; global $product, $post;
@ -1528,6 +1528,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
* @param mixed $args * @param mixed $args
* @param string $value (default: null) * @param string $value (default: null)
* @return void * @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 ) { function woocommerce_form_field( $key, $args, $value = null ) {
$defaults = array( $defaults = array(
@ -1748,7 +1749,8 @@ if ( ! function_exists( 'get_product_search_form' ) ) {
* @access public * @access public
* @subpackage Forms * @subpackage Forms
* @param bool $echo (default: true) * @param bool $echo (default: true)
* @return void * @return string
* @todo [tivnet] Return '' for consistency, or always echo
*/ */
function get_product_search_form( $echo = true ) { function get_product_search_form( $echo = true ) {
do_action( 'get_product_search_form' ); do_action( 'get_product_search_form' );