Skip to content

Commit

Permalink
cs nullable typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 12, 2021
1 parent a1652dc commit 6ba69ce
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/Nette/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MailSender
private $fromEmail;


public function __construct(Nette\Mail\IMailer $mailer, string $fromEmail = null)
public function __construct(Nette\Mail\IMailer $mailer, ?string $fromEmail = null)
{
$this->mailer = $mailer;
$this->fromEmail = $fromEmail;
Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/Bar/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Bar
* Add custom panel.
* @return static
*/
public function addPanel(IBarPanel $panel, string $id = null): self
public function addPanel(IBarPanel $panel, ?string $id = null): self
{
if ($id === null) {
$c = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Tracy/Debugger/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ final public function __construct()
* @param string $logDirectory error log directory
* @param string|array $email administrator email; enables email sending in production mode
*/
public static function enable($mode = null, string $logDirectory = null, $email = null): void
public static function enable($mode = null, ?string $logDirectory = null, $email = null): void
{
if ($mode !== null || self::$productionMode === null) {
self::$productionMode = is_bool($mode)
Expand Down Expand Up @@ -398,7 +398,7 @@ public static function errorHandler(
string $message,
string $file,
int $line,
array $context = null
?array $context = null
): ?bool {
$error = error_get_last();
if (($error['type'] ?? null) === E_COMPILE_WARNING) {
Expand Down Expand Up @@ -589,7 +589,7 @@ public static function dump($var, bool $return = false)
* Starts/stops stopwatch.
* @return float elapsed seconds
*/
public static function timer(string $name = null): float
public static function timer(?string $name = null): float
{
static $time = [];
$now = microtime(true);
Expand All @@ -605,7 +605,7 @@ public static function timer(string $name = null): float
* @param mixed $var
* @return mixed variable itself
*/
public static function barDump($var, string $title = null, array $options = [])
public static function barDump($var, ?string $title = null, array $options = [])
{
if (!self::$productionMode) {
static $panel;
Expand Down
10 changes: 5 additions & 5 deletions src/Tracy/Dumper/Describer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function describe($var): \stdClass
/**
* @return mixed
*/
private function describeVar($var, int $depth = 0, int $refId = null)
private function describeVar($var, int $depth = 0, ?int $refId = null)
{
if ($var === null || is_bool($var)) {
return $var;
Expand Down Expand Up @@ -139,7 +139,7 @@ private function describeString(string $s, int $depth = 0)
/**
* @return Value|array
*/
private function describeArray(array $arr, int $depth = 0, int $refId = null)
private function describeArray(array $arr, int $depth = 0, ?int $refId = null)
{
if ($refId) {
$res = new Value(Value::TYPE_REF, 'p' . $refId);
Expand Down Expand Up @@ -264,8 +264,8 @@ public function addPropertyTo(
string $k,
$v,
$type = Value::PROP_VIRTUAL,
int $refId = null,
string $class = null
?int $refId = null,
?string $class = null
) {
if ($value->depth && $this->maxItems && count($value->items ?? []) >= $this->maxItems) {
$value->length = ($value->length ?? count($value->items)) + 1;
Expand Down Expand Up @@ -300,7 +300,7 @@ private function exposeObject(object $obj, Value $value): ?array
}


private function isSensitive(string $key, $val, string $class = null): bool
private function isSensitive(string $key, $val, ?string $class = null): bool
{
return ($this->scrubber !== null && ($this->scrubber)($key, $val, $class))
|| isset($this->keysToHide[strtolower($key)])
Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/Dumper/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class Value implements \JsonSerializable
public $collapsed;


public function __construct(string $type, $value = null, int $length = null)
public function __construct(string $type, $value = null, ?int $length = null)
{
$this->type = $type;
$this->value = $value;
Expand Down
8 changes: 4 additions & 4 deletions src/Tracy/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Helpers
/**
* Returns HTML link to editor.
*/
public static function editorLink(string $file, int $line = null): string
public static function editorLink(string $file, ?int $line = null): string
{
$file = strtr($origFile = $file, Debugger::$editorMapping);
if ($editor = self::editorUri($origFile, $line)) {
Expand Down Expand Up @@ -52,7 +52,7 @@ public static function editorLink(string $file, int $line = null): string
*/
public static function editorUri(
string $file,
int $line = null,
?int $line = null,
string $action = 'open',
string $search = '',
string $replace = ''
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function escapeHtml($s): string
}


public static function findTrace(array $trace, $method, int &$index = null): ?array
public static function findTrace(array $trace, $method, ?int &$index = null): ?array
{
$m = is_array($method) ? $method : explode('::', $method);
foreach ($trace as $i => $item) {
Expand Down Expand Up @@ -385,7 +385,7 @@ public static function capture(callable $func): string


/** @internal */
public static function encodeString(string $s, int $maxLength = null, bool $showWhitespaces = true): string
public static function encodeString(string $s, ?int $maxLength = null, bool $showWhitespaces = true): string
{
$utf8 = self::isUtf8($s);
$len = $utf8 ? self::utf8Length($s) : strlen($s);
Expand Down
6 changes: 3 additions & 3 deletions src/Tracy/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Logger implements ILogger
/**
* @param string|array|null $email
*/
public function __construct(?string $directory, $email = null, BlueScreen $blueScreen = null)
public function __construct(?string $directory, $email = null, ?BlueScreen $blueScreen = null)
{
$this->directory = $directory;
$this->email = $email;
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function formatMessage($message): string
/**
* @param mixed $message
*/
public static function formatLogLine($message, string $exceptionFile = null): string
public static function formatLogLine($message, ?string $exceptionFile = null): string
{
return implode(' ', [
date('[Y-m-d H-i-s]'),
Expand Down Expand Up @@ -144,7 +144,7 @@ public function getExceptionFile(\Throwable $exception, string $level = self::EX
* Logs exception to the file if file doesn't exist.
* @return string logged error filename
*/
protected function logException(\Throwable $exception, string $file = null): string
protected function logException(\Throwable $exception, ?string $file = null): string
{
$file = $file ?: $this->getExceptionFile($exception);
$bs = $this->blueScreen ?: new BlueScreen;
Expand Down

0 comments on commit 6ba69ce

Please sign in to comment.