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
25 changes: 14 additions & 11 deletions Command/Tool/CalendarCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand All @@ -95,26 +96,28 @@ 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],
$row[3],
$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', '']);
Expand Down
2 changes: 1 addition & 1 deletion Model/Details/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Details
public ?array $labels;
/** @var null|array<string,LanguageValue> */
public ?array $descriptions;
/** @var array<string,string> */
/** @var array<string,object> */
public ?array $nicknames;
public ?int $birth;
public ?int $death;
Expand Down
2 changes: 1 addition & 1 deletion Model/GeoJSON/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Model/GeoJSON/FeatureCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Model/GeoJSON/Geometry/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(array $coordinates)
$this->coordinates = $coordinates;
}

public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'type' => $this->type,
Expand Down
2 changes: 1 addition & 1 deletion Model/GeoJSON/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions Wikidata/Wikidata.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function extractSitelinks($entity, array $languages): array
* @param Entity $entity
* @param string[] $languages
*
* @return null|array<string,string>
* @return null|array<string,object>
*/
public static function extractNicknames($entity, array $languages): ?array
{
Expand All @@ -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;
}
}

Expand Down
Loading