Skip to content

Commit

Permalink
Add $temporaryErrorHandler parameter to HttpApplicationRunner con…
Browse files Browse the repository at this point in the history
…structor (#85)
  • Loading branch information
vjik authored Jan 17, 2025
1 parent 1013a77 commit 73ab45c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Yii Runner HTTP Change Log

## 3.0.1 under development
## 3.1.0 under development

- no changes in this release.
- Chg #85: Add `$temporaryErrorHandler` parameter to `HttpApplicationRunner` constructor. Mark parameter `$logger` and
method `withTemporaryErrorHandler()` as deprecated (@vjik)

## 3.0.0 July 16, 2024

Expand Down
23 changes: 12 additions & 11 deletions src/HttpApplicationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
*/
final class HttpApplicationRunner extends ApplicationRunner
{
private ?ErrorHandler $temporaryErrorHandler = null;

/**
* @param string $rootPath The absolute path to the project root.
* @param bool $debug Whether the debug mode is enabled.
Expand All @@ -54,8 +52,11 @@ final class HttpApplicationRunner extends ApplicationRunner
* @param string $configDirectory The relative path from {@see $rootPath} to the configuration storage location.
* @param string $vendorDirectory The relative path from {@see $rootPath} to the vendor directory.
* @param string $configMergePlanFile The relative path from {@see $configDirectory} to merge plan.
* @param LoggerInterface|null $logger The logger to collect errors while container is building.
* @param LoggerInterface|null $logger (deprecated) The logger to collect errors while container is building.
* @param int|null $bufferSize The size of the buffer in bytes to send the content of the message body.
* @param ErrorHandler|null $temporaryErrorHandler The temporary error handler instance that used to handle
* the creation of configuration and container instances, then the error handler configured in your application
* configuration will be used.
*
* @psalm-param list<string> $nestedParamsGroups
* @psalm-param list<string> $nestedEventsGroups
Expand All @@ -81,6 +82,7 @@ public function __construct(
string $configMergePlanFile = '.merge-plan.php',
private ?LoggerInterface $logger = null,
private ?int $bufferSize = null,
private ?ErrorHandler $temporaryErrorHandler = null,
) {
parent::__construct(
$rootPath,
Expand All @@ -104,6 +106,8 @@ public function __construct(
}

/**
* @deprecated Use `$temporaryErrorHandler` constructor parameter instead.
*
* Returns a new instance with the specified temporary error handler instance {@see ErrorHandler}.
*
* A temporary error handler is needed to handle the creation of configuration and container instances,
Expand Down Expand Up @@ -176,14 +180,11 @@ public function run(): void

private function createTemporaryErrorHandler(): ErrorHandler
{
if ($this->temporaryErrorHandler !== null) {
return $this->temporaryErrorHandler;
}

return new ErrorHandler(
$this->logger ?? new NullLogger(),
new HtmlRenderer(),
);
return $this->temporaryErrorHandler ??
new ErrorHandler(
$this->logger ?? new NullLogger(),
new HtmlRenderer(),
);
}

/**
Expand Down

0 comments on commit 73ab45c

Please sign in to comment.