Merge branch '2.6' into 2.7

* 2.6:
  CS: fixes
  Translator component has default domain for null implemented no need to have default translation domain logic in 3 different places
  [Form] [TwigBridge] Bootstrap layout whitespace control
  [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
  StringUtils::equals() arguments in RememberMe Cookie based implementation are confused
  CS: general fixes
  [SecurityBundle] removed a duplicated service definition and simplified others.

Conflicts:
	src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
This commit is contained in:
Fabien Potencier 2015-03-27 11:22:45 +01:00
commit eccfbe35a4
51 changed files with 2141 additions and 152 deletions

5
.gitignore vendored
View File

@ -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
View File

@ -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')
)
;

View File

@ -25,6 +25,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;

View File

@ -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);
}

View File

@ -4,7 +4,7 @@
{% block form_widget_simple -%}
{% if type is not defined or 'file' != type %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%}
{% endif %}
{{- parent() -}}
{%- endblock form_widget_simple %}
@ -42,48 +42,48 @@
{% block datetime_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %}
{% else -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form.date) }}
{{ form_errors(form.time) }}
{{ form_widget(form.date, { datetime: true } ) }}&nbsp;
{{ form_widget(form.time, { datetime: true } ) }}
{{- form_errors(form.date) -}}
{{- form_errors(form.time) -}}
{{- form_widget(form.date, { datetime: true } ) -}}
{{- form_widget(form.time, { datetime: true } ) -}}
</div>
{% endif %}
{%- endif %}
{%- endblock datetime_widget %}
{% block date_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %}
{% if datetime is not defined or not datetime %}
{% else -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{% if datetime is not defined or not datetime -%}
<div {{ block('widget_container_attributes') -}}>
{% endif %}
{{ date_pattern|replace({
{%- endif %}
{{- date_pattern|replace({
'{{ year }}': form_widget(form.year),
'{{ month }}': form_widget(form.month),
'{{ day }}': form_widget(form.day),
})|raw }}
{% if datetime is not defined or not datetime %}
})|raw -}}
{% if datetime is not defined or not datetime -%}
</div>
{% endif %}
{%- endif -%}
{% endif %}
{%- endblock date_widget %}
{% block time_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %}
{% if datetime is not defined or false == datetime %}
{% else -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{% if datetime is not defined or false == datetime -%}
<div {{ block('widget_container_attributes') -}}>
{% endif %}
{{ form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
{% if datetime is not defined or false == datetime %}
{%- endif -%}
{{- form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
{% if datetime is not defined or false == datetime -%}
</div>
{% endif %}
{%- endif -%}
{% endif %}
{%- endblock time_widget %}
@ -93,57 +93,57 @@
{%- endblock %}
{% block choice_widget_expanded -%}
{% if '-inline' in label_attr.class|default('') %}
{% if '-inline' in label_attr.class|default('') -%}
<div class="control-group">
{% for child in form %}
{{ form_widget(child, {
{%- for child in form %}
{{- form_widget(child, {
parent_label_class: label_attr.class|default(''),
}) }}
{% endfor %}
}) -}}
{% endfor -%}
</div>
{% else %}
{%- else -%}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ form_widget(child, {
{%- for child in form %}
{{- form_widget(child, {
parent_label_class: label_attr.class|default(''),
}) }}
{% endfor %}
}) -}}
{% endfor -%}
</div>
{% endif %}
{%- endif %}
{%- endblock choice_widget_expanded %}
{% block checkbox_widget -%}
{% set parent_label_class = parent_label_class|default('') %}
{% set parent_label_class = parent_label_class|default('') -%}
{% if 'checkbox-inline' in parent_label_class %}
{{ form_label(form, null, { widget: parent() }) }}
{% else %}
{{- form_label(form, null, { widget: parent() }) -}}
{% else -%}
<div class="checkbox">
{{ form_label(form, null, { widget: parent() }) }}
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{% endif %}
{%- endif %}
{%- endblock checkbox_widget %}
{% block radio_widget -%}
{% set parent_label_class = parent_label_class|default('') %}
{%- set parent_label_class = parent_label_class|default('') -%}
{% if 'radio-inline' in parent_label_class %}
{{ form_label(form, null, { widget: parent() }) }}
{% else %}
{{- form_label(form, null, { widget: parent() }) -}}
{% else -%}
<div class="radio">
{{ form_label(form, null, { widget: parent() }) }}
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{% endif %}
{%- endif %}
{%- endblock radio_widget %}
{# Labels #}
{% block form_label -%}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) %}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%}
{{- parent() -}}
{%- endblock form_label %}
{% block choice_label %}
{% block choice_label -%}
{# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #}
{% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) %}
{%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%}
{{- block('form_label') -}}
{% endblock %}
@ -168,8 +168,8 @@
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ widget|raw }}
{{ label is not sameas(false) ? label|trans({}, translation_domain) }}
{{- widget|raw -}}
{{- label is not sameas(false) ? label|trans({}, translation_domain) -}}
</label>
{% endif %}
{% endblock checkbox_radio_label %}
@ -178,9 +178,9 @@
{% block form_row -%}
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
{{ form_label(form) }}
{{ form_widget(form) }}
{{ form_errors(form) }}
{{- form_label(form) -}}
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>
{%- endblock form_row %}
@ -192,35 +192,35 @@
{% block choice_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{{- block('form_row') }}
{%- endblock choice_row %}
{% block date_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{{- block('form_row') }}
{%- endblock date_row %}
{% block time_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{{- block('form_row') }}
{%- endblock time_row %}
{% block datetime_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{{- block('form_row') }}
{%- endblock datetime_row %}
{% block checkbox_row -%}
<div class="form-group{% if not valid %} has-error{% endif %}">
{{ form_widget(form) }}
{{ form_errors(form) }}
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>
{%- endblock checkbox_row %}
{% block radio_row -%}
<div class="form-group{% if not valid %} has-error{% endif %}">
{{ form_widget(form) }}
{{ form_errors(form) }}
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>
{%- endblock radio_row %}
@ -231,7 +231,7 @@
{% if form.parent %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %}
<ul class="list-unstyled">
{%- for error in errors -%}
<li><span class="glyphicon glyphicon-exclamation-sign"></span> {{ error.message }}</li>
<li><span class="glyphicon glyphicon-exclamation-sign"></span>{{ error.message }}</li>
{%- endfor -%}
</ul>
{% if form.parent %}</span>{% else %}</div>{% endif %}

View File

@ -0,0 +1,114 @@
<?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\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Tests\AbstractBootstrap3LayoutTest;
class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
{
/**
* @var FormExtension
*/
protected $extension;
protected function setUp()
{
parent::setUp();
$rendererEngine = new TwigRendererEngine(array(
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
));
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
$this->extension = new FormExtension($renderer);
$loader = new StubFilesystemLoader(array(
__DIR__.'/../../Resources/views/Form',
__DIR__.'/Fixtures/templates/form',
));
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
$environment->addExtension(new TranslationExtension(new StubTranslator()));
$environment->addExtension($this->extension);
$this->extension->initRuntime($environment);
}
protected function tearDown()
{
parent::tearDown();
$this->extension = null;
}
protected function renderForm(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
}
protected function renderEnctype(FormView $view)
{
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'enctype');
}
protected function renderLabel(FormView $view, $label = null, array $vars = array())
{
if ($label !== null) {
$vars += array('label' => $label);
}
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'label', $vars);
}
protected function renderErrors(FormView $view)
{
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'errors');
}
protected function renderWidget(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'widget', $vars);
}
protected function renderRow(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'row', $vars);
}
protected function renderRest(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'rest', $vars);
}
protected function renderStart(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->renderBlock($view, 'form_start', $vars);
}
protected function renderEnd(FormView $view, array $vars = array())
{
return (string) $this->extension->renderer->renderBlock($view, 'form_end', $vars);
}
protected function setTheme(FormView $view, array $themes)
{
$this->extension->renderer->setTheme($view, $themes);
}
}

View File

@ -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 ?>
>

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
<?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
) ?>

View File

@ -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();

View File

@ -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">

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.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" />

View File

@ -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>

View File

@ -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.token_storage" />
<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%"

View File

@ -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" />

View File

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

View File

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

View File

@ -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);

View File

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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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',

View File

@ -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,

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -92,9 +92,15 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
'attr' => array('class' => 'my&class'),
), $vars));
$xpath = trim($xpath).'
[@id="my&id"]
if (!isset($vars['id'])) {
$xpath = trim($xpath).'
[@id="my&id"]';
}
if (!isset($vars['attr']['class'])) {
$xpath .= '
[@class="my&class"]';
}
$this->assertMatchesXpath($html, $xpath);
}

View File

@ -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),
);
}
}

View File

@ -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()

View File

@ -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');
}

View File

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

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

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

View File

@ -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);
}
}

View File

@ -54,7 +54,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', get_class($user)));
}
if (true !== StringUtils::equals($hash, $this->generateCookieHash($class, $username, $expires, $user->getPassword()))) {
if (true !== StringUtils::equals($this->generateCookieHash($class, $username, $expires, $user->getPassword()), $hash)) {
throw new AuthenticationException('The cookie\'s hash is invalid.');
}