Skip to content

Commit

Permalink
fixed various inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 11, 2014
1 parent f964cc8 commit eb3f6c6
Show file tree
Hide file tree
Showing 59 changed files with 143 additions and 145 deletions.
Expand Up @@ -92,7 +92,8 @@ public function refreshUser(UserInterface $user)
);
}

if (null === $refreshedUser = $this->repository->find($id)) {
$refreshedUser = $this->repository->find($id);
if (null === $refreshedUser) {

This comment has been minimized.

Copy link
@trsteel88

trsteel88 Feb 12, 2014

Contributor

Just out of curiosity, why was this logic changed? Is it just for readability?

This comment has been minimized.

Copy link
@FractalizeR

FractalizeR Feb 16, 2014

Contributor

Well, it doesn't seem to be any change of logic. But I greet such readability improvement.

throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($id)));
}
}
Expand Down
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\ORM\Mapping AS ORM;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
Expand Down
Expand Up @@ -22,7 +22,7 @@ public function process(ContainerBuilder $container)
{
$filesystem = new Filesystem();
$filesystem->dumpFile(
$this->getCompilerLogFilename($container),
self::getCompilerLogFilename($container),
implode("\n", $container->getCompiler()->getLog()),
0666 & ~umask()
);
Expand Down
Expand Up @@ -37,7 +37,7 @@ public function testFindAllTemplates()
->will($this->returnValue(array('BaseBundle' => new BaseBundle())))
;

$parser = new TemplateFilenameParser($kernel);
$parser = new TemplateFilenameParser();

$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources');

Expand Down
Expand Up @@ -33,7 +33,7 @@ public function testDefaultConfig()
public function testValidTrustedProxies($trustedProxies, $processedProxies)
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, array(array(
'secret' => 's3cr3t',
'trusted_proxies' => $trustedProxies
Expand Down Expand Up @@ -62,7 +62,7 @@ public function getTestValidTrustedProxiesData()
public function testInvalidTypeTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',
Expand All @@ -77,7 +77,7 @@ public function testInvalidTypeTrustedProxies()
public function testInvalidValueTrustedProxies()
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$processor->processConfiguration($configuration, array(
array(
'secret' => 's3cr3t',
Expand Down
Expand Up @@ -46,7 +46,7 @@ protected static function getKernelClass()
{
require_once __DIR__.'/app/AppKernel.php';

return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\AppKernel';
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
}

protected static function createKernel(array $options = array())
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app;

// get the autoload file
$dir = __DIR__;
Expand Down
Expand Up @@ -46,7 +46,7 @@ protected static function getKernelClass()
{
require_once __DIR__.'/app/AppKernel.php';

return 'Symfony\Bundle\SecurityBundle\Tests\Functional\AppKernel';
return 'Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel';
}

protected static function createKernel(array $options = array())
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;

// get the autoload file
$dir = __DIR__;
Expand Down
Expand Up @@ -22,7 +22,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
public function testConfigTree($options, $results)
{
$processor = new Processor();
$configuration = new Configuration(array());
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, array($options));

$this->assertEquals($results, $config);
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/ClassLoader/XcacheClassLoader.php
Expand Up @@ -116,7 +116,8 @@ public function findFile($class)
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class));
$file = $this->classFinder->findFile($class);
xcache_set($this->prefix.$class, $file);
}

return $file;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/ProgressHelper.php
Expand Up @@ -352,7 +352,7 @@ private function generate($finish = false)
$vars = array();
$percent = 0;
if ($this->max > 0) {
$percent = (double) $this->current / $this->max;
$percent = (float) $this->current / $this->max;
}

if (isset($this->formatVars['bar'])) {
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Expand Up @@ -417,7 +417,7 @@ public function testSetCatchExceptions()
public function testAsText()
{
$application = new Application();
$application->add(new \FooCommand);
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application');
Expand All @@ -426,7 +426,7 @@ public function testAsText()
public function testAsXml()
{
$application = new Application();
$application->add(new \FooCommand);
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application');
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application');
Expand All @@ -450,7 +450,7 @@ public function testRenderException()
$tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command');

$application->add(new \Foo3Command);
$application->add(new \Foo3Command());
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo3:bar'), array('decorated' => false));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
Expand Down Expand Up @@ -797,7 +797,7 @@ public function testRunDispatchesAllEventsWithException()

protected function getDispatcher()
{
$dispatcher = new EventDispatcher;
$dispatcher = new EventDispatcher();
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
$event->getOutput()->write('before.');
});
Expand Down
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\CssSelector\Parser\Handler\NumberHandler;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;

class NumberHandlerTest extends AbstractHandlerTest
{
Expand Down Expand Up @@ -46,6 +45,6 @@ protected function generateHandler()
{
$patterns = new TokenizerPatterns();

return new NumberHandler($patterns, new TokenizerEscaping($patterns));
return new NumberHandler($patterns);
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php
Expand Up @@ -64,6 +64,6 @@ public function testHeaders()
public function testNestedExceptions()
{
$handler = new ExceptionHandler(true);
$response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar')));
$response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
}
}
Expand Up @@ -66,7 +66,7 @@ public function __construct(ContainerBuilder $container)
{
parent::__construct($container);

$this->inlinedDefinitions = new \SplObjectStorage;
$this->inlinedDefinitions = new \SplObjectStorage();
}

/**
Expand Down
Expand Up @@ -238,6 +238,7 @@ public function testRemoveSubscriberWithMultipleListeners()
public function testEventReceivesTheDispatcherInstance()
{
$test = $this;
$dispatcher = null;
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
$dispatcher = $event->getDispatcher();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/EventDispatcher/Tests/EventTest.php
Expand Up @@ -35,7 +35,7 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->event = new Event;
$this->event = new Event();
$this->dispatcher = new EventDispatcher();
}

Expand Down
Expand Up @@ -19,14 +19,11 @@
class DependencyInjectionExtension implements FormExtensionInterface
{
private $container;

private $typeServiceIds;

private $guesserServiceIds;

private $guesser;

private $guesserLoaded = false;
private $typeExtensionServiceIds;

public function __construct(ContainerInterface $container,
array $typeServiceIds, array $typeExtensionServiceIds,
Expand Down
Expand Up @@ -55,7 +55,7 @@ public function setMaxRunningTime($maxRunningTime)
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
$this->maxRunningTime = $maxRunningTime;
} else {
throw new \InvalidArgumentException;
throw new \InvalidArgumentException();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php
Expand Up @@ -27,12 +27,12 @@ protected function setUp()
$this->registry->setAccessible(true);

$this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
$this->type = new FooType;
$this->type = new FooType();
}

public function testAddType()
{
$factoryBuilder = new FormFactoryBuilder;
$factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addType($this->type);

$factory = $factoryBuilder->getFormFactory();
Expand All @@ -46,7 +46,7 @@ public function testAddType()

public function testAddTypeGuesser()
{
$factoryBuilder = new FormFactoryBuilder;
$factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addTypeGuesser($this->guesser);

$factory = $factoryBuilder->getFormFactory();
Expand Down
Expand Up @@ -82,18 +82,15 @@ public function register(ExtensionGuesserInterface $guesser)
* value.
*
* @param string $mimeType The mime type
*
* @return string The guessed extension or NULL, if none could be guessed
*/
public function guess($mimeType)
{
foreach ($this->guessers as $guesser) {
$extension = $guesser->guess($mimeType);

if (null !== $extension) {
break;
if (null !== $extension = $guesser->guess($mimeType)) {
return $extension;
}
}

return $extension;
}
}
8 changes: 4 additions & 4 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -881,14 +881,14 @@ public function testGetClientIpsProvider()

public function testGetContentWorksTwiceInDefaultMode()
{
$req = new Request;
$req = new Request();
$this->assertEquals('', $req->getContent());
$this->assertEquals('', $req->getContent());
}

public function testGetContentReturnsResource()
{
$req = new Request;
$req = new Request();
$retval = $req->getContent(true);
$this->assertInternalType('resource', $retval);
$this->assertEquals("", fread($retval, 1));
Expand All @@ -901,7 +901,7 @@ public function testGetContentReturnsResource()
*/
public function testGetContentCantBeCalledTwiceWithResources($first, $second)
{
$req = new Request;
$req = new Request();
$req->getContent($first);
$req->getContent($second);
}
Expand Down Expand Up @@ -1339,7 +1339,7 @@ public function getBaseUrlData()
*/
public function testUrlencodedStringPrefix($string, $prefix, $expect)
{
$request = new Request;
$request = new Request();

$me = new \ReflectionMethod($request, 'getUrlencodedPrefix');
$me->setAccessible(true);
Expand Down
Expand Up @@ -652,7 +652,7 @@ public function testSettersAreChainable()
'setCharset' => 'UTF-8',
'setPublic' => null,
'setPrivate' => null,
'setDate' => new \DateTime,
'setDate' => new \DateTime(),
'expire' => null,
'setMaxAge' => 1,
'setSharedMaxAge' => 1,
Expand Down
Expand Up @@ -59,7 +59,7 @@ protected function tearDown()
protected function getStorage(array $options = array())
{
$storage = new NativeSessionStorage($options);
$storage->registerBag(new AttributeBag);
$storage->registerBag(new AttributeBag());

return $storage;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public function testCookieOptions()
public function testSetSaveHandlerException()
{
$storage = $this->getStorage();
$storage->setSaveHandler(new \stdClass);
$storage->setSaveHandler(new \stdClass());
}

public function testSetSaveHandler53()
Expand Down
Expand Up @@ -53,7 +53,7 @@ protected function tearDown()
protected function getStorage()
{
$storage = new PhpBridgeSessionStorage();
$storage->registerBag(new AttributeBag);
$storage->registerBag(new AttributeBag());

return $storage;
}
Expand Down
Expand Up @@ -70,7 +70,7 @@ public function getController(Request $request)

if (false === strpos($controller, ':')) {
if (method_exists($controller, '__invoke')) {
return new $controller;
return new $controller();
} elseif (function_exists($controller)) {
return $controller;
}
Expand Down
Expand Up @@ -42,7 +42,7 @@ protected function getMemcache()
$host = $matches[1] ?: $matches[2];
$port = $matches[3];

$memcache = new Memcache;
$memcache = new Memcache();
$memcache->addServer($host, $port);

$this->memcache = $memcache;
Expand Down
Expand Up @@ -42,7 +42,7 @@ protected function getMemcached()
$host = $matches[1] ?: $matches[2];
$port = $matches[3];

$memcached = new Memcached;
$memcached = new Memcached();

//disable compression to allow appending
$memcached->setOption(Memcached::OPT_COMPRESSION, false);
Expand Down
Expand Up @@ -214,7 +214,7 @@ protected function getRedis()
throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.');
}

$redis = new \Redis;
$redis = new \Redis();
$redis->connect($data['host'], $data['port']);

if (isset($data['path'])) {
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/Tests/ClientTest.php
Expand Up @@ -121,6 +121,7 @@ public function testUploadedFile()
new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true),
);

$file = null;
foreach ($files as $file) {
$client->request('POST', '/', array(), array('foo' => $file));

Expand Down

0 comments on commit eb3f6c6

Please sign in to comment.