@@ -42,53 +42,23 @@ class Client implements ClientInterface
4242 */
4343 const SSL_VERIFYHOST = 2 ;
4444
45- /**
46- * @var array
47- */
48- private static $ defaultPorts = [
45+ private static array $ defaultPorts = [
4946 'http ' => 80 ,
5047 'https ' => 443 ,
5148 ];
5249
53- /**
54- * @var int
55- */
56- private $ port ;
57-
58- /**
59- * @var string
60- */
61- private $ url ;
62-
63- /**
64- * @var string
65- */
66- private $ apikeyOrUsername ;
67-
68- /**
69- * @var string|null
70- */
71- private $ pass ;
72-
73- /**
74- * @var bool
75- */
76- private $ checkSslCertificate = false ;
77-
78- /**
79- * @var bool
80- */
81- private $ checkSslHost = false ;
82-
83- /**
84- * @var int
85- */
86- private $ sslVersion = 0 ;
87-
88- /**
89- * @var bool Flag to determine authentication method
90- */
91- private $ useHttpAuth = true ;
50+ private ?int $ port = null ;
51+ private string $ url ;
52+ private string $ apikeyOrUsername ;
53+ private ?string $ pass ;
54+ private bool $ checkSslCertificate = false ;
55+ private bool $ checkSslHost = false ;
56+ private int $ sslVersion = 0 ;
57+ private bool $ useHttpAuth = true ;
58+ private int $ responseCode = 0 ;
59+ private string $ responseContentType = '' ;
60+ private string $ responseBody = '' ;
61+ private array $ curlOptions = [];
9262
9363 /**
9464 * @var string|null username for impersonating API calls
@@ -100,30 +70,10 @@ class Client implements ClientInterface
10070 */
10171 protected $ customHost = null ;
10272
103- /**
104- * @var int|null Redmine response code, null if request is not still completed
105- */
106- private $ responseCode = null ;
107-
108- /**
109- * @var string Redmine response content type
110- */
111- private $ responseContentType = '' ;
112-
113- /**
114- * @var string Redmine response body
115- */
116- private $ responseBody = '' ;
117-
118- /**
119- * @var array cURL options
120- */
121- private $ curlOptions = [];
122-
12373 /**
12474 * Error strings if json is invalid.
12575 */
126- private static $ jsonErrors = [
76+ private static array $ jsonErrors = [
12777 JSON_ERROR_NONE => 'No error has occurred ' ,
12878 JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded ' ,
12979 JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded ' ,
@@ -142,7 +92,7 @@ public function __construct($url, $apikeyOrUsername, $pass = null)
14292 {
14393 $ this ->url = $ url ;
14494 $ this ->getPort ();
145- $ this ->apikeyOrUsername = $ apikeyOrUsername ;
95+ $ this ->apikeyOrUsername = strval ( $ apikeyOrUsername) ;
14696 $ this ->pass = $ pass ;
14797 }
14898
@@ -364,12 +314,7 @@ public function getCheckSslCertificate()
364314 */
365315 public function setCheckSslHost ($ check = false )
366316 {
367- // Make sure verify value is set to "2" for boolean argument
368- // @see http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
369- if (true === $ check ) {
370- $ check = self ::SSL_VERIFYHOST ;
371- }
372- $ this ->checkSslHost = $ check ;
317+ $ this ->checkSslHost = (bool ) $ check ;
373318
374319 return $ this ;
375320 }
@@ -599,7 +544,7 @@ public function getCurlOptions()
599544 */
600545 public function prepareRequest ($ path , $ method = 'GET ' , $ data = '' )
601546 {
602- $ this ->responseCode = null ;
547+ $ this ->responseCode = 0 ;
603548 $ this ->responseContentType = '' ;
604549 $ this ->responseBody = '' ;
605550 $ curl = curl_init ();
@@ -624,7 +569,9 @@ public function prepareRequest($path, $method = 'GET', $data = '')
624569 $ this ->setCurlOption (CURLOPT_PORT , $ this ->getPort ());
625570 if (80 !== $ this ->getPort ()) {
626571 $ this ->setCurlOption (CURLOPT_SSL_VERIFYPEER , (int ) $ this ->checkSslCertificate );
627- $ this ->setCurlOption (CURLOPT_SSL_VERIFYHOST , (int ) $ this ->checkSslHost );
572+ // Make sure verify value is set to "2" for boolean argument
573+ // @see http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
574+ $ this ->setCurlOption (CURLOPT_SSL_VERIFYHOST , ($ this ->checkSslHost === true ) ? self ::SSL_VERIFYHOST : 0 );
628575 $ this ->setCurlOption (CURLOPT_SSLVERSION , $ this ->sslVersion );
629576 }
630577
0 commit comments