From 8ec447f4508e2d7c4dc643cc195553987cab240c Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sun, 22 Apr 2018 23:04:49 +0200 Subject: [PATCH] Apply CS for PSR2 --- src/Gitonomy/Git/Commit.php | 4 +++- src/Gitonomy/Git/Diff/Diff.php | 6 ++++-- src/Gitonomy/Git/Exception/ProcessException.php | 3 ++- src/Gitonomy/Git/Parser/LogParser.php | 3 +-- src/Gitonomy/Git/Parser/ParserBase.php | 5 +++-- src/Gitonomy/Git/Repository.php | 2 +- src/Gitonomy/Git/WorkingCopy.php | 8 ++++++-- tests/Gitonomy/Git/Tests/AdminTest.php | 2 +- tests/Gitonomy/Git/Tests/DiffTest.php | 12 ++++++------ tests/Gitonomy/Git/Tests/PushReferenceTest.php | 8 ++++---- 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/Gitonomy/Git/Commit.php b/src/Gitonomy/Git/Commit.php index 8715e51..8ef3a01 100644 --- a/src/Gitonomy/Git/Commit.php +++ b/src/Gitonomy/Git/Commit.php @@ -221,7 +221,9 @@ public function getIncludingBranches($local = true, $remote = true) } $branchesName = explode("\n", trim(str_replace('*', '', $result))); - $branchesName = array_filter($branchesName, function ($v) { return false === StringHelper::strpos($v, '->');}); + $branchesName = array_filter($branchesName, function ($v) { + return false === StringHelper::strpos($v, '->'); + }); $branchesName = array_map('trim', $branchesName); $references = $this->repository->getReferences(); diff --git a/src/Gitonomy/Git/Diff/Diff.php b/src/Gitonomy/Git/Diff/Diff.php index 180ca25..8ace7ce 100644 --- a/src/Gitonomy/Git/Diff/Diff.php +++ b/src/Gitonomy/Git/Diff/Diff.php @@ -101,7 +101,8 @@ public function toArray() 'files' => array_map( function (File $file) { return $file->toArray(); - }, $this->files + }, + $this->files ), ); } @@ -119,7 +120,8 @@ public static function fromArray(array $array) array_map( function ($array) { return File::fromArray($array); - }, $array['files'] + }, + $array['files'] ), $array['rawDiff'] ); diff --git a/src/Gitonomy/Git/Exception/ProcessException.php b/src/Gitonomy/Git/Exception/ProcessException.php index 604cecb..6d6b691 100644 --- a/src/Gitonomy/Git/Exception/ProcessException.php +++ b/src/Gitonomy/Git/Exception/ProcessException.php @@ -10,7 +10,8 @@ class ProcessException extends RuntimeException implements GitExceptionInterface public function __construct(Process $process) { - parent::__construct("Error while running git command:\n". + parent::__construct( + "Error while running git command:\n". $process->getCommandLine()."\n". "\n". $process->getErrorOutput()."\n". diff --git a/src/Gitonomy/Git/Parser/LogParser.php b/src/Gitonomy/Git/Parser/LogParser.php index d4aa721..62e1ea7 100644 --- a/src/Gitonomy/Git/Parser/LogParser.php +++ b/src/Gitonomy/Git/Parser/LogParser.php @@ -58,8 +58,7 @@ protected function doParse() $message .= $this->consumeTo("\n")."\n"; $this->consumeNewLine(); } - } - else { + } else { $this->cursor--; } diff --git a/src/Gitonomy/Git/Parser/ParserBase.php b/src/Gitonomy/Git/Parser/ParserBase.php index aebd4e6..3bff8aa 100644 --- a/src/Gitonomy/Git/Parser/ParserBase.php +++ b/src/Gitonomy/Git/Parser/ParserBase.php @@ -123,11 +123,12 @@ protected function consumeNewLine() /** * @return string */ - protected function consumeGPGSignature() { + protected function consumeGPGSignature() + { $expected = "\ngpgsig "; $length = strlen($expected); $actual = substr($this->content, $this->cursor, $length); - if($actual != $expected) { + if ($actual != $expected) { return ''; } $this->cursor += $length; diff --git a/src/Gitonomy/Git/Repository.php b/src/Gitonomy/Git/Repository.php index 5adf09c..ffd1428 100644 --- a/src/Gitonomy/Git/Repository.php +++ b/src/Gitonomy/Git/Repository.php @@ -153,7 +153,7 @@ private function initDir($gitDir, $workingDir = null) if (false === $realGitDir) { throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $gitDir)); - } else if (!is_dir($realGitDir)) { + } elseif (!is_dir($realGitDir)) { throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $realGitDir)); } elseif (null === $workingDir && is_dir($realGitDir.'/.git')) { $workingDir = $realGitDir; diff --git a/src/Gitonomy/Git/WorkingCopy.php b/src/Gitonomy/Git/WorkingCopy.php index 7cc0649..1caa79c 100644 --- a/src/Gitonomy/Git/WorkingCopy.php +++ b/src/Gitonomy/Git/WorkingCopy.php @@ -42,8 +42,12 @@ public function getStatus() public function getUntrackedFiles() { $lines = explode("\0", $this->run('status', array('--porcelain', '--untracked-files=all', '-z'))); - $lines = array_filter($lines, function ($l) { return substr($l, 0, 3) === '?? '; }); - $lines = array_map(function ($l) { return substr($l, 3); }, $lines); + $lines = array_filter($lines, function ($l) { + return substr($l, 0, 3) === '?? '; + }); + $lines = array_map(function ($l) { + return substr($l, 3); + }, $lines); return $lines; } diff --git a/tests/Gitonomy/Git/Tests/AdminTest.php b/tests/Gitonomy/Git/Tests/AdminTest.php index 9f2a187..87e7a38 100644 --- a/tests/Gitonomy/Git/Tests/AdminTest.php +++ b/tests/Gitonomy/Git/Tests/AdminTest.php @@ -36,7 +36,7 @@ public function testBare() $objectDir = $this->tmpDir.'/objects'; $this->assertTrue($repository->isBare(), 'Repository is bare'); - $this->assertTrue(is_dir($objectDir), 'objects/ folder is present'); + $this->assertTrue(is_dir($objectDir), 'objects/ folder is present'); $this->assertTrue($repository instanceof Repository, 'Admin::init returns a repository'); $this->assertEquals($this->tmpDir, $repository->getGitDir(), 'The folder passed as argument is git dir'); $this->assertNull($repository->getWorkingDir(), 'No working dir in bare repository'); diff --git a/tests/Gitonomy/Git/Tests/DiffTest.php b/tests/Gitonomy/Git/Tests/DiffTest.php index d9ad4e0..cf6e0ac 100644 --- a/tests/Gitonomy/Git/Tests/DiffTest.php +++ b/tests/Gitonomy/Git/Tests/DiffTest.php @@ -48,13 +48,13 @@ protected function verifyCreateCommitDiff(Diff $diff) $this->assertTrue($files[0]->isCreation(), 'script_A.php created'); - $this->assertEquals(null, $files[0]->getOldName(), 'First file name is a new file'); + $this->assertEquals(null, $files[0]->getOldName(), 'First file name is a new file'); $this->assertEquals('script_A.php', $files[0]->getNewName(), 'First file name is script_A.php'); - $this->assertEquals(null, $files[0]->getOldMode(), 'First file mode is a new file'); - $this->assertEquals('100644', $files[0]->getNewMode(), 'First file mode is correct'); + $this->assertEquals(null, $files[0]->getOldMode(), 'First file mode is a new file'); + $this->assertEquals('100644', $files[0]->getNewMode(), 'First file mode is correct'); $this->assertEquals(1, $files[0]->getAdditions(), '1 line added'); - $this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted'); + $this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted'); } /** @@ -70,8 +70,8 @@ public function testGetFiles_Modification($repository) $this->assertEquals('image.jpg', $files[0]->getOldName(), 'Second file name is image.jpg'); $this->assertEquals('image.jpg', $files[0]->getNewName(), 'Second file name is image.jpg'); - $this->assertEquals('100644', $files[0]->getOldMode(), 'Second file mode is a new file'); - $this->assertEquals('100644', $files[0]->getNewMode(), 'Second file mode is correct'); + $this->assertEquals('100644', $files[0]->getOldMode(), 'Second file mode is a new file'); + $this->assertEquals('100644', $files[0]->getNewMode(), 'Second file mode is correct'); $this->assertTrue($files[0]->isBinary(), 'binary file'); $this->assertEquals(0, $files[0]->getAdditions(), '0 lines added'); diff --git a/tests/Gitonomy/Git/Tests/PushReferenceTest.php b/tests/Gitonomy/Git/Tests/PushReferenceTest.php index 9795b25..b17fae0 100644 --- a/tests/Gitonomy/Git/Tests/PushReferenceTest.php +++ b/tests/Gitonomy/Git/Tests/PushReferenceTest.php @@ -37,10 +37,10 @@ public function provideIsers() public function testIsers($reference, $before, $after, $mask) { $reference = new PushReference(self::createFoobarRepository(), $reference, $before, $after); - $this->assertEquals($mask & self::CREATE, $reference->isCreate(), 'Create value is correct.'); - $this->assertEquals($mask & self::DELETE, $reference->isDelete(), 'Delete value is correct.'); - $this->assertEquals($mask & self::FORCE, $reference->isForce(), 'Force value is correct.'); - $this->assertEquals($mask & self::FAST_FORWARD, $reference->isFastForward(), 'FastForward value is correct.'); + $this->assertEquals($mask & self::CREATE, $reference->isCreate(), 'Create value is correct.'); + $this->assertEquals($mask & self::DELETE, $reference->isDelete(), 'Delete value is correct.'); + $this->assertEquals($mask & self::FORCE, $reference->isForce(), 'Force value is correct.'); + $this->assertEquals($mask & self::FAST_FORWARD, $reference->isFastForward(), 'FastForward value is correct.'); } /**