Skip to content

Commit

Permalink
Increase PHPStand level to 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfeldmann committed Dec 19, 2021
1 parent d479959 commit c7a16b5
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 92 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameters:
level: 5
level: 6
paths:
- %currentWorkingDirectory%/src/
2 changes: 1 addition & 1 deletion src/Command/Add/AddFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $files
*
* @return \SebastianFeldmann\Git\Command\Add\AddFiles
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getCommand(): string
/**
* Return list of acceptable exit codes.
*
* @return array
* @return array<int>
*/
public function getAcceptableExitCodes(): array
{
Expand Down
10 changes: 5 additions & 5 deletions src/Command/Checkout/RestoreWorkingTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
class RestoreWorkingTree extends Base
{
/**
* Files and directories to restore.
* Files and directories to restore
*
* @var string[]
* @var array<string>
*/
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<string> $files
*
* @return \SebastianFeldmann\Git\Command\Checkout\RestoreWorkingTree
*/
Expand All @@ -44,7 +44,7 @@ public function files(array $files): RestoreWorkingTree
}

/**
* Return the command to execute.
* Return the command to execute
*
* @return string
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Config/ListSettings/MapSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
class MapSettings implements OutputFormatter
{
/**
* Format the output.
* Format the output
*
* @param array $output
* @return iterable
* @param array<string> $output
* @return iterable<string, string>
*/
public function format(array $output): iterable
{
Expand Down
36 changes: 18 additions & 18 deletions src/Command/Diff/Compare/FullDiffList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string, array<string>>
*/
private static $lineTypesToCheck = [
self::LINE_TYPE_START => [
Expand Down Expand Up @@ -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<string, string>
*/
private static $opsMap = [
'old' => File::OP_MODIFIED,
Expand All @@ -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<string> $output
* @return iterable<\SebastianFeldmann\Git\Diff\File>
*/
public function format(array $output): iterable
{
Expand All @@ -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
*
Expand All @@ -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];
Expand Down Expand Up @@ -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);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Command/DiffIndex/GetStagedFiles/FilterByStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@
class FilterByStatus implements OutputFormatter
{
/**
* List of status to keep.
* List of status to keep
*
* @var array
* @var array<string>
*/
private $status;

/**
* FilterByStatus constructor.
* FilterByStatus constructor
*
* @param array $status
* @param array<string> $status
*/
public function __construct(array $status)
{
$this->status = $status;
}

/**
* Format the output.
* Format the output
*
* @param array $output
* @return iterable
* @param array<string> $output
* @return iterable<string>
*/
public function format(array $output): iterable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DiffIndex/GetUnstagedPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GetUnstagedPatch extends Base
/**
* Return list of acceptable exit codes.
*
* @return array
* @return array<int>
*/
public function getAcceptableExitCodes(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Log/Commits/Jsonized.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Jsonized implements OutputFormatter
/**
* Format the output.
*
* @param array $output
* @return iterable
* @param array<string> $output
* @return iterable<Commit>
* @throws \Exception
*/
public function format(array $output): iterable
Expand Down
3 changes: 1 addition & 2 deletions src/Command/Rm/RemoveFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $files
* @return \SebastianFeldmann\Git\Command\Rm\RemoveFiles
*/
public function files(array $files): RemoveFiles
Expand Down
18 changes: 9 additions & 9 deletions src/Command/Status/Porcelain/PathList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $output
* @return iterable<Path>
*/
public function format(array $output): iterable
{
Expand All @@ -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<int, array<string, string, mixed>>
* @return array<int, array<int, string|null>>
*/
private function parseStatusLine(string $statusLine): array
{
Expand All @@ -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<string>
*/
private function splitOnNulByte(string $statusLine): array
{
Expand Down
10 changes: 5 additions & 5 deletions src/CommitMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function getRawContent(): string
*
* This includes lines that are comments.
*
* @return array
* @return array<string>
*/
public function getLines(): array
{
Expand Down Expand Up @@ -215,7 +215,7 @@ public function getBody(): string
/**
* Return lines from line nr. 3 to the last line
*
* @return array
* @return array<string>
*/
public function getBodyLines(): array
{
Expand All @@ -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<string> $rawLines
* @param string $commentCharacter
* @return array<string>
*/
private function getContentLines(array $rawLines, string $commentCharacter): array
{
Expand Down
Loading

0 comments on commit c7a16b5

Please sign in to comment.