Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# —— Github Checkout 🔎 ——————————————————————————————————————————————————
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
steps:
# —— Git Checkout PR branch ——————————————————————————————————————————
- name: Git Checkout PR branch (${{ github.ref }})
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -75,7 +75,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ matrix.symfony }}
Expand All @@ -91,10 +91,14 @@ jobs:
composer config extra.symfony.require "${{ matrix.symfony }}.*"
composer update --no-progress --no-scripts

# # —— PHPStan ——————————————————————————————————————————————————————————
# - name: PHPStan (PHP Static Analysis)
# run: php vendor/phpstan/phpstan/phpstan.phar --memory-limit=1G

# —— Run tests —————————————————————————————————————————————————————————
- name: Run Tests
run: php vendor/bin/phpunit

# —— PHPStan ———————————————————————————————————————————————————————————
- name: PHPStan (static analysis)
run: php vendor/bin/phpstan analyse --no-progress

# —— Rector ————————————————————————————————————————————————————————————
- name: Rector (dry-run)
run: php vendor/bin/rector process --dry-run --no-progress-bar
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"require": {
"php": "^8.2",
"ext-json": "*",
"phpdocumentor/reflection-docblock": "^5.3",
"symfony/debug-bundle": "^6.4|^7.4|^8.0",
"symfony/http-client": "^6.4|^7.4|^8.0",
"symfony/property-access": "^6.4|^7.4|^8.0",
Expand All @@ -22,8 +21,9 @@
},
"require-dev" : {
"friendsofphp/php-cs-fixer": "^3.15",
"phpstan/phpstan": "^1.8.7",
"phpunit/phpunit": "^9.5|^10.0",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.0|^12.0|^13.0",
"rector/rector": "^2.0",
"symfony/var-dumper": "^6.4|^7.4|^8.0"
},
"autoload": {
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ parameters:
paths:
- src
- tests
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
# PHPStan 2.0 removed the `checkMissingIterableValueType` parameter;
# keep the project's original opt-out via the equivalent identifier.
- identifier: missingType.iterableValue
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory>./src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite for vroom-php">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src/</directory>
</include>
</source>
</phpunit>
20 changes: 20 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
// Target the lowest supported PHP version so generated code stays
// compatible with every consumer (composer.json requires php ^8.2).
->withPhpSets(php82: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
earlyReturn: true,
);
8 changes: 1 addition & 7 deletions src/Resource/AbsoluteTimeWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

final class AbsoluteTimeWindow implements TimeWindowInterface
{
public \DateTimeImmutable $start;

public \DateTimeImmutable $end;

public function __construct(\DateTimeImmutable $start, \DateTimeImmutable $end)
public function __construct(public \DateTimeImmutable $start, public \DateTimeImmutable $end)
{
$this->start = $start;
$this->end = $end;
}
}
8 changes: 1 addition & 7 deletions src/Resource/RelativeTimeWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

final class RelativeTimeWindow implements TimeWindowInterface
{
public int $start;

public int $end;

public function __construct(int $start, int $end)
public function __construct(public int $start, public int $end)
{
$this->start = $start;
$this->end = $end;
}
}
5 changes: 1 addition & 4 deletions src/Resource/ShipmentStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class ShipmentStep
{
public int $id;

public string $description;

public Location $location;
Expand All @@ -23,8 +21,7 @@ class ShipmentStep
*/
public array $timeWindows;

public function __construct(int $id)
public function __construct(public int $id)
{
$this->id = $id;
}
}
5 changes: 1 addition & 4 deletions src/Resource/Vehicle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
final class Vehicle
{
public int $id;

public string $profile;

public string $description;
Expand Down Expand Up @@ -52,8 +50,7 @@ final class Vehicle

public array $steps;

public function __construct(int $id)
public function __construct(public int $id)
{
$this->id = $id;
}
}
2 changes: 2 additions & 0 deletions src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function __construct()
}

/**
* @return \ArrayObject<array-key, mixed>|array|string|int|float|bool|null
*
* @throws SerializerExceptionInterface
*/
public function normalize(mixed $data, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null
Expand Down
3 changes: 0 additions & 3 deletions src/Serializer/Normalizer/LocationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function normalize(mixed $object, ?string $format = null, array $context
];
}

/**
* @param Location $data
*/
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof Location;
Expand Down
3 changes: 0 additions & 3 deletions src/Serializer/Normalizer/TimeWindowNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public function normalize(mixed $object, ?string $format = null, array $context
return null;
}

/**
* @param TimeWindowInterface $data
*/
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof TimeWindowInterface;
Expand Down
6 changes: 2 additions & 4 deletions src/Util/DateTimeUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ public static function fromUTC(\DateTimeImmutable $dateTime): \DateTimeImmutable

$localDateTime = new \DateTimeImmutable();
$localDateTime = $localDateTime->setDate((int) $dateTime->format('Y'), (int) $dateTime->format('m'), (int) $dateTime->format('d'));
$localDateTime = $localDateTime->seTTime((int) $dateTime->format('H'), (int) $dateTime->format('i'), (int) $dateTime->format('s'));

return $localDateTime;
return $localDateTime->seTTime((int) $dateTime->format('H'), (int) $dateTime->format('i'), (int) $dateTime->format('s'));
}

public static function toUTC(\DateTimeImmutable $dateTime): \DateTimeImmutable
{
$localDateTime = new \DateTimeImmutable();
$localDateTime = $localDateTime->setTimezone(new \DateTimeZone('UTC'));
$localDateTime = $localDateTime->setDate((int) $dateTime->format('Y'), (int) $dateTime->format('m'), (int) $dateTime->format('d'));
$localDateTime = $localDateTime->seTTime((int) $dateTime->format('H'), (int) $dateTime->format('i'), (int) $dateTime->format('s'));

return $localDateTime;
return $localDateTime->seTTime((int) $dateTime->format('H'), (int) $dateTime->format('i'), (int) $dateTime->format('s'));
}
}