Skip to content

Commit

Permalink
PHPStan fixes part2
Browse files Browse the repository at this point in the history
  • Loading branch information
kisztof committed Sep 11, 2023
1 parent a9f279d commit 0280b85
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class AbstractNameSchemaEvent extends AbstractSchemaEvent
private array $languageCodes;

/**
* @param array<string, array<string, string>> $schemaIdentifiers
* @param array<string, array<int, string>> $schemaIdentifiers
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
* @param array<string> $languageCodes
*/
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/Event/NameSchema/AbstractSchemaEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

abstract class AbstractSchemaEvent extends Event
{
/** @var array<string, array<string, string>> */
/** @var array<string, array<int, string>> */
private array $schemaIdentifiers;

/** @var array<string, array<string, string>> */
private array $tokenValues = [];

/**
* @param array<string, array<string, string>> $schemaIdentifiers
* @param array<string, array<int, string>> $schemaIdentifiers
*/
public function __construct(array $schemaIdentifiers)
{
Expand All @@ -43,7 +43,7 @@ final public function setTokenValues(array $names): void
}

/**
* @return array<string, array<string, string>>
* @return array<string, array<int, string>>
*/
public function getSchemaIdentifiers(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class ResolveContentNameSchemaEvent extends AbstractNameSchemaEvent implem

/**
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Content $content
* @param array<string, array<string, string>> $schemaIdentifiers
* @param array<string, array<string>> $schemaIdentifiers
* @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
* @param array<string> $languageCodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ResolveUrlAliasSchemaEvent extends AbstractSchemaEvent implements Co
protected Content $content;

/**
* @param array<string, array<string, string>> $schemaIdentifiers
* @param array<string, array<int, string>> $schemaIdentifiers
*/
public function __construct(
array $schemaIdentifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
interface SchemaIdentifierExtractorInterface
{
/**
* @return array<string, array<string, string>>
* @return array<string, array<int, string>>
*/
public function extract(string $schemaString): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function isValid(AbstractSchemaEvent $event): bool

/**
* @param array<string> $languages
* @param array<string, string> $identifiers
* @param array<int, string> $identifiers
* @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Content|null $content
* @param array<string, array<string, string>> $tokenValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class SchemaIdentifierExtractor implements SchemaIdentifierExtractorInterface
{
/**
* @return array<string, array<string, string>>
* @return array<string, array<int, string>>
*
* @example
* $extractor = new SchemaIdentifierExtractor();
Expand Down
56 changes: 42 additions & 14 deletions tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ public function testResolveUrlAliasSchemaFallbackToNameSchema(): void
}

/**
* @return iterable<array<string, array<string, string>>, array<string>, array<string, string>>
* @return iterable<string, array{
* 0: array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>>,
* 1: array<string, array<string, string>>,
* 2: array<string>,
* 3: array<string, string>
* }>
*/
public static function getDataForTestResolveNameSchema(): iterable
{
Expand Down Expand Up @@ -102,7 +107,7 @@ public static function getDataForTestResolveNameSchema(): iterable
/**
* @dataProvider getDataForTestResolveNameSchema
*
* @param array<string, array<string, string>> $fieldMap A map of Field Definition Identifier and Language Code to Field Value
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
* @param array<string, array<string, string>> $tokenValues
* @param array<string> $languageCodes
* @param array<string, string> $expectedNames
Expand Down Expand Up @@ -140,14 +145,28 @@ public function testResolveNameSchema(
/**
* Data provider for the testResolve method.
*
* @return array<array{
* 0: array<string, array<string>>,
* 1: string,
* 2: array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>>,
* 3: array<string, string>,
* 4: array<string, array<string, string>>,
* 5?: array{limit?: int, sequence?: string}
* }>
*
* @see testResolve
*/
public static function getDataForTestResolve(): array
{
return [
[
['text1'],
['field' => ['text1']],
'<text1>',
[
'text1' => ['cro-HR' => new TextLineValue('jedan'), 'eng-GB' => new TextLineValue('one')],
'text2' => ['cro-HR' => new TextLineValue('Dva'), 'eng-GB' => new TextLineValue('two')],
'text3' => ['eng-GB' => new TextLineValue('three')],
],
[
'eng-GB' => 'one',
'cro-HR' => 'jedan',
Expand All @@ -158,8 +177,13 @@ public static function getDataForTestResolve(): array
],
],
[
['text2'],
['field' => ['text2']],
'<text2>',
[
'text1' => ['cro-HR' => new TextLineValue('jedan'), 'eng-GB' => new TextLineValue('one')],
'text2' => ['cro-HR' => new TextLineValue('Dva'), 'eng-GB' => new TextLineValue('two')],
'text3' => ['eng-GB' => new TextLineValue('three')],
],
[
'eng-GB' => 'two',
'cro-HR' => 'dva',
Expand All @@ -170,8 +194,13 @@ public static function getDataForTestResolve(): array
],
],
[
['text1', 'text2'],
['field' => ['text2', 'text2']],
'Hello, <text1> and <text2> and then goodbye and hello again',
[
'text1' => ['cro-HR' => new TextLineValue('jedan'), 'eng-GB' => new TextLineValue('one')],
'text2' => ['cro-HR' => new TextLineValue('Dva'), 'eng-GB' => new TextLineValue('two')],
'text3' => ['eng-GB' => new TextLineValue('three')],
],
[
'eng-GB' => 'Hello, one and two and then goodbye...',
'cro-HR' => 'Hello, jedan and dva and then goodb...',
Expand All @@ -191,14 +220,16 @@ public static function getDataForTestResolve(): array
/**
* @dataProvider getDataForTestResolve
*
* @param string[] $schemaIdentifiers
* @param string[] $languageFieldValues field value translations
* @param string[] $fieldTitles [language => [field_identifier => title]]
* @param array $settings NameSchemaService settings
* @param array<string, array<string>> $schemaIdentifiers
* @param array<string> $languageFieldValues field value translations
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
* @param array<string, array<string, string>> $fieldTitles [language => [field_identifier => title]]
* @param array{limit?: int, sequence?: string} $settings NameSchemaService settings
*/
public function testResolve(
array $schemaIdentifiers,
string $nameSchema,
array $fieldMap,
array $languageFieldValues,
array $fieldTitles,
array $settings = []
Expand All @@ -209,7 +240,7 @@ public function testResolve(
$event = new ResolveNameSchemaEvent(
$schemaIdentifiers,
$contentType,
$content->fields,
$fieldMap,
$content->versionInfo->languageCodes
);

Expand All @@ -223,7 +254,7 @@ public function testResolve(
$result = $nameSchemaService->resolveNameSchema(
$nameSchema,
$contentType,
$content->fields,
$fieldMap,
$content->versionInfo->languageCodes
);

Expand Down Expand Up @@ -323,9 +354,6 @@ protected function buildTestContentTypeStub(
);
}

/**
* @param array<string, array<string, string>> $schemaIdentifiers
*/
protected function getEventDispatcherMock(
AbstractSchemaEvent $event
): EventDispatcherInterface {
Expand Down

0 comments on commit 0280b85

Please sign in to comment.