8
8
9
9
namespace Ibexa \AdminUi \Util ;
10
10
11
- use RuntimeException ;
11
+ use Ibexa \ AdminUi \ Exception \ FieldTypeExpressionParserException ;
12
12
13
13
final class ContentTypeFieldsExpressionParser implements ContentTypeFieldsExpressionParserInterface
14
14
{
@@ -46,7 +46,7 @@ public function parseExpression(string $expression): array
46
46
$ this ->expectSlash ();
47
47
$ fieldTokens = $ this ->parseSection ();
48
48
} 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. ' );
50
50
}
51
51
}
52
52
@@ -57,7 +57,7 @@ public function parseExpression(string $expression): array
57
57
];
58
58
59
59
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. ' );
61
61
}
62
62
63
63
return $ parsedTokens ;
@@ -71,7 +71,7 @@ private function parseSection(): ?array
71
71
$ items = [];
72
72
73
73
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. ' );
75
75
}
76
76
77
77
// Multiple elements between braces
@@ -83,7 +83,7 @@ private function parseSection(): ?array
83
83
}
84
84
85
85
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. ' );
87
87
}
88
88
89
89
$ this ->lexer ->moveNext ();
@@ -107,19 +107,19 @@ private function getTokenFromInsideBracket(): string
107
107
108
108
$ token = $ this ->expectIdentifierOrWildcard ();
109
109
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. ' );
111
111
}
112
112
113
113
return $ token ;
114
114
}
115
115
116
116
/**
117
- * @throws \RuntimeException
117
+ * @throws \Ibexa\AdminUi\Exception\FieldTypeExpressionParserException
118
118
*/
119
119
private function expectSlash (): void
120
120
{
121
121
if ($ this ->lexer ->token === null ) {
122
- throw new RuntimeException (
122
+ throw new FieldTypeExpressionParserException (
123
123
sprintf (
124
124
'Expected token of type "%s" but got "null" ' ,
125
125
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -128,7 +128,7 @@ private function expectSlash(): void
128
128
}
129
129
130
130
if (!$ this ->lexer ->token ->isA (ContentTypeFieldsExpressionDoctrineLexer::T_SLASH )) {
131
- throw new RuntimeException (
131
+ throw new FieldTypeExpressionParserException (
132
132
sprintf (
133
133
'Expected token of type "%s" but got "%s" ' ,
134
134
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -143,7 +143,7 @@ private function expectSlash(): void
143
143
private function expectIdentifierOrWildcard (): ?string
144
144
{
145
145
if ($ this ->lexer ->token === null ) {
146
- throw new RuntimeException (
146
+ throw new FieldTypeExpressionParserException (
147
147
sprintf (
148
148
'Expected token of type "%s" but got "null" ' ,
149
149
ContentTypeFieldsExpressionDoctrineLexer::T_SLASH ,
@@ -159,7 +159,7 @@ private function expectIdentifierOrWildcard(): ?string
159
159
],
160
160
true ,
161
161
)) {
162
- throw new RuntimeException ('Expected an identifier or wildcard. ' );
162
+ throw new FieldTypeExpressionParserException ('Expected an identifier or wildcard. ' );
163
163
}
164
164
165
165
$ value = $ this ->lexer ->token ->isA (ContentTypeFieldsExpressionDoctrineLexer::T_WILDCARD )
0 commit comments