Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52124eb

Browse files
committed
merged branch fabpot/hostname-rename (PR #6825)
This PR was merged into the master branch. Commits ------- 94f6116 renamed hostname to host in the routing system (closes #6775) 001734a [Validator] fixed phpdoc 18b9e68 [HttpFoundation] renamed hostname to host in the test to be consistent Discussion ---------- Hostname rename to host | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no (does not exist in 2.1) | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6775 | License | MIT | Doc PR | symfony/symfony-docs#2165 see #6775 --------------------------------------------------------------------------- by WouterJ at 2013-01-21T18:44:20Z +1
2 parents b7614e9 + 94f6116 commit 52124eb

40 files changed

+268
-268
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
8383

8484
$maxName = strlen('name');
8585
$maxMethod = strlen('method');
86-
$maxHostname = strlen('hostname');
86+
$maxHost = strlen('host');
8787

8888
foreach ($routes as $name => $route) {
8989
$requirements = $route->getRequirements();
@@ -92,25 +92,25 @@ protected function outputRoutes(OutputInterface $output, $routes = null)
9292
? implode(', ', $requirements['_method']) : $requirements['_method']
9393
)
9494
: 'ANY';
95-
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
95+
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
9696
$maxName = max($maxName, strlen($name));
9797
$maxMethod = max($maxMethod, strlen($method));
98-
$maxHostname = max($maxHostname, strlen($hostname));
98+
$maxHost = max($maxHost, strlen($host));
9999
}
100-
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHostname.'s %s';
100+
$format = '%-'.$maxName.'s %-'.$maxMethod.'s %-'.$maxHost.'s %s';
101101

102102
// displays the generated routes
103-
$format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHostname + 19).'s %s';
104-
$output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Hostname</comment>', '<comment>Pattern</comment>'));
103+
$format1 = '%-'.($maxName + 19).'s %-'.($maxMethod + 19).'s %-'.($maxHost + 19).'s %s';
104+
$output->writeln(sprintf($format1, '<comment>Name</comment>', '<comment>Method</comment>', '<comment>Host</comment>', '<comment>Pattern</comment>'));
105105
foreach ($routes as $name => $route) {
106106
$requirements = $route->getRequirements();
107107
$method = isset($requirements['_method'])
108108
? strtoupper(is_array($requirements['_method'])
109109
? implode(', ', $requirements['_method']) : $requirements['_method']
110110
)
111111
: 'ANY';
112-
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
113-
$output->writeln(sprintf($format, $name, $method, $hostname, $route->getPath()));
112+
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
113+
$output->writeln(sprintf($format, $name, $method, $host, $route->getPath()));
114114
}
115115
}
116116

@@ -124,13 +124,13 @@ protected function outputRoute(OutputInterface $output, $name)
124124
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
125125
}
126126

127-
$hostname = '' !== $route->getHostname() ? $route->getHostname() : 'ANY';
127+
$host = '' !== $route->getHost() ? $route->getHost() : 'ANY';
128128

129129
$output->writeln($this->getHelper('formatter')->formatSection('router', sprintf('Route "%s"', $name)));
130130

131131
$output->writeln(sprintf('<comment>Name</comment> %s', $name));
132132
$output->writeln(sprintf('<comment>Pattern</comment> %s', $route->getPath()));
133-
$output->writeln(sprintf('<comment>Hostname</comment> %s', $hostname));
133+
$output->writeln(sprintf('<comment>Host</comment> %s', $host));
134134
$output->writeln(sprintf('<comment>Class</comment> %s', get_class($route)));
135135

136136
$defaults = '';

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function warmUp($cacheDir)
7878
* - the route defaults,
7979
* - the route requirements,
8080
* - the route pattern.
81-
* - the route hostname.
81+
* - the route host.
8282
*
8383
* @param RouteCollection $collection
8484
*/
@@ -94,7 +94,7 @@ private function resolveParameters(RouteCollection $collection)
9494
}
9595

9696
$route->setPath($this->resolve($route->getPath()));
97-
$route->setHostname($this->resolve($route->getHostname()));
97+
$route->setHost($this->resolve($route->getHost()));
9898
}
9999
}
100100

src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ public function testPatternPlaceholders()
117117
);
118118
}
119119

120-
public function testHostnamePlaceholders()
120+
public function testHostPlaceholders()
121121
{
122122
$routes = new RouteCollection();
123123

124124
$route = new Route('foo');
125-
$route->setHostname('/before/%parameter.foo%/after/%%unescaped%%');
125+
$route->setHost('/before/%parameter.foo%/after/%%unescaped%%');
126126

127127
$routes->add('foo', $route);
128128

@@ -136,7 +136,7 @@ public function testHostnamePlaceholders()
136136

137137
$this->assertEquals(
138138
'/before/foo/after/%unescaped%',
139-
$route->getHostname()
139+
$route->getHost()
140140
);
141141
}
142142

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ public function testGetUri()
303303
$server = array();
304304

305305
// Standard Request on non default PORT
306-
// http://hostname:8080/index.php/path/info?query=string
306+
// http://host:8080/index.php/path/info?query=string
307307

308-
$server['HTTP_HOST'] = 'hostname:8080';
308+
$server['HTTP_HOST'] = 'host:8080';
309309
$server['SERVER_NAME'] = 'servername';
310310
$server['SERVER_PORT'] = '8080';
311311

@@ -321,16 +321,16 @@ public function testGetUri()
321321

322322
$request->initialize(array(), array(), array(), array(), array(), $server);
323323

324-
$this->assertEquals('http://hostname:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port');
324+
$this->assertEquals('http://host:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port');
325325

326326
// Use std port number
327-
$server['HTTP_HOST'] = 'hostname';
327+
$server['HTTP_HOST'] = 'host';
328328
$server['SERVER_NAME'] = 'servername';
329329
$server['SERVER_PORT'] = '80';
330330

331331
$request->initialize(array(), array(), array(), array(), array(), $server);
332332

333-
$this->assertEquals('http://hostname/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port');
333+
$this->assertEquals('http://host/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port');
334334

335335
// Without HOST HEADER
336336
unset($server['HTTP_HOST']);
@@ -344,9 +344,9 @@ public function testGetUri()
344344
// Request with URL REWRITING (hide index.php)
345345
// RewriteCond %{REQUEST_FILENAME} !-f
346346
// RewriteRule ^(.*)$ index.php [QSA,L]
347-
// http://hostname:8080/path/info?query=string
347+
// http://host:8080/path/info?query=string
348348
$server = array();
349-
$server['HTTP_HOST'] = 'hostname:8080';
349+
$server['HTTP_HOST'] = 'host:8080';
350350
$server['SERVER_NAME'] = 'servername';
351351
$server['SERVER_PORT'] = '8080';
352352

@@ -360,17 +360,17 @@ public function testGetUri()
360360
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
361361

362362
$request->initialize(array(), array(), array(), array(), array(), $server);
363-
$this->assertEquals('http://hostname:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite');
363+
$this->assertEquals('http://host:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite');
364364

365365
// Use std port number
366-
// http://hostname/path/info?query=string
367-
$server['HTTP_HOST'] = 'hostname';
366+
// http://host/path/info?query=string
367+
$server['HTTP_HOST'] = 'host';
368368
$server['SERVER_NAME'] = 'servername';
369369
$server['SERVER_PORT'] = '80';
370370

371371
$request->initialize(array(), array(), array(), array(), array(), $server);
372372

373-
$this->assertEquals('http://hostname/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port');
373+
$this->assertEquals('http://host/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port');
374374

375375
// Without HOST HEADER
376376
unset($server['HTTP_HOST']);
@@ -384,7 +384,7 @@ public function testGetUri()
384384
// With encoded characters
385385

386386
$server = array(
387-
'HTTP_HOST' => 'hostname:8080',
387+
'HTTP_HOST' => 'host:8080',
388388
'SERVER_NAME' => 'servername',
389389
'SERVER_PORT' => '8080',
390390
'QUERY_STRING' => 'query=string',
@@ -398,19 +398,19 @@ public function testGetUri()
398398
$request->initialize(array(), array(), array(), array(), array(), $server);
399399

400400
$this->assertEquals(
401-
'http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string',
401+
'http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string',
402402
$request->getUri()
403403
);
404404

405405
// with user info
406406

407407
$server['PHP_AUTH_USER'] = 'fabien';
408408
$request->initialize(array(), array(), array(), array(), array(), $server);
409-
$this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
409+
$this->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
410410

411411
$server['PHP_AUTH_PW'] = 'symfony';
412412
$request->initialize(array(), array(), array(), array(), array(), $server);
413-
$this->assertEquals('http://hostname:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
413+
$this->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri());
414414
}
415415

416416
/**
@@ -433,9 +433,9 @@ public function testGetUriForPath()
433433
$server = array();
434434

435435
// Standard Request on non default PORT
436-
// http://hostname:8080/index.php/path/info?query=string
436+
// http://host:8080/index.php/path/info?query=string
437437

438-
$server['HTTP_HOST'] = 'hostname:8080';
438+
$server['HTTP_HOST'] = 'host:8080';
439439
$server['SERVER_NAME'] = 'servername';
440440
$server['SERVER_PORT'] = '8080';
441441

@@ -451,16 +451,16 @@ public function testGetUriForPath()
451451

452452
$request->initialize(array(), array(), array(), array(), array(),$server);
453453

454-
$this->assertEquals('http://hostname:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port');
454+
$this->assertEquals('http://host:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port');
455455

456456
// Use std port number
457-
$server['HTTP_HOST'] = 'hostname';
457+
$server['HTTP_HOST'] = 'host';
458458
$server['SERVER_NAME'] = 'servername';
459459
$server['SERVER_PORT'] = '80';
460460

461461
$request->initialize(array(), array(), array(), array(), array(), $server);
462462

463-
$this->assertEquals('http://hostname/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port');
463+
$this->assertEquals('http://host/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port');
464464

465465
// Without HOST HEADER
466466
unset($server['HTTP_HOST']);
@@ -474,9 +474,9 @@ public function testGetUriForPath()
474474
// Request with URL REWRITING (hide index.php)
475475
// RewriteCond %{REQUEST_FILENAME} !-f
476476
// RewriteRule ^(.*)$ index.php [QSA,L]
477-
// http://hostname:8080/path/info?query=string
477+
// http://host:8080/path/info?query=string
478478
$server = array();
479-
$server['HTTP_HOST'] = 'hostname:8080';
479+
$server['HTTP_HOST'] = 'host:8080';
480480
$server['SERVER_NAME'] = 'servername';
481481
$server['SERVER_PORT'] = '8080';
482482

@@ -490,17 +490,17 @@ public function testGetUriForPath()
490490
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
491491

492492
$request->initialize(array(), array(), array(), array(), array(), $server);
493-
$this->assertEquals('http://hostname:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite');
493+
$this->assertEquals('http://host:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite');
494494

495495
// Use std port number
496-
// http://hostname/path/info?query=string
497-
$server['HTTP_HOST'] = 'hostname';
496+
// http://host/path/info?query=string
497+
$server['HTTP_HOST'] = 'host';
498498
$server['SERVER_NAME'] = 'servername';
499499
$server['SERVER_PORT'] = '80';
500500

501501
$request->initialize(array(), array(), array(), array(), array(), $server);
502502

503-
$this->assertEquals('http://hostname/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port');
503+
$this->assertEquals('http://host/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port');
504504

505505
// Without HOST HEADER
506506
unset($server['HTTP_HOST']);

src/Symfony/Component/Routing/Annotation/Route.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Route
2525
private $requirements;
2626
private $options;
2727
private $defaults;
28-
private $hostname;
28+
private $host;
2929
private $methods;
3030
private $schemes;
3131

@@ -84,14 +84,14 @@ public function getPath()
8484
return $this->path;
8585
}
8686

87-
public function setHostname($pattern)
87+
public function setHost($pattern)
8888
{
89-
$this->hostname = $pattern;
89+
$this->host = $pattern;
9090
}
9191

92-
public function getHostname()
92+
public function getHost()
9393
{
94-
return $this->hostname;
94+
return $this->host;
9595
}
9696

9797
public function setName($name)

src/Symfony/Component/Routing/CompiledRoute.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class CompiledRoute
2323
private $staticPrefix;
2424
private $regex;
2525
private $pathVariables;
26-
private $hostnameVariables;
27-
private $hostnameRegex;
28-
private $hostnameTokens;
26+
private $hostVariables;
27+
private $hostRegex;
28+
private $hostTokens;
2929

3030
/**
3131
* Constructor.
@@ -34,20 +34,20 @@ class CompiledRoute
3434
* @param string $regex The regular expression to use to match this route
3535
* @param array $tokens An array of tokens to use to generate URL for this route
3636
* @param array $pathVariables An array of path variables
37-
* @param string|null $hostnameRegex Hostname regex
38-
* @param array $hostnameTokens Hostname tokens
39-
* @param array $hostnameVariables An array of hostname variables
40-
* @param array $variables An array of variables (variables defined in the path and in the hostname patterns)
37+
* @param string|null $hostRegex Host regex
38+
* @param array $hostTokens Host tokens
39+
* @param array $hostVariables An array of host variables
40+
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
4141
*/
42-
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostnameRegex = null, array $hostnameTokens = array(), array $hostnameVariables = array(), array $variables = array())
42+
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
4343
{
4444
$this->staticPrefix = (string) $staticPrefix;
4545
$this->regex = $regex;
4646
$this->tokens = $tokens;
4747
$this->pathVariables = $pathVariables;
48-
$this->hostnameRegex = $hostnameRegex;
49-
$this->hostnameTokens = $hostnameTokens;
50-
$this->hostnameVariables = $hostnameVariables;
48+
$this->hostRegex = $hostRegex;
49+
$this->hostTokens = $hostTokens;
50+
$this->hostVariables = $hostVariables;
5151
$this->variables = $variables;
5252
}
5353

@@ -72,13 +72,13 @@ public function getRegex()
7272
}
7373

7474
/**
75-
* Returns the hostname regex
75+
* Returns the host regex
7676
*
77-
* @return string|null The hostname regex or null
77+
* @return string|null The host regex or null
7878
*/
79-
public function getHostnameRegex()
79+
public function getHostRegex()
8080
{
81-
return $this->hostnameRegex;
81+
return $this->hostRegex;
8282
}
8383

8484
/**
@@ -92,13 +92,13 @@ public function getTokens()
9292
}
9393

9494
/**
95-
* Returns the hostname tokens.
95+
* Returns the host tokens.
9696
*
9797
* @return array The tokens
9898
*/
99-
public function getHostnameTokens()
99+
public function getHostTokens()
100100
{
101-
return $this->hostnameTokens;
101+
return $this->hostTokens;
102102
}
103103

104104
/**
@@ -122,13 +122,13 @@ public function getPathVariables()
122122
}
123123

124124
/**
125-
* Returns the hostname variables.
125+
* Returns the host variables.
126126
*
127127
* @return array The variables
128128
*/
129-
public function getHostnameVariables()
129+
public function getHostVariables()
130130
{
131-
return $this->hostnameVariables;
131+
return $this->hostVariables;
132132
}
133133

134134
}

0 commit comments

Comments
 (0)