1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Limoncello\Validation\Contracts\Execution; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015-2020 [email protected] |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Limoncello\Validation\Contracts\Blocks\ExecutionBlockInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package Limoncello\Validation |
25
|
|
|
*/ |
26
|
|
|
interface BlockSerializerInterface |
27
|
|
|
{ |
28
|
|
|
// Serialization structure |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Serialization structure index. |
32
|
|
|
*/ |
33
|
|
|
const SERIALIZATION_BLOCKS = 0; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Serialization structure index. |
37
|
|
|
*/ |
38
|
|
|
const SERIALIZATION_BLOCKS_WITH_START = self::SERIALIZATION_BLOCKS + 1; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Serialization structure index. |
42
|
|
|
*/ |
43
|
|
|
const SERIALIZATION_BLOCKS_WITH_END = self::SERIALIZATION_BLOCKS_WITH_START + 1; |
44
|
|
|
|
45
|
|
|
// Block types |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Serialization property index. |
49
|
|
|
*/ |
50
|
|
|
const TYPE = 0; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Serialization property index. |
54
|
|
|
*/ |
55
|
|
|
const PROPERTIES = self::TYPE + 1; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Serialization property index. |
59
|
|
|
*/ |
60
|
|
|
const TYPE__PROCEDURE = 0; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Serialization property index. |
64
|
|
|
*/ |
65
|
|
|
const TYPE__IF_EXPRESSION = self::TYPE__PROCEDURE + 1; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Serialization property index. |
69
|
|
|
*/ |
70
|
|
|
const TYPE__AND_EXPRESSION = self::TYPE__IF_EXPRESSION + 1; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Serialization property index. |
74
|
|
|
*/ |
75
|
|
|
const TYPE__OR_EXPRESSION = self::TYPE__AND_EXPRESSION + 1; |
76
|
|
|
|
77
|
|
|
// Procedure keys |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Serialization property index. |
81
|
|
|
*/ |
82
|
|
|
const PROCEDURE_EXECUTE_CALLABLE = self::PROPERTIES + 1; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Serialization property index. |
86
|
|
|
*/ |
87
|
|
|
const PROCEDURE_START_CALLABLE = self::PROCEDURE_EXECUTE_CALLABLE + 1; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Serialization property index. |
91
|
|
|
*/ |
92
|
|
|
const PROCEDURE_END_CALLABLE = self::PROCEDURE_START_CALLABLE + 1; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Serialization property index. |
96
|
|
|
*/ |
97
|
|
|
const PROCEDURE_LAST = self::PROCEDURE_END_CALLABLE; |
98
|
|
|
|
99
|
|
|
// IF Expression keys |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Serialization property index. |
103
|
|
|
*/ |
104
|
|
|
const IF_EXPRESSION_CONDITION_CALLABLE = self::PROPERTIES + 1; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Serialization property index. |
108
|
|
|
*/ |
109
|
|
|
const IF_EXPRESSION_ON_TRUE_BLOCK = self::IF_EXPRESSION_CONDITION_CALLABLE + 1; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Serialization property index. |
113
|
|
|
*/ |
114
|
|
|
const IF_EXPRESSION_ON_FALSE_BLOCK = self::IF_EXPRESSION_ON_TRUE_BLOCK + 1; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Serialization property index. |
118
|
|
|
*/ |
119
|
|
|
const IF_EXPRESSION_LAST = self::IF_EXPRESSION_ON_FALSE_BLOCK; |
120
|
|
|
|
121
|
|
|
// AND Expression keys |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Serialization property index. |
125
|
|
|
*/ |
126
|
|
|
const AND_EXPRESSION_PRIMARY = self::PROPERTIES + 1; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Serialization property index. |
130
|
|
|
*/ |
131
|
|
|
const AND_EXPRESSION_SECONDARY = self::AND_EXPRESSION_PRIMARY + 1; |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Serialization property index. |
135
|
|
|
*/ |
136
|
|
|
const AND_EXPRESSION_LAST = self::AND_EXPRESSION_SECONDARY; |
137
|
|
|
|
138
|
|
|
// OR Expression keys |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Serialization property index. |
142
|
|
|
*/ |
143
|
|
|
const OR_EXPRESSION_PRIMARY = self::PROPERTIES + 1; |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Serialization property index. |
147
|
|
|
*/ |
148
|
|
|
const OR_EXPRESSION_SECONDARY = self::OR_EXPRESSION_PRIMARY + 1; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Serialization property index. |
152
|
|
|
*/ |
153
|
|
|
const OR_EXPRESSION_LAST = self::OR_EXPRESSION_SECONDARY; |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param ExecutionBlockInterface $block |
157
|
|
|
* |
158
|
|
|
* @return self |
|
|
|
|
159
|
|
|
*/ |
160
|
|
|
public function serialize(ExecutionBlockInterface $block): self; |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param ExecutionBlockInterface $block |
164
|
|
|
* |
165
|
|
|
* @return int |
166
|
|
|
*/ |
167
|
|
|
public function addBlock(ExecutionBlockInterface $block): int; |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return array |
171
|
|
|
*/ |
172
|
|
|
public function get(): array; |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return array |
176
|
|
|
*/ |
177
|
|
|
public function getSerializedBlocks(): array; |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @return int[] |
181
|
|
|
*/ |
182
|
|
|
public function getBlocksWithStart(): array; |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return int[] |
186
|
|
|
*/ |
187
|
|
|
public function getBlocksWithEnd(): array; |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return self |
|
|
|
|
191
|
|
|
* |
192
|
|
|
*/ |
193
|
|
|
public function clearBlocks(): self; |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return self |
|
|
|
|
197
|
|
|
*/ |
198
|
|
|
public function clearBlocksWithStart(): self; |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return self |
|
|
|
|
202
|
|
|
*/ |
203
|
|
|
public function clearBlocksWithEnd(): self; |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @param array $serialized |
207
|
|
|
* |
208
|
|
|
* @return array |
209
|
|
|
*/ |
210
|
|
|
public static function unserializeBlocks(array $serialized): array; |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param array $serialized |
214
|
|
|
* |
215
|
|
|
* @return array |
216
|
|
|
*/ |
217
|
|
|
public static function unserializeBlocksWithStart(array $serialized): array; |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @param array $serialized |
221
|
|
|
* |
222
|
|
|
* @return array |
223
|
|
|
*/ |
224
|
|
|
public static function unserializeBlocksWithEnd(array $serialized): array; |
225
|
|
|
} |
226
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.