Skip to content

Commit

Permalink
fix: phpstan error, bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Sep 16, 2024
1 parent 550d184 commit 5704214
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
24 changes: 22 additions & 2 deletions src/SiteKitResourceChannelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

/**
* @phpstan-type ContextPhp array{
* tenant: array{
* id: string,
* name: string,
* anchor: string,
* attributes: array<string, mixed>
* },
* publisher: array{
* id: int,
* name: string,
Expand All @@ -17,7 +23,7 @@
* nature: ?string,
* locale: ?string,
* encoding: ?string,
* translationLocales: ?string[]
* translationLocales: ?string[],
* }
* }
*/
Expand Down Expand Up @@ -64,10 +70,19 @@ public function create(): ResourceChannel
$this->configDir,
$searchIndex,
$data['publisher']['translationLocales'] ?? [],
$this->createTenant($data['tanent'] ?? $data['client'] /* deprecated */ ?? []),
$this->createTenant($data['tenant']),
);
}

/**
* @param array{
* id: string,
* name: string,
* anchor: string,
* attributes: array<string, mixed>,
* } $data
* @return ResourceTenant
*/
private function createTenant(array $data): ResourceTenant
{
return new ResourceTenant(
Expand All @@ -90,6 +105,11 @@ private function loadContextPhpFile(): array
);
}

if (isset($context['client'])) {
$context['tenant'] = $context['client'];
unset($context['client']);
}

/** @var ContextPhp $context */
return $context;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'tanent' => [
'client' => [
'id' => '2',
'name' => 'Test-Tanent',
'anchor' => 'test-tanent',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'tanent' => [
'tenant' => [
'id' => '2',
'name' => 'Test-Tanent',
'anchor' => 'test-tanent',
Expand Down

0 comments on commit 5704214

Please sign in to comment.