Skip to content

Commit

Permalink
fix: handle response parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
adamczykpiotr committed Dec 9, 2023
1 parent b3b04aa commit fb788d5
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions src/Telescope.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Telescope
/**
* The list of hidden request headers.
*
* @var array<int|string, string|callable>
* @var array<int|string, string|Closure>
*/
public static $hiddenRequestHeaders = [
'authorization',
Expand All @@ -85,7 +85,7 @@ class Telescope
/**
* The list of hidden request parameters.
*
* @var array<int|string, string|callable>
* @var array<int|string, string|Closure>
*/
public static $hiddenRequestParameters = [
'password',
Expand All @@ -95,7 +95,7 @@ class Telescope
/**
* The list of hidden response parameters.
*
* @var array<int|string, string|callable>
* @var array<int|string, string|Closure>
*/
public static $hiddenResponseParameters = [];

Expand Down Expand Up @@ -728,11 +728,19 @@ protected static function collectUpdates($batchId)
* @return static
*/
public static function hideRequestHeaders(array $headers)
{
static::$hiddenRequestHeaders = array_values(array_unique(array_merge(
static::$hiddenRequestHeaders,
$headers
)));
{
/**
* @var Collection<int, string> $regular
* @var Collection<string, Closure> $closures
*/
[$closures, $regular] = Collection::wrap($headers)
->merge(static::$hiddenRequestHeaders)
->partition(fn($item) => $item instanceof Closure);

static::$hiddenRequestHeaders = $regular
->unique()
->merge($closures)
->toArray();

return new static;
}
Expand All @@ -744,7 +752,7 @@ public static function hideRequestHeaders(array $headers)
* @return static
*/
public static function hideRequestParameters(array $attributes)
{
{
static::$hiddenRequestParameters = array_merge(
static::$hiddenRequestParameters,
$attributes
Expand All @@ -760,11 +768,19 @@ public static function hideRequestParameters(array $attributes)
* @return static
*/
public static function hideResponseParameters(array $attributes)
{
static::$hiddenResponseParameters = array_values(array_unique(array_merge(
static::$hiddenResponseParameters,
$attributes
)));
{
/**
* @var Collection<int, string> $regular
* @var Collection<string, Closure> $closures
*/
[$closures, $regular] = Collection::wrap($headers)

Check failure on line 776 in src/Telescope.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Undefined variable: $headers
->merge(static::$hiddenResponseParameters)
->partition(fn($item) => $item instanceof Closure);

static::$hiddenResponseParameters = $regular
->unique()
->merge($closures)
->toArray();

return new static;
}
Expand Down

0 comments on commit fb788d5

Please sign in to comment.