@@ -115,6 +115,19 @@ final class Route implements RouteDescriptorInterface
115115 */
116116 public function __construct (array $ params )
117117 {
118+ $ params += [
119+ 'name ' => '' ,
120+ 'host ' => null ,
121+ 'path ' => '' ,
122+ 'methods ' => [],
123+ 'middlewares ' => [],
124+ 'attributes ' => [],
125+ 'summary ' => '' ,
126+ 'description ' => '' ,
127+ 'tags ' => [],
128+ 'priority ' => 0 ,
129+ ];
130+
118131 $ this ->name = $ this ->extractNameFromParams ($ params );
119132 $ this ->host = $ this ->extractHostFromParams ($ params );
120133 $ this ->path = $ this ->extractPathFromParams ($ params );
@@ -216,7 +229,7 @@ public function getPriority() : int
216229 */
217230 private function extractNameFromParams (array $ params ) : string
218231 {
219- $ name = $ params ['name ' ] ?? '' ;
232+ $ name = $ params ['name ' ];
220233
221234 if ('' === $ name || !is_string ($ name )) {
222235 throw new InvalidDescriptorArgumentException ('@Route.name must contain a non-empty string. ' );
@@ -234,7 +247,7 @@ private function extractNameFromParams(array $params) : string
234247 */
235248 private function extractHostFromParams (array $ params ) : ?string
236249 {
237- $ host = $ params ['host ' ] ?? null ;
250+ $ host = $ params ['host ' ];
238251
239252 if (isset ($ host ) && ('' === $ host || !is_string ($ host ))) {
240253 throw new InvalidDescriptorArgumentException ('@Route.host must contain a non-empty string. ' );
@@ -252,7 +265,7 @@ private function extractHostFromParams(array $params) : ?string
252265 */
253266 private function extractPathFromParams (array $ params ) : string
254267 {
255- $ path = $ params ['path ' ] ?? '' ;
268+ $ path = $ params ['path ' ];
256269
257270 if ('' === $ path || !is_string ($ path )) {
258271 throw new InvalidDescriptorArgumentException ('@Route.path must contain a non-empty string. ' );
@@ -270,7 +283,7 @@ private function extractPathFromParams(array $params) : string
270283 */
271284 private function extractMethodsFromParams (array $ params ) : array
272285 {
273- $ methods = $ params ['methods ' ] ?? [] ;
286+ $ methods = $ params ['methods ' ];
274287
275288 if ([] === $ methods || !is_array ($ methods )) {
276289 throw new InvalidDescriptorArgumentException ('@Route.methods must contain a non-empty array. ' );
@@ -294,7 +307,7 @@ private function extractMethodsFromParams(array $params) : array
294307 */
295308 private function extractMiddlewaresFromParams (array $ params ) : array
296309 {
297- $ middlewares = $ params ['middlewares ' ] ?? [] ;
310+ $ middlewares = $ params ['middlewares ' ];
298311
299312 if (!is_array ($ middlewares )) {
300313 throw new InvalidDescriptorArgumentException ('@Route.middlewares must contain an array. ' );
@@ -320,7 +333,7 @@ private function extractMiddlewaresFromParams(array $params) : array
320333 */
321334 private function extractAttributesFromParams (array $ params ) : array
322335 {
323- $ attributes = $ params ['attributes ' ] ?? [] ;
336+ $ attributes = $ params ['attributes ' ];
324337
325338 if (!is_array ($ attributes )) {
326339 throw new InvalidDescriptorArgumentException ('@Route.attributes must contain an array. ' );
@@ -338,7 +351,7 @@ private function extractAttributesFromParams(array $params) : array
338351 */
339352 private function extractSummaryFromParams (array $ params ) : string
340353 {
341- $ summary = $ params ['summary ' ] ?? '' ;
354+ $ summary = $ params ['summary ' ];
342355
343356 if (!is_string ($ summary )) {
344357 throw new InvalidDescriptorArgumentException ('@Route.summary must contain a string. ' );
@@ -356,7 +369,7 @@ private function extractSummaryFromParams(array $params) : string
356369 */
357370 private function extractDescriptionFromParams (array $ params ) : string
358371 {
359- $ description = $ params ['description ' ] ?? '' ;
372+ $ description = $ params ['description ' ];
360373
361374 if (!is_string ($ description )) {
362375 throw new InvalidDescriptorArgumentException ('@Route.description must contain a string. ' );
@@ -374,7 +387,7 @@ private function extractDescriptionFromParams(array $params) : string
374387 */
375388 private function extractTagsFromParams (array $ params ) : array
376389 {
377- $ tags = $ params ['tags ' ] ?? [] ;
390+ $ tags = $ params ['tags ' ];
378391
379392 if (!is_array ($ tags )) {
380393 throw new InvalidDescriptorArgumentException ('@Route.tags must contain an array. ' );
@@ -398,7 +411,7 @@ private function extractTagsFromParams(array $params) : array
398411 */
399412 private function extractPriorityFromParams (array $ params ) : int
400413 {
401- $ priority = $ params ['priority ' ] ?? 0 ;
414+ $ priority = $ params ['priority ' ];
402415
403416 if (!is_int ($ priority )) {
404417 throw new InvalidDescriptorArgumentException ('@Route.priority must contain an integer. ' );
0 commit comments