| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | 	exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * Cart Fees API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * Fees are additional costs added to orders. Implemtns Iterator for backwards compatibility. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @class 		WC_Cart_Fees | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @version		2.7.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package		WooCommerce/Classes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @category	Class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @author 		WooThemes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class WC_Cart_Fees implements Iterator { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 * An array of fee objects. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 * @var object[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	private $fees = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * Iterator Position. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * @var integer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	private $position = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * Constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$this->position = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	 * Rewind Iterator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	public function rewind() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		$this->position = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * Current Iterator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	public function current() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		return $this->fees[ $this->position ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	 * Key Iterator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	public function key() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		return $this->position; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	 * Next Iterator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	public function next() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		++$this->position; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 * Valid Iterator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	public function valid() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		return isset( $this->fees[ $this->position ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * Allow 3rd parties to calculate and register fees. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 75 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  | 	public function calculate_fees() { | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  | 		// Remove any existing fees. | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  | 		$this->set_fees( false ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  | 		// Fire an action where developers can add their fees | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 		do_action( 'woocommerce_cart_calculate_fees', WC()->cart ); | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 		// Return fees | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  | 		return $this->get_fees(); | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	 * Generate a unique ID for the fee being added. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * @param string $fee Fee name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * @return string fee key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	public function generate_key( $fee ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		return sanitize_title( $fee ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	 * Get fees. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	public function get_fees() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		return $this->fees; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * Set fees. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 * @param object[] $value Array of fees. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	public function set_fees( $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		$this->fees = array_filter( (array) $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 112 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 113 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: