Merge branch '2.3' into 2.6

* 2.3:
  CS: fixes
  Translator component has default domain for null implemented no need to have default translation domain logic in 3 different places
  [travis] Kill tests when a new commit has been pushed
  fixed CS
  Change behavior to mirror hash_equals() returning early if there is a length mismatch
  CS fixing
  Prevent modifying secrets as much as possible
  Update StringUtils.php
  Whitespace
  Update StringUtils.php
  CS: general fixes
  [SecurityBundle] removed a duplicated service definition and simplified others.

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php
	src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml
	src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php
This commit is contained in:
Fabien Potencier 2015-03-27 11:19:51 +01:00
commit 33abe5c6d6
46 changed files with 139 additions and 88 deletions

5
.gitignore vendored
View File

@ -1,7 +1,8 @@
phpunit.xml .php_cs.cache
autoload.php
composer.lock composer.lock
composer.phar composer.phar
autoload.php
package*.tar package*.tar
packages.json packages.json
phpunit.xml
/vendor/ /vendor/

22
.php_cs
View File

@ -3,4 +3,26 @@
return Symfony\CS\Config\Config::create() return Symfony\CS\Config\Config::create()
->setUsingLinter(false) ->setUsingLinter(false)
->setUsingCache(true) ->setUsingCache(true)
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
->exclude(array(
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
'src/Symfony/Component/DependencyInjection/Tests/Fixtures',
'src/Symfony/Component/Routing/Tests/Fixtures/dumper',
// fixture templates
'src/Symfony/Component/Templating/Tests/Fixtures/templates',
// resource templates
'src/Symfony/Bundle/FrameworkBundle/Resources/views/Form',
))
// file content autogenerated by `var_export`
->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
// autogenerated xmls
->notPath('src/Symfony/Component/Console/Tests/Fixtures/application_1.xml')
->notPath('src/Symfony/Component/Console/Tests/Fixtures/application_2.xml')
// yml
->notPath('src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml')
// test template
->notPath('src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
)
; ;

View File

@ -26,6 +26,8 @@ env:
- SYMFONY_DEPRECATIONS_HELPER=weak - SYMFONY_DEPRECATIONS_HELPER=weak
before_install: before_install:
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then git fetch origin "refs/pull/$TRAVIS_PULL_REQUEST/merge"; else git fetch origin "$TRAVIS_BRANCH"; fi;
- if [[ "$TRAVIS_COMMIT" != `git rev-parse FETCH_HEAD` ]]; then echo "Pull request or branch commit hash has changed, aborting!"; exit 1; fi;
- travis_retry sudo apt-get install parallel - travis_retry sudo apt-get install parallel
- composer self-update - composer self-update
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then phpenv config-rm xdebug.ini; fi; - if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then phpenv config-rm xdebug.ini; fi;

View File

@ -90,19 +90,11 @@ class TranslationExtension extends \Twig_Extension
public function trans($message, array $arguments = array(), $domain = null, $locale = null) public function trans($message, array $arguments = array(), $domain = null, $locale = null)
{ {
if (null === $domain) {
$domain = 'messages';
}
return $this->translator->trans($message, $arguments, $domain, $locale); return $this->translator->trans($message, $arguments, $domain, $locale);
} }
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null) public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
{ {
if (null === $domain) {
$domain = 'messages';
}
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale); return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
} }

View File

@ -3,7 +3,7 @@
$required = false; $required = false;
endif; ?> endif; ?>
<?php echo $view['form']->block($form, 'widget_attributes', array( <?php echo $view['form']->block($form, 'widget_attributes', array(
'required' => $required 'required' => $required,
)) ?> )) ?>
<?php if ($multiple): ?> multiple="multiple"<?php endif ?> <?php if ($multiple): ?> multiple="multiple"<?php endif ?>
> >

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "hidden")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'hidden')) ?>

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "number")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'number')) ?>

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "text")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?>

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "password")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'password')) ?>

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "text")) ?> % <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?> %

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "search")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'search')) ?>

View File

@ -1 +1 @@
<?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : "url")) ?> <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'url')) ?>

View File

@ -1,6 +1,6 @@
This template is used for translation message extraction tests This template is used for translation message extraction tests
<?php echo $view['translator']->trans('single-quoted key') ?> <?php echo $view['translator']->trans('single-quoted key') ?>
<?php echo $view['translator']->trans("double-quoted key") ?> <?php echo $view['translator']->trans('double-quoted key') ?>
<?php echo $view['translator']->trans(<<<EOF <?php echo $view['translator']->trans(<<<EOF
heredoc key heredoc key
EOF EOF
@ -15,11 +15,11 @@ EOF
<?php echo $view['translator']->trans( <?php echo $view['translator']->trans(
'single-quoted key with whitespace and nonescaped \$\n\' sequences' 'single-quoted key with whitespace and nonescaped \$\n\' sequences'
) ?> ) ?>
<?php echo $view['translator']->trans( <<<EOF <?php echo $view['translator']->trans(<<<EOF
heredoc key with whitespace and escaped \$\n sequences heredoc key with whitespace and escaped \$\n sequences
EOF EOF
) ?> ) ?>
<?php echo $view['translator']->trans( <<<'EOF' <?php echo $view['translator']->trans(<<<'EOF'
nowdoc key with whitespace and nonescaped \$\n sequences nowdoc key with whitespace and nonescaped \$\n sequences
EOF EOF
) ?> ) ?>

View File

@ -26,7 +26,7 @@ interface SecurityFactoryInterface
/** /**
* Defines the position at which the provider is called. * Defines the position at which the provider is called.
* Possible values: pre_auth, form, http, and remember_me. * Possible values: pre_auth, form, http, and remember_me.
* *
* @return string * @return string
*/ */
public function getPosition(); public function getPosition();

View File

@ -83,10 +83,10 @@
</service> </service>
<service id="security.encoder_factory.generic" class="%security.encoder_factory.generic.class%" public="false"> <service id="security.encoder_factory.generic" class="%security.encoder_factory.generic.class%" public="false">
<argument type="collection"></argument> <argument type="collection" />
</service> </service>
<service id="security.encoder_factory" alias="security.encoder_factory.generic"></service> <service id="security.encoder_factory" alias="security.encoder_factory.generic" />
<service id="security.user_password_encoder.generic" class="Symfony\Component\Security\Core\Encoder\UserPasswordEncoder" public="false"> <service id="security.user_password_encoder.generic" class="Symfony\Component\Security\Core\Encoder\UserPasswordEncoder" public="false">
<argument type="service" id="security.encoder_factory"></argument> <argument type="service" id="security.encoder_factory"></argument>
@ -104,7 +104,7 @@
<!-- Authorization related services --> <!-- Authorization related services -->
<service id="security.access.decision_manager" class="%security.access.decision_manager.class%" public="false"> <service id="security.access.decision_manager" class="%security.access.decision_manager.class%" public="false">
<argument type="collection"></argument> <argument type="collection" />
</service> </service>
<service id="security.role_hierarchy" class="%security.role_hierarchy.class%" public="false"> <service id="security.role_hierarchy" class="%security.role_hierarchy.class%" public="false">

View File

@ -13,13 +13,13 @@
<parameter key="security.acl.object_identity_retrieval_strategy.class">Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy</parameter> <parameter key="security.acl.object_identity_retrieval_strategy.class">Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy</parameter>
<parameter key="security.acl.security_identity_retrieval_strategy.class">Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy</parameter> <parameter key="security.acl.security_identity_retrieval_strategy.class">Symfony\Component\Security\Acl\Domain\SecurityIdentityRetrievalStrategy</parameter>
<parameter key="security.acl.cache.doctrine.class">Symfony\Component\Security\Acl\Domain\DoctrineAclCache</parameter> <!-- never used? -->
<parameter key="security.acl.collection_cache.class">Symfony\Component\Security\Acl\Domain\AclCollectionCache</parameter> <parameter key="security.acl.collection_cache.class">Symfony\Component\Security\Acl\Domain\AclCollectionCache</parameter>
<parameter key="security.acl.cache.doctrine.class">Symfony\Component\Security\Acl\Domain\DoctrineAclCache</parameter>
</parameters> </parameters>
<services> <services>
<service id="security.acl.object_identity_retrieval_strategy" class="%security.acl.object_identity_retrieval_strategy.class%" public="false"></service> <service id="security.acl.object_identity_retrieval_strategy" class="%security.acl.object_identity_retrieval_strategy.class%" public="false" />
<service id="security.acl.security_identity_retrieval_strategy" class="%security.acl.security_identity_retrieval_strategy.class%" public="false"> <service id="security.acl.security_identity_retrieval_strategy" class="%security.acl.security_identity_retrieval_strategy.class%" public="false">
<argument type="service" id="security.role_hierarchy" /> <argument type="service" id="security.role_hierarchy" />
@ -32,7 +32,7 @@
</call> </call>
</service> </service>
<service id="security.acl.permission.map" class="%security.acl.permission.map.class%" public="false"></service> <service id="security.acl.permission.map" class="%security.acl.permission.map.class%" public="false" />
<service id="security.acl.voter.basic_permissions" class="%security.acl.voter.class%" public="false"> <service id="security.acl.voter.basic_permissions" class="%security.acl.voter.class%" public="false">
<tag name="monolog.logger" channel="security" /> <tag name="monolog.logger" channel="security" />

View File

@ -48,7 +48,5 @@
</service> </service>
<service id="security.acl.cache.doctrine.cache_impl" alias="doctrine.orm.default_result_cache" public="false" /> <service id="security.acl.cache.doctrine.cache_impl" alias="doctrine.orm.default_result_cache" public="false" />
<service id="security.acl.permission.map" class="%security.acl.permission.map.class%" public="false"></service>
</services> </services>
</container> </container>

View File

@ -83,7 +83,7 @@
<service id="security.context_listener" class="%security.context_listener.class%" public="false"> <service id="security.context_listener" class="%security.context_listener.class%" public="false">
<tag name="monolog.logger" channel="security" /> <tag name="monolog.logger" channel="security" />
<argument type="service" id="security.context" /> <argument type="service" id="security.context" />
<argument type="collection"></argument> <argument type="collection" />
<argument /> <!-- Provider Key --> <argument /> <!-- Provider Key -->
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
<argument type="service" id="event_dispatcher" on-invalid="null"/> <argument type="service" id="event_dispatcher" on-invalid="null"/>
@ -95,7 +95,9 @@
<argument type="service" id="security.logout.success_handler" /> <argument type="service" id="security.logout.success_handler" />
<argument /> <!-- Options --> <argument /> <!-- Options -->
</service> </service>
<service id="security.logout.handler.session" class="%security.logout.handler.session.class%" public="false" /> <service id="security.logout.handler.session" class="%security.logout.handler.session.class%" public="false" />
<service id="security.logout.handler.cookie_clearing" class="%security.logout.handler.cookie_clearing.class%" public="false" abstract="true" /> <service id="security.logout.handler.cookie_clearing" class="%security.logout.handler.cookie_clearing.class%" public="false" abstract="true" />
<service id="security.logout.success_handler" class="%security.logout.success_handler.class%" public="false" abstract="true"> <service id="security.logout.success_handler" class="%security.logout.success_handler.class%" public="false" abstract="true">
@ -116,7 +118,7 @@
<argument /> <argument />
<argument type="service" id="security.authentication.success_handler" /> <argument type="service" id="security.authentication.success_handler" />
<argument type="service" id="security.authentication.failure_handler" /> <argument type="service" id="security.authentication.failure_handler" />
<argument type="collection"></argument> <argument type="collection" />
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
<argument type="service" id="event_dispatcher" on-invalid="null" /> <argument type="service" id="event_dispatcher" on-invalid="null" />
</service> </service>
@ -148,8 +150,7 @@
<service id="security.authentication.listener.form" <service id="security.authentication.listener.form"
class="%security.authentication.listener.form.class%" class="%security.authentication.listener.form.class%"
parent="security.authentication.listener.abstract" parent="security.authentication.listener.abstract"
abstract="true"> abstract="true" />
</service>
<service id="security.authentication.listener.simple_form" <service id="security.authentication.listener.simple_form"
class="%security.authentication.listener.simple_form.class%" class="%security.authentication.listener.simple_form.class%"

View File

@ -31,7 +31,7 @@
<argument type="service" id="security.user_checker" /> <argument type="service" id="security.user_checker" />
</service> </service>
<service id="security.rememberme.token.provider.in_memory" class="%security.rememberme.token.provider.in_memory.class%" public="false"/> <service id="security.rememberme.token.provider.in_memory" class="%security.rememberme.token.provider.in_memory.class%" public="false" />
<service id="security.authentication.rememberme.services.abstract" abstract="true" public="false"> <service id="security.authentication.rememberme.services.abstract" abstract="true" public="false">
<tag name="monolog.logger" channel="security" /> <tag name="monolog.logger" channel="security" />
@ -52,8 +52,7 @@
<service id="security.authentication.rememberme.services.simplehash" <service id="security.authentication.rememberme.services.simplehash"
class="%security.authentication.rememberme.services.simplehash.class%" class="%security.authentication.rememberme.services.simplehash.class%"
parent="security.authentication.rememberme.services.abstract" parent="security.authentication.rememberme.services.abstract"
abstract="true"> abstract="true" />
</service>
<service id="security.rememberme.response_listener" class="%security.rememberme.response_listener.class%"> <service id="security.rememberme.response_listener" class="%security.rememberme.response_listener.class%">
<tag name="kernel.event_subscriber" /> <tag name="kernel.event_subscriber" />

View File

@ -1,4 +1,5 @@
<?php <?php
namespace { namespace {
class A class A
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace { namespace {
trait TFoo trait TFoo
{ {

View File

@ -114,7 +114,7 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertFinalizedValueIs('new_value', $test); $this->assertFinalizedValueIs('new_value', $test);
$test = $this->getTestBuilder() $test = $this->getTestBuilder()
->ifNotInArray(array('foo', 'bar', 'value_from_config' )) ->ifNotInArray(array('foo', 'bar', 'value_from_config'))
->then($this->returnClosure('new_value')) ->then($this->returnClosure('new_value'))
->end(); ->end();
$this->assertFinalizedValueIs('new_value', $test); $this->assertFinalizedValueIs('new_value', $test);

View File

@ -820,7 +820,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
$bagClass $bagClass
/** /**
* $class * $class.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -10,7 +10,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/** /**
* Container * Container.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/** /**
* ProjectServiceContainer * ProjectServiceContainer.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Dependency Injection Component. * by the Symfony Dependency Injection Component.

View File

@ -36,7 +36,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
return array( return array(
array( array(
$tmpDir, $tmpDir,
array( // paths array(
// paths
$tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git', $tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git',
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py', $tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py',
$tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo', $tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo',
@ -44,7 +45,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php', $tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
$tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto', $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
), ),
array( // subPaths array(
// subPaths
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '', $tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => '', $tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
$tmpDir.DIRECTORY_SEPARATOR.'foo' => '', $tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
@ -52,7 +54,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => '', $tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
$tmpDir.DIRECTORY_SEPARATOR.'toto' => '', $tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
), ),
array( // subPathnames array(
// subPathnames
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git', $tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py', $tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
$tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo', $tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',

View File

@ -57,7 +57,7 @@ abstract class BaseType extends AbstractType
$uniqueBlockPrefix = '_'.$blockName; $uniqueBlockPrefix = '_'.$blockName;
} }
if (!$translationDomain) { if (null === $translationDomain) {
$translationDomain = $view->parent->vars['translation_domain']; $translationDomain = $view->parent->vars['translation_domain'];
} }
@ -81,10 +81,6 @@ abstract class BaseType extends AbstractType
} }
$blockPrefixes[] = $uniqueBlockPrefix; $blockPrefixes[] = $uniqueBlockPrefix;
if (!$translationDomain) {
$translationDomain = 'messages';
}
$view->vars = array_replace($view->vars, array( $view->vars = array_replace($view->vars, array(
'form' => $view, 'form' => $view,
'id' => $id, 'id' => $id,

View File

@ -1,13 +1,13 @@
<?php <?php
/* /*
* This file is part of the Symfony package. * This file is part of the Symfony package.
* *
* (c) Fabien Potencier <fabien@symfony.com> * (c) Fabien Potencier <fabien@symfony.com>
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Symfony\Component\Form\Tests; namespace Symfony\Component\Form\Tests;

View File

@ -1,5 +1,14 @@
<?php <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Tests; namespace Symfony\Component\Form\Tests;
use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\CallbackTransformer;
@ -30,8 +39,8 @@ class CallbackTransformerTest extends \PHPUnit_Framework_TestCase
public function invalidCallbacksProvider() public function invalidCallbacksProvider()
{ {
return array( return array(
array( null, function () {} ), array(null, function () {}),
array( function () {}, null ), array(function () {}, null),
); );
} }
} }

View File

@ -112,7 +112,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
->getForm() ->getForm()
->createView(); ->createView();
$this->assertEquals('messages', $view['child']->vars['translation_domain']); $this->assertNull($view['child']->vars['translation_domain']);
} }
public function testPassLabelToView() public function testPassLabelToView()

View File

@ -212,13 +212,13 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array( $this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX, 'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff)) 'options' => array('min_range' => 1, 'max_range' => 0xff),
), '->filter() gets a value of parameter as integer between boundaries'); )), '->filter() gets a value of parameter as integer between boundaries');
$this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array( $this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX, 'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff)) 'options' => array('min_range' => 1, 'max_range' => 0xff),
), '->filter() gets a value of parameter as integer between boundaries'); )), '->filter() gets a value of parameter as integer between boundaries');
$this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array'); $this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array');
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of the Symfony package. * This file is part of the Symfony package.
* *

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Intl\Tests\Collator; namespace Symfony\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\Collator; use Symfony\Component\Intl\Collator\Collator;
use Symfony\Component\Intl\Locale;
/** /**
* Test case for Collator implementations. * Test case for Collator implementations.

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\Intl\Tests\Collator\Verification; namespace Symfony\Component\Intl\Tests\Collator\Verification;
use Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest; use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest;
use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Intl\Util\IntlTestHelper;

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Intl\Tests\NumberFormatter; namespace Symfony\Component\Intl\Tests\NumberFormatter;
use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\NumberFormatter\NumberFormatter; use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Intl\Util\IntlTestHelper;

View File

@ -63,7 +63,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
/** /**
* {$options['class']} * {$options['class']}.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Routing Component. * by the Symfony Routing Component.

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
/** /**
* ProjectUrlMatcher * ProjectUrlMatcher.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Routing Component. * by the Symfony Routing Component.

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
/** /**
* ProjectUrlMatcher * ProjectUrlMatcher.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Routing Component. * by the Symfony Routing Component.

View File

@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
/** /**
* ProjectUrlMatcher * ProjectUrlMatcher.
* *
* This class has been auto-generated * This class has been auto-generated
* by the Symfony Routing Component. * by the Symfony Routing Component.

View File

@ -1,4 +1,5 @@
<?php <?php
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;

View File

@ -38,29 +38,56 @@ class StringUtils
*/ */
public static function equals($knownString, $userInput) public static function equals($knownString, $userInput)
{ {
$knownString = (string) $knownString; // Avoid making unnecessary duplications of secret data
$userInput = (string) $userInput; if (!is_string($knownString)) {
$knownString = (string) $knownString;
}
if (!is_string($userInput)) {
$userInput = (string) $userInput;
}
if (function_exists('hash_equals')) { if (function_exists('hash_equals')) {
return hash_equals($knownString, $userInput); return hash_equals($knownString, $userInput);
} }
$knownLen = strlen($knownString); $knownLen = self::safeStrlen($knownString);
$userLen = strlen($userInput); $userLen = self::safeStrlen($userInput);
// Extend the known string to avoid uninitialized string offsets if ($userLen !== $knownLen) {
$knownString .= $userInput; return false;
}
// Set the result to the difference between the lengths $result = 0;
$result = $knownLen - $userLen;
// Note that we ALWAYS iterate over the user-supplied length for ($i = 0; $i < $knownLen; $i++) {
// This is to mitigate leaking length information
for ($i = 0; $i < $userLen; $i++) {
$result |= (ord($knownString[$i]) ^ ord($userInput[$i])); $result |= (ord($knownString[$i]) ^ ord($userInput[$i]));
} }
// They are only identical strings if $result is exactly 0... // They are only identical strings if $result is exactly 0...
return 0 === $result; return 0 === $result;
} }
/**
* Returns the number of bytes in a string.
*
* @param string $string The string whose length we wish to obtain
*
* @return int
*/
public static function safeStrlen($string)
{
// Premature optimization
// Since this cannot be changed at runtime, we can cache it
static $funcExists = null;
if (null === $funcExists) {
$funcExists = function_exists('mb_strlen');
}
if ($funcExists) {
return mb_strlen($string, '8bit');
}
return strlen($string);
}
} }