diff --git a/src/Argument/Argument.php b/src/Argument/Argument.php index a1d4e4e5..b839a184 100644 --- a/src/Argument/Argument.php +++ b/src/Argument/Argument.php @@ -3,6 +3,7 @@ namespace League\CLImate\Argument; use League\CLImate\Exceptions\UnexpectedValueException; + use function is_array; class Argument diff --git a/src/Decorator/Component/BackgroundColor.php b/src/Decorator/Component/BackgroundColor.php index 70f5d9f6..dade7309 100644 --- a/src/Decorator/Component/BackgroundColor.php +++ b/src/Decorator/Component/BackgroundColor.php @@ -10,7 +10,7 @@ class BackgroundColor extends Color * * @const integer ADD */ - const ADD = 10; + public const ADD = 10; /** * Get the code for the requested color diff --git a/src/Logger.php b/src/Logger.php index a234edfc..d91a9f63 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -5,6 +5,7 @@ use Psr\Log\AbstractLogger; use Psr\Log\InvalidArgumentException; use Psr\Log\LogLevel; + use function array_key_exists; use function is_array; use function str_replace; @@ -50,7 +51,7 @@ public function __construct($level = LogLevel::INFO, CLImate $climate = null) $this->level = $this->convertLevel($level); if ($climate === null) { - $climate = new CLImate; + $climate = new CLImate(); } $this->climate = $climate; diff --git a/src/TerminalObject/Basic/BasicTerminalObject.php b/src/TerminalObject/Basic/BasicTerminalObject.php index 5201cc2c..1b3ceb10 100644 --- a/src/TerminalObject/Basic/BasicTerminalObject.php +++ b/src/TerminalObject/Basic/BasicTerminalObject.php @@ -10,7 +10,9 @@ abstract class BasicTerminalObject implements BasicTerminalObjectInterface { - use SettingsImporter, ParserImporter, UtilImporter; + use SettingsImporter; + use ParserImporter; + use UtilImporter; /** * Set the property if there is a valid value diff --git a/src/TerminalObject/Basic/Table.php b/src/TerminalObject/Basic/Table.php index f40f7899..6160eb4f 100644 --- a/src/TerminalObject/Basic/Table.php +++ b/src/TerminalObject/Basic/Table.php @@ -197,7 +197,7 @@ protected function buildHeaderRow() $header_row = $this->getHeaderRow(); if ($header_row) { $this->addLine($this->buildRow($header_row)); - $this->addLine((new Border)->char('=')->length($this->table_width)->result()); + $this->addLine((new Border())->char('=')->length($this->table_width)->result()); } } diff --git a/src/TerminalObject/Dynamic/Animation.php b/src/TerminalObject/Dynamic/Animation.php index 4b5ee214..aa8a63b1 100644 --- a/src/TerminalObject/Dynamic/Animation.php +++ b/src/TerminalObject/Dynamic/Animation.php @@ -138,7 +138,7 @@ protected function setSleeper($sleeper = null) */ protected function setKeyFrames($keyframes) { - $this->keyframes = $keyframes ?: new Keyframe; + $this->keyframes = $keyframes ?: new Keyframe(); } /** diff --git a/src/TerminalObject/Dynamic/Animation/Keyframe.php b/src/TerminalObject/Dynamic/Animation/Keyframe.php index cb9fe398..8f535f1c 100644 --- a/src/TerminalObject/Dynamic/Animation/Keyframe.php +++ b/src/TerminalObject/Dynamic/Animation/Keyframe.php @@ -8,7 +8,9 @@ class Keyframe { - use StringLength, ParserImporter, UtilImporter; + use StringLength; + use ParserImporter; + use UtilImporter; /** * Get the enter keyframes for the desired direction diff --git a/src/TerminalObject/Dynamic/Checkbox/Checkbox.php b/src/TerminalObject/Dynamic/Checkbox/Checkbox.php index 793fdcc4..53141264 100644 --- a/src/TerminalObject/Dynamic/Checkbox/Checkbox.php +++ b/src/TerminalObject/Dynamic/Checkbox/Checkbox.php @@ -8,7 +8,9 @@ class Checkbox { - use StringLength, ParserImporter, UtilImporter; + use StringLength; + use ParserImporter; + use UtilImporter; /** * The value of the checkbox diff --git a/src/TerminalObject/Dynamic/Checkbox/CheckboxGroup.php b/src/TerminalObject/Dynamic/Checkbox/CheckboxGroup.php index 3a09d684..c91afaa5 100644 --- a/src/TerminalObject/Dynamic/Checkbox/CheckboxGroup.php +++ b/src/TerminalObject/Dynamic/Checkbox/CheckboxGroup.php @@ -8,7 +8,9 @@ class CheckboxGroup { - use OutputImporter, ParserImporter, UtilImporter; + use OutputImporter; + use ParserImporter; + use UtilImporter; protected $checkboxes = []; @@ -136,7 +138,7 @@ protected function getCurrent() */ protected function getCurrentKey($direction, $option, $key) { - $method = 'get' . ucwords($direction). 'Key'; + $method = 'get' . ucwords($direction) . 'Key'; return $this->{$method}($option, $key); } diff --git a/src/TerminalObject/Dynamic/Checkboxes.php b/src/TerminalObject/Dynamic/Checkboxes.php index 89c3bfe2..1eec76e2 100644 --- a/src/TerminalObject/Dynamic/Checkboxes.php +++ b/src/TerminalObject/Dynamic/Checkboxes.php @@ -102,15 +102,15 @@ protected function handleCharacter($char) case "\n": $this->output->sameLine()->write($this->util->cursor->defaultStyle()); $this->output->sameLine()->write("\e[0m"); - return true; // Break the while loop as well + return true; // Break the while loop as well case "\e": $this->handleAnsi(); - break; + break; case ' ': $this->checkboxes->toggleCurrent(); - break; + break; } return false; @@ -136,12 +136,12 @@ protected function handleAnsi() // Up arrow case '[A': $this->checkboxes->setCurrent('previous'); - break; + break; // Down arrow case '[B': $this->checkboxes->setCurrent('next'); - break; + break; } } diff --git a/src/TerminalObject/Dynamic/Confirm.php b/src/TerminalObject/Dynamic/Confirm.php index a917987f..656ea1eb 100644 --- a/src/TerminalObject/Dynamic/Confirm.php +++ b/src/TerminalObject/Dynamic/Confirm.php @@ -3,14 +3,13 @@ namespace League\CLImate\TerminalObject\Dynamic; use League\CLImate\Util\Reader\ReaderInterface; + use function in_array; use function strtolower; use function substr; class Confirm extends Input { - - /** * @inheritdoc */ diff --git a/src/TerminalObject/Dynamic/DynamicTerminalObject.php b/src/TerminalObject/Dynamic/DynamicTerminalObject.php index c8f8751d..8ad04809 100644 --- a/src/TerminalObject/Dynamic/DynamicTerminalObject.php +++ b/src/TerminalObject/Dynamic/DynamicTerminalObject.php @@ -14,5 +14,8 @@ abstract class DynamicTerminalObject implements DynamicTerminalObjectInterface { - use SettingsImporter, ParserImporter, OutputImporter, UtilImporter; + use SettingsImporter; + use ParserImporter; + use OutputImporter; + use UtilImporter; } diff --git a/src/TerminalObject/Dynamic/Spinner.php b/src/TerminalObject/Dynamic/Spinner.php index 66b6fac2..f34d78f4 100644 --- a/src/TerminalObject/Dynamic/Spinner.php +++ b/src/TerminalObject/Dynamic/Spinner.php @@ -3,6 +3,7 @@ namespace League\CLImate\TerminalObject\Dynamic; use League\CLImate\Exceptions\UnexpectedValueException; + use function array_merge; use function count; use function microtime; diff --git a/src/TerminalObject/Router/Router.php b/src/TerminalObject/Router/Router.php index 0edc6409..7632086e 100644 --- a/src/TerminalObject/Router/Router.php +++ b/src/TerminalObject/Router/Router.php @@ -10,7 +10,10 @@ class Router { - use ParserImporter, SettingsImporter, OutputImporter, UtilImporter; + use ParserImporter; + use SettingsImporter; + use OutputImporter; + use UtilImporter; /** * An instance of the Settings Manager class diff --git a/src/Util/Output.php b/src/Util/Output.php index 51d6dcca..f937946b 100644 --- a/src/Util/Output.php +++ b/src/Util/Output.php @@ -47,9 +47,9 @@ class Output public function __construct() { - $this->add('out', new Writer\StdOut); - $this->add('error', new Writer\StdErr); - $this->add('buffer', new Writer\Buffer); + $this->add('out', new Writer\StdOut()); + $this->add('error', new Writer\StdErr()); + $this->add('buffer', new Writer\Buffer()); $this->defaultTo('out'); } diff --git a/src/Util/System/Windows.php b/src/Util/System/Windows.php index a04e504a..af4faef7 100644 --- a/src/Util/System/Windows.php +++ b/src/Util/System/Windows.php @@ -72,7 +72,7 @@ protected function systemHasAnsiSupport() return (function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT)) || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') - || 'Hyper' === getenv('TERM_PROGRAM') + || 'Hyper' === getenv('TERM_PROGRAM') || 'xterm' === getenv('TERM'); } } diff --git a/tests/Animation/AnimationTest.php b/tests/Animation/AnimationTest.php index a7a50775..a739c1e7 100644 --- a/tests/Animation/AnimationTest.php +++ b/tests/Animation/AnimationTest.php @@ -7,7 +7,11 @@ class AnimationTest extends TestBase { - use ExitToTopFrames, ExitToBottomFrames, ExitToLeftFrames, ExitToRightFrames, RunFrames; + use ExitToTopFrames; + use ExitToBottomFrames; + use ExitToLeftFrames; + use ExitToRightFrames; + use RunFrames; private function addArt(): void diff --git a/tests/Argument/ManagerTest.php b/tests/Argument/ManagerTest.php index 2a66c186..dcb46d30 100644 --- a/tests/Argument/ManagerTest.php +++ b/tests/Argument/ManagerTest.php @@ -12,7 +12,7 @@ class ManagerTest extends TestCase public function setUp(): void { - $this->manager = new Manager; + $this->manager = new Manager(); } diff --git a/tests/ArgumentTest.php b/tests/ArgumentTest.php index d3fbc599..15abbc6d 100644 --- a/tests/ArgumentTest.php +++ b/tests/ArgumentTest.php @@ -25,7 +25,7 @@ public function it_throws_an_exception_when_building_arguments_from_an_unknown_t $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Please provide an argument name or object."); - $this->cli->arguments->add(new \stdClass); + $this->cli->arguments->add(new \stdClass()); } protected function getFullArguments() diff --git a/tests/BufferTest.php b/tests/BufferTest.php index 78284468..6c46680a 100644 --- a/tests/BufferTest.php +++ b/tests/BufferTest.php @@ -10,8 +10,8 @@ class BufferTest extends TestBase /** @test */ public function it_can_buffer_content() { - $buffer = new Buffer; - $output = new Output; + $buffer = new Buffer(); + $output = new Output(); $output->add('buffer', $buffer); $output->defaultTo('buffer'); @@ -23,8 +23,8 @@ public function it_can_buffer_content() /** @test */ public function it_can_buffer_content_without_a_new_line() { - $buffer = new Buffer; - $output = new Output; + $buffer = new Buffer(); + $output = new Output(); $output->add('buffer', $buffer); $output->defaultTo('buffer'); @@ -36,8 +36,8 @@ public function it_can_buffer_content_without_a_new_line() /** @test */ public function it_can_buffer_multiple_lines() { - $buffer = new Buffer; - $output = new Output; + $buffer = new Buffer(); + $output = new Output(); $output->add('buffer', $buffer); $output->defaultTo('buffer'); @@ -50,8 +50,8 @@ public function it_can_buffer_multiple_lines() /** @test */ public function it_can_clean_buffered_content() { - $buffer = new Buffer; - $output = new Output; + $buffer = new Buffer(); + $output = new Output(); $output->add('buffer', $buffer); $output->defaultTo('buffer'); diff --git a/tests/CLImateTest.php b/tests/CLImateTest.php index 769940e5..29ed0f92 100644 --- a/tests/CLImateTest.php +++ b/tests/CLImateTest.php @@ -70,7 +70,7 @@ public function it_can_be_extended_using_a_basic_object() $this->shouldWrite("\e[mThis just outputs this.\e[0m"); $this->shouldHavePersisted(); - $this->cli->extend(new BasicObject); + $this->cli->extend(new BasicObject()); $this->cli->basicObject(); } @@ -83,7 +83,7 @@ public function it_can_be_extended_using_a_basic_object_with_argument_setter() $this->shouldWrite("\e[mHey: This is the thing that will print to the console.\e[0m"); $this->shouldHavePersisted(); - $this->cli->extend(new BasicObjectArgument); + $this->cli->extend(new BasicObjectArgument()); $this->cli->basicObjectArgument('This is the thing that will print to the console.'); } diff --git a/tests/FileTest.php b/tests/FileTest.php index 47599251..68a23b4b 100644 --- a/tests/FileTest.php +++ b/tests/FileTest.php @@ -35,7 +35,7 @@ public function it_can_write_to_a_file() ->with($this->file->url(), 'a') ->andReturn(fopen($this->file->url(), 'a')); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); @@ -49,7 +49,7 @@ public function it_will_accept_a_resource() { $resource = fopen($this->file->url(), 'a'); $file = $this->getFileMock($resource); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); @@ -74,7 +74,7 @@ public function it_can_lock_the_file() $file->lock(); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); @@ -120,7 +120,7 @@ public function it_will_yell_when_a_non_writable_resource_is_passed() $this->expectExceptionMessage("is not writable"); $file = $this->getFileMock($this->file->url()); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); @@ -134,7 +134,7 @@ public function it_will_yell_when_a_non_existent_resource_is_passed() $this->expectExceptionMessage("The resource [something-that-doesnt-exist] is not writable"); $file = $this->getFileMock('something-that-doesnt-exist'); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); @@ -154,7 +154,7 @@ public function it_will_yell_when_it_failed_to_open_a_resource() ->with($this->file->url(), 'a') ->andReturn(false); - $output = new Output; + $output = new Output(); $output->add('file', $file); $output->defaultTo('file'); diff --git a/tests/LoggerTest.php b/tests/LoggerTest.php index b82b6bf6..fd32f159 100644 --- a/tests/LoggerTest.php +++ b/tests/LoggerTest.php @@ -45,7 +45,7 @@ public function tearDown(): void public function testConstructor1() { - $logger = new Logger; + $logger = new Logger(); $this->assertInstanceOf(LoggerInterface::class, $logger); $this->assertInstanceOf(Logger::class, $logger); } diff --git a/tests/OutputTest.php b/tests/OutputTest.php index f7b0b744..aaeb4eec 100644 --- a/tests/OutputTest.php +++ b/tests/OutputTest.php @@ -5,6 +5,7 @@ use League\CLImate\Exceptions\InvalidArgumentException; use League\CLImate\Util\Output; use Mockery; + use function get_class; class OutputTest extends TestBase @@ -18,7 +19,7 @@ public function it_can_output_content() $out = Mockery::mock('League\CLImate\Util\Writer\StdOut'); $out->shouldReceive('write')->once()->with("Oh, hey there." . \PHP_EOL); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->defaultTo('out'); @@ -34,7 +35,7 @@ public function it_can_output_content_without_a_new_line() $out = Mockery::mock('League\CLImate\Util\Writer\StdOut'); $out->shouldReceive('write')->once()->with("Oh, hey there."); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->defaultTo('out'); @@ -50,7 +51,7 @@ public function it_can_default_to_a_writer() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with("Oh, hey there."); - $output = new Output; + $output = new Output(); $output->add('error', $error); $output->defaultTo('error'); @@ -70,7 +71,7 @@ public function it_can_default_to_multiple_writers() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with("Oh, hey there."); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -91,7 +92,7 @@ public function it_can_add_a_default() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with("Oh, hey there."); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -113,7 +114,7 @@ public function it_can_handle_multiple_writers_for_one_key() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with('Oh, hey there.'); - $output = new Output; + $output = new Output(); $output->add('combo', [$out, $error]); $output->defaultTo('combo'); @@ -133,7 +134,7 @@ public function it_can_take_existing_writer_keys_and_resolve_them() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with('Oh, hey there.'); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -150,7 +151,7 @@ public function it_can_get_the_available_writers() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $buffer = Mockery::mock('League\CLImate\Util\Writer\Buffer'); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -184,7 +185,7 @@ public function it_can_get_the_available_writers() public function it_will_yell_if_writer_does_not_implement_writer_interface() { $out = Mockery::mock('League\CLImate\Util\Writer\Wat'); - $output = new Output; + $output = new Output(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Class [" . get_class($out) . "] must implement League\CLImate\Util\Writer\WriterInterface."); @@ -195,7 +196,7 @@ public function it_will_yell_if_writer_does_not_implement_writer_interface() /** @test */ public function it_will_yell_if_trying_to_add_a_non_existent_nested_writer_key() { - $output = new Output; + $output = new Output(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Unable to resolve writer [nothin]"); @@ -215,7 +216,7 @@ public function it_can_write_to_a_non_default_writer_once() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->once()->with('First time.'); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -238,7 +239,7 @@ public function it_will_persist_writer_if_told_to() $error = Mockery::mock('League\CLImate\Util\Writer\StdErr'); $error->shouldReceive('write')->times(3)->with('First time.'); - $output = new Output; + $output = new Output(); $output->add('out', $out); $output->add('error', $error); @@ -260,7 +261,7 @@ public function it_can_retrieve_a_writer() $buffer->shouldReceive('write')->once()->with('Oh, hey there.'); $buffer->shouldReceive('get')->once()->andReturn('Oh, hey there.'); - $output = new Output; + $output = new Output(); $output->add('buffer', $buffer); $output->defaultTo('buffer'); diff --git a/tests/PaddingTest.php b/tests/PaddingTest.php index 74e2d0ac..5a65daf8 100644 --- a/tests/PaddingTest.php +++ b/tests/PaddingTest.php @@ -104,5 +104,4 @@ public function it_can_wrap_a_multibyte_line() $padding->label($content)->result('result'); } - } diff --git a/tests/SleeperTest.php b/tests/SleeperTest.php index 4fa86d3f..ad9d461a 100644 --- a/tests/SleeperTest.php +++ b/tests/SleeperTest.php @@ -14,7 +14,7 @@ class SleeperTest extends TestBase */ public function it_can_slow_down_the_sleeper_speed() { - $sleeper = new Sleeper; + $sleeper = new Sleeper(); $sleeper->speed(50); @@ -31,7 +31,7 @@ public function it_can_slow_down_the_sleeper_speed() */ public function it_can_speed_up_the_sleeper_speed() { - $sleeper = new Sleeper; + $sleeper = new Sleeper(); $sleeper->speed(200); @@ -48,7 +48,7 @@ public function it_can_speed_up_the_sleeper_speed() */ public function it_will_ignore_zero_percentages() { - $sleeper = new Sleeper; + $sleeper = new Sleeper(); $sleeper->speed(0); diff --git a/tests/StdinTest.php b/tests/StdinTest.php index ca32f1c9..74f21394 100644 --- a/tests/StdinTest.php +++ b/tests/StdinTest.php @@ -11,7 +11,7 @@ class StdinTest extends TestBase /** @test */ public function it_can_read_a_line_from_stdin() { - $stdin = new Stdin; + $stdin = new Stdin(); self::$functions->shouldReceive('fopen') ->once() @@ -31,7 +31,7 @@ public function it_can_read_a_line_from_stdin() /** @test */ public function it_can_read_multiple_lines_from_stdin() { - $stdin = new Stdin; + $stdin = new Stdin(); self::$functions->shouldReceive('fopen') ->once() @@ -51,7 +51,7 @@ public function it_can_read_multiple_lines_from_stdin() /** @test */ public function it_can_several_characters_from_stdin() { - $stdin = new Stdin; + $stdin = new Stdin(); self::$functions->shouldReceive('fopen') ->once() diff --git a/tests/TerminalObject/Basic/ClearLineTest.php b/tests/TerminalObject/Basic/ClearLineTest.php index 40792299..ac44daf1 100644 --- a/tests/TerminalObject/Basic/ClearLineTest.php +++ b/tests/TerminalObject/Basic/ClearLineTest.php @@ -6,7 +6,6 @@ class ClearLineTest extends TestBase { - /** * @doesNotPerformAssertions */ diff --git a/tests/TerminalObject/Basic/JsonTest.php b/tests/TerminalObject/Basic/JsonTest.php index db52fd48..1ef49b9f 100644 --- a/tests/TerminalObject/Basic/JsonTest.php +++ b/tests/TerminalObject/Basic/JsonTest.php @@ -3,6 +3,7 @@ namespace League\CLImate\Tests\TerminalObject\Basic; use League\CLImate\Tests\TestBase; + use function json_encode; use function str_replace; diff --git a/tests/TerminalObject/Dynamic/SpinnerTest.php b/tests/TerminalObject/Dynamic/SpinnerTest.php index 450887c0..dce12a50 100644 --- a/tests/TerminalObject/Dynamic/SpinnerTest.php +++ b/tests/TerminalObject/Dynamic/SpinnerTest.php @@ -3,11 +3,11 @@ namespace League\CLImate\Tests\TerminalObject\Dynamic; use League\CLImate\Tests\TestBase; + use function usleep; class SpinnerTest extends TestBase { - private function wait() { usleep(1000000);