Skip to content

Commit

Permalink
Merge branch '2.6' into 2.7
Browse files Browse the repository at this point in the history
* 2.6:
  Php Inspections (EA Extended): squash all PR-13813 commits
  replaced the last remaining is_integer() call
  [2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup
  [FrameworkBundle] simplify dep declaration
  [VarDumper] Fix "next element is already occupied"
  [Validator] Added missing galician (gl) translations
  [PropertyAccess] stop overwriting once a reference is reached (3rd)
  [OptionsResolver] Remove Unused Variable from Foreach Cycles
  [travis] Tests Security sub-components
  [Twig] bootstrap_3_layout.html.twig is usable as a trait
  [travis] Tests Security sub-components
  CS fixes
  [TwigBridge] Bootstrap Layout - Fix the label of checkbox cannot be empty
  [travis] test with php nightly

Conflicts:
	.travis.yml
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
	src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
  • Loading branch information
fabpot committed Mar 7, 2015
2 parents 0ab3beb + 6cd8734 commit 0f00f7c
Show file tree
Hide file tree
Showing 40 changed files with 206 additions and 116 deletions.
21 changes: 12 additions & 9 deletions .travis.yml
Expand Up @@ -10,8 +10,10 @@ matrix:
env: deps=low
- php: 5.6
env: deps=high
- php: nightly
- php: hhvm-nightly
allow_failures:
- php: nightly
- php: hhvm-nightly
fast_finish: true

Expand All @@ -25,12 +27,12 @@ env:
before_install:
- travis_retry sudo apt-get install parallel
- composer self-update
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then phpenv config-rm xdebug.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then pecl install -f memcached-2.1.0; fi;
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then php -i; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then phpenv config-rm xdebug.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then pecl install -f memcached-2.1.0; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" != *"nightly" ]]; then php -i; fi;
- sudo locale-gen fr_FR.UTF-8 && sudo update-locale
# Set the COMPOSER_ROOT_VERSION to the right version according to the branch being built
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
Expand All @@ -39,8 +41,9 @@ install:
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;

script:
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
- if [ "$deps" = "no" ]; then export SYMFONY_DEPRECATIONS_HELPER=strict; fi;
- if [ "$deps" = "no" ]; then ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
- if [ "$deps" = "high" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist | sed 's#\(.*\)/.*#\1#' | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; phpunit --exclude-group tty,benchmark,intl-data,legacy || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j25% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; phpunit --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
@@ -1,4 +1,4 @@
{% extends "form_div_layout.html.twig" %}
{% use "form_div_layout.html.twig" %}

{# Widgets #}

Expand Down Expand Up @@ -164,12 +164,12 @@
{% if parent_label_class is defined %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
{% endif %}
{% if label is empty %}
{% if label is not sameas(false) and label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ widget|raw }}
{{ label|trans({}, translation_domain) }}
{{ label is not sameas(false) ? label|trans({}, translation_domain) }}
</label>
{% endif %}
{% endblock checkbox_radio_label %}
Expand Down
Expand Up @@ -388,7 +388,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
);

foreach ($urls as $i => $url) {
if (is_integer($i)) {
if (is_int($i)) {
if (0 === strpos($url, 'https://') || 0 === strpos($url, '//')) {
$urls['http'][] = $urls['ssl'][] = $url;
} else {
Expand Down
Expand Up @@ -303,7 +303,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
'memcached' => 'Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage',
'redis' => 'Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage',
);
list($class, ) = explode(':', $config['dsn'], 2);
list($class) = explode(':', $config['dsn'], 2);
if (!isset($supported[$class])) {
throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.', $class));
}
Expand Down
Expand Up @@ -472,7 +472,7 @@ protected function validatePrototypeNode(PrototypedArrayNode $node)
);
}

if (null !== $this->key && (null === $this->addDefaultChildren || is_integer($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
if (null !== $this->key && (null === $this->addDefaultChildren || is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
throw new InvalidDefinitionException(
sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path)
);
Expand Down
Expand Up @@ -117,7 +117,7 @@ public function setAddChildrenIfNoneSet($children = array('defaults'))
if (null === $children) {
$this->defaultChildren = array('defaults');
} else {
$this->defaultChildren = is_integer($children) && $children > 0 ? range(1, $children) : (array) $children;
$this->defaultChildren = is_int($children) && $children > 0 ? range(1, $children) : (array) $children;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Util/XmlUtils.php
Expand Up @@ -222,7 +222,7 @@ protected static function getXmlErrors($internalErrors)
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
$error->code,
trim($error->message),
$error->file ? $error->file : 'n/a',
$error->file ?: 'n/a',
$error->line,
$error->column
);
Expand Down
Expand Up @@ -149,7 +149,7 @@ public function setOption($option)
));
}

if (false === array_search(static::$availableOptions[$option], $this->options)) {
if (!in_array(static::$availableOptions[$option], $this->options)) {
$this->options[] = static::$availableOptions[$option];
}
}
Expand Down
Expand Up @@ -177,7 +177,7 @@ public function testNoInteraction()
protected function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
fputs($stream, $input);
fwrite($stream, $input);
rewind($stream);

return $stream;
Expand Down
Expand Up @@ -274,7 +274,7 @@ public function testNoInteraction()
protected function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
fputs($stream, $input);
fwrite($stream, $input);
rewind($stream);

return $stream;
Expand Down
Expand Up @@ -1175,7 +1175,7 @@ private function getServiceCallsFromArguments(array $arguments, array &$calls, a
$behavior[$id] = $argument->getInvalidBehavior();
}

$calls[$id] += 1;
++$calls[$id];
}
}
}
Expand Down Expand Up @@ -1487,12 +1487,12 @@ private function getNextVariableName()
}

while ($i > 0) {
$i -= 1;
--$i;
$name .= $nonFirstChars[$i%$nonFirstCharsLength];
$i = intval($i/$nonFirstCharsLength);
}

$this->variableCount += 1;
++$this->variableCount;

// check that the name is not reserved
if (in_array($name, $this->reservedVariables, true)) {
Expand Down
Expand Up @@ -260,7 +260,8 @@ public function testAddGetCompilerPass()
$builder->setResourceTracking(false);
$builderCompilerPasses = $builder->getCompiler()->getPassConfig()->getPasses();
$builder->addCompilerPass($this->getMock('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'));
$this->assertEquals(sizeof($builderCompilerPasses) + 1, sizeof($builder->getCompiler()->getPassConfig()->getPasses()));

$this->assertCount(count($builder->getCompiler()->getPassConfig()->getPasses()) - 1, $builderCompilerPasses);
}

/**
Expand Down
Expand Up @@ -74,8 +74,8 @@ public function testDumpRelativeDir()

$container = new ContainerBuilder();
$container->setDefinition('test', $definition);
$container->setParameter('foo', 'wiz'.dirname(dirname(__FILE__)));
$container->setParameter('bar', dirname(__FILE__));
$container->setParameter('foo', 'wiz'.dirname(__DIR__));
$container->setParameter('bar', __DIR__);
$container->setParameter('baz', '%bar%/PhpDumperTest.php');
$container->setParameter('buz', dirname(dirname(__DIR__)));
$container->compile();
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/DomCrawler/Crawler.php
Expand Up @@ -45,9 +45,10 @@ class Crawler extends \SplObjectStorage
/**
* Constructor.
*
* @param mixed $node A Node to use as the base for the crawling
* @param mixed $node A Node to use as the base for the crawling
* @param string $currentUri The current URI
* @param string $baseHref The base href value
* @param string $baseHref The base href value
*
* @api
*/
public function __construct($node = null, $currentUri = null, $baseHref = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
Expand Up @@ -327,7 +327,7 @@ public function testReduce()
{
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
$nodes = $crawler->reduce(function ($node, $i) {
return $i == 1 ? false : true;
return $i !== 1;
});
$this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler');
$this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler');
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Form/AbstractRendererEngine.php
Expand Up @@ -67,8 +67,7 @@ public function setTheme(FormView $view, $themes)
// Unset instead of resetting to an empty array, in order to allow
// implementations (like TwigRendererEngine) to check whether $cacheKey
// is set at all.
unset($this->resources[$cacheKey]);
unset($this->resourceHierarchyLevels[$cacheKey]);
unset($this->resources[$cacheKey], $this->resourceHierarchyLevels[$cacheKey]);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Form/FormBuilder.php
Expand Up @@ -138,8 +138,7 @@ public function remove($name)
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}

unset($this->unresolvedChildren[$name]);
unset($this->children[$name]);
unset($this->unresolvedChildren[$name], $this->children[$name]);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FormEvents.php
Expand Up @@ -14,10 +14,10 @@

/**
* To learn more about how form events work check the documentation
* entry at {@link http://symfony.com/doc/any/components/form/form_events.html}
* entry at {@link http://symfony.com/doc/any/components/form/form_events.html}.
*
* To learn how to dynamically modify forms using events check the cookbook
* entry at {@link http://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}
* entry at {@link http://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Form/FormRenderer.php
Expand Up @@ -296,8 +296,7 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va
// Clear the caches if they were filled for the first time within
// this function call
if ($hierarchyInit) {
unset($this->blockNameHierarchyMap[$viewAndSuffixCacheKey]);
unset($this->hierarchyLevelMap[$viewAndSuffixCacheKey]);
unset($this->blockNameHierarchyMap[$viewAndSuffixCacheKey], $this->hierarchyLevelMap[$viewAndSuffixCacheKey]);
}

if ($varInit) {
Expand Down
Expand Up @@ -54,7 +54,7 @@ protected function runTest()
*/
public function setMaxRunningTime($maxRunningTime)
{
if (is_integer($maxRunningTime) && $maxRunningTime >= 0) {
if (is_int($maxRunningTime) && $maxRunningTime >= 0) {
$this->maxRunningTime = $maxRunningTime;
} else {
throw new \InvalidArgumentException();
Expand Down
Expand Up @@ -147,8 +147,7 @@ public function onKernelRequest(GetResponseEvent $event)
}

$request->attributes->add($parameters);
unset($parameters['_route']);
unset($parameters['_controller']);
unset($parameters['_route'], $parameters['_controller']);
$request->attributes->set('_route_params', $parameters);
} catch (ResourceNotFoundException $e) {
$message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
Expand Down
Expand Up @@ -29,7 +29,7 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount

$this->assertSame('logger', $c->getName());
$this->assertSame($nb, $c->countErrors());
$this->assertSame($expectedLogs ? $expectedLogs : $logs, $c->getLogs());
$this->assertSame($expectedLogs ?: $logs, $c->getLogs());
$this->assertSame($expectedDeprecationCount, $c->countDeprecations());
$this->assertSame($expectedScreamCount, $c->countScreams());

Expand Down
14 changes: 4 additions & 10 deletions src/Symfony/Component/OptionsResolver/OptionsResolver.php
Expand Up @@ -258,7 +258,7 @@ public function setRequired($optionNames)
throw new AccessException('Options cannot be made required from a lazy option or normalizer.');
}

foreach ((array) $optionNames as $key => $option) {
foreach ((array) $optionNames as $option) {
$this->defined[$option] = true;
$this->required[$option] = true;
}
Expand Down Expand Up @@ -339,7 +339,7 @@ public function setDefined($optionNames)
throw new AccessException('Options cannot be defined from a lazy option or normalizer.');
}

foreach ((array) $optionNames as $key => $option) {
foreach ((array) $optionNames as $option) {
$this->defined[$option] = true;
}

Expand Down Expand Up @@ -686,14 +686,8 @@ public function remove($optionNames)
}

foreach ((array) $optionNames as $option) {
unset($this->defined[$option]);
unset($this->defaults[$option]);
unset($this->required[$option]);
unset($this->resolved[$option]);
unset($this->lazy[$option]);
unset($this->normalizers[$option]);
unset($this->allowedTypes[$option]);
unset($this->allowedValues[$option]);
unset($this->defined[$option], $this->defaults[$option], $this->required[$option], $this->resolved[$option]);
unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option]);
}

return $this;
Expand Down
41 changes: 20 additions & 21 deletions src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Expand Up @@ -70,7 +70,6 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
}

$propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1);
$overwrite = true;

// Add the root object to the list
array_unshift($propertyValues, array(
Expand All @@ -81,18 +80,19 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
for ($i = count($propertyValues) - 1; $i >= 0; --$i) {
$objectOrArray = & $propertyValues[$i][self::VALUE];

if ($overwrite) {
$property = $propertyPath->getElement($i);
$property = $propertyPath->getElement($i);

if ($propertyPath->isIndex($i)) {
$this->writeIndex($objectOrArray, $property, $value);
} else {
$this->writeProperty($objectOrArray, $property, $value);
}
if ($propertyPath->isIndex($i)) {
$this->writeIndex($objectOrArray, $property, $value);
} else {
$this->writeProperty($objectOrArray, $property, $value);
}

if ($propertyValues[$i][self::IS_REF]) {
return;
}

$value = & $objectOrArray;
$overwrite = !$propertyValues[$i][self::IS_REF];
}
}

Expand Down Expand Up @@ -127,7 +127,6 @@ public function isWritable($objectOrArray, $propertyPath)

try {
$propertyValues = $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1);
$overwrite = true;

// Add the root object to the list
array_unshift($propertyValues, array(
Expand All @@ -138,21 +137,21 @@ public function isWritable($objectOrArray, $propertyPath)
for ($i = count($propertyValues) - 1; $i >= 0; --$i) {
$objectOrArray = $propertyValues[$i][self::VALUE];

if ($overwrite) {
$property = $propertyPath->getElement($i);
$property = $propertyPath->getElement($i);

if ($propertyPath->isIndex($i)) {
if (!$objectOrArray instanceof \ArrayAccess && !is_array($objectOrArray)) {
return false;
}
} else {
if (!$this->isPropertyWritable($objectOrArray, $property)) {
return false;
}
if ($propertyPath->isIndex($i)) {
if (!$objectOrArray instanceof \ArrayAccess && !is_array($objectOrArray)) {
return false;
}
} else {
if (!$this->isPropertyWritable($objectOrArray, $property)) {
return false;
}
}

$overwrite = !$propertyValues[$i][self::IS_REF];
if ($propertyValues[$i][self::IS_REF]) {
return true;
}
}

return true;
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php
Expand Up @@ -264,8 +264,7 @@ private function resize($offset, $cutLength, $insertionLength)

// All remaining elements should be removed
for (; $i < $length; ++$i) {
unset($this->elements[$i]);
unset($this->isIndex[$i]);
unset($this->elements[$i], $this->isIndex[$i]);
}
} else {
$diff = $insertionLength - $cutLength;
Expand Down

0 comments on commit 0f00f7c

Please sign in to comment.