diff --git a/phpstan.neon b/phpstan.neon index f4476cb..3090d32 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 5 + level: 6 paths: - %currentWorkingDirectory%/src/ diff --git a/src/Command/Add/AddFiles.php b/src/Command/Add/AddFiles.php index 394bf5d..abc1002 100644 --- a/src/Command/Add/AddFiles.php +++ b/src/Command/Add/AddFiles.php @@ -150,7 +150,7 @@ public function intentToAdd(bool $bool = true): AddFiles * `dir/file1` modified in the working tree, a file `dir/file2` added to the * working tree, but also a file `dir/file3` removed from the working tree). * - * @param array $files + * @param array $files * * @return \SebastianFeldmann\Git\Command\Add\AddFiles */ diff --git a/src/Command/Base.php b/src/Command/Base.php index a0a259b..91dc1ba 100644 --- a/src/Command/Base.php +++ b/src/Command/Base.php @@ -65,7 +65,7 @@ public function getCommand(): string /** * Return list of acceptable exit codes. * - * @return array + * @return array */ public function getAcceptableExitCodes(): array { diff --git a/src/Command/Checkout/RestoreWorkingTree.php b/src/Command/Checkout/RestoreWorkingTree.php index d27b1ae..e0724c8 100644 --- a/src/Command/Checkout/RestoreWorkingTree.php +++ b/src/Command/Checkout/RestoreWorkingTree.php @@ -24,16 +24,16 @@ class RestoreWorkingTree extends Base { /** - * Files and directories to restore. + * Files and directories to restore * - * @var string[] + * @var array */ private $files = ['.']; /** - * Limits the paths affected by the operation to those specified here. + * Limits the paths affected by the operation to those specified here * - * @param array $files + * @param array $files * * @return \SebastianFeldmann\Git\Command\Checkout\RestoreWorkingTree */ @@ -44,7 +44,7 @@ public function files(array $files): RestoreWorkingTree } /** - * Return the command to execute. + * Return the command to execute * * @return string */ diff --git a/src/Command/Config/ListSettings/MapSettings.php b/src/Command/Config/ListSettings/MapSettings.php index 2af9357..fcc8919 100644 --- a/src/Command/Config/ListSettings/MapSettings.php +++ b/src/Command/Config/ListSettings/MapSettings.php @@ -24,10 +24,10 @@ class MapSettings implements OutputFormatter { /** - * Format the output. + * Format the output * - * @param array $output - * @return iterable + * @param array $output + * @return iterable */ public function format(array $output): iterable { diff --git a/src/Command/Diff/Compare/FullDiffList.php b/src/Command/Diff/Compare/FullDiffList.php index f5e9ca7..105a407 100644 --- a/src/Command/Diff/Compare/FullDiffList.php +++ b/src/Command/Diff/Compare/FullDiffList.php @@ -29,7 +29,7 @@ class FullDiffList implements OutputFormatter { /** - * Available line types of git diff output. + * Available line types of git diff output */ private const LINE_TYPE_START = 'Start'; private const LINE_TYPE_HEADER = 'Header'; @@ -41,11 +41,11 @@ class FullDiffList implements OutputFormatter private const LINE_TYPE_CODE = 'ChangeCode'; /** - * Search and parse strategy. + * Search and parse strategy * * Define possible follow up lines for each line type to minimize search effort. * - * @var array + * @var array> */ private static $lineTypesToCheck = [ self::LINE_TYPE_START => [ @@ -82,9 +82,9 @@ class FullDiffList implements OutputFormatter ]; /** - * Maps git diff output to file operations. + * Maps git diff output to file operations * - * @var array + * @var array */ private static $opsMap = [ 'old' => File::OP_MODIFIED, @@ -95,52 +95,52 @@ class FullDiffList implements OutputFormatter ]; /** - * List of diff File objects. + * List of diff File objects * - * @var \SebastianFeldmann\Git\Diff\File[] + * @var array<\SebastianFeldmann\Git\Diff\File> */ private $files = []; /** - * The currently processed file. + * The currently processed file * * @var \SebastianFeldmann\Git\Diff\File */ private $currentFile; /** - * The file name of the currently processed file. + * The file name of the currently processed file * * @var string */ private $currentFileName; /** - * The change position of the currently processed file. + * The change position of the currently processed file * * @var string */ private $currentPosition; /** - * The operation of the currently processed file. + * The operation of the currently processed file * * @var string */ private $currentOperation; /** - * List of collected changes. + * List of collected changes * * @var \SebastianFeldmann\Git\Diff\Change[] */ private $currentChanges = []; /** - * Format the output. + * Format the output * - * @param array $output - * @return iterable + * @param array $output + * @return iterable<\SebastianFeldmann\Git\Diff\File> */ public function format(array $output): iterable { @@ -166,7 +166,7 @@ public function format(array $output): iterable } /** - * Is the given line a diff header line. + * Is the given line a diff header line * * diff --git a/some/file b/some/file * @@ -176,7 +176,7 @@ public function format(array $output): iterable private function isHeaderLine(string $line): bool { $matches = []; - if (preg_match('#^diff --git [a|b|c|i|w|o]/(.*) [a|b|c|i|w|o]/(.*)#', $line, $matches)) { + if (preg_match('#^diff --git [abciwo]/(.*) [abciwo]/(.*)#', $line, $matches)) { $this->appendCollectedFileAndChanges(); $this->currentOperation = File::OP_MODIFIED; $this->currentFileName = $matches[2]; @@ -250,7 +250,7 @@ private function isHeaderIndexLine(string $line): bool private function isHeaderFormatLine(string $line): bool { $matches = []; - return (bool)preg_match('#^[\-\+]{3} [a|b|c|i|w|o]?/.*#', $line, $matches); + return (bool)preg_match('#^[\\-\\+]{3} [abciwo]?/.*#', $line, $matches); } /** diff --git a/src/Command/DiffIndex/GetStagedFiles/FilterByStatus.php b/src/Command/DiffIndex/GetStagedFiles/FilterByStatus.php index 9c7a958..17dd962 100644 --- a/src/Command/DiffIndex/GetStagedFiles/FilterByStatus.php +++ b/src/Command/DiffIndex/GetStagedFiles/FilterByStatus.php @@ -24,16 +24,16 @@ class FilterByStatus implements OutputFormatter { /** - * List of status to keep. + * List of status to keep * - * @var array + * @var array */ private $status; /** - * FilterByStatus constructor. + * FilterByStatus constructor * - * @param array $status + * @param array $status */ public function __construct(array $status) { @@ -41,10 +41,10 @@ public function __construct(array $status) } /** - * Format the output. + * Format the output * - * @param array $output - * @return iterable + * @param array $output + * @return iterable */ public function format(array $output): iterable { diff --git a/src/Command/DiffIndex/GetUnstagedPatch.php b/src/Command/DiffIndex/GetUnstagedPatch.php index c6d30ca..29c7944 100644 --- a/src/Command/DiffIndex/GetUnstagedPatch.php +++ b/src/Command/DiffIndex/GetUnstagedPatch.php @@ -34,7 +34,7 @@ class GetUnstagedPatch extends Base /** * Return list of acceptable exit codes. * - * @return array + * @return array */ public function getAcceptableExitCodes(): array { diff --git a/src/Command/Log/Commits/Jsonized.php b/src/Command/Log/Commits/Jsonized.php index d955561..064c1c4 100644 --- a/src/Command/Log/Commits/Jsonized.php +++ b/src/Command/Log/Commits/Jsonized.php @@ -34,8 +34,8 @@ class Jsonized implements OutputFormatter /** * Format the output. * - * @param array $output - * @return iterable + * @param array $output + * @return iterable * @throws \Exception */ public function format(array $output): iterable diff --git a/src/Command/Rm/RemoveFiles.php b/src/Command/Rm/RemoveFiles.php index 6249fb0..db3183a 100644 --- a/src/Command/Rm/RemoveFiles.php +++ b/src/Command/Rm/RemoveFiles.php @@ -107,8 +107,7 @@ public function recursive(bool $bool = true): RemoveFiles * `git rm 'd*'` and `git rm 'd/*'`, as the former will also remove all of * directory `d2`. * - * @param array $files - * + * @param array $files * @return \SebastianFeldmann\Git\Command\Rm\RemoveFiles */ public function files(array $files): RemoveFiles diff --git a/src/Command/Status/Porcelain/PathList.php b/src/Command/Status/Porcelain/PathList.php index db68f18..f51e609 100644 --- a/src/Command/Status/Porcelain/PathList.php +++ b/src/Command/Status/Porcelain/PathList.php @@ -25,15 +25,15 @@ class PathList implements OutputFormatter { /** - * Nul-byte used as a separator in `--porcelain=v1 -z` output. + * Nul-byte used as a separator in `--porcelain=v1 -z` output */ private const NUL_BYTE = "\x00"; /** - * Format the output. + * Format the output * - * @param array $output - * @return iterable + * @param array $output + * @return iterable */ public function format(array $output): iterable { @@ -52,13 +52,13 @@ public function format(array $output): iterable } /** - * Parse the status line and return a 3-tuple of path parts. + * Parse the status line and return a 3-tuple of path parts * * - 0: status code * - 1: path * - 2: original path, if renamed or copied * - * @return array> + * @return array> */ private function parseStatusLine(string $statusLine): array { @@ -83,10 +83,10 @@ private function parseStatusLine(string $statusLine): array } /** - * Split the status line on the nul-byte. + * Split the status line on the nul-byte * - * @param string $statusLine - * @return array + * @param string $statusLine + * @return array */ private function splitOnNulByte(string $statusLine): array { diff --git a/src/CommitMessage.php b/src/CommitMessage.php index 0ba7a30..965c3ce 100644 --- a/src/CommitMessage.php +++ b/src/CommitMessage.php @@ -139,7 +139,7 @@ public function getRawContent(): string * * This includes lines that are comments. * - * @return array + * @return array */ public function getLines(): array { @@ -215,7 +215,7 @@ public function getBody(): string /** * Return lines from line nr. 3 to the last line * - * @return array + * @return array */ public function getBodyLines(): array { @@ -237,9 +237,9 @@ public function getCommentCharacter(): string /** * Get the lines that are not comments * - * @param array $rawLines - * @param string $commentCharacter - * @return string[] + * @param array $rawLines + * @param string $commentCharacter + * @return array */ private function getContentLines(array $rawLines, string $commentCharacter): array { diff --git a/src/Diff/Change.php b/src/Diff/Change.php index 5e8c115..fcb2f9b 100644 --- a/src/Diff/Change.php +++ b/src/Diff/Change.php @@ -62,7 +62,7 @@ public function __construct(string $ranges, string $header = '') } /** - * Header getter. + * Header getter * * @return string */ @@ -72,9 +72,9 @@ public function getHeader(): string } /** - * Pre range getter. + * Pre range getter * - * @return array + * @return array */ public function getPre(): array { @@ -82,9 +82,9 @@ public function getPre(): array } /** - * Post range getter. + * Post range getter * - * @return array + * @return array */ public function getPost(): array { @@ -92,7 +92,7 @@ public function getPost(): array } /** - * Return list of changed lines. + * Return list of changed lines * * @return \SebastianFeldmann\Git\Diff\Line[] */ @@ -118,7 +118,7 @@ public function getAddedContent(): array } /** - * Add a line to the change. + * Add a line to the change * * @param \SebastianFeldmann\Git\Diff\Line $line * @return void @@ -129,7 +129,7 @@ public function addLine(Line $line): void } /** - * Parse ranges and split them into pre and post range. + * Parse ranges and split them into pre and post range * * @param string $ranges * @return void @@ -153,12 +153,12 @@ function ($value) { $this->pre = [ 'from' => isset($matches[1]) ? (int) $matches[1] : null, - 'to' => isset($matches[2]) ? (int) $matches[2] : null, + 'to' => isset($matches[2]) ? (int) $matches[2] : null, ]; $this->post = [ 'from' => isset($matches[3]) ? (int) $matches[3] : null, - 'to' => isset($matches[4]) ? (int) $matches[4] : null, + 'to' => isset($matches[4]) ? (int) $matches[4] : null, ]; } } diff --git a/src/Diff/Line.php b/src/Diff/Line.php index 59005cb..f2c94f8 100644 --- a/src/Diff/Line.php +++ b/src/Diff/Line.php @@ -29,7 +29,7 @@ class Line /** * Map diff output to file operation - * @var array + * @var array */ public static $opsMap = [ '+' => self::ADDED, diff --git a/src/Log/Commit.php b/src/Log/Commit.php index 1bcc96b..e52b1d1 100644 --- a/src/Log/Commit.php +++ b/src/Log/Commit.php @@ -27,7 +27,7 @@ class Commit private $hash; /** - * @var array + * @var array */ private $names; @@ -52,10 +52,10 @@ class Commit private $author; /** - * Commit constructor. + * Commit constructor * * @param string $hash - * @param array $names + * @param array $names * @param string $subject * @param string $body * @param \DateTimeImmutable $date @@ -78,7 +78,7 @@ public function __construct( } /** - * Hash getter. + * Hash getter * * @return string */ @@ -88,7 +88,7 @@ public function getHash(): string } /** - * Does the commit have names. + * Does the commit have names * * @return bool */ @@ -98,9 +98,9 @@ public function hasNames(): bool } /** - * Names getter. + * Names getter * - * @return array + * @return array */ public function getNames(): array { @@ -108,7 +108,7 @@ public function getNames(): array } /** - * Description getter. + * Description getter * * @deprecated * @@ -120,7 +120,7 @@ public function getDescription(): string } /** - * Subject getter. + * Subject getter * * @return string */ @@ -130,7 +130,7 @@ public function getSubject(): string } /** - * Body getter. + * Body getter * * @return string */ @@ -140,7 +140,7 @@ public function getBody(): string } /** - * Date getter. + * Date getter * * @return \DateTimeImmutable */ @@ -150,7 +150,7 @@ public function getDate(): \DateTimeImmutable } /** - * Author getter. + * Author getter * * @return string */ diff --git a/src/Operator/Config.php b/src/Operator/Config.php index b44465b..58138ae 100644 --- a/src/Operator/Config.php +++ b/src/Operator/Config.php @@ -76,7 +76,7 @@ public function getSafely(string $name, string $default = '') * * For example: ['color.branch' => 'auto', 'color.diff' => 'auto] * - * @return array + * @return array */ public function getSettings(): array { diff --git a/src/Operator/Index.php b/src/Operator/Index.php index 41280c0..b06903a 100644 --- a/src/Operator/Index.php +++ b/src/Operator/Index.php @@ -53,7 +53,7 @@ class Index extends Base * Get the list of files that changed * * @param array $diffFilter List of status you want to get returned, choose from [A,C,D,M,R,T,U,X,B,*] - * @return array + * @return array */ public function getStagedFiles(array $diffFilter = []): array { @@ -125,8 +125,8 @@ public function updateIndex(array $files): bool * If `$ignoreRemoval` is `true`, files removed in the working tree are * ignored and not removed from the index. * - * @param array $files - * @param bool $ignoreRemoval Ignore files that have been removed from the working tree + * @param array $files + * @param bool $ignoreRemoval Ignore files that have been removed from the working tree * @return bool */ public function updateIndexToMatchWorkingTree(array $files, bool $ignoreRemoval = false): bool @@ -148,7 +148,7 @@ public function updateIndexToMatchWorkingTree(array $files, bool $ignoreRemoval * * An entry for the path is placed in the index with no content. * - * @param array $files + * @param array $files * @return bool */ public function recordIntentToAddFiles(array $files): bool @@ -162,10 +162,10 @@ public function recordIntentToAddFiles(array $files): bool /** * Remove files from the working tree and from the index * - * @param array $files The files to remove. - * @param bool $recursive Allow recursive removal when a leading directory name is given - * @param bool $cachedOnly Unstage and remove paths only from the index. - * The working tree is untouched. + * @param array $files The files to remove. + * @param bool $recursive Allow recursive removal when a leading directory name is given + * @param bool $cachedOnly Unstage and remove paths only from the index. + * The working tree is untouched. * @return bool */ public function removeFiles( @@ -234,17 +234,20 @@ private function cacheFiles(array $diffFilter, array $files): void /** * Retrieve files from cache * - * @param array $diffFilter - * @return array + * @param array $diffFilter + * @return array */ private function retrieveFromCache(array $diffFilter): array { - print_r($this->files); return $this->files[implode($diffFilter)]; } /** * Sort files by file suffix + * + * @param string $suffix + * @param array $diffFilter + * @return array */ private function retrieveStagedFilesByType(string $suffix, array $diffFilter): array { diff --git a/src/Repository.php b/src/Repository.php index b64054f..8705eba 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -55,7 +55,7 @@ class Repository /** * Map of operators * - * @var array + * @var array */ private $operator = []; diff --git a/src/Url.php b/src/Url.php index d6644fb..dbdd5e1 100644 --- a/src/Url.php +++ b/src/Url.php @@ -145,7 +145,7 @@ public function getRepoName(): string * Detect the url components * * @param string $url - * @return array + * @return array */ private function parseUrl(string $url): array {