From 213cabcf9531e261de239a0666a4506b35a953de Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 26 Feb 2015 10:25:20 +0100 Subject: [PATCH 01/14] [travis] test with php nightly --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a97b93102e..9d1eb930c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,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 @@ -26,12 +28,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; From 96896390d722f7da9935131145f9cb9e2ffd76df Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Fri, 27 Feb 2015 01:42:10 +0100 Subject: [PATCH 02/14] [TwigBridge] Bootstrap Layout - Fix the label of checkbox cannot be empty --- .../Twig/Resources/views/Form/bootstrap_3_layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index f82979cd62..8aa5ceabc9 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -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 %} {{ widget|raw }} - {{ label|trans({}, translation_domain) }} + {{ label is not sameas(false) ? label|trans({}, translation_domain) }} {% endif %} {% endblock checkbox_radio_label %} From 7fd6ba06b18d2f128ee724ba8bc1876b84d0ef7c Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Wed, 18 Feb 2015 08:05:44 +0100 Subject: [PATCH 03/14] CS fixes --- .../DependencyInjection/FrameworkExtension.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 5 +++-- src/Symfony/Component/Form/FormEvents.php | 4 ++-- .../PreAuthenticatedAuthenticationProvider.php | 2 +- .../Security/Tests/Acl/Voter/AclVoterTest.php | 12 ++++++------ .../Tests/Http/Firewall/RememberMeListenerTest.php | 8 ++++---- .../Validator/Mapping/Loader/AbstractLoader.php | 14 +++++++------- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 56220995dc..127e7f9c84 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -226,7 +226,7 @@ class FrameworkExtension extends Extension '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)); } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 1fe5df87cf..7fe313e118 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -35,9 +35,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) diff --git a/src/Symfony/Component/Form/FormEvents.php b/src/Symfony/Component/Form/FormEvents.php index c48dff3880..d8c0510c28 100644 --- a/src/Symfony/Component/Form/FormEvents.php +++ b/src/Symfony/Component/Form/FormEvents.php @@ -12,10 +12,10 @@ namespace Symfony\Component\Form; /** * 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 */ diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php index a73c244787..87b7114750 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php @@ -60,7 +60,7 @@ class PreAuthenticatedAuthenticationProvider implements AuthenticationProviderIn throw new BadCredentialsException('No pre-authenticated principal found in request.'); } - $user = $this->userProvider->loadUserByUsername($user); + $user = $this->userProvider->loadUserByUsername($user); $this->userChecker->checkPostAuth($user); diff --git a/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php b/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php index 57f9d1bc73..8544b19078 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php @@ -27,7 +27,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testSupportsAttribute($attribute, $supported) { - list($voter, , $permissionMap, ,) = $this->getVoter(true, false); + list($voter, , $permissionMap) = $this->getVoter(true, false); $permissionMap ->expects($this->once()) @@ -44,7 +44,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testSupportsAttributeNonString($attribute) { - list($voter, , , , ,) = $this->getVoter(true, false); + list($voter) = $this->getVoter(true, false); $this->assertFalse($voter->supportsAttribute($attribute)); } @@ -72,7 +72,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testSupportsClass($class) { - list($voter, , , ,) = $this->getVoter(); + list($voter) = $this->getVoter(); $this->assertTrue($voter->supportsClass($class)); } @@ -88,7 +88,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase public function testVote() { - list($voter, , $permissionMap, ,) = $this->getVoter(); + list($voter, , $permissionMap) = $this->getVoter(); $permissionMap ->expects($this->atLeastOnce()) ->method('getMasks') @@ -103,7 +103,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testVoteWhenNoObjectIsPassed($allowIfObjectIdentityUnavailable) { - list($voter, , $permissionMap, ,) = $this->getVoter($allowIfObjectIdentityUnavailable); + list($voter, , $permissionMap) = $this->getVoter($allowIfObjectIdentityUnavailable); $permissionMap ->expects($this->once()) ->method('getMasks') @@ -124,7 +124,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testVoteWhenOidStrategyReturnsNull($allowIfUnavailable) { - list($voter, , $permissionMap, $oidStrategy,) = $this->getVoter($allowIfUnavailable); + list($voter, , $permissionMap, $oidStrategy) = $this->getVoter($allowIfUnavailable); $permissionMap ->expects($this->once()) ->method('getMasks') diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php index 3624f11781..067cacb6cb 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php @@ -19,7 +19,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase { public function testOnCoreSecurityDoesNotTryToPopulateNonEmptySecurityContext() { - list($listener, $context, $service, ,) = $this->getListener(); + list($listener, $context, $service) = $this->getListener(); $context ->expects($this->once()) @@ -37,7 +37,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() { - list($listener, $context, $service, ,) = $this->getListener(); + list($listener, $context, $service) = $this->getListener(); $context ->expects($this->once()) @@ -63,7 +63,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation() { - list($listener, $context, $service, $manager,) = $this->getListener(); + list($listener, $context, $service, $manager) = $this->getListener(); $context ->expects($this->once()) @@ -101,7 +101,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase public function testOnCoreSecurity() { - list($listener, $context, $service, $manager,) = $this->getListener(); + list($listener, $context, $service, $manager) = $this->getListener(); $context ->expects($this->once()) diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index a69752d6df..6b77e6a3f7 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -58,13 +58,13 @@ abstract class AbstractLoader implements LoaderInterface /** * Creates a new constraint instance for the given constraint name. * - * @param string $name The constraint name. Either a constraint relative - * to the default constraint namespace, or a fully - * qualified class name. Alternatively, the constraint - * may be preceded by a namespace alias and a colon. - * The namespace alias must have been defined using - * {@link addNamespaceAlias()}. - * @param mixed $options The constraint options + * @param string $name The constraint name. Either a constraint relative + * to the default constraint namespace, or a fully + * qualified class name. Alternatively, the constraint + * may be preceded by a namespace alias and a colon. + * The namespace alias must have been defined using + * {@link addNamespaceAlias()}. + * @param mixed $options The constraint options * * @return Constraint * From 8aef213246f203267622d7f4f616809108885526 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Mar 2015 21:53:03 +0100 Subject: [PATCH 04/14] [travis] Tests Security sub-components --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d1eb930c5..2049fa50f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,8 @@ install: - if [ "$deps" = "no" ]; then composer --prefer-source install; fi; script: - - 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; + - components=`find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -print0 | sed 's#\\(.*\\)/.*#\\1#'` + - if [ "$deps" = "no" ]; then echo $components | parallel -0 --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 -0 --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 -0 --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; From 4509d36991bad58a5ceddc64c151c09ca622769d Mon Sep 17 00:00:00 2001 From: Dusan Kasan Date: Sat, 28 Feb 2015 16:09:17 +0100 Subject: [PATCH 05/14] [Twig] bootstrap_3_layout.html.twig is usable as a trait --- .../Twig/Resources/views/Form/bootstrap_3_layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index f82979cd62..ed265d297a 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -1,4 +1,4 @@ -{% extends "form_div_layout.html.twig" %} +{% use "form_div_layout.html.twig" %} {# Widgets #} From 16cdcf2b942b2564fde3bb7d06ecd4f82658aff8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Mar 2015 21:53:03 +0100 Subject: [PATCH 06/14] [travis] Tests Security sub-components --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2049fa50f4..6c70c3c307 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,8 @@ install: - if [ "$deps" = "no" ]; then composer --prefer-source install; fi; script: - - components=`find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -print0 | sed 's#\\(.*\\)/.*#\\1#'` - - if [ "$deps" = "no" ]; then echo $components | parallel -0 --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi; + - components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n') + - if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; phpunit --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi; - if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; phpunit --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi; - - if [ "$deps" = "high" ]; then echo $components | parallel -0 --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 -0 --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; From 77f4dbfa1082d6cdf7c8697c7f300ecaab15b40b Mon Sep 17 00:00:00 2001 From: Vadim Kharitonov Date: Tue, 3 Mar 2015 17:59:03 +0300 Subject: [PATCH 07/14] [OptionsResolver] Remove Unused Variable from Foreach Cycles --- src/Symfony/Component/OptionsResolver/OptionsResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 4d9653c45b..da6e43b678 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -252,7 +252,7 @@ class OptionsResolver implements Options, OptionsResolverInterface 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; } @@ -333,7 +333,7 @@ class OptionsResolver implements Options, OptionsResolverInterface 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; } From d733a887df44f12155aff4dc403fbd2f0b0109fc Mon Sep 17 00:00:00 2001 From: Philip Frank Date: Mon, 2 Mar 2015 21:56:10 +0100 Subject: [PATCH 08/14] [PropertyAccess] stop overwriting once a reference is reached (3rd) --- .../PropertyAccess/PropertyAccessor.php | 41 +++++++++---------- .../Tests/Fixtures/TestClass.php | 7 ++++ .../Tests/PropertyAccessorTest.php | 8 ++++ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index cef1c6e7f5..17f62bcc45 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -70,7 +70,6 @@ class PropertyAccessor implements PropertyAccessorInterface } $propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1); - $overwrite = true; // Add the root object to the list array_unshift($propertyValues, array( @@ -81,18 +80,19 @@ class PropertyAccessor implements PropertyAccessorInterface 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]; } } @@ -127,7 +127,6 @@ class PropertyAccessor implements PropertyAccessorInterface try { $propertyValues = $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1); - $overwrite = true; // Add the root object to the list array_unshift($propertyValues, array( @@ -138,21 +137,21 @@ class PropertyAccessor implements PropertyAccessorInterface 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; diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClass.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClass.php index 5cd605b164..7b1b927529 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClass.php +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClass.php @@ -25,6 +25,7 @@ class TestClass private $publicAccessorWithMoreRequiredParameters; private $publicIsAccessor; private $publicHasAccessor; + private $publicGetter; public function __construct($value) { @@ -37,6 +38,7 @@ class TestClass $this->publicAccessorWithMoreRequiredParameters = $value; $this->publicIsAccessor = $value; $this->publicHasAccessor = $value; + $this->publicGetter = $value; } public function setPublicAccessor($value) @@ -166,4 +168,9 @@ class TestClass { return 'foobar'; } + + public function getPublicGetter() + { + return $this->publicGetter; + } } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 58d4d74402..0c46467567 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -419,6 +419,14 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase array(array('index' => array('%!@$§.' => 'Bernhard')), '[index][%!@$§.]', 'Bernhard'), array((object) array('%!@$§' => 'Bernhard'), '%!@$§', 'Bernhard'), array((object) array('property' => (object) array('%!@$§' => 'Bernhard')), 'property.%!@$§', 'Bernhard'), + + // nested objects and arrays + array(array('foo' => new TestClass('bar')), '[foo].publicGetSetter', 'bar'), + array(new TestClass(array('foo' => 'bar')), 'publicGetSetter[foo]', 'bar'), + array(new TestClass(new TestClass('bar')), 'publicGetter.publicGetSetter', 'bar'), + array(new TestClass(array('foo' => new TestClass('bar'))), 'publicGetter[foo].publicGetSetter', 'bar'), + array(new TestClass(new TestClass(new TestClass('bar'))), 'publicGetter.publicGetter.publicGetSetter', 'bar'), + array(new TestClass(array('foo' => array('baz' => new TestClass('bar')))), 'publicGetter[foo][baz].publicGetSetter', 'bar'), ); } From ec11915895c79b9e0fb403b5714aeb3e541b24c0 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Date: Wed, 4 Mar 2015 00:44:54 +0100 Subject: [PATCH 09/14] [Validator] Added missing galician (gl) translations --- .../Resources/translations/validators.gl.xlf | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf index 13c7ffe0d2..c9d9f046a5 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf @@ -278,6 +278,38 @@ This value should not be identical to {{ compared_value_type }} {{ compared_value }}. Este valor non debería ser identico a {{ compared_value_type }} {{ compared_value }}. + + The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. + A proporción da imaxe é demasiado grande ({{ ratio }}). A proporción máxima permitida é {{ max_ratio }}. + + + The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. + A proporción da é demasiado pequena ({{ ratio }}). A proporción mínima permitida é {{ min_ratio }}. + + + The image is square ({{ width }}x{{ height }}px). Square images are not allowed. + A imaxe é cadrada ({{ width }}x{{ height }}px). As imáxenes cadradas non están permitidas. + + + The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. + A imaxe está orientada horizontalmente ({{ width }}x{{ height }}px). As imáxenes orientadas horizontalmente non están permitidas. + + + The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. + A imaxe está orientada verticalmente ({{ width }}x{{ height }}px). As imáxenes orientadas verticalmente non están permitidas. + + + An empty file is not allowed. + Non está permitido un arquivo baleiro. + + + The host could not be resolved. + Non se puido resolver o host. + + + This value does not match the expected {{ charset }} charset. + A codificación de caracteres para este valor debería ser {{ charset }}. + From 32a81f79aa8fd91f2d5fcea5f38bfe60e22401d7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 6 Mar 2015 17:45:31 +0100 Subject: [PATCH 10/14] [VarDumper] Fix "next element is already occupied" --- .../Component/VarDumper/Cloner/VarCloner.php | 15 ++++--- .../VarDumper/Tests/VarClonerTest.php | 43 +++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 5434d7d18b..dd40512819 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -38,8 +38,9 @@ class VarCloner extends AbstractCloner $maxItems = $this->maxItems; $maxString = $this->maxString; $cookie = (object) array(); // Unique object used to detect hard references + $gid = uniqid(mt_rand(), true); // Unique string used to detect the special $GLOBALS variable $a = null; // Array cast for nested structures - $stub = null; // Stub capturing the main properties of an original item value, + $stub = null; // Stub capturing the main properties of an original item value // or null if the original value is used directly $zval = array( // Main properties of the current value 'type' => null, @@ -121,16 +122,20 @@ class VarCloner extends AbstractCloner $stub->value = $zval['array_count'] ?: count($v); $a = $v; - $a[] = null; - $h = count($v); - array_pop($a); + + // Copies of $GLOBALS have very strange behavior, + // let's detect them with some black magic + $a[$gid] = true; // Happens with copies of $GLOBALS - if ($h !== $stub->value) { + if (isset($v[$gid])) { + unset($v[$gid]); $a = array(); foreach ($v as $gk => &$gv) { $a[$gk] =& $gv; } + } else { + $a = $v; } } break; diff --git a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php index 0e28ebac06..1bb9410036 100644 --- a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php +++ b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php @@ -18,6 +18,49 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; */ class VarClonerTest extends \PHPUnit_Framework_TestCase { + public function testMaxIntBoundary() + { + $data = array(PHP_INT_MAX => 123); + + $cloner = new VarCloner(); + $clone = $cloner->cloneVar($data); + + $expected = << Array + ( + [0] => Array + ( + [0] => Symfony\Component\VarDumper\Cloner\Stub Object + ( + [type] => array + [class] => assoc + [value] => 1 + [cut] => 0 + [handle] => 0 + [refCount] => 0 + [position] => 1 + ) + + ) + + [1] => Array + ( + [%s] => 123 + ) + + ) + + [maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20 + [maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1 + [useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1 +) + +EOTXT; + $this->assertSame(sprintf($expected, PHP_INT_MAX), print_r($clone, true)); + } + public function testClone() { $json = json_decode('{"1":{"var":"val"},"2":{"var":"val"}}'); From 37035b0696cd5990ff6c7d07f986f501828d9237 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 5 Mar 2015 10:42:26 +0100 Subject: [PATCH 11/14] [FrameworkBundle] simplify dep declaration --- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index d5ff3e0d41..d330e54510 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/http-foundation": "~2.4.9|~2.5,>=2.5.4", "symfony/http-kernel": "~2.6", "symfony/filesystem": "~2.3", - "symfony/routing": "~2.3.25,>2.3.25|~2.6,>2.6.4", + "symfony/routing": "~2.3.26|~2.6,>=2.6.5", "symfony/security-core": "~2.6", "symfony/security-csrf": "~2.6", "symfony/stopwatch": "~2.3", From f13b5f75830921d2f3a05ee97062929c3517ffdd Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 6 Mar 2015 20:37:36 +0100 Subject: [PATCH 12/14] [2.3] [Config] [Console] [DependencyInjection] [DomCrawler] [Form] [HttpKernel] [PropertyAccess] [Security] [Translation] [Yaml] static code analysis, code cleanup --- .../Definition/Builder/ArrayNodeDefinition.php | 2 +- .../Config/Definition/PrototypedArrayNode.php | 2 +- src/Symfony/Component/Config/Util/XmlUtils.php | 2 +- .../Console/Formatter/OutputFormatterStyle.php | 2 +- .../Console/Tests/Helper/DialogHelperTest.php | 2 +- .../DependencyInjection/Dumper/PhpDumper.php | 6 +++--- .../Tests/ContainerBuilderTest.php | 3 ++- .../Tests/Dumper/PhpDumperTest.php | 4 ++-- .../Component/DomCrawler/Tests/CrawlerTest.php | 2 +- .../Component/Form/AbstractRendererEngine.php | 3 +-- src/Symfony/Component/Form/FormBuilder.php | 3 +-- src/Symfony/Component/Form/FormRenderer.php | 3 +-- .../Component/Form/Test/FormPerformanceTestCase.php | 2 +- .../HttpKernel/EventListener/RouterListener.php | 3 +-- .../Tests/DataCollector/LoggerDataCollectorTest.php | 2 +- .../Component/PropertyAccess/PropertyPathBuilder.php | 3 +-- .../Component/Security/Acl/Dbal/AclProvider.php | 12 +++++++----- .../Tests/Acl/Dbal/AclProviderBenchmarkTest.php | 8 ++++---- .../Security/Tests/Core/Util/SecureRandomTest.php | 8 ++++---- .../Tests/Http/Firewall/ExceptionListenerTest.php | 6 +++--- .../Component/Translation/Loader/XliffFileLoader.php | 2 +- src/Symfony/Component/Yaml/Inline.php | 4 ++-- 22 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index 7cf662dbc0..d2226f63f1 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -480,7 +480,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition ); } - 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) ); diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index febb016e82..2c7a7ab052 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -131,7 +131,7 @@ class PrototypedArrayNode extends ArrayNode 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; } } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 78a16e9ac8..7d66799c08 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -215,7 +215,7 @@ class XmlUtils 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 ); diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php index c414a8232d..48e9850725 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -149,7 +149,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface )); } - if (false === array_search(static::$availableOptions[$option], $this->options)) { + if (!in_array(static::$availableOptions[$option], $this->options)) { $this->options[] = static::$availableOptions[$option]; } } diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php index ce44fc773d..8caf6569c6 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php @@ -159,7 +159,7 @@ class DialogHelperTest extends \PHPUnit_Framework_TestCase protected function getInputStream($input) { $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); + fwrite($stream, $input); rewind($stream); return $stream; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 3cd728faf0..e152b9af2f 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1087,7 +1087,7 @@ EOF; $behavior[$id] = $argument->getInvalidBehavior(); } - $calls[$id] += 1; + ++$calls[$id]; } } } @@ -1345,12 +1345,12 @@ EOF; } 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)) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index ac67bab9fe..da37230489 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -259,7 +259,8 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $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); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 905e600e78..86c2b72ba2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -89,8 +89,8 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $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(); diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 5743eebebe..9c57bdef4a 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -316,7 +316,7 @@ EOF { $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'); diff --git a/src/Symfony/Component/Form/AbstractRendererEngine.php b/src/Symfony/Component/Form/AbstractRendererEngine.php index 00bf85401c..8202cbf97b 100644 --- a/src/Symfony/Component/Form/AbstractRendererEngine.php +++ b/src/Symfony/Component/Form/AbstractRendererEngine.php @@ -67,8 +67,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface // 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]); } /** diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 9437dad1c1..8b5b919413 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -138,8 +138,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB 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; } diff --git a/src/Symfony/Component/Form/FormRenderer.php b/src/Symfony/Component/Form/FormRenderer.php index 09b010563f..2c6b1dd0be 100644 --- a/src/Symfony/Component/Form/FormRenderer.php +++ b/src/Symfony/Component/Form/FormRenderer.php @@ -279,8 +279,7 @@ class FormRenderer implements FormRendererInterface // 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) { diff --git a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php index 3060472975..090eb8bc4f 100644 --- a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php +++ b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php @@ -54,7 +54,7 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase */ public function setMaxRunningTime($maxRunningTime) { - if (is_integer($maxRunningTime) && $maxRunningTime >= 0) { + if (is_int($maxRunningTime) && $maxRunningTime >= 0) { $this->maxRunningTime = $maxRunningTime; } else { throw new \InvalidArgumentException(); diff --git a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php index 33d340f27a..2e9cb7b6bb 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -107,8 +107,7 @@ class RouterListener implements EventSubscriberInterface } $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()); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 59401662d3..3420bf2986 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -32,7 +32,7 @@ class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase $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()); } diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index 079da283f2..5d7fdac6fd 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -264,8 +264,7 @@ class PropertyPathBuilder // 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; diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index b53dc751ac..5074614bd3 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -173,7 +173,8 @@ class AclProvider implements AclProviderInterface } // Is it time to load the current batch? - if ((self::MAX_BATCH_SIZE === count($currentBatch) || ($i + 1) === $c) && count($currentBatch) > 0) { + $currentBatchesCount = count($currentBatch); + if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) { try { $loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup); } catch (AclNotFoundException $aclNotFoundexception) { @@ -557,10 +558,11 @@ QUERY; // attach ACL to the result set; even though we do not enforce that every // object identity has only one instance, we must make sure to maintain // referential equality with the oids passed to findAcls() - if (!isset($oidCache[$objectIdentifier.$classType])) { - $oidCache[$objectIdentifier.$classType] = $acl->getObjectIdentity(); + $oidCacheKey = $objectIdentifier.$classType; + if (!isset($oidCache[$oidCacheKey])) { + $oidCache[$oidCacheKey] = $acl->getObjectIdentity(); } - $result->attach($oidCache[$objectIdentifier.$classType], $acl); + $result->attach($oidCache[$oidCacheKey], $acl); // so, this hasn't been hydrated yet } else { // create object identity if we haven't done so yet @@ -668,7 +670,7 @@ QUERY; // let's see if we have already hydrated this if (isset($acls[$parentId])) { $aclParentAclProperty->setValue($acl, $acls[$parentId]); - $processed += 1; + ++$processed; continue; } diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php index c25a697fb4..1a46d2712c 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php @@ -122,7 +122,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase if ($id === 1000 || ($id < 1500 && rand(0, 1))) { $this->insertClassStmt->execute(array($id, $this->getRandomString(rand(20, 100), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\_'))); - $id += 1; + ++$id; return $id-1; } else { @@ -148,7 +148,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase } $this->generateAces($classId, $id); - $id += 1; + ++$id; return $id-1; } @@ -163,7 +163,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase $this->getRandomString(rand(5, 30)), rand(0, 1), )); - $id += 1; + ++$id; return $id-1; } else { @@ -215,7 +215,7 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase rand(0, 1), )); - $id += 1; + ++$id; } } diff --git a/src/Symfony/Component/Security/Tests/Core/Util/SecureRandomTest.php b/src/Symfony/Component/Security/Tests/Core/Util/SecureRandomTest.php index bd9fec5b61..a8cc660614 100644 --- a/src/Symfony/Component/Security/Tests/Core/Util/SecureRandomTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Util/SecureRandomTest.php @@ -41,7 +41,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase for ($j = 1; $j <= 5000; $j++) { $k = 4 * $j - 1; - $c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]] += 1; + ++$c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]]; } $f = 0; @@ -73,14 +73,14 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase $run = 6; } - $runs[$run] += 1; + ++$runs[$run]; }; $currentRun = 0; $lastBit = null; for ($i = 0; $i < 20000; $i++) { if ($lastBit === $b[$i]) { - $currentRun += 1; + ++$currentRun; } else { if ($currentRun > 0) { $addRun($currentRun); @@ -115,7 +115,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase $lastBit = null; for ($i = 0; $i < 20000; $i++) { if ($lastBit === $b[$i]) { - $currentRun += 1; + ++$currentRun; } else { if ($currentRun > $longestRun) { $longestRun = $currentRun; diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/ExceptionListenerTest.php index b1c7622414..12f18a6832 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/ExceptionListenerTest.php @@ -177,9 +177,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createExceptionListener(SecurityContextInterface $context = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) { return new ExceptionListener( - $context ? $context : $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'), - $trustResolver ? $trustResolver : $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), - $httpUtils ? $httpUtils : $this->getMock('Symfony\Component\Security\Http\HttpUtils'), + $context ?: $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'), + $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), + $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'), 'key', $authenticationEntryPoint, $errorPage, diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 0950a46d2e..79723f3830 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -137,7 +137,7 @@ class XliffFileLoader implements LoaderInterface 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 ); diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 3aa248b2f4..ab7c72e405 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -273,7 +273,7 @@ class Inline { $output = array(); $len = strlen($sequence); - $i += 1; + ++$i; // [foo, bar, ...] while ($i < $len) { @@ -332,7 +332,7 @@ class Inline { $output = array(); $len = strlen($mapping); - $i += 1; + ++$i; // {foo: bar, bar:foo, ...} while ($i < $len) { From e64b75f7d3b313a07e27315930ff64853fb3effc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 7 Mar 2015 08:38:33 +0100 Subject: [PATCH 13/14] replaced the last remaining is_integer() call --- .../FrameworkBundle/DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index d4ef0f968b..2de60489a8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -233,7 +233,7 @@ class Configuration implements ConfigurationInterface ); 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 { From 1530c355d5c51cc012f471ee1723b3532f54248b Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 6 Mar 2015 21:37:14 +0100 Subject: [PATCH 14/14] Php Inspections (EA Extended): squash all PR-13813 commits --- .../Console/Tests/Helper/QuestionHelperTest.php | 2 +- .../Component/OptionsResolver/OptionsResolver.php | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index e5499fc086..0ab0849371 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -208,7 +208,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase protected function getInputStream($input) { $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); + fwrite($stream, $input); rewind($stream); return $stream; diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index da6e43b678..4965e3156b 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -670,14 +670,8 @@ class OptionsResolver implements Options, OptionsResolverInterface } 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;