From ab4f5a586930c2e80571cf9a28a566ee9aa094cf Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 7 Jan 2024 15:10:12 -0500 Subject: [PATCH] Code style fixes. --- src/CodeCleaner/ImplicitReturnPass.php | 2 +- src/Readline/Libedit.php | 1 + src/TabCompletion/Matcher/ClassNamesMatcher.php | 1 + src/Util/Str.php | 1 + test/Exception/BreakExceptionTest.php | 2 +- test/ShellTest.php | 2 +- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CodeCleaner/ImplicitReturnPass.php b/src/CodeCleaner/ImplicitReturnPass.php index 2e4ebf3d..202a0825 100644 --- a/src/CodeCleaner/ImplicitReturnPass.php +++ b/src/CodeCleaner/ImplicitReturnPass.php @@ -80,7 +80,7 @@ private function addImplicitReturn(array $nodes): array 'startLine' => $last->getStartLine(), 'endLine' => $last->getEndLine(), ]); - // @codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } elseif ($last instanceof Expression && !($last->expr instanceof Exit_)) { $nodes[\count($nodes) - 1] = new Return_($last->expr, [ 'startLine' => $last->getStartLine(), diff --git a/src/Readline/Libedit.php b/src/Readline/Libedit.php index 953ed2af..6259e2ff 100644 --- a/src/Readline/Libedit.php +++ b/src/Readline/Libedit.php @@ -63,6 +63,7 @@ public function listHistory(): array // decode the line $history = \array_map([$this, 'parseHistoryLine'], $history); + // filter empty lines & comments return \array_values(\array_filter($history)); } diff --git a/src/TabCompletion/Matcher/ClassNamesMatcher.php b/src/TabCompletion/Matcher/ClassNamesMatcher.php index ca2515d6..32a34640 100644 --- a/src/TabCompletion/Matcher/ClassNamesMatcher.php +++ b/src/TabCompletion/Matcher/ClassNamesMatcher.php @@ -36,6 +36,7 @@ function ($className) use ($class) { // get the number of namespace separators $nsPos = \substr_count($class, '\\'); $pieces = \explode('\\', $className); + // $methods = Mirror::get($class); return \implode('\\', \array_slice($pieces, $nsPos, \count($pieces))); }, diff --git a/src/Util/Str.php b/src/Util/Str.php index 032520dc..dd126d1b 100644 --- a/src/Util/Str.php +++ b/src/Util/Str.php @@ -60,6 +60,7 @@ class Str public static function unvis(string $input): string { $output = \preg_replace_callback(self::UNVIS_RX, [self::class, 'unvisReplace'], $input); + // other escapes & octal are handled by stripcslashes return \stripcslashes($output); } diff --git a/test/Exception/BreakExceptionTest.php b/test/Exception/BreakExceptionTest.php index fde277f9..0d808e80 100644 --- a/test/Exception/BreakExceptionTest.php +++ b/test/Exception/BreakExceptionTest.php @@ -34,7 +34,7 @@ public function testMessage() public function testExitShell() { - $this->expectException(\Psy\Exception\BreakException::class); + $this->expectException(BreakException::class); $this->expectExceptionMessage('Goodbye'); BreakException::exitShell(); diff --git a/test/ShellTest.php b/test/ShellTest.php index e85a2e86..ee90b98c 100644 --- a/test/ShellTest.php +++ b/test/ShellTest.php @@ -382,7 +382,7 @@ public function testKeepCodeBufferOpen() public function testCodeBufferThrowsParseExceptions() { - $this->expectException(\Psy\Exception\ParseErrorException::class); + $this->expectException(ParseErrorException::class); $shell = new Shell($this->getConfig()); $shell->addCode('this is not valid');