Skip to content

Commit 39ab324

Browse files
committed
chore: update phpstan and fix warnings
1 parent 998ba36 commit 39ab324

File tree

10 files changed

+49
-57
lines changed

10 files changed

+49
-57
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"infection/infection": "^0.11.5",
2727
"php-http/mock-client": "^1.1",
2828
"phpspec/prophecy": "~1.0",
29-
"phpstan/phpstan": "^0.10.7",
29+
"phpstan/phpstan": "^0.12",
3030
"phpunit/phpunit": "^7"
3131
},
3232
"config": {

composer.lock

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

src/Factory/ElementFactory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
namespace MultiTheftAuto\Sdk\Factory;
1616

1717
use MultiTheftAuto\Sdk\Model\Element;
18-
use MultiTheftAuto\Sdk\Model\Resource;
18+
use MultiTheftAuto\Sdk\Model\Resource as MtaResource;
1919

2020
class ElementFactory
2121
{
22+
/**
23+
* @return Element|MtaResource|string
24+
*/
2225
public static function fromServer(string $value)
2326
{
2427
$valuePrefix = substr($value, 0, 3);
@@ -27,8 +30,8 @@ public static function fromServer(string $value)
2730
case Element::SERVER_PREFIX: {
2831
return Element::fromServer($value);
2932
}
30-
case Resource::SERVER_PREFIX: {
31-
return Resource::fromServer($value);
33+
case MtaResource::SERVER_PREFIX: {
34+
return MtaResource::fromServer($value);
3235
}
3336
}
3437

src/Model/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Element implements JsonSerializable
2525

2626
public const SERVER_PREFIX = '^E^';
2727

28-
public function __construct(string $id)
28+
final public function __construct(string $id)
2929
{
3030
$this->id = $id;
3131
}

src/Model/Resource.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Resource implements JsonSerializable
3838
public const SERVER_PREFIX = '^R^';
3939
protected const UNDEFINED_SERVICE_EXCEPTION = 'Resource %s can not be called because Mta service is not defined';
4040

41-
public function __construct(string $name, MtaService $mtaService = null)
41+
final public function __construct(string $name, MtaService $mtaService = null)
4242
{
4343
$this->name = $name;
4444
$this->mtaService = $mtaService;
@@ -51,14 +51,16 @@ public static function fromServer(string $value): self
5151
return new static($name);
5252
}
5353

54-
public function getName()
54+
public function getName(): string
5555
{
5656
return $this->name;
5757
}
5858

5959
/**
60+
* @param mixed ...$arguments
61+
*
6062
* @throws \Http\Client\Exception
61-
* @throws Exception
63+
* @return array|mixed[]|null
6264
*/
6365
public function call(string $function, ...$arguments)
6466
{

src/Model/ResourceCall.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public function __construct(MtaResource $resource)
2828
$this->resource = $resource;
2929
}
3030

31+
/**
32+
* @param mixed[] $arguments
33+
*
34+
* @throws \Http\Client\Exception
35+
* @return array|mixed[]|null
36+
*/
3137
public function __call(string $name, array $arguments)
3238
{
3339
return $this->resource->call($name, ...$arguments);

src/Mta.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ public function getResourcesInstance(): Resources
8181

8282
/**
8383
* @codeCoverageIgnore
84+
* @return array|mixed[]|null
8485
*/
8586
public static function getInput(): ?array
8687
{
8788
return ElementTransformer::fromServer(Input::get()) ?? null;
8889
}
8990

91+
/**
92+
* @param mixed ...$arguments
93+
*/
9094
public static function doReturn(...$arguments): void
9195
{
9296
echo ElementTransformer::toServer($arguments);

src/Response/HttpStatusValidator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ public function validate(): void
4646
case 401:
4747
{
4848
throw new AccessDeniedException();
49-
break;
5049
}
5150
case 404:
5251
{
5352
throw new NotFoundStatusException();
54-
break;
5553
}
5654
case 200:
5755
{

src/Service/MtaService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public function __construct(
6868
}
6969

7070
/**
71+
* @param mixed[] $arguments
72+
*
7173
* @throws \Http\Client\Exception
7274
* @throws \Exception
75+
* @return mixed[]|null
7376
*/
7477
public function callFunction(string $resourceName, string $functionName, array $arguments = []): ?array
7578
{

src/Transformer/ElementTransformer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
abstract class ElementTransformer
2020
{
21+
/**
22+
* @return mixed[]|null
23+
*/
2124
public static function fromServer(?string $dataFromServer): ?array
2225
{
2326
if (empty($dataFromServer)) {
@@ -33,11 +36,18 @@ public static function fromServer(?string $dataFromServer): ?array
3336
return $data;
3437
}
3538

39+
/**
40+
* @param mixed[] $inputData
41+
*
42+
*/
3643
public static function toServer(array $inputData): string
3744
{
3845
return json_encode($inputData) ?: '';
3946
}
4047

48+
/**
49+
* @param mixed[]|string $value
50+
*/
4151
private static function stringValuesToObjects(&$value): void
4252
{
4353
if (is_array($value)) {

0 commit comments

Comments
 (0)