From cfdb925c472f9b03809a22a05e92b734dc69d8a4 Mon Sep 17 00:00:00 2001 From: Szijarto Tamas Date: Thu, 4 Dec 2014 22:06:34 +0100 Subject: [PATCH 1/3] [ClassLoader] Fix undefined index in ClassCollectionLoader --- .../ClassLoader/ClassCollectionLoader.php | 15 +++++---- .../Tests/ClassCollectionLoaderTest.php | 32 +++++++++++++++++++ .../Tests/Fixtures/ClassesWithParents/F.php | 8 +++++ .../Tests/Fixtures/ClassesWithParents/G.php | 8 +++++ 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/F.php create mode 100644 src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/G.php diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index d3092e1582..e576e5c62b 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -353,14 +353,17 @@ class ClassCollectionLoader $unresolved = new \ArrayObject(); } $nodeName = $node->getName(); - $unresolved[$nodeName] = $node; - foreach ($tree[$nodeName] as $dependency) { - if (!$resolved->offsetExists($dependency->getName())) { - self::resolveDependencies($tree, $dependency, $resolved, $unresolved); + + if (isset($tree[$nodeName])) { + $unresolved[$nodeName] = $node; + foreach ($tree[$nodeName] as $dependency) { + if (!$resolved->offsetExists($dependency->getName())) { + self::resolveDependencies($tree, $dependency, $resolved, $unresolved); + } } + $resolved[$nodeName] = $node; + unset($unresolved[$nodeName]); } - $resolved[$nodeName] = $node; - unset($unresolved[$nodeName]); return $resolved; } diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 696943ed93..e821e45063 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -146,6 +146,38 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase ); } + public function testFixClassWithTraitsOrdering() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('Requires PHP > 5.4'); + + return; + } + + require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/F.php'; + require_once __DIR__.'/Fixtures/ClassesWithParents/G.php'; + + $classes = array( + 'ClassesWithParents\\F', + 'ClassesWithParents\\G', + ); + + $expected = array( + 'ClassesWithParents\\CTrait', + 'ClassesWithParents\\F', + 'ClassesWithParents\\G', + ); + + $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); + $m = $r->getMethod('getOrderedClasses'); + $m->setAccessible(true); + + $ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes); + + $this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered)); + } + /** * @dataProvider getFixNamespaceDeclarationsData */ diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/F.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/F.php new file mode 100644 index 0000000000..a0a5172d71 --- /dev/null +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/F.php @@ -0,0 +1,8 @@ + Date: Sun, 7 Dec 2014 18:02:39 +0100 Subject: [PATCH 2/3] Minor phpcs fixes --- src/Symfony/Component/EventDispatcher/Event.php | 8 ++++---- .../Component/EventDispatcher/EventDispatcher.php | 14 +++++++------- .../EventDispatcher/EventSubscriberInterface.php | 8 ++++---- .../HttpFoundation/BinaryFileResponse.php | 2 +- .../Intl/Data/Generator/CurrencyDataGenerator.php | 2 +- .../Component/PropertyAccess/StringUtil.php | 2 +- .../Security/Acl/Dbal/MutableAclProvider.php | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/Event.php b/src/Symfony/Component/EventDispatcher/Event.php index 996eda4fd2..204d0ab2aa 100644 --- a/src/Symfony/Component/EventDispatcher/Event.php +++ b/src/Symfony/Component/EventDispatcher/Event.php @@ -20,10 +20,10 @@ namespace Symfony\Component\EventDispatcher; * You can call the method stopPropagation() to abort the execution of * further listeners in your event listener. * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek * * @api */ diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index e189a57e42..3700125f38 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -17,13 +17,13 @@ namespace Symfony\Component\EventDispatcher; * Listeners are registered on the manager and events are dispatched through the * manager. * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + * @author Fabien Potencier + * @author Jordi Boggiano + * @author Jordan Alliot * * @api */ diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index 080f892fdf..ff7e305cd5 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -17,10 +17,10 @@ namespace Symfony\Component\EventDispatcher; * {@link getSubscribedEvents} and registers the subscriber as a listener for all * returned events. * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek * * @api */ diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 58b91a0bac..1e151be793 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -191,7 +191,7 @@ class BinaryFileResponse extends Response $path = $this->file->getRealPath(); if (strtolower($type) == 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. - foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { + foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); if (2 == count($mapping)) { diff --git a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php index a00104913e..fea260558f 100644 --- a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php @@ -164,7 +164,7 @@ class CurrencyDataGenerator extends AbstractDataGenerator } /** - * @param $rootBundle + * @param ArrayAccessibleResourceBundle $rootBundle * * @return array */ diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index c8176db964..91adedb2bc 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -186,7 +186,7 @@ class StringUtil return $singulars; } - return $newBase.($firstUpper ? ucFirst($newSuffix) : $newSuffix); + return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix); } // Suffix is longer than word diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index e2ec89bc55..34f1ea68e1 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -361,7 +361,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf protected function getDeleteAccessControlEntriesSql($oidPK) { return sprintf( - 'DELETE FROM %s WHERE object_identity_id = %d', + 'DELETE FROM %s WHERE object_identity_id = %d', $this->options['entry_table_name'], $oidPK ); From f5886107226b9f7eaafc1b0e3e636f11fdc8e379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sun, 7 Dec 2014 19:24:30 +0100 Subject: [PATCH 3/3] fix phpdoc's alignment --- .../Bridge/Propel1/Form/Type/TranslationType.php | 4 ++-- .../Form/Extension/Core/ChoiceList/ChoiceList.php | 14 +++++++------- .../Provider/AuthenticationProviderInterface.php | 14 +++++++------- .../Component/Serializer/Encoder/XmlEncoder.php | 2 +- .../Tests/Normalizer/TestDenormalizer.php | 8 ++++---- .../Serializer/Tests/Normalizer/TestNormalizer.php | 8 ++++---- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php b/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php index 8315b4f347..6881476533 100644 --- a/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php +++ b/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php @@ -24,8 +24,8 @@ use Symfony\Bridge\Propel1\Form\EventListener\TranslationFormListener; class TranslationType extends AbstractType { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->addEventSubscriber( diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php index 02b59f6822..358cc4cd17 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php @@ -495,14 +495,14 @@ class ChoiceList implements ChoiceListInterface } /** - * Fixes the data type of the given choices to avoid comparison problems. + * Fixes the data type of the given choices to avoid comparison problems. * - * @param array $choices The choices. - * - * @return array The fixed choices. - * - * @see fixChoice - */ + * @param array $choices The choices. + * + * @return array The fixed choices. + * + * @see fixChoice + */ protected function fixChoices(array $choices) { return $choices; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/AuthenticationProviderInterface.php b/src/Symfony/Component/Security/Core/Authentication/Provider/AuthenticationProviderInterface.php index 401df6da64..8007234175 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/AuthenticationProviderInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/AuthenticationProviderInterface.php @@ -24,12 +24,12 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac */ interface AuthenticationProviderInterface extends AuthenticationManagerInterface { - /** - * Checks whether this provider supports the given token. - * - * @param TokenInterface $token A TokenInterface instance - * - * @return bool true if the implementation supports the Token, false otherwise - */ + /** + * Checks whether this provider supports the given token. + * + * @param TokenInterface $token A TokenInterface instance + * + * @return bool true if the implementation supports the Token, false otherwise + */ public function supports(TokenInterface $token); } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 43cbfd591e..25f07f40e9 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -114,7 +114,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec return $this->parseXml($xml); } - /** + /** * Checks whether the serializer can encode to given format * * @param string $format format name diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php index e881ad1397..7525d5c928 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php @@ -21,15 +21,15 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; class TestDenormalizer implements DenormalizerInterface { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function denormalize($data, $class, $format = null, array $context = array()) { } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function supportsDenormalization($data, $type, $format = null) { return true; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php index 4c000b3eb4..4b29e8fa5d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php @@ -21,15 +21,15 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class TestNormalizer implements NormalizerInterface { /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function normalize($object, $format = null, array $context = array()) { } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function supportsNormalization($data, $format = null) { return true;