1
1
<?php
2
+ declare (strict_types=1 );
2
3
/**
3
- * Contains \JamesIArmes\PhpNtlm\NTLMSoapClient.
4
+ * Contains \JamesIArmes\PhpNtlm\NTLMSoapClient
4
5
*/
5
6
6
7
namespace jamesiarmes \PhpNtlm ;
7
8
9
+ use CurlHandle ;
10
+
8
11
/**
9
12
* Soap Client using Microsoft's NTLM Authentication.
10
13
*
@@ -15,18 +18,27 @@ class SoapClient extends \SoapClient
15
18
/**
16
19
* cURL resource used to make the SOAP request
17
20
*
18
- * @var resource
21
+ * @var resource|false|CurlHandle
19
22
*/
20
23
protected $ ch ;
21
24
22
25
/**
23
26
* Options passed to the client constructor.
24
- *
25
- * @var array
26
27
*/
27
- protected $ options ;
28
+ protected array $ options ;
28
29
29
- /**
30
+ private string $ __last_request ;
31
+
32
+ /**
33
+ * @var string[]
34
+ */
35
+ private array $ __last_request_headers ;
36
+
37
+ private string |false $ __last_response ;
38
+
39
+ private string |false $ __last_response_headers ;
40
+
41
+ /**
30
42
* {@inheritdoc}
31
43
*
32
44
* Additional options:
@@ -43,7 +55,7 @@ class SoapClient extends \SoapClient
43
55
* characters are stripped. This has no affect unless strip_bad_chars is
44
56
* true.
45
57
*/
46
- public function __construct ($ wsdl , array $ options = [])
58
+ public function __construct (? string $ wsdl , array $ options = [])
47
59
{
48
60
// Set missing indexes to their default value.
49
61
$ options += array (
@@ -68,8 +80,8 @@ public function __construct($wsdl, array $options = [])
68
80
/**
69
81
* {@inheritdoc}
70
82
*/
71
- public function __doRequest ($ request , $ location , $ action , $ version , $ one_way = 0 )
72
- {
83
+ public function __doRequest (string $ request , string $ location , string $ action , int $ version , bool $ oneWay = false ): ? string
84
+ {
73
85
$ headers = $ this ->buildHeaders ($ action );
74
86
$ this ->__last_request = $ request ;
75
87
$ this ->__last_request_headers = $ headers ;
@@ -103,21 +115,19 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
103
115
/**
104
116
* {@inheritdoc}
105
117
*/
106
- public function __getLastRequestHeaders ()
107
- {
118
+ public function __getLastRequestHeaders (): ? string
119
+ {
108
120
return implode ("\n" , $ this ->__last_request_headers ) . "\n" ;
109
121
}
110
122
111
123
/**
112
124
* Returns the response code from the last request
113
125
*
114
- * @return integer
115
- *
116
126
* @throws \BadMethodCallException
117
127
* If no cURL resource has been initialized.
118
128
*/
119
- public function getResponseCode ()
120
- {
129
+ public function getResponseCode (): int
130
+ {
121
131
if (empty ($ this ->ch )) {
122
132
throw new \BadMethodCallException ('No cURL resource has been '
123
133
. 'initialized. This is probably because no request has not '
@@ -129,12 +139,9 @@ public function getResponseCode()
129
139
130
140
/**
131
141
* Builds the headers for the request.
132
- *
133
- * @param string $action
134
- * The SOAP action to be performed.
135
142
*/
136
- protected function buildHeaders ($ action )
137
- {
143
+ protected function buildHeaders (string $ action ): array
144
+ {
138
145
return array (
139
146
'Method: POST ' ,
140
147
'Connection: Keep-Alive ' ,
@@ -178,16 +185,9 @@ protected function cleanResponse()
178
185
179
186
/**
180
187
* Builds an array of curl options for the request
181
- *
182
- * @param string $action
183
- * The SOAP action to be performed.
184
- * @param string $request
185
- * The XML SOAP request.
186
- * @return array
187
- * Array of curl options.
188
188
*/
189
- protected function curlOptions ($ action , $ request )
190
- {
189
+ protected function curlOptions (string $ action , string $ request ): array
190
+ {
191
191
$ options = $ this ->options ['curlopts ' ] + array (
192
192
CURLOPT_SSL_VERIFYPEER => true ,
193
193
CURLOPT_RETURNTRANSFER => true ,
@@ -212,7 +212,7 @@ protected function curlOptions($action, $request)
212
212
* @param string $response
213
213
* The response from the cURL request, including headers and body.
214
214
*/
215
- public function parseResponse ($ response )
215
+ public function parseResponse (string $ response )
216
216
{
217
217
// Parse the response and set the last response and headers.
218
218
$ info = curl_getinfo ($ this ->ch );
0 commit comments