@@ -105,30 +105,21 @@ With this knowledge, you can implement the ``guessType()`` method of the
105
105
}
106
106
107
107
// otherwise, base the type on the @var annotation
108
- switch ($annotations['var']) {
109
- case 'string':
110
- // there is a high confidence that the type is text when
111
- // @var string is used
112
- return new TypeGuess(TextType::class, [], Guess::HIGH_CONFIDENCE);
113
-
114
- case 'int':
115
- case 'integer':
116
- // integers can also be the id of an entity or a checkbox (0 or 1)
117
- return new TypeGuess(IntegerType::class, [], Guess::MEDIUM_CONFIDENCE);
118
-
119
- case 'float':
120
- case 'double':
121
- case 'real':
122
- return new TypeGuess(NumberType::class, [], Guess::MEDIUM_CONFIDENCE);
123
-
124
- case 'boolean':
125
- case 'bool':
126
- return new TypeGuess(CheckboxType::class, [], Guess::HIGH_CONFIDENCE);
127
-
128
- default:
129
- // there is a very low confidence that this one is correct
130
- return new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE);
131
- }
108
+ return match($annotations['var']) {
109
+ // there is a high confidence that the type is text when
110
+ // @var string is used
111
+ 'string' => new TypeGuess(TextType::class, [], Guess::HIGH_CONFIDENCE),
112
+
113
+ // integers can also be the id of an entity or a checkbox (0 or 1)
114
+ 'int', 'integer' => new TypeGuess(IntegerType::class, [], Guess::MEDIUM_CONFIDENCE),
115
+
116
+ 'float', 'double', 'real' => new TypeGuess(NumberType::class, [], Guess::MEDIUM_CONFIDENCE),
117
+
118
+ 'boolean', 'bool' => new TypeGuess(CheckboxType::class, [], Guess::HIGH_CONFIDENCE),
119
+
120
+ // there is a very low confidence that this one is correct
121
+ default => new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE)
122
+ };
132
123
}
133
124
134
125
protected function readPhpDocAnnotations(string $class, string $property): array
0 commit comments