Skip to content

Commit

Permalink
style: fix some code check error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 4, 2021
1 parent e8a3803 commit 432f556
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 175 deletions.
2 changes: 1 addition & 1 deletion app/Common/Cmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Cmd extends CmdBuilder
/**
* @var string
*/
protected $cmdline = '';
protected string $cmdline = '';

/**
* @param string $cmdline
Expand Down
6 changes: 3 additions & 3 deletions app/Common/CmdRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class CmdRunner extends AbstractCmdBuilder
*
* @var array[]|array
*/
private $commands = [];
private array $commands = [];

/**
* @param string|array $cmd
* @param array|string $cmd
* @param string $workDir
*
* @return static
*/
public static function new($cmd = '', string $workDir = ''): self
public static function new(array|string $cmd = '', string $workDir = ''): self
{
return new self($cmd, $workDir);
}
Expand Down
8 changes: 4 additions & 4 deletions app/Common/Creator/AbstractCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ abstract class AbstractCreator
*
* @var string
*/
protected $error = '';
protected string $error = '';

/**
* new project/component/library name
*
* @var string
*/
protected $name = '';
protected string $name = '';

/**
* Current work dir
*
* @var string
*/
protected $workDir = '';
protected string $workDir = '';

/**
* @var callable
Expand All @@ -43,7 +43,7 @@ abstract class AbstractCreator
*
* @return static
*/
public static function new(array $config = [])
public static function new(array $config = []): self
{
return new static($config);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Common/Creator/PhpPkgCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
class PhpPkgCreator extends AbstractCreator
{

public function validate(): bool
{
// TODO: Implement validate() method.
return true;
}

public function create(): void
Expand Down
23 changes: 14 additions & 9 deletions app/Common/Creator/ProjectCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,40 @@ class ProjectCreator extends AbstractCreator
*
* @var string
*/
private $type = '';
private string $type = '';

/**
* Repository name or repository url
*
* @var string
*/
private $repo = '';
private string $repo = '';

/**
* Repository github url
*
* @var string
*/
private $repoUrl = '';
private string $repoUrl = '';

/**
* Project path
*
* @var string
*/
private $projectPath = '';
private string $projectPath = '';

/**
* @var bool
*/
private $refresh = false;
private bool $refresh = false;

public static function new(array $config = [])
/**
* @param array $config
*
* @return static
*/
public static function new(array $config = []): self
{
return new self($config);
}
Expand Down Expand Up @@ -176,15 +181,15 @@ public function deleteDir(string $path): bool
*/
public function isFullUrl(string $str): bool
{
if (strpos($str, 'http:') === 0) {
if (str_starts_with($str, 'http:')) {
return true;
}

if (strpos($str, 'https:') === 0) {
if (str_starts_with($str, 'https:')) {
return true;
}

if (strpos($str, 'git@') === 0) {
if (str_starts_with($str, 'git@')) {
return true;
}

Expand Down
11 changes: 6 additions & 5 deletions app/Common/GitAPI/AbstractGitAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Inhere\Kite\Common\GitAPI;

use JsonException;
use PhpComp\Http\Client\AbstractClient;
use PhpComp\Http\Client\Client;
use PhpComp\Http\Client\ClientInterface;
Expand All @@ -21,21 +22,21 @@ abstract class AbstractGitAPI extends AbstractObj
/**
* @var string
*/
protected $baseUrl = 'https://gitlab.example.com/api/v4';
protected string $baseUrl = 'https://gitlab.example.com/api/v4';

/**
* The repository owner user/group
*
* @var string
*/
protected $group = '';
protected string $group = '';

/**
* The repository name
*
* @var string
*/
protected $repo = '';
protected string $repo = '';

/**
* Gitlab/Github person access token
Expand All @@ -44,7 +45,7 @@ abstract class AbstractGitAPI extends AbstractObj
* @see https://HOST/profile/personal_access_tokens on Gitlab
* @var string
*/
protected $token = '';
protected string $token = '';

/**
* @param string $group "gookit"
Expand Down Expand Up @@ -180,7 +181,7 @@ public function sendGET(string $uri): array
* @param array $data
*
* @return array
* @throws \JsonException
* @throws JsonException
*/
public function sendPOST(string $uriPath, array $data): array
{
Expand Down
2 changes: 1 addition & 1 deletion app/Common/GitAPI/GitHubV3API.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GitHubV3API extends AbstractGitAPI
/**
* @var string
*/
protected $baseUrl = self::BASE_API_URL;
protected string $baseUrl = self::BASE_API_URL;

/**
* @param int $issueId
Expand Down
8 changes: 4 additions & 4 deletions app/Common/GitAPI/GitLabV4API.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class GitLabV4API extends AbstractGitAPI
*
* @return array
*/
public function getGroupMembers($groupId): array
public function getGroupMembers(int|string $groupId): array
{

return [];
}

/**
Expand All @@ -26,8 +26,8 @@ public function getGroupMembers($groupId): array
*
* @return array
*/
public function getProjectMembers($projectId): array
public function getProjectMembers(int|string $projectId): array
{

return [];
}
}
44 changes: 22 additions & 22 deletions app/Common/GitLocal/AbstractGitLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,81 +26,81 @@ abstract class AbstractGitLocal
/**
* @var Repo
*/
protected $repo;
protected Repo $repo;

/**
* @var string
*/
protected $host = '';
protected string $host = '';

/**
* eg. git@gitlab.gongzl.com
*
* @var string
*/
protected $gitUrl = '';
protected string $gitUrl = '';

/**
* @var string
*/
protected $workDir = '';
protected string $workDir = '';

/**
* @var array
*/
protected $config;
protected array $config;

/**
* @var Output
*/
protected $output;
protected Output $output;

/**
* default remote name
*
* @var string
*/
protected $remote = 'origin';
protected string $remote = 'origin';

/**
* @var string
*/
protected $mainRemote = 'main';
protected string $mainRemote = 'main';

/**
* @var string
*/
protected $forkRemote = 'origin';
protected string $forkRemote = 'origin';

/**
* @var array
*/
protected $projects;
protected array $projects;

/**
* @var array
*/
protected $remoteInfo = [];
protected array $remoteInfo = [];

/**
* @var string
*/
protected $curMainGroup = '';
protected string $curMainGroup = '';

/**
* @var string
*/
protected $curForkGroup = '';
protected string $curForkGroup = '';

/**
* @var string
*/
protected $curRepo = '';
protected string $curRepo = '';

/**
* @var string
*/
protected $defaultBranch = 'master';
protected string $defaultBranch = 'master';

/**
* @var string
Expand All @@ -112,12 +112,12 @@ abstract class AbstractGitLocal
*
* @var string
*/
protected $curPjName = '';
protected string $curPjName = '';

/**
* @var array
*/
protected $curPjInfo = [];
protected array $curPjInfo = [];

/**
* @param Output|null $output
Expand Down Expand Up @@ -240,7 +240,7 @@ public function getCurBranch(): string
public function getRepoUrl(bool $toMain = false): string
{
$group = $toMain ? $this->getGroupName() : $this->getForkGroupName();
$path = "$group/{$this->curRepo}";
$path = $group . '/' . $this->curRepo;

return $this->host . '/' . $path . '.git';
}
Expand Down Expand Up @@ -428,22 +428,22 @@ public function getConfig(): array

/**
* @param string $key
* @param mixed $default
* @param mixed|null $default
*
* @return mixed
*/
public function getValue(string $key, $default = null)
public function getValue(string $key, mixed $default = null): mixed
{
return $this->config[$key] ?? $default;
}

/**
* @param string $key
* @param mixed $default
* @param mixed|null $default
*
* @return mixed
*/
public function getParam(string $key, $default = null)
public function getParam(string $key, mixed $default = null): mixed
{
return $this->config[$key] ?? $default;
}
Expand Down
6 changes: 3 additions & 3 deletions app/Common/GitLocal/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class GitHub extends AbstractGitLocal
*
* @var string
*/
private $curGroup = '';
private string $curGroup = '';

/**
* @var string
*/
private $srcBranch = '';
private string $srcBranch = '';

/**
* @var string
*/
private $dstBranch = '';
private string $dstBranch = '';

protected function init(array $config): void
{
Expand Down
Loading

0 comments on commit 432f556

Please sign in to comment.