Skip to content

Commit

Permalink
readonly context options & removed debug mode setter
Browse files Browse the repository at this point in the history
  • Loading branch information
cappuc committed Dec 25, 2024
1 parent 1a08b08 commit 3e9e5c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions src/EnvironmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,33 @@ public function setProfile(bool $profile = true): EnvironmentFactory

public function setRethrowExceptions(bool $rethrowExceptions = true): EnvironmentFactory
{
$this->defaultRenderContextOptions->rethrowExceptions = $rethrowExceptions;
$this->defaultRenderContextOptions = new RenderContextOptions(
strictVariables: $this->defaultRenderContextOptions->strictVariables,
strictFilters: $this->defaultRenderContextOptions->strictFilters,
rethrowExceptions: $rethrowExceptions,
);

return $this;
}

public function setStrictVariables(bool $strictVariables = true): EnvironmentFactory
{
$this->defaultRenderContextOptions->strictVariables = $strictVariables;
$this->defaultRenderContextOptions = new RenderContextOptions(
strictVariables: $strictVariables,
strictFilters: $this->defaultRenderContextOptions->strictFilters,
rethrowExceptions: $this->defaultRenderContextOptions->rethrowExceptions,
);

return $this;
}

public function setStrictFilters(bool $strictFilters = true): EnvironmentFactory
{
$this->defaultRenderContextOptions->strictFilters = $strictFilters;

return $this;
}

/**
* Enable/disabled rethrowExceptions and strictVariables.
*/
public function setDebugMode(bool $debugMode = true): EnvironmentFactory
{
$this->defaultRenderContextOptions->rethrowExceptions = $debugMode;
$this->defaultRenderContextOptions->strictVariables = $debugMode;
$this->defaultRenderContextOptions->strictFilters = $debugMode;
$this->defaultRenderContextOptions = new RenderContextOptions(
strictVariables: $this->defaultRenderContextOptions->strictVariables,
strictFilters: $strictFilters,
rethrowExceptions: $this->defaultRenderContextOptions->rethrowExceptions,
);

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Render/RenderContextOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public function __construct(
/**
* Report an error when an undefined variable is used.
*/
public bool $strictVariables = false,
public readonly bool $strictVariables = false,
/**
* Report an error when an undefined filter is used.
*/
public bool $strictFilters = false,
public readonly bool $strictFilters = false,
/**
* Rethrow exceptions that occur during rendering instead of rendering the error message.
*/
public bool $rethrowExceptions = false,
public readonly bool $rethrowExceptions = false,
) {}
}

0 comments on commit 3e9e5c6

Please sign in to comment.