Skip to content

Commit 627d2d4

Browse files
authored
Merge branch 'master' into equalto-override
2 parents a0c80d8 + 45d8ad7 commit 627d2d4

29 files changed

+675
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ jobs:
2626
strategy:
2727
matrix:
2828
include:
29-
- name: PHP 8.1
30-
PHP_VERSION: 8.1
3129
- name: PHP 8.2
3230
PHP_VERSION: 8.2
31+
- name: PHP 8.1
32+
PHP_VERSION: 8.1
3333
fail-fast: false
34+
name: Test ${{ matrix.name }}
3435
steps:
3536
- uses: actions/checkout@v3
3637
- name: Use Node.js

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [2.2.0](https://github.com/parse-community/parse-php-sdk/compare/2.1.0...2.2.0) (2023-05-13)
2+
3+
4+
### Features
5+
6+
* Allow http options to be passed into `ParseClient` ([#513](https://github.com/parse-community/parse-php-sdk/issues/513)) ([ee2a5fa](https://github.com/parse-community/parse-php-sdk/commit/ee2a5fa389d553e73e483130647fd93cf187d142))
7+
18
# [2.1.0](https://github.com/parse-community/parse-php-sdk/compare/2.0.0...2.1.0) (2023-04-29)
29

310

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A library that gives you access to the powerful Parse Server backend from your P
2424

2525
## Table of Contents <!-- omit in toc -->
2626

27+
- [Compatibility](#compatibility)
2728
- [Installation](#installation)
2829
- [Install with Composer](#install-with-composer)
2930
- [Install with Git](#install-with-git)
@@ -64,6 +65,15 @@ A library that gives you access to the powerful Parse Server backend from your P
6465
- [Logs](#logs)
6566
- [Contributing / Testing](#contributing--testing)
6667

68+
## Compatibility
69+
70+
The Parse PHP SDK is continuously tested with the most recent releases of PHP to ensure compatibility. We follow the [PHP Long Term Support plan](https://www.php.net/supported-versions.php) and only test against versions that are officially supported and have not reached their end-of-life date.
71+
72+
| Version | End-of-Life | Compatible |
73+
|---------|-------------|------------|
74+
| PHP 8.2 | Dec 2024 | ✅ Yes |
75+
| PHP 8.1 | Nov 2023 | ✅ Yes |
76+
6777
## Installation
6878
There are various ways to install and use this sdk. We'll elaborate on a couple here.
6979
Note that the Parse PHP SDK requires PHP 5.4 or newer. It can also run on HHVM (recommended 3.0 or newer).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
"semantic-release": "21.0.1",
3333
"winston": "3.2.1"
3434
},
35-
"version": "2.1.0"
35+
"version": "2.2.0"
3636
}

src/Parse/HttpClients/ParseCurlHttpClient.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,18 @@ public function setCAFile($caFile)
306306
$this->parseCurl->setOption(CURLOPT_CAINFO, $caFile);
307307
}
308308

309+
/**
310+
* Sets multiple curl options
311+
* https://www.php.net/manual/en/function.curl-setopt.php
312+
*
313+
* @param array $options Array of options to set
314+
* @throws ParseException
315+
*/
316+
public function setHttpOptions($options)
317+
{
318+
$this->parseCurl->setOptionsArray($options);
319+
}
320+
309321
/**
310322
* Gets the error code
311323
*

src/Parse/HttpClients/ParseHttpable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ public function setTimeout($timeout);
6363
*/
6464
public function setCAFile($caFile);
6565

66+
/**
67+
* Sets http options to pass to the http client
68+
*
69+
* @param string $httpOptions Options to set
70+
*/
71+
public function setHttpOptions($httpOptions);
72+
6673
/**
6774
* Gets the error code
6875
*

src/Parse/HttpClients/ParseStreamHttpClient.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class ParseStreamHttpClient implements ParseHttpable
7878
*/
7979
private $caFile;
8080

81+
/**
82+
* Options to pass to the stream context.
83+
*
84+
* @var array
85+
*/
86+
private $httpOptions;
87+
8188
/**
8289
* Optional timeout for this request
8390
*
@@ -195,6 +202,12 @@ public function send($url, $method = 'GET', $data = array())
195202
$this->options['ssl']['cafile'] = $this->caFile;
196203
}
197204

205+
if (isset($this->httpOptions)) {
206+
foreach ($this->httpOptions as $key => $value) {
207+
$this->options[$key] = $value;
208+
}
209+
}
210+
198211
// add additional options for this request
199212
$this->options['http'] = array(
200213
'method' => $method,
@@ -264,6 +277,7 @@ public function send($url, $method = 'GET', $data = array())
264277

265278
// clear options
266279
$this->options = array();
280+
$this->httpOptions = array();
267281

268282
// flush our existing headers
269283
$this->headers = array();
@@ -348,6 +362,17 @@ public function setCAFile($caFile)
348362
$this->caFile = $caFile;
349363
}
350364

365+
/**
366+
* Sets http options to pass to the stream context
367+
* https://www.php.net/manual/en/context.php
368+
*
369+
* @param array $httpOptions options to set
370+
*/
371+
public function setHttpOptions($httpOptions)
372+
{
373+
$this->httpOptions = $httpOptions;
374+
}
375+
351376
/**
352377
* Sets the request timeout
353378
*

src/Parse/ParseClient.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,19 @@ final class ParseClient
103103
*/
104104
private static $caFile;
105105

106+
/**
107+
* Options to pass to the http client.
108+
*
109+
* @var array
110+
*/
111+
private static $httpOptions;
112+
106113
/**
107114
* Constant for version string to include with requests.
108115
*
109116
* @var string
110117
*/
111-
const VERSION_STRING = '2.1.0';
118+
const VERSION_STRING = '2.2.0';
112119

113120
/**
114121
* Parse\Client::initialize, must be called before using Parse features.
@@ -301,6 +308,21 @@ public static function setCAFile($caFile)
301308
self::$caFile = $caFile;
302309
}
303310

311+
/**
312+
* Sets http options to pass to the http client
313+
* For curl
314+
* https://www.php.net/manual/en/function.curl-setopt.php
315+
*
316+
* For stream context
317+
* https://www.php.net/manual/en/context.php
318+
*
319+
* @param array $httpOptions options to set
320+
*/
321+
public static function setHttpOptions($httpOptions)
322+
{
323+
self::$httpOptions = $httpOptions;
324+
}
325+
304326
/**
305327
* ParseClient::_encode, internal method for encoding object values.
306328
*
@@ -452,6 +474,9 @@ private static function getPreparedHttpClient()
452474
// set CA file
453475
$httpClient->setCAFile(self::$caFile);
454476
}
477+
if (isset(self::$httpOptions)) {
478+
$httpClient->setHttpOptions(self::$httpOptions);
479+
}
455480

456481
return $httpClient;
457482
}

tests/Parse/Helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,10 @@ public static function print($text)
105105
{
106106
fwrite(STDOUT, $text . "\n");
107107
}
108+
109+
public static function printArray($array)
110+
{
111+
print_r($array);
112+
ob_end_flush();
113+
}
108114
}

0 commit comments

Comments
 (0)