[HttpFoundation] removed deprecated Request::splitHttpAcceptHeader() method
This commit is contained in:
parent
c28f1b0926
commit
09a5969b89
@ -1426,31 +1426,6 @@ class Request
|
|||||||
return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
|
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)
|
* The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24)
|
||||||
*
|
*
|
||||||
|
@ -17,15 +17,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
|
|
||||||
class RequestTest extends \PHPUnit_Framework_TestCase
|
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
|
* @covers Symfony\Component\HttpFoundation\Request::__construct
|
||||||
*/
|
*/
|
||||||
@ -908,8 +899,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// restore initial $_SERVER array
|
// restore initial $_SERVER array
|
||||||
$_SERVER = $server;
|
$_SERVER = $server;
|
||||||
|
|
||||||
restore_error_handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetScriptName()
|
public function testGetScriptName()
|
||||||
@ -1158,32 +1147,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString());
|
$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()
|
public function testIsMethod()
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
|
Reference in New Issue
Block a user