Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b739899

Browse files
committed
update some logic
1 parent 6563a42 commit b739899

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

‎libs/cli-utils/src/Cli.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ public static function log(string $msg, array $data = [], string $type = 'info',
178178
}
179179

180180
$optString = $userOpts ? '' . implode('', $userOpts) : '';
181+
$dataString = $data ? PHP_EOL . json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : '';
181182

182-
self::write(sprintf('%s [%s]%s %s %s', date('Y/m/d H:i:s'), $type, $optString, trim($msg),
183-
$data ? PHP_EOL . json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : ''));
183+
self::writef('%s [%s]%s %s %s', date('Y/m/d H:i:s'), $type, $optString, trim($msg), $dataString);
184184
}
185185

186186
/*******************************************************************************
@@ -245,6 +245,7 @@ public static function isAnsiSupport(): bool
245245
*/
246246
public static function isInteractive($fileDescriptor): bool
247247
{
248+
/** @noinspection PhpComposerExtensionStubsInspection */
248249
return function_exists('posix_isatty') && @posix_isatty($fileDescriptor);
249250
}
250251

‎libs/cli-utils/src/Highlighter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ public function highlight(string $source, bool $withLineNumber = false): string
123123
return implode(PHP_EOL, $lines);
124124
}
125125

126+
/**
127+
* @param string $file
128+
* @param bool $withLineNumber
129+
*
130+
* @return string
131+
*/
126132
public function highlightFile(string $file, bool $withLineNumber = false): string
127133
{
134+
if (!file_exists($file)) {
135+
throw new InvalidArgumentException("the target file is not exist! file: $file");
136+
}
137+
128138
$source = file_get_contents($file);
129139

130140
return $this->highlight($source, $withLineNumber);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /