Skip to content
Browse files

Merge branch '2.0' into 2.1

* 2.0:
  fixed CS
  added doc comments
  [HttpKernel][Translator] Fixed type-hints
  [Translation] forced the catalogue to be regenerated when a resource is added (closes symfony/translation#1)
  [HttpFoundation] Fixed #5611 - Request::splitHttpAcceptHeader incorrect result order.

Conflicts:
	src/Symfony/Component/Process/Process.php
	tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php
  • Loading branch information...
2 parents 8062031 + 9b3525c commit 60b54090bb4324a31ce65ba6056a5135fb0fa762 @fabpot fabpot committed Oct 6, 2012
View
18 src/Symfony/Component/HttpFoundation/Request.php
@@ -1277,23 +1277,31 @@ public function splitHttpAcceptHeader($header)
}
$values = array();
+ $groups = array();
foreach (array_filter(explode(',', $header)) as $value) {
// Cut off any q-value that might come after a semi-colon
if (preg_match('/;\s*(q=.*$)/', $value, $match)) {
- $q = (float) substr(trim($match[1]), 2);
+ $q = substr(trim($match[1]), 2);
$value = trim(substr($value, 0, -strlen($match[0])));
} else {
$q = 1;
}
+ $groups[$q][] = $value;
+ }
+
+ krsort($groups);
+
+ foreach ($groups as $q => $items) {
+ $q = (float) $q;
+
if (0 < $q) {
- $values[trim($value)] = $q;
+ foreach ($items as $value) {
+ $values[trim($value)] = $q;
+ }
}
}
- arsort($values);
- reset($values);
-
return $values;
}
View
16 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
@@ -913,7 +913,7 @@ public function testGetCharsets()
$request = new Request();
$request->headers->set('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
- $this->assertEquals(array('ISO-8859-1', '*', 'utf-8'), $request->getCharsets());
+ $this->assertEquals(array('ISO-8859-1', 'utf-8', '*'), $request->getCharsets());
}
public function testGetAcceptableContentTypes()
@@ -925,7 +925,7 @@ public function testGetAcceptableContentTypes()
$request = new Request();
$request->headers->set('Accept', 'application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*');
- $this->assertEquals(array('multipart/mixed', '*/*', 'text/html', 'application/xhtml+xml', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/vnd.wap.wmlscriptc'), $request->getAcceptableContentTypes());
+ $this->assertEquals(array('application/vnd.wap.wmlscriptc', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml', 'application/xhtml+xml', 'text/html', 'multipart/mixed', '*/*'), $request->getAcceptableContentTypes());
}
public function testGetLanguages()
@@ -939,6 +939,18 @@ public function testGetLanguages()
$this->assertEquals(array('zh', 'en_US', 'en'), $request->getLanguages());
$request = new Request();
+ $request->headers->set('Accept-language', 'zh, en-us; q=0.6, en; q=0.8');
+ $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); // Test out of order qvalues
+
+ $request = new Request();
+ $request->headers->set('Accept-language', 'zh, en, en-us');
+ $this->assertEquals(array('zh', 'en', 'en_US'), $request->getLanguages()); // Test equal weighting without qvalues
+
+ $request = new Request();
+ $request->headers->set('Accept-language', 'zh; q=0.6, en, en-us; q=0.6');
+ $this->assertEquals(array('en', 'zh', 'en_US'), $request->getLanguages()); // Test equal weighting with qvalues
+
+ $request = new Request();
$request->headers->set('Accept-language', 'zh, i-cherokee; q=0.6');
$this->assertEquals(array('zh', 'cherokee'), $request->getLanguages());
}
View
6 src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php
@@ -28,14 +28,14 @@ class GetResponseEvent extends KernelEvent
{
/**
* The response object
- * @var Symfony\Component\HttpFoundation\Response
+ * @var Response
*/
private $response;
/**
* Returns the response object
*
- * @return Symfony\Component\HttpFoundation\Response
+ * @return Response
*
* @api
*/
@@ -47,7 +47,7 @@ public function getResponse()
/**
* Sets a response and stops event propagation
*
- * @param Symfony\Component\HttpFoundation\Response $response
+ * @param Response $response
*
* @api
*/
View
8 src/Symfony/Component/HttpKernel/Event/KernelEvent.php
@@ -26,13 +26,13 @@ class KernelEvent extends Event
{
/**
* The kernel in which this event was thrown
- * @var Symfony\Component\HttpKernel\HttpKernelInterface
+ * @var HttpKernelInterface
*/
private $kernel;
/**
* The request the kernel is currently processing
- * @var Symfony\Component\HttpFoundation\Request
+ * @var Request
*/
private $request;
@@ -53,7 +53,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, $requ
/**
* Returns the kernel in which this event was thrown
*
- * @return Symfony\Component\HttpKernel\HttpKernelInterface
+ * @return HttpKernelInterface
*
* @api
*/
@@ -65,7 +65,7 @@ public function getKernel()
/**
* Returns the request the kernel is currently processing
*
- * @return Symfony\Component\HttpFoundation\Request
+ * @return Request
*
* @api
*/
View
69 src/Symfony/Component/Process/Process.php
@@ -539,7 +539,7 @@ public function hasBeenStopped()
}
/**
- * Returns the number of the signal that caused the child process to stop its execution
+ * Returns the number of the signal that caused the child process to stop its execution.
*
* It is only meaningful if hasBeenStopped() returns true.
*
@@ -610,26 +610,51 @@ public function stop($timeout=10)
return $this->exitcode;
}
+ /**
+ * Adds a line to the STDOUT stream.
+ *
+ * @param string $line The line to append
+ */
public function addOutput($line)
{
$this->stdout .= $line;
}
+ /**
+ * Adds a line to the STDERR stream.
+ *
+ * @param string $line The line to append
+ */
public function addErrorOutput($line)
{
$this->stderr .= $line;
}
+ /**
+ * Gets the command line to be executed.
+ *
+ * @return string The command to execute
+ */
public function getCommandLine()
{
return $this->commandline;
}
+ /**
+ * Sets the command line to be executed.
+ *
+ * @param string $commandline The command to execute
+ */
public function setCommandLine($commandline)
{
$this->commandline = $commandline;
}
+ /**
+ * Gets the process timeout.
+ *
+ * @return integer The timeout in seconds
+ */
public function getTimeout()
{
return $this->timeout;
@@ -640,7 +665,7 @@ public function getTimeout()
*
* To disable the timeout, set this value to null.
*
- * @param integer|null
+ * @param integer|null $timeout The timeout in seconds
*/
public function setTimeout($timeout)
{
@@ -659,41 +684,81 @@ public function setTimeout($timeout)
$this->timeout = $timeout;
}
+ /**
+ * Gets the working directory.
+ *
+ * @return string The current working directory
+ */
public function getWorkingDirectory()
{
return $this->cwd;
}
+ /**
+ * Sets the current working directory.
+ *
+ * @param string $cwd The new working directory
+ */
public function setWorkingDirectory($cwd)
{
$this->cwd = $cwd;
}
+ /**
+ * Gets the environment variables.
+ *
+ * @return array The current environment variables
+ */
public function getEnv()
{
return $this->env;
}
+ /**
+ * Sets the environment variables.
+ *
+ * @param array $env The new environment variables
+ */
public function setEnv(array $env)
{
$this->env = $env;
}
+ /**
+ * Gets the contents of STDIN.
+ *
+ * @return string The current contents
+ */
public function getStdin()
{
return $this->stdin;
}
+ /**
+ * Sets the contents of STDIN.
+ *
+ * @param string $stdin The new contents
+ */
public function setStdin($stdin)
{
$this->stdin = $stdin;
}
+ /**
+ * Gets the options for proc_open.
+ *
+ * @return array The current options
+ */
public function getOptions()
{
return $this->options;
}
+ /**
+ * Sets the options for proc_open.
+ *
+ * @param array $options The new options
+ */
public function setOptions(array $options)
{
$this->options = $options;
View
4 src/Symfony/Component/Translation/Loader/XliffFileLoader.php
@@ -54,7 +54,7 @@ public function load($resource, $locale, $domain = 'messages')
*
* @param string $file
*
- * @return SimpleXMLElement
+ * @return \SimpleXMLElement
*/
private function parseFile($file)
{
@@ -109,7 +109,7 @@ private function parseFile($file)
/**
* Returns the XML errors of the internal XML parser
*
- * @return array An array of errors
+ * @return array An array of errors
*/
private function getXmlErrors($internalErrors)
{
View
2 src/Symfony/Component/Translation/MessageSelector.php
@@ -44,7 +44,7 @@ class MessageSelector
*
* @return string
*
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
*
* @api
*/
View
2 src/Symfony/Component/Translation/Translator.php
@@ -73,6 +73,8 @@ public function addLoader($format, LoaderInterface $loader)
public function addResource($format, $resource, $locale, $domain = 'messages')
{
$this->resources[$locale][] = array($format, $resource, $domain);
+
+ unset($this->catalogues[$locale]);
}
/**

0 comments on commit 60b5409

Please sign in to comment.
Something went wrong with that request. Please try again.