Merge branch '2.6' into 2.7

* 2.6:
  [Translator] Cache does not take fallback locales into consideration
  [VarDumper] Fix call site detection
  [Process] Fix volatile test
  Remove some useless @group annotations
  Removed useless strtolower call
  [Validator] Use strict comparisons in loaders
  CS: Use "self" keyword instead of class name if possible

Conflicts:
	.travis.yml
	src/Symfony/Component/Translation/Translator.php
This commit is contained in:
Fabien Potencier 2015-04-10 09:19:44 +02:00
commit 30b31611a5
29 changed files with 32 additions and 69 deletions

View File

@ -46,5 +46,5 @@ install:
script:
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;

View File

@ -336,9 +336,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
$this->assertNoViolation();
}
/**
* @group GH-1635
*/
public function testAssociatedEntity()
{
$constraint = new UniqueEntity(array(
@ -395,7 +392,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
/**
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
* @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field
* @group GH-1635
*/
public function testAssociatedCompositeEntity()
{

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class FragmentTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class ProfilerTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class SessionTest extends WebTestCase
{
/**

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
/**
* @group functional
*/
class SubRequestsTest extends WebTestCase
{
public function testStateAfterSubRequest()

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class CsrfFormLoginTest extends WebTestCase
{
/**

View File

@ -13,9 +13,6 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub;
/**
* @group functional
*/
class FirewallEntryPointTest extends WebTestCase
{
public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class FormLoginTest extends WebTestCase
{
/**

View File

@ -57,7 +57,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
/**
* @dataProvider getConfigs
* @group ip_whitelist
*/
public function testSecurityConfigurationForSingleIPAddress($config)
{
@ -70,7 +69,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
/**
* @dataProvider getConfigs
* @group ip_whitelist
*/
public function testSecurityConfigurationForMultipleIPAddresses($config)
{

View File

@ -11,9 +11,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
/**
* @group functional
*/
class SwitchUserTest extends WebTestCase
{
/**

View File

@ -224,7 +224,7 @@ class ExprBuilder
public static function buildExpressions(array $expressions)
{
foreach ($expressions as $k => $expr) {
if ($expr instanceof ExprBuilder) {
if ($expr instanceof self) {
$if = $expr->ifPart;
$then = $expr->thenPart;
$expressions[$k] = function ($v) use ($if, $then) {

View File

@ -82,7 +82,7 @@ abstract class FileLoader extends Loader
try {
$loader = $this->resolve($resource, $type);
if ($loader instanceof FileLoader && null !== $this->currentDir) {
if ($loader instanceof self && null !== $this->currentDir) {
// we fallback to the current locator to keep BC
// as some some loaders do not call the parent __construct()
// @deprecated should be removed in 3.0

View File

@ -768,7 +768,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/
public function register($id, $class = null)
{
return $this->setDefinition(strtolower($id), new Definition($class));
return $this->setDefinition($id, new Definition($class));
}
/**

View File

@ -132,8 +132,6 @@ class FinderTest extends Iterator\RealIteratorTestCase
/**
* @dataProvider getRegexNameTestData
*
* @group regexName
*/
public function testRegexName($adapter, $regex)
{
@ -506,7 +504,6 @@ class FinderTest extends Iterator\RealIteratorTestCase
/**
* @dataProvider getContainsTestData
* @group grep
*/
public function testContains($adapter, $matchPatterns, $noMatchPatterns, $expected)
{

View File

@ -139,7 +139,7 @@ class File extends \SplFileInfo
$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
return new File($target, false);
return new self($target, false);
}
/**

View File

@ -84,7 +84,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
$line = $trace[$i]['line'];
while (++$i < 7) {
if (isset($trace[$i]['function']) && empty($trace[$i]['class']) && 'call_user_func' !== $trace[$i]['function']) {
if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) {
$file = $trace[$i]['file'];
$line = $trace[$i]['line'];

View File

@ -117,7 +117,7 @@ final class Intl
{
if (null === self::$currencyBundle) {
self::$currencyBundle = new CurrencyBundle(
self::getDataDirectory().'/'.Intl::CURRENCY_DIR,
self::getDataDirectory().'/'.self::CURRENCY_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);
@ -135,11 +135,11 @@ final class Intl
{
if (null === self::$languageBundle) {
self::$languageBundle = new LanguageBundle(
self::getDataDirectory().'/'.Intl::LANGUAGE_DIR,
self::getDataDirectory().'/'.self::LANGUAGE_DIR,
self::getEntryReader(),
self::getLocaleBundle(),
new ScriptDataProvider(
self::getDataDirectory().'/'.Intl::SCRIPT_DIR,
self::getDataDirectory().'/'.self::SCRIPT_DIR,
self::getEntryReader()
)
);
@ -157,7 +157,7 @@ final class Intl
{
if (null === self::$localeBundle) {
self::$localeBundle = new LocaleBundle(
self::getDataDirectory().'/'.Intl::LOCALE_DIR,
self::getDataDirectory().'/'.self::LOCALE_DIR,
self::getEntryReader()
);
}
@ -174,7 +174,7 @@ final class Intl
{
if (null === self::$regionBundle) {
self::$regionBundle = new RegionBundle(
self::getDataDirectory().'/'.Intl::REGION_DIR,
self::getDataDirectory().'/'.self::REGION_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);

View File

@ -818,9 +818,6 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($process->isSuccessful());
}
/**
* @group idle-timeout
*/
public function testIdleTimeout()
{
$process = $this->getProcess('php -r "sleep(3);"');
@ -838,21 +835,18 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
}
}
/**
* @group idle-timeout
*/
public function testIdleTimeoutNotExceededWhenOutputIsSent()
{
$process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); echo \'foo\'; sleep(1); "');
$process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
$process->setTimeout(2);
$process->setIdleTimeout(1.5);
$process->setIdleTimeout(1);
try {
$process->run();
$this->fail('A timeout exception was expected.');
} catch (ProcessTimedOutException $ex) {
$this->assertTrue($ex->isGeneralTimeout());
$this->assertFalse($ex->isIdleTimeout());
$this->assertTrue($ex->isGeneralTimeout(), 'A general timeout is expected.');
$this->assertFalse($ex->isIdleTimeout(), 'No idle timeout is expected.');
$this->assertEquals(2, $ex->getExceededTimeout());
}
}

View File

@ -76,7 +76,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
public function __construct($propertyPath)
{
// Can be used as copy constructor
if ($propertyPath instanceof PropertyPath) {
if ($propertyPath instanceof self) {
/* @var PropertyPath $propertyPath */
$this->elements = $propertyPath->elements;
$this->singulars = $propertyPath->singulars;

View File

@ -50,7 +50,7 @@ class DumperCollection implements \IteratorAggregate
*/
public function add($child)
{
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
$this->children[] = $child;
@ -64,7 +64,7 @@ class DumperCollection implements \IteratorAggregate
public function setAll(array $children)
{
foreach ($children as $child) {
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
}

View File

@ -66,7 +66,7 @@ class DumperPrefixCollection extends DumperCollection
// Prefix starts with route's prefix
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new DumperPrefixCollection();
$child = new self();
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
$collection->add($child);

View File

@ -52,7 +52,7 @@ final class RoleSecurityIdentity implements SecurityIdentityInterface
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof RoleSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

View File

@ -102,7 +102,7 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof UserSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

View File

@ -76,6 +76,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$event->stop();
@ -93,6 +94,7 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$this->assertEquals(100, $event->getDuration(), null, self::DELTA);

View File

@ -232,7 +232,7 @@ abstract class Constraint
*/
public function addImplicitGroupName($group)
{
if (in_array(Constraint::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) {
if (in_array(self::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) {
$this->groups[] = $group;
}
}

View File

@ -58,7 +58,7 @@ class AnnotationLoader implements LoaderInterface
}
foreach ($reflClass->getProperties() as $property) {
if ($property->getDeclaringClass()->name == $className) {
if ($property->getDeclaringClass()->name === $className) {
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
if ($constraint instanceof Constraint) {
$metadata->addPropertyConstraint($property->name, $constraint);
@ -70,7 +70,7 @@ class AnnotationLoader implements LoaderInterface
}
foreach ($reflClass->getMethods() as $method) {
if ($method->getDeclaringClass()->name == $className) {
if ($method->getDeclaringClass()->name === $className) {
foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
if ($constraint instanceof Callback) {
$constraint->callback = $method->getName();

View File

@ -85,7 +85,7 @@ class YamlFileLoader extends FileLoader
$values = array();
foreach ($nodes as $name => $childNodes) {
if (is_numeric($name) && is_array($childNodes) && count($childNodes) == 1) {
if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) {
$options = current($childNodes);
if (is_array($options)) {

View File

@ -93,7 +93,7 @@ class Parser
// array
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
} else {
@ -102,7 +102,7 @@ class Parser
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$block = $values['value'];
@ -159,7 +159,7 @@ class Parser
$value = $this->getNextEmbedBlock();
}
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap);
@ -210,7 +210,7 @@ class Parser
}
} else {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport, $objectForMap);
// Spec: Keys MUST be unique; first one wins.