Skip to content
Permalink
Browse files

IBarPanel, ILogger: added typehints to interfaces (BC break)

  • Loading branch information...
dg committed Mar 21, 2018
1 parent fb7a9c7 commit 4b05eb53a0939e85ead63c349561ba5f4af1947b
@@ -38,7 +38,7 @@ public function __construct(Psr\Log\LoggerInterface $psrLogger)
}
public function log($value, $priority = self::INFO)
public function log($value, string $priority = self::INFO)
{
if ($value instanceof \Throwable) {
$message = Tracy\Helpers::getClass($value) . ': ' . $value->getMessage() . ($value->getCode() ? ' #' . $value->getCode() : '') . ' in ' . $value->getFile() . ':' . $value->getLine();
@@ -144,7 +144,7 @@ private function renderPanels(string $suffix = ''): array
foreach ($this->panels as $id => $panel) {
$idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id) . $suffix;
try {
$tab = (string) $panel->getTab();
$tab = $panel->getTab();
$panelHtml = $tab ? $panel->getPanel() : null;
} catch (\Throwable $e) {
@@ -20,11 +20,11 @@ interface IBarPanel
* Renders HTML code for custom tab.
* @return string
*/
function getTab();
function getTab(): ?string;
/**
* Renders HTML code for custom panel.
* @return string
*/
function getPanel();
function getPanel(): ?string;
}
@@ -32,7 +32,7 @@ class FireLogger implements ILogger
* Sends message to FireLogger console.
* @param mixed $message
*/
public function log($message, $priority = self::DEBUG): bool
public function log($message, string $priority = self::DEBUG): bool
{
if (!isset($_SERVER['HTTP_X_FIRELOGGER']) || headers_sent()) {
return false;
@@ -23,5 +23,5 @@ interface ILogger
EXCEPTION = 'exception',
CRITICAL = 'critical';
function log($value, $priority = self::INFO);
function log($value, string $priority = self::INFO);
}
@@ -52,7 +52,7 @@ public function __construct(?string $directory, $email = null, BlueScreen $blueS
* @param string $priority one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
* @return string|null logged error filename
*/
public function log($message, $priority = self::INFO)
public function log($message, string $priority = self::INFO): ?string
{
if (!$this->directory) {
throw new \LogicException('Logging directory is not specified.');
@@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php';
class CustomLogger implements ILogger
{
public function log($value, $priority = self::INFO)
public function log($value, string $priority = self::INFO)
{
}
}
@@ -19,7 +19,7 @@ class DummyTracyLogger implements ILogger
public $entries = [];
public function log($value, $priority = self::INFO)
public function log($value, string $priority = self::INFO)
{
$this->entries[] = [$priority, $value];
}
@@ -19,7 +19,7 @@ class CustomLogger extends Logger
public $collector = [];
public function log($value, $priority = self::INFO): ?string
public function log($value, string $priority = self::INFO): ?string
{
$exceptionFile = $value instanceof \Exception ? $this->logException($value) : null;

0 comments on commit 4b05eb5

Please sign in to comment.
You can’t perform that action at this time.