Skip to content

Commit

Permalink
[9.x] Add preventDumpingSource to CliDumper and HtmlDumper (lar…
Browse files Browse the repository at this point in the history
…avel#44623)

* feat: prevent dumping source

* formatting

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
innocenzi and taylorotwell authored Oct 19, 2022
1 parent 3b26f7a commit 4335c5c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait ResolvesDumpSource
/**
* The source resolver.
*
* @var (callable(): (array{0: string, 1: string, 2: int|null}|null))|null
* @var (callable(): (array{0: string, 1: string, 2: int|null}|null))|null|false
*/
protected static $dumpSourceResolver;

Expand All @@ -43,6 +43,10 @@ trait ResolvesDumpSource
*/
public function resolveDumpSource()
{
if (static::$dumpSourceResolver === false) {
return null;
}

if (static::$dumpSourceResolver) {
return call_user_func(static::$dumpSourceResolver);
}
Expand Down Expand Up @@ -161,4 +165,14 @@ public static function resolveDumpSourceUsing($callable)
{
static::$dumpSourceResolver = $callable;
}

/**
* Don't include the location / file of the dump in dumps.
*
* @return void
*/
public static function dontIncludeSource()
{
static::$dumpSourceResolver = false;
}
}

0 comments on commit 4335c5c

Please sign in to comment.