Skip to content

Commit

Permalink
Merge branch 'sensitive-parameter' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Mar 23, 2023
2 parents 2414df3 + 481cf33 commit 00c8777
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ With it it is possible to obtain the protocol:

.. code-block:: php
$protocol = $response->getProtocol();
$protocol = $response->getProtocol(); // string
Response Status
###############
Expand All @@ -273,9 +273,9 @@ Also, you can get the response status:

.. code-block:: php
$response->getStatusCode();
$response->getStatusReason();
$response->getStatus();
$response->getStatusCode(); // int
$response->getStatusReason(); // string
$response->getStatus(); // string
Response Headers
################
Expand All @@ -284,7 +284,7 @@ It is also possible to get all headers at once:

.. code-block:: php
$headers = $response->getHeaders();
$headers = $response->getHeaders(); // array
Or, get the headers individually:

Expand All @@ -302,7 +302,7 @@ The message body, when set, can be obtained with the ``getBody`` method:

.. code-block:: php
$body = $response->getBody();
$body = $response->getBody(); // string
JSON Response
#############
Expand All @@ -313,7 +313,7 @@ as an object or array in PHP:
.. code-block:: php
if ($response->isJson()) {
$data = $response->getJson();
$data = $response->getJson(); // object or false
}
Conclusion
Expand Down
9 changes: 6 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use JetBrains\PhpStorm\Pure;
use JsonException;
use OutOfBoundsException;
use SensitiveParameter;

/**
* Class Request.
Expand Down Expand Up @@ -475,8 +476,10 @@ public function removeHeaders() : static
*
* @return static
*/
public function setBasicAuth(string $username, string $password) : static
{
public function setBasicAuth(
string $username,
#[SensitiveParameter] string $password
) : static {
return $this->setHeader(
RequestHeader::AUTHORIZATION,
'Basic ' . \base64_encode($username . ':' . $password)
Expand All @@ -490,7 +493,7 @@ public function setBasicAuth(string $username, string $password) : static
*
* @return static
*/
public function setBearerAuth(string $token) : static
public function setBearerAuth(#[SensitiveParameter] string $token) : static
{
return $this->setHeader(
RequestHeader::AUTHORIZATION,
Expand Down

0 comments on commit 00c8777

Please sign in to comment.