Skip to content

Commit

Permalink
[HttpFoundation] removed deprecated Request::splitHttpAcceptHeader() …
Browse files Browse the repository at this point in the history
…method
  • Loading branch information
fabpot committed Mar 23, 2013
1 parent c28f1b0 commit 09a5969
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
25 changes: 0 additions & 25 deletions src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -1426,31 +1426,6 @@ public function isXmlHttpRequest()
return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
}

/**
* Splits an Accept-* HTTP header.
*
* @param string $header Header to split
*
* @return array Array indexed by the values of the Accept-* header in preferred order
*
* @deprecated Deprecated since version 2.2, to be removed in 2.3.
*/
public function splitHttpAcceptHeader($header)
{
trigger_error('splitHttpAcceptHeader() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED);

$headers = array();
foreach (AcceptHeader::fromString($header)->all() as $item) {
$key = $item->getValue();
foreach ($item->getAttributes() as $name => $value) {
$key .= sprintf(';%s=%s', $name, $value);
}
$headers[$key] = $item->getQuality();
}

return $headers;
}

/*
* The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24)
*
Expand Down
37 changes: 0 additions & 37 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -17,15 +17,6 @@

class RequestTest extends \PHPUnit_Framework_TestCase
{
public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context)
{
if ($errorNumber & E_USER_DEPRECATED) {
return true;
}

return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
}

/**
* @covers Symfony\Component\HttpFoundation\Request::__construct
*/
Expand Down Expand Up @@ -908,8 +899,6 @@ public function testOverrideGlobals()

// restore initial $_SERVER array
$_SERVER = $server;

restore_error_handler();
}

public function testGetScriptName()
Expand Down Expand Up @@ -1158,32 +1147,6 @@ public function testToString()
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString());
}

/**
* @dataProvider splitHttpAcceptHeaderData
*/
public function testSplitHttpAcceptHeader($acceptHeader, $expected)
{
$request = new Request();

set_error_handler(array($this, "deprecationErrorHandler"));
$this->assertEquals($expected, $request->splitHttpAcceptHeader($acceptHeader));
restore_error_handler();
}

public function splitHttpAcceptHeaderData()
{
return array(
array(null, array()),
array('text/html;q=0.8', array('text/html' => 0.8)),
array('text/html;foo=bar;q=0.8 ', array('text/html;foo=bar' => 0.8)),
array('text/html;charset=utf-8; q=0.8', array('text/html;charset=utf-8' => 0.8)),
array('text/html,application/xml;q=0.9,*/*;charset=utf-8; q=0.8', array('text/html' => 1.0, 'application/xml' => 0.9, '*/*;charset=utf-8' => 0.8)),
array('text/html,application/xhtml+xml;q=0.9,*/*;q=0.8; foo=bar', array('text/html' => 1.0, 'application/xhtml+xml' => 0.9, '*/*;foo=bar' => 0.8)),
array('text/html,application/xhtml+xml;charset=utf-8;q=0.9; foo=bar,*/*', array('text/html' => 1.0, '*/*' => 1.0, 'application/xhtml+xml;charset=utf-8;foo=bar' => 0.9)),
array('text/html,application/xhtml+xml', array('text/html' => 1.0, 'application/xhtml+xml' => 1.0)),
);
}

public function testIsMethod()
{
$request = new Request();
Expand Down

0 comments on commit 09a5969

Please sign in to comment.