@@ -55,7 +55,7 @@ abstract class AbstractApi
5555 /**
5656 * PHP API version
5757 */
58- const PHP_API_VERSION = '3.5.0 ' ;
58+ const PHP_API_VERSION = '3.5.1 ' ;
5959
6060 /**
6161 * Event dispatcher
@@ -128,7 +128,7 @@ abstract protected function configureOptions(OptionsResolver $resolver);
128128 * @param Request $request
129129 * @param ResponseInterface $response
130130 *
131- * @return AbstractResponse|string|array <Transaction>
131+ * @return AbstractResponse|string|list <Transaction>
132132 */
133133 abstract protected function handleResponse (Request $ request , ResponseInterface $ response );
134134
@@ -157,7 +157,7 @@ public function __construct(Authentication $authentication)
157157 /**
158158 * Generate the response
159159 *
160- * @return AbstractResponse|string|array <Transaction>
160+ * @return AbstractResponse|string|list <Transaction>
161161 * @throws GuzzleException
162162 * @throws ResponseHeaderException
163163 * @throws ResponseMessageException
@@ -233,7 +233,9 @@ protected function doConfigureOptions()
233233 $ this ->setCustomerInfoResolver ($ resolver );
234234 $ this ->setValidationUrlResolver ($ resolver );
235235 $ this ->setAppleDomainResolver ($ resolver );
236- $ this ->options = $ resolver ->resolve ($ this ->unresolvedOptions );
236+ /** @var array<string, mixed> */
237+ $ options = $ resolver ->resolve ($ this ->unresolvedOptions );
238+ $ this ->options = $ options ;
237239 }
238240
239241 /**
@@ -253,13 +255,13 @@ protected function validateResponse($response)
253255 }
254256
255257 if (property_exists ($ response , 'MerchantErrorMessage ' )) {
256- if ($ response ->MerchantErrorMessage ) {
258+ if ($ response ->MerchantErrorMessage && is_string ( $ response -> MerchantErrorMessage ) ) {
257259 throw new Exceptions \ResponseMessageException ($ response ->MerchantErrorMessage );
258260 }
259261 }
260262
261263 if (property_exists ($ response , 'CardHolderErrorMessage ' ) && property_exists ($ response , 'CardHolderMessageMustBeShown ' )) {
262- if ($ response ->CardHolderMessageMustBeShown ) {
264+ if ($ response ->CardHolderMessageMustBeShown && is_string ( $ response -> CardHolderErrorMessage ) ) {
263265 throw new Exceptions \ResponseMessageException ($ response ->CardHolderErrorMessage );
264266 }
265267 }
@@ -268,7 +270,7 @@ protected function validateResponse($response)
268270 /**
269271 * Generate the response
270272 *
271- * @return AbstractResponse|string|array <Transaction>
273+ * @return AbstractResponse|string|list <Transaction>
272274 * @throws GuzzleException
273275 * @throws ClientException
274276 * @throws ResponseHeaderException
@@ -318,7 +320,7 @@ protected function parseUrl()
318320 /**
319321 * Get User Agent details
320322 *
321- * @return string
323+ * @return ? string
322324 */
323325 protected function getUserAgent ()
324326 {
@@ -328,14 +330,14 @@ protected function getUserAgent()
328330 $ userAgent = 'api-php/ ' . self ::PHP_API_VERSION ;
329331 if (extension_loaded ('curl ' ) && function_exists ('curl_version ' )) {
330332 $ curlInfo = \curl_version ();
331- if (is_array ($ curlInfo ) && array_key_exists ("version " , $ curlInfo )) {
333+ if (is_array ($ curlInfo ) && array_key_exists ("version " , $ curlInfo ) && is_string ( $ curlInfo [ " version " ]) ) {
332334 $ userAgent .= ' curl/ ' . $ curlInfo ["version " ];
333335 }
334336 }
335337 $ userAgent .= ' PHP/ ' . PHP_VERSION ;
336338 }
337339
338- return $ userAgent ;
340+ return is_string ( $ userAgent) ? $ userAgent : null ;
339341 }
340342
341343 /**
@@ -380,7 +382,10 @@ protected function getBasicHeaders()
380382 );
381383 }
382384
383- $ headers ['User-Agent ' ] = $ this ->getUserAgent ();
385+ $ userAgen = $ this ->getUserAgent ();
386+ if ($ userAgen ) {
387+ $ headers ['User-Agent ' ] = $ userAgen ;
388+ }
384389
385390 return $ headers ;
386391 }
0 commit comments