bug #10700 Fixes various inconsistencies in the code (fabpot)

This PR was merged into the 2.3 branch.

Discussion
----------

Fixes various inconsistencies in the code

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

4b7a275 removed extra/unsupported arguments
f4adfc4 [HttpKernel] fixed an error message
8aa322c [TwigBundle] removed undefined argument
This commit is contained in:
Fabien Potencier 2014-04-14 07:36:52 +02:00
commit eabfd0dcc4
6 changed files with 17 additions and 19 deletions

View File

@ -12,7 +12,6 @@
namespace Symfony\Bundle\TwigBundle\Debug;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
use Symfony\Component\Templating\TemplateNameParserInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Config\FileLocatorInterface;
@ -33,11 +32,10 @@ class TimedTwigEngine extends TwigEngine
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
* @param FileLocatorInterface $locator A FileLocatorInterface instance
* @param Stopwatch $stopwatch A Stopwatch instance
* @param GlobalVariables $globals A GlobalVariables instance
*/
public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator, Stopwatch $stopwatch, GlobalVariables $globals = null)
public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator, Stopwatch $stopwatch)
{
parent::__construct($environment, $parser, $locator, $globals);
parent::__construct($environment, $parser, $locator);
$this->stopwatch = $stopwatch;
}

View File

@ -14,7 +14,6 @@
<argument type="service" id="templating.name_parser" />
<argument type="service" id="templating.locator" />
<argument type="service" id="debug.stopwatch" />
<argument type="service" id="templating.globals" />
</service>
<service id="twig.extension.debug" class="Twig_Extension_Debug" public="false">

View File

@ -34,7 +34,7 @@ class GenericEventTest extends \PHPUnit_Framework_TestCase
parent::setUp();
$this->subject = new \stdClass();
$this->event = new GenericEvent($this->subject, array('name' => 'Event'), 'foo');
$this->event = new GenericEvent($this->subject, array('name' => 'Event'));
}
/**

View File

@ -32,7 +32,7 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
public function testIncompleteOptions()
{
$this->setExpectedException('InvalidArgumentException');
$storage = new PdoSessionHandler($this->pdo, array(), array());
$storage = new PdoSessionHandler($this->pdo, array());
}
public function testWrongPdoErrMode()
@ -42,42 +42,42 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
$pdo->exec("CREATE TABLE sessions (sess_id VARCHAR(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)");
$this->setExpectedException('InvalidArgumentException');
$storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions'), array());
$storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions'));
}
public function testWrongTableOptionsWrite()
{
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array());
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
$this->setExpectedException('RuntimeException');
$storage->write('foo', 'bar');
}
public function testWrongTableOptionsRead()
{
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'), array());
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
$this->setExpectedException('RuntimeException');
$storage->read('foo', 'bar');
}
public function testWriteRead()
{
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'));
$storage->write('foo', 'bar');
$this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly');
}
public function testMultipleInstances()
{
$storage1 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
$storage1 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'));
$storage1->write('foo', 'bar');
$storage2 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
$storage2 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'));
$this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances');
}
public function testSessionDestroy()
{
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'));
$storage->write('foo', 'bar');
$this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll());
@ -88,7 +88,7 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
public function testSessionGC()
{
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'));
$storage->write('foo', 'bar');
$storage->write('baz', 'bar');

View File

@ -298,10 +298,11 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
} elseif ($expires instanceof \DateTime) {
$expires = $expires->getTimestamp();
} else {
$expires = strtotime($expires);
if (false === $expires || -1 == $expires) {
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
$tmp = strtotime($expires);
if (false === $tmp || -1 == $tmp) {
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires));
}
$expires = $tmp;
}
$cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T'));

View File

@ -40,7 +40,7 @@ class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
$_SERVER = $server;
$result = $matcher->match($pathinfo, $server);
$result = $matcher->match($pathinfo);
$this->assertSame(var_export($expect, true), var_export($result, true));
}