Skip to content

Commit c39ec39

Browse files
committed
:octocat:
1 parent 96258a8 commit c39ec39

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# chillerlan/php-httpinterface
22

3-
A http client wrapper/PSR-7/PSR-17/PSR-18 implementation for PHP 7.2+.
3+
A [PSR-7](https://www.php-fig.org/psr/psr-7/)/[PSR-17](https://www.php-fig.org/psr/psr-17/)/[PSR-18](https://www.php-fig.org/psr/psr-18/) implementation for PHP 7.2+.
44

55
[![version][packagist-badge]][packagist]
66
[![license][license-badge]][license]
@@ -81,11 +81,26 @@ $http->request('https://www.example.com', $http::METHOD_GET, ['foo' => 'bar']);
8181
```
8282
Both methods will return a PSR-7 `ResponseInterface`.
8383

84-
### PSR-7 Message helpers
85-
These static methods can be found in the `chillerlan\HTTP\Psr7` namespace
86-
87-
88-
### PSR-17 Factory helpers
84+
### [PSR-7](https://www.php-fig.org/psr/psr-7/) Message helpers
85+
These static methods can be found in the `chillerlan\HTTP\Psr7` namespace:
86+
87+
- `normalize_request_headers(array $headers)`
88+
- `r_rawurlencode($data)` - recursive rawurlencode, accepts a string or an array as input
89+
- `build_http_query(array $params, bool $urlencode = null, string $delimiter = null, string $enclosure = null)` - see [abraham/twitteroauth](https://github.com/abraham/twitteroauth/blob/master/src/Util.php#L82)
90+
- `clean_query_params(iterable $params, int $bool_cast = null, bool $remove_empty = null)` - clean an array of parameters for URL queries (or JSON output etc.) using the following cast formats:
91+
- `BOOLEANS_AS_BOOL` - bool types will be left untouched (default)
92+
- `BOOLEANS_AS_INT` - cast to integer `1` and `0`
93+
- `BOOLEANS_AS_STRING` - a string value `"true"` and `"false"`
94+
- `BOOLEANS_AS_INT_STRING` - integer values, but as string, `"1"` and `"0"`
95+
- `merge_query(string $uri, array $query)` - merges an array of parameters into an URL query string
96+
- `normalize_files(array $files)`
97+
- `create_uploaded_file_from_spec(array $value)`
98+
- `normalize_nested_file_spec(array $files = [])`
99+
- `get_json(ResponseInterface $response, bool $assoc = null)`
100+
- `get_xml(ResponseInterface $response)`
101+
- `message_to_string(MessageInterface $message)` - returns the string representation of a `MessageInterface`
102+
103+
### [PSR-17](https://www.php-fig.org/psr/psr-17/) Factory helpers
89104
These static methods can be found in the `chillerlan\HTTP\Psr17` namespace:
90105

91106
- `create_server_request_from_globals()` - creates a PSR-7 `ServerRequestInterface` object that is populated with the GPCS superglobals.

src/Psr7/MultipartStream.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ public function addElement(array $e):MultipartStream{
149149
}
150150

151151
/**
152-
* @param array $headers
153-
* @param $key
152+
* @param array $headers
153+
* @param string $key
154154
*
155155
* @return bool
156156
*/
157-
private function hasHeader(array $headers, $key){
157+
private function hasHeader(array $headers, string $key):bool{
158158
$lowercaseHeader = strtolower($key);
159159

160160
foreach ($headers as $k => $v) {

src/Psr7/message_helpers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,12 @@ function get_xml(ResponseInterface $response){
409409
/**
410410
* Returns the string representation of an HTTP message. (from Guzzle)
411411
*
412-
* @param MessageInterface $message Message to convert to a string.
412+
* @param \Psr\Http\Message\MessageInterface $message Message to convert to a string.
413413
*
414414
* @return string
415415
*/
416416
function message_to_string(MessageInterface $message):string{
417+
$msg = '';
417418

418419
if($message instanceof RequestInterface){
419420
$msg = trim($message->getMethod().' '.$message->getRequestTarget()).' HTTP/'.$message->getProtocolVersion();

0 commit comments

Comments
 (0)