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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
strategy:
matrix:
prefer_lowest: ["", "--prefer-lowest"]
php: ["8.1", "8.2", "8.3"]
php: ["8.2", "8.5"]
container:
image: skpr/php-cli:${{ matrix.php }}-dev-v2-edge
image: skpr/php-cli:${{ matrix.php }}-dev-v2-stable
options:
--pull always
--user 1001:1001
Expand All @@ -30,6 +30,7 @@ jobs:
- name: 📦 Composer Update
run: composer update --with-all-dependencies --prefer-dist --no-progress --no-interaction ${{ matrix.prefer_lowest }}
- name: 🧹 PHPCS
if: matrix.php != '8.5'
run: ./bin/phpcs --report=checkstyle -q | ./bin/cs2pr
- name: 🧹 PHPStan
run: ./bin/phpstan --error-format=github analyse
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.phpunit.cache
/bin
/vendor
/.phpunit.result.cache
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"psr/http-message": "^1.0 || ^2.0",
"psr/http-message-implementation": "*",
"psr/log": "^3.0",
"symfony/serializer": "^6.2 || ^6.4"
"symfony/serializer": "^6.4 || ^7.4"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"guzzlehttp/psr7": "^2.6",
"http-interop/http-factory-guzzle": "^1.2",
"php-http/mock-client": "^1.6",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6",
"previousnext/coding-standard": "^0.1.3",
"staabm/annotate-pull-request-from-checkstyle": "^1.8"
"dealerdirect/phpcodesniffer-composer-installer": "^1.2",
"guzzlehttp/psr7": "^2.9",
"http-interop/http-factory-guzzle": "^1.2.1",
"php-http/mock-client": "^1.6.1",
"phpstan/phpstan": "^2.1.50",
"phpunit/phpunit": "^11.5.55",
"previousnext/coding-standard": "^1.1.1",
"staabm/annotate-pull-request-from-checkstyle": "^1.8.6"
},
"autoload": {
"psr-4": {"BomWeather\\": "src/"}
Expand Down
6 changes: 1 addition & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Method BomWeather\\\\Util\\\\BaseNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#"
count: 1
path: src/Util/BaseNormalizer.php
ignoreErrors: []
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ parameters:
paths:
- src
- tests/src
checkMissingIterableValueType: false
ignoreErrors:
- "#^Call to an undefined method Symfony\\\\Component\\\\Serializer\\\\SerializerInterface\\:\\:denormalize\\(\\)\\.$#"
18 changes: 8 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<testsuites>
<testsuite name="default">
<directory>tests/src</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/BomClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
protected RequestFactoryInterface $requestFactory,
protected LoggerInterface $logger,
protected ?SerializerInterface $forecastSerializer = NULL,
protected ?SerializerInterface $observationSerializer = NULL
protected ?SerializerInterface $observationSerializer = NULL,
) {
if ($forecastSerializer == NULL) {
$forecastSerializer = ForecastSerializerFactory::create();
Expand Down
2 changes: 1 addition & 1 deletion src/Forecast/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function setDescription(string $description): Area {
* @return string
* The parent.
*/
public function getParentAac(): ?string {
public function getParentAac(): string {
return $this->parentAac;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Forecast/Forecast.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function addLocation(Area $location): Forecast {
/**
* Gets the issue time.
*/
public function getIssueTime(): ?\DateTimeImmutable {
public function getIssueTime(): \DateTimeImmutable {
return $this->issueTime;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Forecast/ForecastPeriod.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getProbabilityOfPrecipitation(): ?string {
* Sets the probability of precipitation.
*/
public function setProbabilityOfPrecipitation(
string $probabilityOfPrecipitation
string $probabilityOfPrecipitation,
): ForecastPeriod {
$this->probabilityOfPrecipitation = $probabilityOfPrecipitation;
return $this;
Expand Down
16 changes: 15 additions & 1 deletion src/Forecast/Serializer/AreaNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@
*/
class AreaNormalizer extends BaseNormalizer {

/**
* The supported interface or class.
*
* @var string|array<string>
*/
protected string|array $supportedInterfaceOrClass = Area::class;

/**
* {@inheritdoc}
*
* @param mixed $data
* Data to restore.
* @param string $type
* The expected class to instantiate.
* @param string|null $format
* Format the given data was extracted from.
* @param array<string, mixed> $context
* Context options for the denormalizer.
*/
public function denormalize($data, $type, $format = NULL, array $context = []) {
public function denormalize(mixed $data, string $type, ?string $format = NULL, array $context = []): mixed {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new \RuntimeException('The serializer must implement the DenormalizerInterface.');
}
Expand Down
17 changes: 14 additions & 3 deletions src/Forecast/Serializer/ForecastNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
class ForecastNormalizer extends BaseNormalizer {

/**
* {@inheritdoc}
* The supported interface or class.
*
* @var string|array<string>
*/
protected string|array $supportedInterfaceOrClass = Forecast::class;

/**
* {@inheritdoc}
*
* @param mixed $data
* Data to restore.
* @param string $type
* The expected class to instantiate.
* @param string|null $format
* Format the given data was extracted from.
* @param array<string, mixed> $context
* Context options for the denormalizer.
*/
public function denormalize($data, $type, $format = NULL, array $context = []) {
public function denormalize(mixed $data, string $type, ?string $format = NULL, array $context = []): mixed {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new \RuntimeException('The serializer must implement the DenormalizerInterface.');
}
Expand All @@ -45,7 +56,7 @@ public function denormalize($data, $type, $format = NULL, array $context = []) {
/**
* Sets the area value.
*
* @param array $area
* @param array<string, mixed> $area
* The area data.
* @param \BomWeather\Forecast\Forecast $forecast
* The forecast.
Expand Down
20 changes: 17 additions & 3 deletions src/Forecast/Serializer/ForecastPeriodNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@
*/
class ForecastPeriodNormalizer extends BaseNormalizer {

/**
* The supported interface or class.
*
* @var string|array<string>
*/
protected string|array $supportedInterfaceOrClass = ForecastPeriod::class;

/**
* {@inheritdoc}
*
* @param mixed $data
* Data to restore.
* @param string $type
* The expected class to instantiate.
* @param string|null $format
* Format the given data was extracted from.
* @param array<string, mixed> $context
* Context options for the denormalizer.
*/
public function denormalize($data, $type, $format = NULL, array $context = []) {
public function denormalize(mixed $data, string $type, ?string $format = NULL, array $context = []): mixed {
$period = (new ForecastPeriod())
->setStartTime($this->serializer->denormalize($data['@start-time-utc'], \DateTimeImmutable::class))
->setEndTime($this->serializer->denormalize($data['@end-time-utc'], \DateTimeImmutable::class));
Expand Down Expand Up @@ -51,7 +65,7 @@ public function denormalize($data, $type, $format = NULL, array $context = []) {
/**
* Set an element value.
*
* @param array $element
* @param array<string, mixed> $element
* The element array.
* @param \BomWeather\Forecast\ForecastPeriod $period
* The period.
Expand Down Expand Up @@ -80,7 +94,7 @@ protected function setElementValue(array $element, ForecastPeriod $period): void
/**
* Sets a text value.
*
* @param array $text
* @param array<string, mixed> $text
* The text array.
* @param \BomWeather\Forecast\ForecastPeriod $period
* The period.
Expand Down
2 changes: 1 addition & 1 deletion src/Observation/Observation.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getTemperature(): ?Temperature {
/**
* Sets the Temperature.
*/
public function setTemperature(Temperature $temperature): ?Observation {
public function setTemperature(Temperature $temperature): self {
$this->temperature = $temperature;
return $this;
}
Expand Down
16 changes: 15 additions & 1 deletion src/Observation/Serializer/ObservationListNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@
*/
class ObservationListNormalizer extends BaseNormalizer {

/**
* The supported interface or class.
*
* @var string|array<string>
*/
protected string|array $supportedInterfaceOrClass = ObservationList::class;

/**
* {@inheritdoc}
*
* @param mixed $data
* Data to restore.
* @param string $type
* The expected class to instantiate.
* @param string|null $format
* Format the given data was extracted from.
* @param array<string, mixed> $context
* Context options for the denormalizer.
*/
public function denormalize($data, $type, $format = NULL, array $context = []) {
public function denormalize(mixed $data, string $type, ?string $format = NULL, array $context = []): mixed {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new \RuntimeException('The serializer must implement the DenormalizerInterface.');
}
Expand Down
16 changes: 15 additions & 1 deletion src/Observation/Serializer/ObservationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@
*/
class ObservationNormalizer extends BaseNormalizer {

/**
* The supported interface or class.
*
* @var string|array<string>
*/
protected string|array $supportedInterfaceOrClass = Observation::class;

/**
* {@inheritdoc}
*
* @param mixed $data
* Data to restore.
* @param string $type
* The expected class to instantiate.
* @param string|null $format
* Format the given data was extracted from.
* @param array<string, mixed> $context
* Context options for the denormalizer.
*/
public function denormalize($data, $type, $format = NULL, array $context = []) {
public function denormalize(mixed $data, string $type, ?string $format = NULL, array $context = []): mixed {
$station = (new Station())
->setId($data['wmo'])
->setLatitude($data['lat'])
Expand Down
14 changes: 12 additions & 2 deletions src/Util/BaseNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@ abstract class BaseNormalizer extends AbstractNormalizer {

/**
* {@inheritdoc}
*
* @param mixed $object
* Object to normalize.
* @param string|null $format
* Format the normalization result will be encoded as.
* @param array<string, mixed> $context
* Context options for the normalizer.
*
* @return array<string, mixed>|\ArrayObject<string, mixed>|bool|float|int|string|null
* The normalized data.
*/
public function normalize(mixed $object, string $format = NULL, array $context = []) {
public function normalize(mixed $object, ?string $format = NULL, array $context = []): array|\ArrayObject|bool|float|int|string|null {
throw new \RuntimeException("Method not implemented.");
}

/**
* Checks whether the array is associative.
*
* @param array $array
* @param array<mixed> $array
* The array.
*
* @return bool
Expand Down
Loading
Loading