| Conditions | 29 |
| Paths | 56 |
| Total Lines | 252 |
| Code Lines | 193 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 40 | protected function VisitT($expression, array &$followup, array &$references): ?iterable |
||
| 41 | { |
||
| 42 | assert($expression instanceof IExpression); |
||
| 43 | // Trying to reduce amount of noise in errors - if this expression is bad, then most likely it will have an unacceptable kind, no need to report it. |
||
| 44 | $expressionKindError = null; |
||
| 45 | if (!InterfaceValidator::IsCheckableBad($expression)) { |
||
| 46 | switch ($expression->getExpressionKind()) { |
||
| 47 | case ExpressionKind::IntegerConstant(): |
||
| 48 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 49 | $expression, |
||
| 50 | $expression->getExpressionKind(), |
||
| 51 | 'ExpressionKind', |
||
| 52 | IIntegerConstantExpression::class |
||
| 53 | ); |
||
| 54 | break; |
||
| 55 | |||
| 56 | case ExpressionKind::StringConstant(): |
||
| 57 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 58 | $expression, |
||
| 59 | $expression->getExpressionKind(), |
||
| 60 | 'ExpressionKind', |
||
| 61 | IStringConstantExpression::class |
||
| 62 | ); |
||
| 63 | break; |
||
| 64 | |||
| 65 | case ExpressionKind::BinaryConstant(): |
||
| 66 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 67 | $expression, |
||
| 68 | $expression->getExpressionKind(), |
||
| 69 | 'ExpressionKind', |
||
| 70 | IBinaryConstantExpression::class |
||
| 71 | ); |
||
| 72 | break; |
||
| 73 | |||
| 74 | case ExpressionKind::BooleanConstant(): |
||
| 75 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 76 | $expression, |
||
| 77 | $expression->getExpressionKind(), |
||
| 78 | 'ExpressionKind', |
||
| 79 | IBooleanConstantExpression::class |
||
| 80 | ); |
||
| 81 | break; |
||
| 82 | |||
| 83 | case ExpressionKind::DateTimeConstant(): |
||
| 84 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 85 | $expression, |
||
| 86 | $expression->getExpressionKind(), |
||
| 87 | 'ExpressionKind', |
||
| 88 | IDateTimeConstantExpression::class |
||
| 89 | ); |
||
| 90 | break; |
||
| 91 | |||
| 92 | case ExpressionKind::DateTimeOffsetConstant(): |
||
| 93 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 94 | $expression, |
||
| 95 | $expression->getExpressionKind(), |
||
| 96 | 'ExpressionKind', |
||
| 97 | IDateTimeOffsetConstantExpression::class |
||
| 98 | ); |
||
| 99 | break; |
||
| 100 | |||
| 101 | case ExpressionKind::TimeConstant(): |
||
| 102 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 103 | $expression, |
||
| 104 | $expression->getExpressionKind(), |
||
| 105 | 'ExpressionKind', |
||
| 106 | ITimeConstantExpression::class |
||
| 107 | ); |
||
| 108 | break; |
||
| 109 | |||
| 110 | case ExpressionKind::DecimalConstant(): |
||
| 111 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 112 | $expression, |
||
| 113 | $expression->getExpressionKind(), |
||
| 114 | 'ExpressionKind', |
||
| 115 | IDecimalConstantExpression::class |
||
| 116 | ); |
||
| 117 | break; |
||
| 118 | |||
| 119 | case ExpressionKind::FloatingConstant(): |
||
| 120 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 121 | $expression, |
||
| 122 | $expression->getExpressionKind(), |
||
| 123 | 'ExpressionKind', |
||
| 124 | IFloatingConstantExpression::class |
||
| 125 | ); |
||
| 126 | break; |
||
| 127 | |||
| 128 | case ExpressionKind::GuidConstant(): |
||
| 129 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 130 | $expression, |
||
| 131 | $expression->getExpressionKind(), |
||
| 132 | 'ExpressionKind', |
||
| 133 | IGuidConstantExpression::class |
||
| 134 | ); |
||
| 135 | break; |
||
| 136 | |||
| 137 | case ExpressionKind::Null(): |
||
| 138 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 139 | $expression, |
||
| 140 | $expression->getExpressionKind(), |
||
| 141 | 'ExpressionKind', |
||
| 142 | INullExpression::class |
||
| 143 | ); |
||
| 144 | break; |
||
| 145 | |||
| 146 | case ExpressionKind::Record(): |
||
| 147 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 148 | $expression, |
||
| 149 | $expression->getExpressionKind(), |
||
| 150 | 'ExpressionKind', |
||
| 151 | IRecordExpression::class |
||
| 152 | ); |
||
| 153 | break; |
||
| 154 | |||
| 155 | case ExpressionKind::Collection(): |
||
| 156 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 157 | $expression, |
||
| 158 | $expression->getExpressionKind(), |
||
| 159 | 'ExpressionKind', |
||
| 160 | ICollectionExpression::class |
||
| 161 | ); |
||
| 162 | break; |
||
| 163 | |||
| 164 | case ExpressionKind::Path(): |
||
| 165 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 166 | $expression, |
||
| 167 | $expression->getExpressionKind(), |
||
| 168 | 'ExpressionKind', |
||
| 169 | IPathExpression::class |
||
| 170 | ); |
||
| 171 | break; |
||
| 172 | |||
| 173 | case ExpressionKind::ParameterReference(): |
||
| 174 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 175 | $expression, |
||
| 176 | $expression->getExpressionKind(), |
||
| 177 | 'ExpressionKind', |
||
| 178 | IParameterReferenceExpression::class |
||
| 179 | ); |
||
| 180 | break; |
||
| 181 | |||
| 182 | case ExpressionKind::FunctionReference(): |
||
| 183 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 184 | $expression, |
||
| 185 | $expression->getExpressionKind(), |
||
| 186 | 'ExpressionKind', |
||
| 187 | IFunctionReferenceExpression::class |
||
| 188 | ); |
||
| 189 | break; |
||
| 190 | |||
| 191 | case ExpressionKind::PropertyReference(): |
||
| 192 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 193 | $expression, |
||
| 194 | $expression->getExpressionKind(), |
||
| 195 | 'ExpressionKind', |
||
| 196 | IPropertyReferenceExpression::class |
||
| 197 | ); |
||
| 198 | break; |
||
| 199 | |||
| 200 | case ExpressionKind::ValueTermReference(): |
||
| 201 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 202 | $expression, |
||
| 203 | $expression->getExpressionKind(), |
||
| 204 | 'ExpressionKind', |
||
| 205 | IValueTermReferenceExpression::class |
||
| 206 | ); |
||
| 207 | break; |
||
| 208 | |||
| 209 | case ExpressionKind::EntitySetReference(): |
||
| 210 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 211 | $expression, |
||
| 212 | $expression->getExpressionKind(), |
||
| 213 | 'ExpressionKind', |
||
| 214 | IEntitySetReferenceExpression::class |
||
| 215 | ); |
||
| 216 | break; |
||
| 217 | |||
| 218 | case ExpressionKind::EnumMemberReference(): |
||
| 219 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 220 | $expression, |
||
| 221 | $expression->getExpressionKind(), |
||
| 222 | 'ExpressionKind', |
||
| 223 | IEnumMemberReferenceExpression::class |
||
| 224 | ); |
||
| 225 | break; |
||
| 226 | |||
| 227 | case ExpressionKind::If(): |
||
| 228 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 229 | $expression, |
||
| 230 | $expression->getExpressionKind(), |
||
| 231 | 'ExpressionKind', |
||
| 232 | IIfExpression::class |
||
| 233 | ); |
||
| 234 | break; |
||
| 235 | |||
| 236 | case ExpressionKind::AssertType(): |
||
| 237 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 238 | $expression, |
||
| 239 | $expression->getExpressionKind(), |
||
| 240 | 'ExpressionKind', |
||
| 241 | IAssertTypeExpression::class |
||
| 242 | ); |
||
| 243 | break; |
||
| 244 | |||
| 245 | case ExpressionKind::IsType(): |
||
| 246 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 247 | $expression, |
||
| 248 | $expression->getExpressionKind(), |
||
| 249 | 'ExpressionKind', |
||
| 250 | IIsTypeExpression::class |
||
| 251 | ); |
||
| 252 | break; |
||
| 253 | |||
| 254 | case ExpressionKind::FunctionApplication(): |
||
| 255 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 256 | $expression, |
||
| 257 | $expression->getExpressionKind(), |
||
| 258 | 'ExpressionKind', |
||
| 259 | IApplyExpression::class |
||
| 260 | ); |
||
| 261 | break; |
||
| 262 | |||
| 263 | case ExpressionKind::Labeled(): |
||
| 264 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 265 | $expression, |
||
| 266 | $expression->getExpressionKind(), |
||
| 267 | 'ExpressionKind', |
||
| 268 | ILabeledExpression::class |
||
| 269 | ); |
||
| 270 | break; |
||
| 271 | |||
| 272 | case ExpressionKind::LabeledExpressionReference(): |
||
| 273 | $expressionKindError = InterfaceValidator::CheckForInterfaceKindValueMismatchError( |
||
| 274 | $expression, |
||
| 275 | $expression->getExpressionKind(), |
||
| 276 | 'ExpressionKind', |
||
| 277 | ILabeledExpressionReferenceExpression::class |
||
| 278 | ); |
||
| 279 | break; |
||
| 280 | |||
| 281 | default: |
||
| 282 | $expressionKindError = InterfaceValidator::CreateInterfaceKindValueUnexpectedError( |
||
| 283 | $expression, |
||
| 284 | $expression->getExpressionKind()->getKey(), |
||
| 285 | 'ExpressionKind' |
||
| 286 | ); |
||
| 287 | break; |
||
| 288 | } |
||
| 289 | } |
||
| 290 | |||
| 291 | return null !== $expressionKindError ? [ $expressionKindError ] : null; |
||
|
|
|||
| 292 | } |
||
| 299 |