diff --git a/Command/Tool/CalendarCommand.php b/Command/Tool/CalendarCommand.php index 6a6a9f7..ad674ad 100644 --- a/Command/Tool/CalendarCommand.php +++ b/Command/Tool/CalendarCommand.php @@ -76,10 +76,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $time = sprintf('%02s:%02s', $parts[1], $parts[0]); - $duplicates = array_filter($data, function ($row) use ($day, $time, $cron): bool { - return $row[4]->getNextRunDate()->format('c') === $cron->getNextRunDate()->format('c'); - // return ($row[1] === $day && $row[3] === $time) || ($row[1] === '*' && $row[3] === $time) || ($day === '*' && $row[3] === $time); - }); + $duplicates = array_filter( + $data, + fn (array $row): bool => $row[4]->getNextRunDate()->format('c') === $cron->getNextRunDate()->format('c') + // fn (array $row): bool => ($row[1] === $day && $row[3] === $time) || ($row[1] === '*' && $row[3] === $time) || ($day === '*' && $row[3] === $time) + ); $warning = count($duplicates) > 0 ? '⚠ Duplicate' : null; $data[] = [ @@ -95,17 +96,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $nextRun = array_map(function ($row) { - return $row[4]->getNextRunDate()->format('c'); - }, $data); + $nextRun = array_map( + fn (array $row): string => $row[4]->getNextRunDate()->format('c'), + $data + ); array_multisort( $nextRun, SORT_ASC, $data ); - $display = array_map(function ($row) { - return [ + $display = array_map( + fn (array $row): array => [ $row[0], $row[1], $row[2], @@ -113,8 +115,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $row[4]->getExpression(), $row[4]->getNextRunDate()->format('d M Y H:i'), $row[5], - ]; - }, $data); + ], + $data + ); $table = new Table($output); $table->setHeaders(['City', 'Day of week', 'Day of month', 'Time', 'Cron', 'Next run', '']); diff --git a/Model/Details/Details.php b/Model/Details/Details.php index 93edc57..005ce5f 100644 --- a/Model/Details/Details.php +++ b/Model/Details/Details.php @@ -11,7 +11,7 @@ class Details public ?array $labels; /** @var null|array */ public ?array $descriptions; - /** @var array */ + /** @var array */ public ?array $nicknames; public ?int $birth; public ?int $death; diff --git a/Model/GeoJSON/Feature.php b/Model/GeoJSON/Feature.php index 69070af..9f904bb 100644 --- a/Model/GeoJSON/Feature.php +++ b/Model/GeoJSON/Feature.php @@ -12,7 +12,7 @@ class Feature implements JsonSerializable public Properties $properties; public ?Geometry $geometry; - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'type' => $this->type, diff --git a/Model/GeoJSON/FeatureCollection.php b/Model/GeoJSON/FeatureCollection.php index 0b91d7b..d49277e 100644 --- a/Model/GeoJSON/FeatureCollection.php +++ b/Model/GeoJSON/FeatureCollection.php @@ -10,7 +10,7 @@ class FeatureCollection implements JsonSerializable /** @var Feature[] $features */ public array $features = []; - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'type' => $this->type, diff --git a/Model/GeoJSON/Geometry/Geometry.php b/Model/GeoJSON/Geometry/Geometry.php index b50708f..493b86f 100644 --- a/Model/GeoJSON/Geometry/Geometry.php +++ b/Model/GeoJSON/Geometry/Geometry.php @@ -19,7 +19,7 @@ public function __construct(array $coordinates) $this->coordinates = $coordinates; } - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'type' => $this->type, diff --git a/Model/GeoJSON/Properties.php b/Model/GeoJSON/Properties.php index 3438015..a7c9a50 100644 --- a/Model/GeoJSON/Properties.php +++ b/Model/GeoJSON/Properties.php @@ -14,7 +14,7 @@ class Properties implements JsonSerializable /** @var null|Details|Details[] */ public $details; - public function jsonSerialize() + public function jsonSerialize(): array { return [ 'name' => $this->name, diff --git a/Wikidata/Wikidata.php b/Wikidata/Wikidata.php index 32b70f0..6afbae6 100644 --- a/Wikidata/Wikidata.php +++ b/Wikidata/Wikidata.php @@ -93,7 +93,7 @@ public static function extractSitelinks($entity, array $languages): array * @param Entity $entity * @param string[] $languages * - * @return null|array + * @return null|array */ public static function extractNicknames($entity, array $languages): ?array { @@ -102,10 +102,12 @@ public static function extractNicknames($entity, array $languages): ?array $claims = $entity->claims->P1449 ?? []; foreach ($claims as $value) { - $language = $value->mainsnak->datavalue->value->language; // @phpstan-ignore-line + /** @var \stdClass */ + $mainValue = $value->mainsnak->datavalue->value; // @phpstan-ignore-line + $language = $mainValue->language; if (in_array($language, $languages, true)) { - $nicknames[$language] = $value->mainsnak->datavalue->value; // @phpstan-ignore-line + $nicknames[$language] = $mainValue; } }