Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5932390

Browse files
style: #43 Slevomat
1 parent e4622cd commit 5932390

25 files changed

+266
-24
lines changed

‎composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"mockery/mockery": "^1.4",
1414
"phpmd/phpmd": "^2.10",
1515
"phpunit/phpunit": "^9.5",
16+
"slevomat/coding-standard": "^7.0",
1617
"squizlabs/php_codesniffer": "^3.6"
1718
},
1819
"license": "Apache-2.0",
@@ -25,6 +26,13 @@
2526
"scripts": {
2627
"post-install-cmd": [
2728
"php -r \"if (is_dir('.git/hooks/')) {copy('.git-pre-commit', '.git/hooks/pre-commit'); chmod('.git/hooks/pre-commit', 0755);}\""
28-
]
29+
],
30+
"lint": "phpcs --standard=phpcs.xml .",
31+
"lint-fix": "phpcbf --standard=phpcs.xml ."
32+
},
33+
"config": {
34+
"allow-plugins": {
35+
"dealerdirect/phpcodesniffer-composer-installer": true
36+
}
2937
}
3038
}

‎composer.lock-php8.0

Lines changed: 182 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lang/en/validation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return [
46

57
/*

‎phpcs.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
<?xml version="1.0"?>
2-
<ruleset name="PSR12-FOO">
3-
<description>The PSR12 standard.</description>
2+
<ruleset name="PSR12-Slevomat">
43
<exclude-pattern>/vendor/</exclude-pattern>
54
<arg name="extensions" value="php" />
65

76
<!-- Include the whole PSR12 standard -->
8-
<rule ref="PSR12"/>
7+
<rule ref="PSR12" />
8+
9+
<config name="installed_paths" value="../../slevomat/coding-standard" />
10+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
11+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
12+
<properties>
13+
<property name="declareOnFirstLine" value="false" />
14+
<property name="linesCountBeforeDeclare" value="1" />
15+
<property name="linesCountAfterDeclare" value="1" />
16+
<property name="spacesCountAroundEqualsSign" value="0" />
17+
</properties>
18+
</rule>
919
</ruleset>

‎src/Base.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding;
46

57
use Coding\Exceptions\ValidationException;
@@ -14,7 +16,7 @@ public function __construct(Client $client = null)
1416
$this->client = $client ?? new Client();
1517
}
1618

17-
protected function validate(array $data, array $rules)
19+
protected function validate(array $data, array $rules): void
1820
{
1921
$validator = Validator::getInstance()->make($data, $rules);
2022
if ($validator->fails()) {

‎src/Client.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding;
46

57
use Coding\Exceptions\ApiError;
@@ -34,14 +36,14 @@ public function setHttpClient(ClientInterface $http): void
3436

3537
public function getHttpClient(): ClientInterface
3638
{
37-
if (null === $this->http) {
39+
if (is_null($this->http)) {
3840
$this->http = new GuzzleClient();
3941
}
4042

4143
return $this->http;
4244
}
4345

44-
public function request(string $action, array $data)
46+
public function request(string $action, array $data): array
4547
{
4648
$params = ['Action' => $action];
4749
$response = $this->getHttpClient()->request('POST', $this->config['api_url'], [
@@ -52,14 +54,14 @@ public function request(string $action, array $data)
5254
],
5355
'json' => array_merge($params, $data),
5456
]);
55-
$result = json_decode($response->getBody(), true);
57+
$result = json_decode($response->getBody()->getContents(), true);
5658
if (isset($result['Response']['Error']['Message'])) {
5759
throw new ApiError($result['Response']['Error']['Message']);
5860
}
5961
return $result['Response'];
6062
}
6163

62-
public function requestProjectApi(string $action, array $data = [])
64+
public function requestProjectApi(string $action, array $data = []): array
6365
{
6466
if (empty($this->config['project_name'])) {
6567
throw new ValidationException('Need set project name first.');
@@ -68,22 +70,22 @@ public function requestProjectApi(string $action, array $data = [])
6870
return $this->request($action, $data);
6971
}
7072

71-
public function setPersonalToken(string $token)
73+
public function setPersonalToken(string $token): void
7274
{
7375
$this->config['personal_token'] = $token;
7476
}
7577

76-
public function setProjectName(string $projectName)
78+
public function setProjectName(string $projectName): void
7779
{
7880
$this->config['project_name'] = $projectName;
7981
}
8082

81-
public function setProjectToken(string $token)
83+
public function setProjectToken(string $token): void
8284
{
8385
$this->config['project_token'] = $token;
8486
}
8587

86-
private function getToken()
88+
private function getToken(): string
8789
{
8890
if ($this->usePersonalToken) {
8991
if (empty($this->config['personal_token'])) {

‎src/Exceptions/ApiError.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding\Exceptions;
46

57
use Exception;

‎src/Exceptions/ValidationException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding\Exceptions;
46

57
use Exception;

‎src/GitBranch.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding;
46

57
use Illuminate\Validation\Rule;
68

79
class GitBranch extends Base
810
{
9-
public function index(array $data)
11+
public function index(array $data): array
1012
{
1113
$this->validate($data, [
1214
'DepotId' => 'integer|required',

‎src/Handlers/Validator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Coding\Handlers;
46

57
use Illuminate\Filesystem\Filesystem;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /