| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Pronamic\WordPress\Pay\Gateways\Ingenico\AbstractIntegration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Pronamic\WordPress\Pay\Gateways\Ingenico\Settings; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class Integration extends AbstractIntegration { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 	public function __construct( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		$args = wp_parse_args( $args, array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 			'id'   => 'ogone-directlink', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 			'name' => 'Ingenico/Ogone - DirectLink', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		parent::__construct( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	public function get_settings_fields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		return Settings::get_settings_fields( 'directlink' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 	public function get_config( $post_id ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | 		$config = new Config(); | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 		$config->mode                = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 		$config->psp_id              = get_post_meta( $post_id, '_pronamic_gateway_ogone_psp_id', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 		$config->hash_algorithm      = get_post_meta( $post_id, '_pronamic_gateway_ogone_hash_algorithm', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 		$config->sha_out_pass_phrase = get_post_meta( $post_id, '_pronamic_gateway_ogone_sha_out_pass_phrase', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 		$config->user_id             = get_post_meta( $post_id, '_pronamic_gateway_ogone_user_id', true ); | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 		$config->password            = get_post_meta( $post_id, '_pronamic_gateway_ogone_password', true ); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 		$config->sha_in_pass_phrase  = get_post_meta( $post_id, '_pronamic_gateway_ogone_directlink_sha_in_pass_phrase', true ); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 		$config->enabled_3d_secure   = get_post_meta( $post_id, '_pronamic_gateway_ogone_3d_secure_enabled', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 		$config->order_id            = get_post_meta( $post_id, '_pronamic_gateway_ogone_order_id', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 		$config->alias_enabled       = get_post_meta( $post_id, '_pronamic_gateway_ogone_alias_enabled', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 		$config->alias_usage         = get_post_meta( $post_id, '_pronamic_gateway_ogone_alias_usage', true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 		// API URL | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 		$is_utf8 = strcasecmp( get_bloginfo( 'charset' ), 'UTF-8' ) === 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 		switch ( $config->mode ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 			case Gateway::MODE_TEST: | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 				if ( $is_utf8 ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 					$config->api_url = DirectLink::API_TEST_UTF8_URL; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 				} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 					$config->api_url = DirectLink::API_TEST_URL; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 				break; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | 			default: | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 				if ( $is_utf8 ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 					$config->api_url = DirectLink::API_PRODUCTION_UTF8_URL; | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 				} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 					$config->api_url = DirectLink::API_PRODUCTION_URL; | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 		return $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 * Get gateway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * @param int $post_id Post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * @return Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	public function get_gateway( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		return new Gateway( $this->get_config( $post_id ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 70 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |  | 
            
                        
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.