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:
commit
33abe5c6d6
|
@ -1,7 +1,8 @@
|
|||
phpunit.xml
|
||||
.php_cs.cache
|
||||
autoload.php
|
||||
composer.lock
|
||||
composer.phar
|
||||
autoload.php
|
||||
package*.tar
|
||||
packages.json
|
||||
phpunit.xml
|
||||
/vendor/
|
||||
|
|
22
.php_cs
22
.php_cs
|
@ -3,4 +3,26 @@
|
|||
return Symfony\CS\Config\Config::create()
|
||||
->setUsingLinter(false)
|
||||
->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')
|
||||
)
|
||||
;
|
||||
|
|
|
@ -26,6 +26,8 @@ env:
|
|||
- SYMFONY_DEPRECATIONS_HELPER=weak
|
||||
|
||||
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
|
||||
- composer self-update
|
||||
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then phpenv config-rm xdebug.ini; fi;
|
||||
|
|
|
@ -90,19 +90,11 @@ class TranslationExtension extends \Twig_Extension
|
|||
|
||||
public function trans($message, array $arguments = array(), $domain = null, $locale = null)
|
||||
{
|
||||
if (null === $domain) {
|
||||
$domain = 'messages';
|
||||
}
|
||||
|
||||
return $this->translator->trans($message, $arguments, $domain, $locale);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
$required = false;
|
||||
endif; ?>
|
||||
<?php echo $view['form']->block($form, 'widget_attributes', array(
|
||||
'required' => $required
|
||||
'required' => $required,
|
||||
)) ?>
|
||||
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
|
||||
>
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -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')) ?> %
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -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')) ?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
This template is used for translation message extraction tests
|
||||
<?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
|
||||
heredoc key
|
||||
EOF
|
||||
|
@ -15,11 +15,11 @@ EOF
|
|||
<?php echo $view['translator']->trans(
|
||||
'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
|
||||
EOF
|
||||
) ?>
|
||||
<?php echo $view['translator']->trans( <<<'EOF'
|
||||
<?php echo $view['translator']->trans(<<<'EOF'
|
||||
nowdoc key with whitespace and nonescaped \$\n sequences
|
||||
EOF
|
||||
) ?>
|
||||
|
|
|
@ -26,7 +26,7 @@ interface SecurityFactoryInterface
|
|||
/**
|
||||
* Defines the position at which the provider is called.
|
||||
* Possible values: pre_auth, form, http, and remember_me.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition();
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
</service>
|
||||
|
||||
<service id="security.encoder_factory.generic" class="%security.encoder_factory.generic.class%" public="false">
|
||||
<argument type="collection"></argument>
|
||||
<argument type="collection" />
|
||||
</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">
|
||||
<argument type="service" id="security.encoder_factory"></argument>
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
<!-- Authorization related services -->
|
||||
<service id="security.access.decision_manager" class="%security.access.decision_manager.class%" public="false">
|
||||
<argument type="collection"></argument>
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
||||
<service id="security.role_hierarchy" class="%security.role_hierarchy.class%" public="false">
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
<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.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.cache.doctrine.class">Symfony\Component\Security\Acl\Domain\DoctrineAclCache</parameter>
|
||||
</parameters>
|
||||
|
||||
<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">
|
||||
<argument type="service" id="security.role_hierarchy" />
|
||||
|
@ -32,7 +32,7 @@
|
|||
</call>
|
||||
</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">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
|
|
|
@ -48,7 +48,5 @@
|
|||
</service>
|
||||
|
||||
<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>
|
||||
</container>
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<service id="security.context_listener" class="%security.context_listener.class%" public="false">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="collection"></argument>
|
||||
<argument type="collection" />
|
||||
<argument /> <!-- Provider Key -->
|
||||
<argument type="service" id="logger" 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 /> <!-- Options -->
|
||||
</service>
|
||||
|
||||
<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.success_handler" class="%security.logout.success_handler.class%" public="false" abstract="true">
|
||||
|
@ -116,7 +118,7 @@
|
|||
<argument />
|
||||
<argument type="service" id="security.authentication.success_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="event_dispatcher" on-invalid="null" />
|
||||
</service>
|
||||
|
@ -148,8 +150,7 @@
|
|||
<service id="security.authentication.listener.form"
|
||||
class="%security.authentication.listener.form.class%"
|
||||
parent="security.authentication.listener.abstract"
|
||||
abstract="true">
|
||||
</service>
|
||||
abstract="true" />
|
||||
|
||||
<service id="security.authentication.listener.simple_form"
|
||||
class="%security.authentication.listener.simple_form.class%"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<argument type="service" id="security.user_checker" />
|
||||
</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">
|
||||
<tag name="monolog.logger" channel="security" />
|
||||
|
@ -52,8 +52,7 @@
|
|||
<service id="security.authentication.rememberme.services.simplehash"
|
||||
class="%security.authentication.rememberme.services.simplehash.class%"
|
||||
parent="security.authentication.rememberme.services.abstract"
|
||||
abstract="true">
|
||||
</service>
|
||||
abstract="true" />
|
||||
|
||||
<service id="security.rememberme.response_listener" class="%security.rememberme.response_listener.class%">
|
||||
<tag name="kernel.event_subscriber" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace {
|
||||
class A
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace {
|
||||
trait TFoo
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifNotInArray(array('foo', 'bar', 'value_from_config' ))
|
||||
->ifNotInArray(array('foo', 'bar', 'value_from_config'))
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
|
|
@ -820,7 +820,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
$bagClass
|
||||
|
||||
/**
|
||||
* $class
|
||||
* $class.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -10,7 +10,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* Container
|
||||
* Container.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
|
||||
/**
|
||||
* ProjectServiceContainer
|
||||
* ProjectServiceContainer.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Dependency Injection Component.
|
||||
|
|
|
@ -36,7 +36,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
|
|||
return array(
|
||||
array(
|
||||
$tmpDir,
|
||||
array( // paths
|
||||
array(
|
||||
// paths
|
||||
$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',
|
||||
|
@ -44,7 +45,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
|
|||
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
|
||||
),
|
||||
array( // subPaths
|
||||
array(
|
||||
// subPaths
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
|
||||
|
@ -52,7 +54,8 @@ class FilePathsIteratorTest extends RealIteratorTestCase
|
|||
$tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
|
||||
),
|
||||
array( // subPathnames
|
||||
array(
|
||||
// subPathnames
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
|
||||
$tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',
|
||||
|
|
|
@ -57,7 +57,7 @@ abstract class BaseType extends AbstractType
|
|||
$uniqueBlockPrefix = '_'.$blockName;
|
||||
}
|
||||
|
||||
if (!$translationDomain) {
|
||||
if (null === $translationDomain) {
|
||||
$translationDomain = $view->parent->vars['translation_domain'];
|
||||
}
|
||||
|
||||
|
@ -81,10 +81,6 @@ abstract class BaseType extends AbstractType
|
|||
}
|
||||
$blockPrefixes[] = $uniqueBlockPrefix;
|
||||
|
||||
if (!$translationDomain) {
|
||||
$translationDomain = 'messages';
|
||||
}
|
||||
|
||||
$view->vars = array_replace($view->vars, array(
|
||||
'form' => $view,
|
||||
'id' => $id,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?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.
|
||||
*/
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
|
@ -30,8 +39,8 @@ class CallbackTransformerTest extends \PHPUnit_Framework_TestCase
|
|||
public function invalidCallbacksProvider()
|
||||
{
|
||||
return array(
|
||||
array( null, function () {} ),
|
||||
array( function () {}, null ),
|
||||
array(null, function () {}),
|
||||
array(function () {}, null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||
->getForm()
|
||||
->createView();
|
||||
|
||||
$this->assertEquals('messages', $view['child']->vars['translation_domain']);
|
||||
$this->assertNull($view['child']->vars['translation_domain']);
|
||||
}
|
||||
|
||||
public function testPassLabelToView()
|
||||
|
|
|
@ -212,13 +212,13 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array(
|
||||
'flags' => FILTER_FLAG_ALLOW_HEX,
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff))
|
||||
), '->filter() gets a value of parameter as integer between boundaries');
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff),
|
||||
)), '->filter() gets a value of parameter as integer between boundaries');
|
||||
|
||||
$this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array(
|
||||
'flags' => FILTER_FLAG_ALLOW_HEX,
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff))
|
||||
), '->filter() gets a value of parameter as integer between boundaries');
|
||||
'options' => array('min_range' => 1, 'max_range' => 0xff),
|
||||
)), '->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');
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Component\Intl\Tests\Collator;
|
||||
|
||||
use Symfony\Component\Intl\Collator\Collator;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Test case for Collator implementations.
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
namespace Symfony\Component\Intl\Tests\Collator\Verification;
|
||||
|
||||
use Symfony\Component\Intl\Locale;
|
||||
use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest;
|
||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
||||
|
||||
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
|
||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* {$options['class']}
|
||||
* {$options['class']}.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
|
|
|
@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
|
|
|
@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
|
|
|
@ -5,7 +5,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
|
|
|
@ -38,29 +38,56 @@ class StringUtils
|
|||
*/
|
||||
public static function equals($knownString, $userInput)
|
||||
{
|
||||
$knownString = (string) $knownString;
|
||||
$userInput = (string) $userInput;
|
||||
// Avoid making unnecessary duplications of secret data
|
||||
if (!is_string($knownString)) {
|
||||
$knownString = (string) $knownString;
|
||||
}
|
||||
|
||||
if (!is_string($userInput)) {
|
||||
$userInput = (string) $userInput;
|
||||
}
|
||||
|
||||
if (function_exists('hash_equals')) {
|
||||
return hash_equals($knownString, $userInput);
|
||||
}
|
||||
|
||||
$knownLen = strlen($knownString);
|
||||
$userLen = strlen($userInput);
|
||||
$knownLen = self::safeStrlen($knownString);
|
||||
$userLen = self::safeStrlen($userInput);
|
||||
|
||||
// Extend the known string to avoid uninitialized string offsets
|
||||
$knownString .= $userInput;
|
||||
if ($userLen !== $knownLen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the result to the difference between the lengths
|
||||
$result = $knownLen - $userLen;
|
||||
$result = 0;
|
||||
|
||||
// Note that we ALWAYS iterate over the user-supplied length
|
||||
// This is to mitigate leaking length information
|
||||
for ($i = 0; $i < $userLen; $i++) {
|
||||
for ($i = 0; $i < $knownLen; $i++) {
|
||||
$result |= (ord($knownString[$i]) ^ ord($userInput[$i]));
|
||||
}
|
||||
|
||||
// They are only identical strings if $result is exactly 0...
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue