From 859153afb8cb26f642903d68cd186e4ea378c822 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 29 Nov 2024 10:47:27 +1100 Subject: [PATCH] Fixed coding standards. --- src/Commands/ArtifactCommand.php | 8 ++++---- src/Traits/FilesystemTrait.php | 4 ++-- tests/phpunit/Exception/ErrorException.php | 2 +- tests/phpunit/Traits/CommandTrait.php | 8 ++++---- tests/phpunit/Traits/ReflectionTrait.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Commands/ArtifactCommand.php b/src/Commands/ArtifactCommand.php index 84c0277..0b79b54 100644 --- a/src/Commands/ArtifactCommand.php +++ b/src/Commands/ArtifactCommand.php @@ -138,8 +138,8 @@ class ArtifactCommand extends Command { * Command name. */ public function __construct( - ArtifactGit $gitWrapper = NULL, - Filesystem $fsFileSystem = NULL, + ?ArtifactGit $gitWrapper = NULL, + ?Filesystem $fsFileSystem = NULL, ?string $name = NULL, ) { parent::__construct($name); @@ -813,7 +813,7 @@ protected function restoreLocalExclude(string $path): void { * @throws \Exception * If removal command finished with an error. */ - protected function removeIgnoredFiles(string $location, string $gitignorePath = NULL): void { + protected function removeIgnoredFiles(string $location, ?string $gitignorePath = NULL): void { $location = $this->getSourcePathGitRepository(); $gitignorePath = $gitignorePath ?: $location . DIRECTORY_SEPARATOR . '.gitignore'; @@ -912,7 +912,7 @@ protected function getTokenBranch(): string { * * @throws \Exception */ - protected function getTokenTags(string $delimiter = NULL): string { + protected function getTokenTags(?string $delimiter = NULL): string { $delimiter = $delimiter ?: '-'; // We just want to get all tags point to the HEAD. $tags = $this diff --git a/src/Traits/FilesystemTrait.php b/src/Traits/FilesystemTrait.php index f306e02..a1d4f3d 100644 --- a/src/Traits/FilesystemTrait.php +++ b/src/Traits/FilesystemTrait.php @@ -41,7 +41,7 @@ trait FilesystemTrait { * * @throws \Exception */ - protected function fsSetRootDir(string $path = NULL): void { + protected function fsSetRootDir(?string $path = NULL): void { $path = empty($path) ? $this->fsGetRootDir() : $this->fsGetAbsolutePath($path); $this->fsPathsExist($path); $this->fsRootDir = $path; @@ -129,7 +129,7 @@ protected function fsIsCommandAvailable(string $command): bool { * @return string * Absolute path for provided file. */ - protected function fsGetAbsolutePath(string $file, string $root = NULL): string { + protected function fsGetAbsolutePath(string $file, ?string $root = NULL): string { if ($this->fsFileSystem->isAbsolutePath($file)) { return $this->realpath($file); } diff --git a/tests/phpunit/Exception/ErrorException.php b/tests/phpunit/Exception/ErrorException.php index a2a08bf..f4e7e43 100644 --- a/tests/phpunit/Exception/ErrorException.php +++ b/tests/phpunit/Exception/ErrorException.php @@ -14,7 +14,7 @@ class ErrorException extends Exception { /** * {@inheritdoc} */ - public function __construct(string $message, int $code, string $file, int $line, \Exception $previous = NULL) { + public function __construct(string $message, int $code, string $file, int $line, ?\Exception $previous = NULL) { parent::__construct($message, $code, $previous); $this->file = $file; diff --git a/tests/phpunit/Traits/CommandTrait.php b/tests/phpunit/Traits/CommandTrait.php index e745275..2063818 100644 --- a/tests/phpunit/Traits/CommandTrait.php +++ b/tests/phpunit/Traits/CommandTrait.php @@ -183,7 +183,7 @@ protected function gitGetCommittedFiles(string $path): array { * Optional path to the repository directory. If not provided, fixture * directory is used. */ - protected function gitCreateFixtureCommits(int $count, int $offset = 0, string $path = NULL): void { + protected function gitCreateFixtureCommits(int $count, int $offset = 0, ?string $path = NULL): void { $path = $path ? $path : $this->src; for ($i = $offset; $i < $count + $offset; $i++) { $this->gitCreateFixtureCommit($i + 1, $path); @@ -202,7 +202,7 @@ protected function gitCreateFixtureCommits(int $count, int $offset = 0, string $ * @return string * Hash of created commit. */ - protected function gitCreateFixtureCommit(int $index, string $path = NULL): string { + protected function gitCreateFixtureCommit(int $index, ?string $path = NULL): string { $path = $path ? $path : $this->src; $filename = 'f' . $index; $this->gitCreateFixtureFile($path, $filename); @@ -348,7 +348,7 @@ protected function gitAddTag(string $path, string $name, bool $annotate = FALSE) * * @todo Update arguments order and add assertion message. */ - protected function gitAssertFilesExist(string $path, $files, string $branch = NULL): void { + protected function gitAssertFilesExist(string $path, $files, ?string $branch = NULL): void { $files = is_array($files) ? $files : [$files]; if ($branch) { $this->gitCheckout($path, $branch); @@ -368,7 +368,7 @@ protected function gitAssertFilesExist(string $path, $files, string $branch = NU * @param string|null $branch * Optional branch. If set, will be checked out before assertion. */ - protected function gitAssertFilesNotExist(string $path, $files, string $branch = NULL): void { + protected function gitAssertFilesNotExist(string $path, $files, ?string $branch = NULL): void { $files = is_array($files) ? $files : [$files]; if ($branch) { $this->gitCheckout($path, $branch); diff --git a/tests/phpunit/Traits/ReflectionTrait.php b/tests/phpunit/Traits/ReflectionTrait.php index adaf451..bec0658 100644 --- a/tests/phpunit/Traits/ReflectionTrait.php +++ b/tests/phpunit/Traits/ReflectionTrait.php @@ -89,7 +89,7 @@ protected static function setProtectedValue($object, $property, mixed $value): v * @return mixed * Protected property value. */ - protected static function getProtectedValue($object, $property) { + protected static function getProtectedValue($object, $property): mixed { $class = new \ReflectionClass($object::class); $property = $class->getProperty($property); $property->setAccessible(TRUE);