Skip to content

Commit

Permalink
Remove logger from parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Oct 11, 2024
1 parent 056f301 commit 6cb99ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Internal/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ private function __construct()
{
}

public static function register(LoggerInterface &$logger): void
public static function register(LoggerInterface $logger): void
{
if (self::$logger !== null) {
throw new \LogicException(\sprintf('%s(): Already registered', __METHOD__));
}

self::$logger = &$logger;
self::$logger = $logger;
\set_error_handler(self::handleError(...));
\set_exception_handler(self::handleException(...));
}
Expand All @@ -53,9 +53,9 @@ public static function unregister(): void
return;
}

self::$logger = null;
\restore_error_handler();
\restore_exception_handler();
self::$logger = null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MasterProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class MasterProcess implements MessageHandler, MessageBus, Container
private Supervisor $supervisor;
private Scheduler $scheduler;
private Container $container;
private LoggerInterface $logger;

/**
* @var array<class-string<Plugin>, Plugin>
Expand All @@ -64,7 +65,6 @@ final class MasterProcess implements MessageHandler, MessageBus, Container
public function __construct(
string|null $pidFile,
int $stopTimeout,
private LoggerInterface|null $logger,
) {
if (!\in_array(PHP_SAPI, ['cli', 'phpdbg', 'micro'], true)) {
throw new \RuntimeException('Works in command line mode only');
Expand Down
6 changes: 0 additions & 6 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ public function __construct(
* Timeout in seconds that master process will be waiting before force kill child processes after sending stop command.
*/
int $stopTimeout = 15,

/**
* PSR-3 Logger implementation
*/
LoggerInterface|null $logger = null,
) {
$this->masterProcess = new MasterProcess(
pidFile: $pidFile,
stopTimeout: $stopTimeout,
logger: $logger,
);

$this->app = new App();
Expand Down

0 comments on commit 6cb99ff

Please sign in to comment.