Skip to content

Commit ac843a1

Browse files
authored
Task/49 Upgrade valinor (#86)
* Updates error handling for 2.x messages. * Adds rector to the project. * Update PHP container to PHP 8.4 to use property hooks * Adds a custom rector rule to change phpstan hints for non-empty-strings to use property hook to validate when setting * Adds a custom rector rule to change phpstan hints for non-negative-int to use property hook to validate when setting * Add rector rule to turn positive-int var hints into a set hook property. * Apply more set property hooks to value objects. * Upgrades phpstan, phpcode sniffer dev dependencies.
1 parent 9c8a0ce commit ac843a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1047
-197
lines changed

.phpcs.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66

77
<rule ref="Squiz.ControlStructures.ControlSignature">
88
<properties>
9-
<property name="requiredSpacesBeforeColon" value="0" />
9+
<property name="requiredSpacesBeforeColon" value="1" />
1010
</properties>
1111
</rule>
12+
<rule ref="PSR12.Functions.ReturnTypeDeclaration">
13+
<exclude-pattern>src/Value/*</exclude-pattern>
14+
</rule>
15+
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.EmptyLine">
16+
<exclude-pattern>src/Value/*</exclude-pattern>
17+
</rule>
18+
1219
<rule ref="PSR12">
1320
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace" />
1421
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
1522
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
23+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.Indent" />
24+
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
1625
</rule>
1726

1827
<rule ref="Generic.Files.LineLength">

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,13 @@ Get Info about your agent:
1515
./spacetraders agent
1616
```
1717

18-
Add the token to `.env` file to authenticate other requests.
18+
Add the token to `.env` file to authenticate other requests.
19+
20+
## Branch Names
21+
22+
For any PR, the commit hook will check the following requirements for a branch name:
23+
24+
1. Must start with 'task/', 'bug/', or 'feature/'
25+
2. Must include an issue number (digits) followed by a dash.
26+
3. Must end with a descriptive slug (letters, numbers, dashes).
27+

bin/rector.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CONTAINER="php"
5+
docker compose run \
6+
--rm \
7+
--workdir /var/www \
8+
"$CONTAINER" \
9+
./vendor/bin/rector "$@"

cli/Command/Fleet/ExtractShipController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Phparch\SpaceTradersCLI\Render;
1414

1515
#[HelpInfo(
16-
description: "Extract mininerals at a waypoint.",
16+
description: "Extract minerals at a waypoint.",
1717
params: ['ship symbol']
1818
)]
1919
class ExtractShipController extends CommandController
@@ -30,7 +30,6 @@ public function handle(): void
3030

3131
try {
3232
$response = $client->extractShip($shipSymbol);
33-
//$response = $this->getMock();
3433

3534
$cooldown = new Render\Ship\Cooldown($response->cooldown);
3635
echo $cooldown->output();
@@ -42,7 +41,10 @@ public function handle(): void
4241
} catch (APIException $ex) {
4342
$error = new Render\Exception($ex);
4443
echo $error->output();
45-
$cooldown = Value\Ship\CoolDown::fromArray($ex->data['cooldown']);
44+
45+
/** @var iterable<string, mixed> $raw */
46+
$raw = $ex->data['cooldown'];
47+
$cooldown = Value\Ship\CoolDown::fromArray($raw);
4648
$render = new Render\Ship\Cooldown($cooldown);
4749
echo $render->output();
4850
}

cli/Render/Agent.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class Agent extends AbstractRenderer
66
{
77
public function __construct(
88
public \Phparch\SpaceTraders\Value\Agent $agent,
9-
)
10-
{
9+
) {
1110
}
1211

1312
public function output(): string

cli/Render/Exception.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class Exception extends AbstractRenderer
66
{
77
public function __construct(
88
public \Exception $ex,
9-
)
10-
{
9+
) {
1110
}
1211

1312
public function output(): string

cli/Render/GoodsDetailList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class GoodsDetailList extends AbstractRenderer
99
public function __construct(
1010
/** @var Detail[] $goods */
1111
public array $goods,
12-
)
13-
{
12+
) {
1413
}
1514

1615
public function output(): string

cli/Render/Market.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class Market extends AbstractRenderer
99
{
1010
public function __construct(
1111
public Value\Market $market,
12-
)
13-
{
12+
) {
1413
}
1514

1615
public function output(): string

cli/Render/Market/Transaction.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class Transaction extends AbstractRenderer
99
{
1010
public function __construct(
1111
public readonly Value\Market\Transaction $transaction,
12-
)
13-
{
12+
) {
1413
}
1514

1615
public function output(): string

cli/Render/Market/TransactionsList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class TransactionsList extends AbstractRenderer
1010
public function __construct(
1111
/** @var Transaction[] $transactions */
1212
public array $transactions,
13-
)
14-
{
13+
) {
1514
}
1615

1716
public function output(): string

0 commit comments

Comments
 (0)