@@ -181,57 +181,56 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
181
181
}
182
182
183
183
$ schemeAuthority = '' ;
184
- if ( $ host = $ this ->context ->getHost ()) {
185
- $ scheme = $ this ->context ->getScheme ();
184
+ $ host = $ this ->context ->getHost ();
185
+ $ scheme = $ this ->context ->getScheme ();
186
186
187
- if ($ requiredSchemes ) {
188
- if (!in_array ($ scheme , $ requiredSchemes , true )) {
189
- $ referenceType = self ::ABSOLUTE_URL ;
190
- $ scheme = current ($ requiredSchemes );
191
- }
187
+ if ($ requiredSchemes ) {
188
+ if (!in_array ($ scheme , $ requiredSchemes , true )) {
189
+ $ referenceType = self ::ABSOLUTE_URL ;
190
+ $ scheme = current ($ requiredSchemes );
192
191
}
192
+ }
193
193
194
- if ($ hostTokens ) {
195
- $ routeHost = '' ;
196
- foreach ($ hostTokens as $ token ) {
197
- if ('variable ' === $ token [0 ]) {
198
- if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$#i ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ token [3 ]])) {
199
- if ($ this ->strictRequirements ) {
200
- throw new InvalidParameterException (strtr ($ message , array ('{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ mergedParams [$ token [3 ]])));
201
- }
202
-
203
- if ($ this ->logger ) {
204
- $ this ->logger ->error ($ message , array ('parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]));
205
- }
194
+ if ($ hostTokens ) {
195
+ $ routeHost = '' ;
196
+ foreach ($ hostTokens as $ token ) {
197
+ if ('variable ' === $ token [0 ]) {
198
+ if (null !== $ this ->strictRequirements && !preg_match ('#^ ' .$ token [2 ].'$#i ' .(empty ($ token [4 ]) ? '' : 'u ' ), $ mergedParams [$ token [3 ]])) {
199
+ if ($ this ->strictRequirements ) {
200
+ throw new InvalidParameterException (strtr ($ message , array ('{parameter} ' => $ token [3 ], '{route} ' => $ name , '{expected} ' => $ token [2 ], '{given} ' => $ me
10000
rgedParams [$ token [3 ]])));
201
+ }
206
202
207
- return ;
203
+ if ($ this ->logger ) {
204
+ $ this ->logger ->error ($ message , array ('parameter ' => $ token [3 ], 'route ' => $ name , 'expected ' => $ token [2 ], 'given ' => $ mergedParams [$ token [3 ]]));
208
205
}
209
206
210
- $ routeHost = $ token [1 ].$ mergedParams [$ token [3 ]].$ routeHost ;
211
- } else {
212
- $ routeHost = $ token [1 ].$ routeHost ;
207
+ return ;
213
208
}
214
- }
215
209
216
- if ($ routeHost !== $ host ) {
217
- $ host = $ routeHost ;
218
- if (self ::ABSOLUTE_URL !== $ referenceType ) {
219
- $ referenceType = self ::NETWORK_PATH ;
220
- }
210
+ $ routeHost = $ token [1 ].$ mergedParams [$ token [3 ]].$ routeHost ;
211
+ } else {
212
+ $ routeHost = $ token [1 ].$ routeHost ;
221
213
}
222
214
}
223
215
224
- if (self ::ABSOLUTE_URL === $ referenceType || self ::NETWORK_PATH === $ referenceType ) {
225
- $ port = '' ;
226
- if ('http ' === $ scheme && 80 != $ this ->context ->getHttpPort ()) {
227
- $ port = ': ' .$ this ->context ->getHttpPort ();
228
- } elseif ('https ' === $ scheme && 443 != $ this ->context ->getHttpsPort ()) {
229
- $ port = ': ' .$ this ->context ->getHttpsPort ();
216
+ if ($ routeHost !== $ host ) {
217
+ $ host = $ routeHost ;
218
+ if (self ::ABSOLUTE_URL !== $ referenceType ) {
219
+ $ referenceType = self ::NETWORK_PATH ;
230
220
}
221
+ }
222
+ }
231
223
232
- $ schemeAuthority = self ::NETWORK_PATH === $ referenceType ? '// ' : "$ scheme:// " ;
233
- $ schemeAuthority .= $ host .$ port ;
224
+ if ((self ::ABSOLUTE_URL === $ referenceType || self ::NETWORK_PATH === $ referenceType ) && !empty ($ host )) {
225
+ $ port = '' ;
226
+ if ('http ' === $ scheme && 80 != $ this ->context ->getHttpPort ()) {
227
+ $ port = ': ' .$ this ->context ->getHttpPort ();
228
+ } elseif ('https ' === $ scheme && 443 != $ this ->context ->getHttpsPort ()) {
229
+ $ port = ': ' .$ this ->context ->getHttpsPort ();
234
230
}
231
+
232
+ $ schemeAuthority = self ::NETWORK_PATH === $ referenceType ? '// ' : "$ scheme:// " ;
233
+ $ schemeAuthority .= $ host .$ port ;
235
234
}
236
235
237
236
if (self ::RELATIVE_PATH === $ referenceType ) {
0 commit comments