| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Pronamic\WordPress\Pay\Gateways\TargetPay; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Title: TargetPay integration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * Description: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Copyright: 2005-2019 Pronamic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Company: Pronamic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @author  Remco Tolsma | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @version 2.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @since   1.0.0 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | class Integration extends AbstractIntegration { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 		$this->id            = 'targetpay-ideal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		$this->name          = 'TargetPay - iDEAL'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		$this->product_url   = __( 'https://www.targetpay.com/info/ideal?setlang=en', 'pronamic_ideal' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		$this->dashboard_url = 'https://www.targetpay.com/login'; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 23 |  |  | 		$this->provider      = 'targetpay'; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 	 * Get settings fields. | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 	 * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 	public function get_settings_fields() { | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 		$fields = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 		// Intro. | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 		$fields[] = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 			'section' => 'general', | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 			'type'    => 'html', | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 			'html'    => sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 				/* translators: 1: TargetPay */ | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 				__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 				__( 'TargetPay', 'pronamic_ideal' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 		// Layout Code. | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 		$fields[] = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 			'section'  => 'general', | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 			'filter'   => FILTER_SANITIZE_STRING, | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 			'meta_key' => '_pronamic_gateway_targetpay_layoutcode', | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | 			'title'    => __( 'Layout Code', 'pronamic_ideal' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 			'type'     => 'text', | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 			'tooltip'  => __( 'Layout code as mentioned at <strong>Sub accounts</strong> in the TargetPay dashboard.', 'pronamic_ideal' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 		return $fields; | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	public function get_config( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$config = new Config(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		$config->layoutcode = get_post_meta( $post_id, '_pronamic_gateway_targetpay_layoutcode', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		$config->mode       = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  | 		return $config; | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 	 * Get gateway. | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	 * @param int $post_id Post ID. | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 	 * @return Gateway | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	public function get_gateway( $post_id ) { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  | 		return new Gateway( $this->get_config( $post_id ) ); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 75 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 76 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |  | 
            
                        
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.