Skip to content

Commit 7079418

Browse files
committed
IBX-9631: Applied review remarks
1 parent 78947c5 commit 7079418

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

src/bundle/Resources/config/services/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ services:
1212
Ibexa\AdminUi\Service\ContentTypeFieldsByExpressionService: ~
1313

1414
Ibexa\Contracts\AdminUi\Service\ContentTypeFieldsByExpressionServiceInterface:
15-
'@Ibexa\AdminUi\Service\ContentTypeFieldsByExpressionService'
15+
'@Ibexa\AdminUi\Service\ContentTypeFieldsByExpressionService'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\AdminUi\Exception;
10+
11+
use RuntimeException;
12+
13+
final class FieldTypeExpressionParserException extends RuntimeException
14+
{
15+
}

src/lib/Util/ContentTypeFieldsExpressionParser.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Ibexa\AdminUi\Util;
1010

11-
use RuntimeException;
11+
use Ibexa\AdminUi\Exception\FieldTypeExpressionParserException;
1212

1313
final class ContentTypeFieldsExpressionParser implements ContentTypeFieldsExpressionParserInterface
1414
{
@@ -46,7 +46,7 @@ public function parseExpression(string $expression): array
4646
$this->expectSlash();
4747
$fieldTokens = $this->parseSection();
4848
} else {
49-
throw new RuntimeException('Invalid expression, expected one or two T_SLASH delimiters.');
49+
throw new FieldTypeExpressionParserException('Invalid expression, expected one or two T_SLASH delimiters.');
5050
}
5151
}
5252

@@ -57,7 +57,7 @@ public function parseExpression(string $expression): array
5757
];
5858

5959
if (array_filter($parsedTokens) === []) {
60-
throw new RuntimeException('Choosing every possible content type field is not allowed.');
60+
throw new FieldTypeExpressionParserException('Choosing every possible content type field is not allowed.');
6161
}
6262

6363
return $parsedTokens;
@@ -71,7 +71,7 @@ private function parseSection(): ?array
7171
$items = [];
7272

7373
if ($this->lexer->token === null) {
74-
throw new RuntimeException('A token inside a section cannot be empty.');
74+
throw new FieldTypeExpressionParserException('A token inside a section cannot be empty.');
7575
}
7676

7777
// Multiple elements between braces
@@ -83,7 +83,7 @@ private function parseSection(): ?array
8383
}
8484

8585
if (!$this->lexer->token->isA(ContentTypeFieldsExpressionDoctrineLexer::T_RBRACE)) {
86-
throw new RuntimeException('Expected T_RBRACE to close the list.');
86+
throw new FieldTypeExpressionParserException('Expected T_RBRACE to close the list.');
8787
}
8888

8989
$this->lexer->moveNext();
@@ -107,19 +107,19 @@ private function getTokenFromInsideBracket(): string
107107

108108
$token = $this->expectIdentifierOrWildcard();
109109
if ($token === null) {
110-
throw new RuntimeException('Wildcards cannot be mixed with identifiers inside the expression.');
110+
throw new FieldTypeExpressionParserException('Wildcards cannot be mixed with identifiers inside the expression.');
111111
}
112112

113113
return $token;
114114
}
115115

116116
/**
117-
* @throws \RuntimeException
117+
* @throws \Ibexa\AdminUi\Exception\FieldTypeExpressionParserException
118118
*/
119119
private function expectSlash(): void
120120
{
121121
if ($this->lexer->token === null) {
122-
throw new RuntimeException(
122+
throw new FieldTypeExpressionParserException(
123123
sprintf(
124124
'Expected token of type "%s" but got "null"',
125125
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH,
@@ -128,7 +128,7 @@ private function expectSlash(): void
128128
}
129129

130130
if (!$this->lexer->token->isA(ContentTypeFieldsExpressionDoctrineLexer::T_SLASH)) {
131-
throw new RuntimeException(
131+
throw new FieldTypeExpressionParserException(
132132
sprintf(
133133
'Expected token of type "%s" but got "%s"',
134134
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH,
@@ -143,7 +143,7 @@ private function expectSlash(): void
143143
private function expectIdentifierOrWildcard(): ?string
144144
{
145145
if ($this->lexer->token === null) {
146-
throw new RuntimeException(
146+
throw new FieldTypeExpressionParserException(
147147
sprintf(
148148
'Expected token of type "%s" but got "null"',
149149
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH,
@@ -159,7 +159,7 @@ private function expectIdentifierOrWildcard(): ?string
159159
],
160160
true,
161161
)) {
162-
throw new RuntimeException('Expected an identifier or wildcard.');
162+
throw new FieldTypeExpressionParserException('Expected an identifier or wildcard.');
163163
}
164164

165165
$value = $this->lexer->token->isA(ContentTypeFieldsExpressionDoctrineLexer::T_WILDCARD)

src/lib/Util/ContentTypeFieldsExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function isFieldWithinExpression(int $fieldDefinitionId, string $expressi
4747
/**
4848
* @param array{non-empty-list<string>|null, non-empty-list<string>|null, non-empty-list<string>|null} $extractedMetadata
4949
*
50-
* @return list<ContentType>
50+
* @return list<\Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType>
5151
*/
5252
private function resolveContentTypes(array $extractedMetadata): array
5353
{
@@ -109,7 +109,7 @@ private function resolveFieldIds(?array $fieldIdentifiers, ContentType $contentT
109109
}
110110

111111
/**
112-
* @param non-empty-list<ContentType> $contentTypes
112+
* @param non-empty-list<\Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType> $contentTypes
113113
* @param list<string> $contentTypeGroupIdentifiers
114114
*/
115115
private function validateContentTypesInsideGroups(

0 commit comments

Comments
 (0)