Merge branch '2.2' into 2.3

* 2.2:
  [FrameworkBundle][Security] Replaced void return type with null for consistency
  fixed CS
  NativeSessionStorage regenerate
  removed unneeded comment
  Use setTimeZone if this method exists.
  Fix FileResource test
  fixed wrong usage of unset()
  [HttpFoundation] Fixed the way path to directory is trimmed.
  [Console] Fixed argument parsing when a single dash is passed.

Conflicts:
	src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
This commit is contained in:
Fabien Potencier 2013-09-13 14:20:37 +02:00
commit 33e9571886
10 changed files with 20 additions and 10 deletions

View File

@ -26,6 +26,9 @@ class GlobalVariables
{
protected $container;
/**
* @param ContainerInterface $container The DI container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
@ -46,7 +49,7 @@ class GlobalVariables
/**
* Returns the current user.
*
* @return mixed|void
* @return mixed
*
* @see TokenInterface::getUser()
*/

View File

@ -20,7 +20,7 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->file = sys_get_temp_dir().'/tmp.xml';
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
touch($this->file);
$this->resource = new FileResource($this->file);
}

View File

@ -84,7 +84,7 @@ class ArgvInput extends Input
$parseOptions = false;
} elseif ($parseOptions && 0 === strpos($token, '--')) {
$this->parseLongOption($token);
} elseif ($parseOptions && '-' === $token[0]) {
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
$this->parseShortOption($token);
} else {
$this->parseArgument($token);

View File

@ -306,4 +306,11 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'),
);
}
public function testParseSingleDashAsArgument()
{
$input = new ArgvInput(array('cli.php', '-'));
$input->bind(new InputDefinition(array(new InputArgument('file'))));
$this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument');
}
}

View File

@ -137,7 +137,7 @@ class ErrorHandler
return;
}
unset($this->reservedMemory);
$this->reservedMemory = '';
$type = $error['type'];
if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) {
return;

View File

@ -247,7 +247,7 @@ class DateType extends AbstractType
$pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId();
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
if ($setTimeZone = method_exists($formatter, 'setTimeZone')) {
$formatter->setTimeZone('UTC');
} else {
$formatter->setTimeZoneId('UTC');
@ -265,7 +265,7 @@ class DateType extends AbstractType
$formatter->setPattern($pattern);
}
if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) {
if ($setTimeZone) {
$formatter->setTimeZone($timezone);
} else {
$formatter->setTimeZoneId($timezone);

View File

@ -137,7 +137,7 @@ class File extends \SplFileInfo
throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
}
$target = trim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
return new File($target, false);
}

View File

@ -219,6 +219,8 @@ class NativeSessionStorage implements SessionStorageInterface
} else {
session_start();
}
$this->loadSession();
}
return $ret;

View File

@ -136,7 +136,7 @@ class ProfilerListener implements EventSubscriberInterface
if ($master) {
$this->saveProfiles($profile);
unset($this->children);
$this->children = new \SplObjectStorage();
}
}

View File

@ -80,8 +80,6 @@ interface UserInterface
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*
* @return void
*/
public function eraseCredentials();
}