Skip to content

Commit acf160f

Browse files
authored
Added parameter and response types to support php 8.1 (#14)
1 parent 94ce607 commit acf160f

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Ignore files created by composer.
22
composer.lock
33
vendor/
4+
.idea

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Dependencies
1212
------------
1313

1414
* Composer
15-
* PHP 5.4 or greater
15+
* PHP 8.1
1616
* cURL with NTLM support (7.23.0+ recommended)
1717

1818
Installation

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"prefer-stable": true,
1212
"require": {
13-
"php": ">=5.3.9",
13+
"php": ">=8.1",
1414
"ext-soap": "*",
1515
"ext-curl": "*"
1616
},

src/SoapClient.php

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
2+
declare(strict_types=1);
23
/**
3-
* Contains \JamesIArmes\PhpNtlm\NTLMSoapClient.
4+
* Contains \JamesIArmes\PhpNtlm\NTLMSoapClient
45
*/
56

67
namespace jamesiarmes\PhpNtlm;
78

9+
use CurlHandle;
10+
811
/**
912
* Soap Client using Microsoft's NTLM Authentication.
1013
*
@@ -15,18 +18,27 @@ class SoapClient extends \SoapClient
1518
/**
1619
* cURL resource used to make the SOAP request
1720
*
18-
* @var resource
21+
* @var resource|false|CurlHandle
1922
*/
2023
protected $ch;
2124

2225
/**
2326
* Options passed to the client constructor.
24-
*
25-
* @var array
2627
*/
27-
protected $options;
28+
protected array $options;
2829

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+
/**
3042
* {@inheritdoc}
3143
*
3244
* Additional options:
@@ -43,7 +55,7 @@ class SoapClient extends \SoapClient
4355
* characters are stripped. This has no affect unless strip_bad_chars is
4456
* true.
4557
*/
46-
public function __construct($wsdl, array $options = [])
58+
public function __construct(?string $wsdl, array $options = [])
4759
{
4860
// Set missing indexes to their default value.
4961
$options += array(
@@ -68,8 +80,8 @@ public function __construct($wsdl, array $options = [])
6880
/**
6981
* {@inheritdoc}
7082
*/
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+
{
7385
$headers = $this->buildHeaders($action);
7486
$this->__last_request = $request;
7587
$this->__last_request_headers = $headers;
@@ -103,21 +115,19 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
103115
/**
104116
* {@inheritdoc}
105117
*/
106-
public function __getLastRequestHeaders()
107-
{
118+
public function __getLastRequestHeaders(): ?string
119+
{
108120
return implode("\n", $this->__last_request_headers) . "\n";
109121
}
110122

111123
/**
112124
* Returns the response code from the last request
113125
*
114-
* @return integer
115-
*
116126
* @throws \BadMethodCallException
117127
* If no cURL resource has been initialized.
118128
*/
119-
public function getResponseCode()
120-
{
129+
public function getResponseCode(): int
130+
{
121131
if (empty($this->ch)) {
122132
throw new \BadMethodCallException('No cURL resource has been '
123133
. 'initialized. This is probably because no request has not '
@@ -129,12 +139,9 @@ public function getResponseCode()
129139

130140
/**
131141
* Builds the headers for the request.
132-
*
133-
* @param string $action
134-
* The SOAP action to be performed.
135142
*/
136-
protected function buildHeaders($action)
137-
{
143+
protected function buildHeaders(string $action): array
144+
{
138145
return array(
139146
'Method: POST',
140147
'Connection: Keep-Alive',
@@ -178,16 +185,9 @@ protected function cleanResponse()
178185

179186
/**
180187
* 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.
188188
*/
189-
protected function curlOptions($action, $request)
190-
{
189+
protected function curlOptions(string $action, string $request): array
190+
{
191191
$options = $this->options['curlopts'] + array(
192192
CURLOPT_SSL_VERIFYPEER => true,
193193
CURLOPT_RETURNTRANSFER => true,
@@ -212,7 +212,7 @@ protected function curlOptions($action, $request)
212212
* @param string $response
213213
* The response from the cURL request, including headers and body.
214214
*/
215-
public function parseResponse($response)
215+
public function parseResponse(string $response)
216216
{
217217
// Parse the response and set the last response and headers.
218218
$info = curl_getinfo($this->ch);

0 commit comments

Comments
 (0)