From 3e90138214c54f8cbf7914706562771b40017cc0 Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Thu, 7 Sep 2017 11:04:22 +0200 Subject: [PATCH] [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction --- .php_cs.dist | 3 ++ .../AbstractDoctrineExtension.php | 6 +-- .../Form/ChoiceList/ORMQueryBuilderLoader.php | 2 +- .../MergeDoctrineCollectionListener.php | 2 +- .../Doctrine/Form/Type/DoctrineType.php | 2 +- .../Bridge/Twig/Command/DebugCommand.php | 20 +++++----- .../Twig/Extension/StopwatchExtension.php | 2 +- ...xtensionBootstrap3HorizontalLayoutTest.php | 2 +- .../FormExtensionBootstrap3LayoutTest.php | 2 +- .../Extension/FormExtensionDivLayoutTest.php | 2 +- .../FormExtensionTableLayoutTest.php | 2 +- .../Command/TranslationUpdateCommand.php | 10 ++--- .../Controller/ControllerNameParser.php | 2 +- .../Controller/RedirectController.php | 2 +- .../Controller/TemplateController.php | 2 +- .../views/FormTable/button_row.html.php | 2 +- .../views/FormTable/form_row.html.php | 6 +-- .../FormTable/form_widget_compound.html.php | 10 ++--- .../views/FormTable/hidden_row.html.php | 2 +- .../FrameworkBundle/Test/KernelTestCase.php | 2 +- .../Fixtures/StubTemplateNameParser.php | 4 +- .../Resources/Child/form_label.html.php | 2 +- .../Parent/form_widget_simple.html.php | 4 +- .../Templating/TemplateFilenameParserTest.php | 2 +- .../SecurityBundle/Command/SetAclCommand.php | 2 +- .../DependencyInjection/MainConfiguration.php | 2 +- .../Security/Factory/RememberMeFactory.php | 2 +- .../CompleteConfigurationTest.php | 2 +- src/Symfony/Component/BrowserKit/History.php | 2 +- .../ClassLoader/ClassCollectionLoader.php | 2 +- .../ClassLoader/ClassMapGenerator.php | 2 +- .../Definition/Dumper/YamlReferenceDumper.php | 2 +- src/Symfony/Component/Config/FileLocator.php | 6 +-- .../Component/Config/Util/XmlUtils.php | 2 +- src/Symfony/Component/Console/Application.php | 8 ++-- .../Console/Descriptor/XmlDescriptor.php | 4 +- .../Component/Console/Helper/DialogHelper.php | 6 +-- .../Console/Helper/ProgressHelper.php | 2 +- .../Console/Helper/QuestionHelper.php | 6 +-- .../Component/Console/Input/ArgvInput.php | 2 +- .../Console/Logger/ConsoleLogger.php | 2 +- .../Tests/Helper/LegacyDialogHelperTest.php | 2 +- .../Tests/Helper/LegacyProgressHelperTest.php | 2 +- .../Tests/Helper/QuestionHelperTest.php | 2 +- .../Parser/Shortcut/EmptyStringParser.php | 2 +- .../DependencyInjection/Container.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 2 +- .../DependencyInjection/Definition.php | 2 +- .../DependencyInjection/Dumper/PhpDumper.php | 6 +-- .../DependencyInjection/Dumper/XmlDumper.php | 4 +- .../Extension/Extension.php | 2 +- .../Loader/XmlFileLoader.php | 4 +- .../Loader/YamlFileLoader.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- .../DomCrawler/Tests/CrawlerTest.php | 2 +- .../ContainerAwareEventDispatcher.php | 2 +- .../Component/ExpressionLanguage/Parser.php | 6 +-- .../ExpressionLanguage/TokenStream.php | 2 +- .../Component/Filesystem/Filesystem.php | 4 +- .../Finder/Adapter/GnuFindAdapter.php | 2 +- .../Component/Finder/Expression/Regex.php | 4 +- .../Tests/Iterator/SortableIteratorTest.php | 6 +-- .../ChoiceToBooleanArrayTransformer.php | 2 +- .../DateTimeToLocalizedStringTransformer.php | 4 +- .../EventListener/CsrfValidationListener.php | 2 +- .../Component/Form/ResolvedFormType.php | 8 ++-- .../Form/Test/FormPerformanceTestCase.php | 2 +- .../Form/Tests/AbstractLayoutTest.php | 4 +- .../ViolationMapper/ViolationMapperTest.php | 4 +- .../Tests/Fixtures/AlternatingRowType.php | 2 +- .../Tests/Fixtures/FixedDataTransformer.php | 2 +- .../HttpFoundation/AcceptHeaderItem.php | 4 +- .../HttpFoundation/BinaryFileResponse.php | 6 +-- .../HttpFoundation/File/UploadedFile.php | 4 +- .../Component/HttpFoundation/IpUtils.php | 2 +- .../Component/HttpFoundation/Request.php | 28 ++++++------- .../HttpFoundation/RequestMatcher.php | 2 +- .../Component/HttpFoundation/Response.php | 4 +- .../Component/HttpFoundation/ServerBag.php | 2 +- .../Attribute/NamespacedAttributeBag.php | 2 +- .../Handler/MemcachedSessionHandler.php | 2 +- .../Tests/File/MimeType/MimeTypeTest.php | 2 +- .../HttpFoundation/Tests/RequestTest.php | 2 +- .../Component/HttpKernel/HttpCache/Store.php | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- .../Profiler/BaseMemcacheProfilerStorage.php | 6 +-- .../Profiler/RedisProfilerStorage.php | 8 ++-- .../Data/Bundle/Compiler/GenrbCompiler.php | 2 +- .../DateFormat/TimeZoneTransformer.php | 4 +- ...odArgumentValueNotImplementedException.php | 2 +- .../Intl/NumberFormatter/NumberFormatter.php | 18 ++++----- .../AbstractCurrencyDataProviderTest.php | 4 +- .../AbstractNumberFormatterTest.php | 6 +-- .../Component/Intl/Util/SvnRepository.php | 6 +-- .../Exception/ProcessTimedOutException.php | 4 +- src/Symfony/Component/Process/Process.php | 8 ++-- .../Component/Process/Tests/ProcessTest.php | 6 +-- .../Exception/UnexpectedTypeException.php | 2 +- .../Matcher/Dumper/PhpMatcherDumper.php | 6 +-- .../Tests/Fixtures/dumper/url_matcher1.php | 36 ++++++++--------- .../Tests/Fixtures/dumper/url_matcher2.php | 40 +++++++++---------- .../Tests/Fixtures/dumper/url_matcher3.php | 4 +- .../Security/Acl/Dbal/MutableAclProvider.php | 8 ++-- .../Tests/Dbal/AclProviderBenchmarkTest.php | 8 ++-- .../Authorization/AccessDecisionManager.php | 2 +- .../Core/User/InMemoryUserProvider.php | 2 +- .../Authentication/AuthenticationUtils.php | 2 +- .../Component/Security/Http/HttpUtils.php | 2 +- .../RememberMe/AbstractRememberMeServices.php | 2 +- ...PersistentTokenBasedRememberMeServices.php | 4 +- .../TokenBasedRememberMeServices.php | 2 +- .../Tests/Firewall/ContextListenerTest.php | 2 +- .../Tests/RememberMe/ResponseListenerTest.php | 2 +- .../Serializer/Encoder/XmlEncoder.php | 8 ++-- .../Normalizer/AbstractNormalizer.php | 2 +- .../Normalizer/GetSetMethodNormalizer.php | 2 +- .../Normalizer/ObjectNormalizer.php | 6 +-- .../Normalizer/PropertyNormalizer.php | 2 +- .../Serializer/Tests/Fixtures/ScalarDummy.php | 4 +- .../Templating/Loader/FilesystemLoader.php | 6 +-- .../Translation/Loader/MoFileLoader.php | 8 ++-- .../Translation/Loader/PoFileLoader.php | 14 +++---- .../Translation/Loader/QtFileLoader.php | 2 +- .../Translation/PluralizationRules.php | 28 ++++++------- .../Component/Translation/Translator.php | 2 +- .../Component/Validator/Constraint.php | 2 +- .../Validator/Constraints/ChoiceValidator.php | 4 +- .../Validator/Constraints/Collection.php | 2 +- .../Validator/Constraints/ImageValidator.php | 2 +- .../Validator/Constraints/TypeValidator.php | 2 +- .../Validator/Constraints/UuidValidator.php | 2 +- .../Mapping/Loader/AbstractLoader.php | 4 +- .../Component/VarDumper/Caster/SplCaster.php | 2 +- .../VarDumper/Tests/VarClonerTest.php | 2 +- src/Symfony/Component/Yaml/Inline.php | 2 +- src/Symfony/Component/Yaml/Parser.php | 10 ++--- src/Symfony/Component/Yaml/Yaml.php | 2 +- 137 files changed, 313 insertions(+), 310 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index d84a0624bd..624618ab80 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -9,11 +9,14 @@ return PhpCsFixer\Config::create() '@Symfony' => true, '@Symfony:risky' => true, 'array_syntax' => array('syntax' => 'long'), + 'no_break_comment' => false, + 'protected_to_private' => false, )) ->setRiskyAllowed(true) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__.'/src') + ->append(array(__FILE__)) ->exclude(array( // directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code 'Symfony/Component/DependencyInjection/Tests/Fixtures', diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index b3fecad9df..c0623572ec 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -199,13 +199,13 @@ abstract class AbstractDoctrineExtension extends Extension if ($container->hasDefinition($mappingService)) { $mappingDriverDef = $container->getDefinition($mappingService); $args = $mappingDriverDef->getArguments(); - if ($driverType == 'annotation') { + if ('annotation' == $driverType) { $args[1] = array_merge(array_values($driverPaths), $args[1]); } else { $args[0] = array_merge(array_values($driverPaths), $args[0]); } $mappingDriverDef->setArguments($args); - } elseif ($driverType == 'annotation') { + } elseif ('annotation' == $driverType) { $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( new Reference($this->getObjectManagerElementName('metadata.annotation_reader')), array_values($driverPaths), @@ -333,7 +333,7 @@ abstract class AbstractDoctrineExtension extends Extension $memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%'; $memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%'; $memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%'; - $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; + $memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && 0 === $cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%'; $cacheDef = new Definition($memcacheClass); $memcacheInstance = new Definition($memcacheInstanceClass); $memcacheInstance->addMethodCall('connect', array( diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php index 297e2ddfe7..8d73c32d9e 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php @@ -111,7 +111,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface // Like above, but we just filter out empty strings. $values = array_values(array_filter($values, function ($v) { - return (string) $v !== ''; + return '' !== (string) $v; })); } else { $parameterType = Connection::PARAM_STR_ARRAY; diff --git a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php index 4edf1043c5..bb4cfa5087 100644 --- a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php +++ b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php @@ -41,7 +41,7 @@ class MergeDoctrineCollectionListener implements EventSubscriberInterface // If all items were removed, call clear which has a higher // performance on persistent collections - if ($collection instanceof Collection && count($data) === 0) { + if ($collection instanceof Collection && 0 === count($data)) { $collection->clear(); } } diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 2dd139750c..17036a5913 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -176,7 +176,7 @@ abstract class DoctrineType extends AbstractType $entityLoader ); - if ($hash !== null) { + if (null !== $hash) { $choiceLoaders[$hash] = $doctrineChoiceLoader; } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index d62aef0f2c..f86013b0e2 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -88,7 +88,7 @@ EOF $types = array('functions', 'filters', 'tests', 'globals'); - if ($input->getOption('format') === 'json') { + if ('json' === $input->getOption('format')) { $data = array(); foreach ($types as $type) { foreach ($twig->{'get'.ucfirst($type)}() as $name => $entity) { @@ -129,13 +129,13 @@ EOF private function getMetadata($type, $entity) { - if ($type === 'globals') { + if ('globals' === $type) { return $entity; } - if ($type === 'tests') { + if ('tests' === $type) { return; } - if ($type === 'functions' || $type === 'filters') { + if ('functions' === $type || 'filters' === $type) { $cb = $entity->getCallable(); if (null === $cb) { return; @@ -165,7 +165,7 @@ EOF array_shift($args); } - if ($type === 'filters') { + if ('filters' === $type) { // remove the value the filter is applied on array_shift($args); } @@ -185,20 +185,20 @@ EOF private function getPrettyMetadata($type, $entity) { - if ($type === 'tests') { + if ('tests' === $type) { return ''; } try { $meta = $this->getMetadata($type, $entity); - if ($meta === null) { + if (null === $meta) { return '(unknown?)'; } } catch (\UnexpectedValueException $e) { return ' '.$e->getMessage().''; } - if ($type === 'globals') { + if ('globals' === $type) { if (is_object($meta)) { return ' = object('.get_class($meta).')'; } @@ -206,11 +206,11 @@ EOF return ' = '.substr(@json_encode($meta), 0, 50); } - if ($type === 'functions') { + if ('functions' === $type) { return '('.implode(', ', $meta).')'; } - if ($type === 'filters') { + if ('filters' === $type) { return $meta ? '('.implode(', ', $meta).')' : ''; } } diff --git a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php index 635188b738..cb91ff428b 100644 --- a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php @@ -48,7 +48,7 @@ class StopwatchExtension extends AbstractExtension * Some stuff which will be recorded on the timeline * {% endstopwatch %} */ - new StopwatchTokenParser($this->stopwatch !== null && $this->enabled), + new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled), ); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index 9d84946177..3fb3a19c27 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -75,7 +75,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori protected function renderLabel(FormView $view, $label = null, array $vars = array()) { - if ($label !== null) { + if (null !== $label) { $vars += array('label' => $label); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 10161cbd4e..85ef2ceed5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -75,7 +75,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest protected function renderLabel(FormView $view, $label = null, array $vars = array()) { - if ($label !== null) { + if (null !== $label) { $vars += array('label' => $label); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 2d7339b369..e2fbb48ce0 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -158,7 +158,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest protected function renderLabel(FormView $view, $label = null, array $vars = array()) { - if ($label !== null) { + if (null !== $label) { $vars += array('label' => $label); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 1d526d5138..1b5f4022da 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -76,7 +76,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest protected function renderLabel(FormView $view, $label = null, array $vars = array()) { - if ($label !== null) { + if (null !== $label) { $vars += array('label' => $label); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index f310613d10..3f1605da58 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -72,7 +72,7 @@ EOF $output = new SymfonyStyle($input, $output); // check presence of force or dump-message - if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) { + if (true !== $input->getOption('force') && true !== $input->getOption('dump-messages')) { $output->error('You must choose one of --force or --dump-messages'); return 1; @@ -151,7 +151,7 @@ EOF } // show compiled list of messages - if ($input->getOption('dump-messages') === true) { + if (true === $input->getOption('dump-messages')) { $output->newLine(); foreach ($operation->getDomains() as $domain) { $output->section(sprintf('Displaying messages for domain %s:', $domain)); @@ -168,17 +168,17 @@ EOF )); } - if ($input->getOption('output-format') == 'xlf') { + if ('xlf' == $input->getOption('output-format')) { $output->writeln('Xliff output version is 1.2'); } } - if ($input->getOption('no-backup') === true) { + if (true === $input->getOption('no-backup')) { $writer->disableBackup(); } // save the files - if ($input->getOption('force') === true) { + if (true === $input->getOption('force')) { $output->text('Writing files'); $bundleTransPath = false; diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php index 989dc8cd23..5cfb30f371 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php @@ -141,7 +141,7 @@ class ControllerNameParser } $lev = levenshtein($nonExistentBundleName, $bundleName); - if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) { + if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) { $alternative = $bundleName; $shortest = $lev; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index b8f4e6415a..9d060ed43a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -100,7 +100,7 @@ class RedirectController extends ContainerAware $qs = $request->getQueryString(); if ($qs) { - if (strpos($path, '?') === false) { + if (false === strpos($path, '?')) { $qs = '?'.$qs; } else { $qs = '&'.$qs; diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 16d15f9023..f75ab2d795 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -46,7 +46,7 @@ class TemplateController extends ContainerAware if ($private) { $response->setPrivate(); - } elseif ($private === false || (null === $private && ($maxAge || $sharedAge))) { + } elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) { $response->setPublic(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php index ef4d22b975..67d0137e20 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php @@ -1,6 +1,6 @@ - widget($form) ?> + widget($form); ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_row.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_row.html.php index 7e1f2f5d28..e2f03ff2b7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_row.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_row.html.php @@ -1,9 +1,9 @@ - label($form) ?> + label($form); ?> - errors($form) ?> - widget($form) ?> + errors($form); ?> + widget($form); ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php index 20b9668aa4..adc8973388 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php @@ -1,11 +1,11 @@ -block($form, 'widget_container_attributes') ?>> +
block($form, 'widget_container_attributes'); ?>> parent && $errors): ?> - - block($form, 'form_rows') ?> - rest($form) ?> + + block($form, 'form_rows'); ?> + rest($form); ?>
- errors($form) ?> + errors($form); ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/hidden_row.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/hidden_row.html.php index 491ece3602..116b300bd5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/hidden_row.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/hidden_row.html.php @@ -1,5 +1,5 @@ - widget($form) ?> + widget($form); ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index 5dadca83f2..6b979c4f36 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -77,7 +77,7 @@ abstract class KernelTestCase extends TestCase $dir = null; $reversedArgs = array_reverse($_SERVER['argv']); foreach ($reversedArgs as $argIndex => $testArg) { - if (preg_match('/^-[^ \-]*c$/', $testArg) || $testArg === '--configuration') { + if (preg_match('/^-[^ \-]*c$/', $testArg) || '--configuration' === $testArg) { $dir = realpath($reversedArgs[$argIndex - 1]); break; } elseif (0 === strpos($testArg, '--configuration=')) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php index 3a66454947..9835bc2a22 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php @@ -30,9 +30,9 @@ class StubTemplateNameParser implements TemplateNameParserInterface { list($bundle, $controller, $template) = explode(':', $name, 3); - if ($template[0] == '_') { + if ('_' == $template[0]) { $path = $this->rootTheme.'/Custom/'.$template; - } elseif ($bundle === 'TestBundle') { + } elseif ('TestBundle' === $bundle) { $path = $this->rootTheme.'/'.$controller.'/'.$template; } else { $path = $this->root.'/'.$controller.'/'.$template; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php index 0c1af407cb..aebb53d3e7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php @@ -1 +1 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php index 3c6c158a53..1b53a7213f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php @@ -1,2 +1,2 @@ - -block($form, 'widget_attributes') ?> value="" rel="theme" /> + +block($form, 'widget_attributes'); ?> value="" rel="theme" /> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php index 77dd2699ab..8cdc26ecfe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php @@ -36,7 +36,7 @@ class TemplateFilenameParserTest extends TestCase { $template = $this->parser->parse($file); - if ($ref === false) { + if (false === $ref) { $this->assertFalse($template); } else { $this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); diff --git a/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php index ba34782346..7d0f3a261b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php @@ -120,7 +120,7 @@ EOF foreach ($userOption as $user) { $data = explode(':', $user, 2); - if (count($data) === 1) { + if (1 === count($data)) { throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".'); } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index df6380224c..382c4ade6a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -394,7 +394,7 @@ class MainConfiguration implements ConfigurationInterface ->thenInvalid('You cannot set multiple provider types for the same provider') ->end() ->validate() - ->ifTrue(function ($v) { return count($v) === 0; }) + ->ifTrue(function ($v) { return 0 === count($v); }) ->thenInvalid('You must set a provider definition for the provider.') ->end() ; diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index c6688affb4..a77d872e26 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -93,7 +93,7 @@ class RememberMeFactory implements SecurityFactoryInterface $userProviders[] = new Reference('security.user.provider.concrete.'.$providerName); } } - if (count($userProviders) === 0) { + if (0 === count($userProviders)) { throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.'); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index d273fb0594..6da50316a4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -133,7 +133,7 @@ abstract class CompleteConfigurationTest extends TestCase $rules = array(); foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) { - if ($call[0] == 'add') { + if ('add' == $call[0]) { $rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]); } } diff --git a/src/Symfony/Component/BrowserKit/History.php b/src/Symfony/Component/BrowserKit/History.php index 8e38fe5ca8..13af2b4f37 100644 --- a/src/Symfony/Component/BrowserKit/History.php +++ b/src/Symfony/Component/BrowserKit/History.php @@ -49,7 +49,7 @@ class History */ public function isEmpty() { - return count($this->stack) == 0; + return 0 == count($this->stack); } /** diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index cd3c433ed2..3f2a8ab1c9 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -215,7 +215,7 @@ REGEX; do { $token = $tokens[++$i]; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; - } while ($token[0] !== T_END_HEREDOC); + } while (T_END_HEREDOC !== $token[0]); $output .= "\n"; $rawChunk = ''; } elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) { diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index a35c90ca10..ab9762cd04 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -66,7 +66,7 @@ class ClassMapGenerator $path = $file->getRealPath() ?: $file->getPathname(); - if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') { + if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) { continue; } diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index 12ababe394..2b103d9533 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -117,7 +117,7 @@ class YamlReferenceDumper $comments[] = 'Example: '.$example; } - $default = (string) $default != '' ? ' '.$default : ''; + $default = '' != (string) $default ? ' '.$default : ''; $comments = count($comments) ? '# '.implode(', ', $comments) : ''; $text = rtrim(sprintf('%-21s%s %s', $node->getName().':', $default, $comments), ' '); diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 4816724c81..94e7e23b43 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -81,10 +81,10 @@ class FileLocator implements FileLocatorInterface */ private function isAbsolutePath($file) { - if ($file[0] === '/' || $file[0] === '\\' + if ('/' === $file[0] || '\\' === $file[0] || (strlen($file) > 3 && ctype_alpha($file[0]) - && $file[1] === ':' - && ($file[2] === '\\' || $file[2] === '/') + && ':' === $file[1] + && ('\\' === $file[2] || '/' === $file[2]) ) || null !== parse_url($file, PHP_URL_SCHEME) ) { diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 0f16fc080b..9c7ac126ef 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -68,7 +68,7 @@ class XmlUtils libxml_disable_entity_loader($disableEntities); foreach ($dom->childNodes as $child) { - if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { + if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new \InvalidArgumentException('Document types are not allowed.'); } } diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 873b09e808..21b2e8ea5c 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -709,8 +709,8 @@ class Application $trace = $e->getTrace(); array_unshift($trace, array( 'function' => '', - 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', - 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', + 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a', + 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a', 'args' => array(), )); @@ -838,9 +838,9 @@ class Application $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); $input->setInteractive(false); } else { - if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { + if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) { $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); - } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { + } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) { $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php index b5676beb37..0f1fb472c2 100644 --- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -94,9 +94,9 @@ class XmlDescriptor extends Descriptor $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($rootXml = $dom->createElement('symfony')); - if ($application->getName() !== 'UNKNOWN') { + if ('UNKNOWN' !== $application->getName()) { $rootXml->setAttribute('name', $application->getName()); - if ($application->getVersion() !== 'UNKNOWN') { + if ('UNKNOWN' !== $application->getVersion()) { $rootXml->setAttribute('version', $application->getVersion()); } } diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 7f5a5df2ce..342fe02638 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -159,7 +159,7 @@ class DialogHelper extends InputAwareHelper $output->write("\033[1D"); } - if ($i === 0) { + if (0 === $i) { $ofs = -1; $matches = $autocomplete; $numMatches = count($matches); @@ -324,7 +324,7 @@ class DialogHelper extends InputAwareHelper if (false !== $shell = $this->getShell()) { $output->write($question); - $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; + $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword'; $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); $value = rtrim(shell_exec($command)); $output->writeln(''); @@ -462,7 +462,7 @@ class DialogHelper extends InputAwareHelper exec('stty 2>&1', $output, $exitcode); - return self::$stty = $exitcode === 0; + return self::$stty = 0 === $exitcode; } /** diff --git a/src/Symfony/Component/Console/Helper/ProgressHelper.php b/src/Symfony/Component/Console/Helper/ProgressHelper.php index 625fb81208..b95befe00f 100644 --- a/src/Symfony/Component/Console/Helper/ProgressHelper.php +++ b/src/Symfony/Component/Console/Helper/ProgressHelper.php @@ -423,7 +423,7 @@ class ProgressHelper extends Helper $text = ''; foreach ($this->timeFormats as $format) { if ($secs < $format[0]) { - if (count($format) == 2) { + if (2 == count($format)) { $text = $format[1]; break; } else { diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 676c3c0451..4cdecfd41a 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -235,7 +235,7 @@ class QuestionHelper extends Helper $output->write("\033[1D"); } - if ($i === 0) { + if (0 === $i) { $ofs = -1; $matches = $autocomplete; $numMatches = count($matches); @@ -365,7 +365,7 @@ class QuestionHelper extends Helper } if (false !== $shell = $this->getShell()) { - $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; + $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword'; $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); $value = rtrim(shell_exec($command)); $output->writeln(''); @@ -447,6 +447,6 @@ class QuestionHelper extends Helper exec('stty 2>&1', $output, $exitcode); - return self::$stty = $exitcode === 0; + return self::$stty = 0 === $exitcode; } } diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 119be49170..55df649ed7 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -328,7 +328,7 @@ class ArgvInput extends Input return $match[1].$self->escapeToken($match[2]); } - if ($token && $token[0] !== '-') { + if ($token && '-' !== $token[0]) { return $self->escapeToken($token); } diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index 987e96a658..4b237c17c6 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -82,7 +82,7 @@ class ConsoleLogger extends AbstractLogger } // Write to the error output if necessary and available - if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) { + if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) { $output = $this->output->getErrorOutput(); } else { $output = $this->output; diff --git a/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php index d50366d1bf..b7d1b5cf19 100644 --- a/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/LegacyDialogHelperTest.php @@ -253,6 +253,6 @@ class LegacyDialogHelperTest extends TestCase { exec('stty 2>&1', $output, $exitcode); - return $exitcode === 0; + return 0 === $exitcode; } } diff --git a/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php index 2e473c2eef..76d003e78d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php @@ -217,7 +217,7 @@ class LegacyProgressHelperTest extends TestCase { $expectedout = $expected; - if ($this->lastMessagesLength !== null) { + if (null !== $this->lastMessagesLength) { $expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); } diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 7d45025230..4fb462cc10 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -502,6 +502,6 @@ class QuestionHelperTest extends TestCase { exec('stty 2>&1', $output, $exitcode); - return $exitcode === 0; + return 0 === $exitcode; } } diff --git a/src/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php b/src/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php index 98a08fde06..a35450dcd0 100644 --- a/src/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php +++ b/src/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php @@ -35,7 +35,7 @@ class EmptyStringParser implements ParserInterface public function parse($source) { // Matches an empty string - if ($source == '') { + if ('' == $source) { return array(new SelectorNode(new ElementNode(null, '*'))); } diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 4019504a5a..0ba5d646c8 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -477,7 +477,7 @@ class Container implements IntrospectableContainerInterface $this->scopeChildren[$name] = array(); // normalize the child relations - while ($parentScope !== self::SCOPE_CONTAINER) { + while (self::SCOPE_CONTAINER !== $parentScope) { $this->scopeChildren[$parentScope][] = $name; $parentScope = $this->scopes[$parentScope]; } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index c1a2ee85c4..f9658fcf68 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1038,7 +1038,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface foreach ($value as $v) { $services = array_unique(array_merge($services, self::getServiceConditionals($v))); } - } elseif ($value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { + } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { $services[] = (string) $value; } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 780ad187cd..97b4913286 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -60,7 +60,7 @@ class Definition */ public function setFactory($factory) { - if (is_string($factory) && strpos($factory, '::') !== false) { + if (is_string($factory) && false !== strpos($factory, '::')) { $factory = explode('::', $factory, 2); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 4d576df1bd..e67c0869f4 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -533,7 +533,7 @@ class PhpDumper extends Dumper $class = $this->dumpValue($callable[0]); // If the class is a string we can optimize call_user_func away - if (strpos($class, "'") === 0) { + if (0 === strpos($class, "'")) { return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName); } @@ -753,7 +753,7 @@ EOF; $class = $this->dumpValue($callable[0]); // If the class is a string we can optimize call_user_func away - if (strpos($class, "'") === 0) { + if (0 === strpos($class, "'")) { return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : ''); } @@ -766,7 +766,7 @@ EOF; $class = $this->dumpValue($definition->getFactoryClass(false)); // If the class is a string we can optimize call_user_func away - if (strpos($class, "'") === 0) { + if (0 === strpos($class, "'")) { return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(false), $arguments ? implode(', ', $arguments) : ''); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index c793e9aed0..4a4ac00d08 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -282,9 +282,9 @@ class XmlDumper extends Dumper $element->setAttribute('type', 'service'); $element->setAttribute('id', (string) $value); $behaviour = $value->getInvalidBehavior(); - if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) { + if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behaviour) { $element->setAttribute('on-invalid', 'null'); - } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) { + } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behaviour) { $element->setAttribute('on-invalid', 'ignore'); } if (!$value->isStrict()) { diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index ced39f7281..5a6573b70e 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -65,7 +65,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn public function getAlias() { $className = get_class($this); - if (substr($className, -9) != 'Extension') { + if ('Extension' != substr($className, -9)) { throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); } $classBaseName = substr(strrchr($className, '\\'), 1, -9); diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index b3e4ef4d3e..bc57828f35 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -414,7 +414,7 @@ class XmlFileLoader extends FileLoader { $children = array(); foreach ($node->childNodes as $child) { - if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) { + if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) { $children[] = $child; } } @@ -533,7 +533,7 @@ EOF private function loadFromExtensions(\DOMDocument $xml) { foreach ($xml->documentElement->childNodes as $node) { - if (!$node instanceof \DOMElement || $node->namespaceURI === self::NS) { + if (!$node instanceof \DOMElement || self::NS === $node->namespaceURI) { continue; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index d93891e9c8..ba12fdc821 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -192,7 +192,7 @@ class YamlFileLoader extends FileLoader if (isset($service['factory'])) { if (is_string($service['factory'])) { - if (strpos($service['factory'], ':') !== false && strpos($service['factory'], '::') === false) { + if (false !== strpos($service['factory'], ':') && false === strpos($service['factory'], '::')) { $parts = explode(':', $service['factory']); $definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1])); } else { diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index f711c02bff..e54dd9b9f1 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -969,7 +969,7 @@ class Crawler extends \SplObjectStorage $nodes = array(); do { - if ($node !== $this->getNode(0) && $node->nodeType === 1) { + if ($node !== $this->getNode(0) && 1 === $node->nodeType) { $nodes[] = $node; } } while ($node = $node->$siblingDir); diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 495a4a9d14..335406ab24 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -295,7 +295,7 @@ EOF { $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $nodes = $crawler->reduce(function ($node, $i) { - return $i !== 1; + return 1 !== $i; }); $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/EventDispatcher/ContainerAwareEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php index dc2816f169..1c5e5b1d55 100644 --- a/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -175,7 +175,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher $key = $serviceId.'.'.$method; if (!isset($this->listeners[$eventName][$key])) { $this->addListener($eventName, array($listener, $method), $priority); - } elseif ($listener !== $this->listeners[$eventName][$key]) { + } elseif ($this->listeners[$eventName][$key] !== $listener) { parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); $this->addListener($eventName, array($listener, $method), $priority); } diff --git a/src/Symfony/Component/ExpressionLanguage/Parser.php b/src/Symfony/Component/ExpressionLanguage/Parser.php index d847dfa4b0..68d48a9af8 100644 --- a/src/Symfony/Component/ExpressionLanguage/Parser.php +++ b/src/Symfony/Component/ExpressionLanguage/Parser.php @@ -305,14 +305,14 @@ class Parser public function parsePostfixExpression($node) { $token = $this->stream->current; - while ($token->type == Token::PUNCTUATION_TYPE) { + while (Token::PUNCTUATION_TYPE == $token->type) { if ('.' === $token->value) { $this->stream->next(); $token = $this->stream->current; $this->stream->next(); if ( - $token->type !== Token::NAME_TYPE + Token::NAME_TYPE !== $token->type && // Operators like "not" and "matches" are valid method or property names, // @@ -325,7 +325,7 @@ class Parser // Other types, such as STRING_TYPE and NUMBER_TYPE, can't be parsed as property nor method names. // // As a result, if $token is NOT an operator OR $token->value is NOT a valid property or method name, an exception shall be thrown. - ($token->type !== Token::OPERATOR_TYPE || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value)) + (Token::OPERATOR_TYPE !== $token->type || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value)) ) { throw new SyntaxError('Expected name', $token->cursor, $this->stream->getExpression()); } diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index 3c22fc1d46..471d67a83a 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -84,7 +84,7 @@ class TokenStream */ public function isEOF() { - return $this->current->type === Token::EOF_TYPE; + return Token::EOF_TYPE === $this->current->type; } /** diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index b4f238f02b..02a90c9969 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -404,7 +404,7 @@ class Filesystem } // Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels) - if (count($startPathArr) === 1 && $startPathArr[0] === '') { + if (1 === count($startPathArr) && '' === $startPathArr[0]) { $depth = 0; } else { $depth = count($startPathArr) - $index; @@ -512,7 +512,7 @@ class Filesystem { return strspn($file, '/\\', 0, 1) || (strlen($file) > 3 && ctype_alpha($file[0]) - && substr($file, 1, 1) === ':' + && ':' === substr($file, 1, 1) && strspn($file, '/\\', 2, 1) ) || null !== parse_url($file, PHP_URL_SCHEME) diff --git a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php index 0fbf48ffa4..9f03953e5e 100644 --- a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php @@ -72,7 +72,7 @@ class GnuFindAdapter extends AbstractFindAdapter */ protected function canBeUsed() { - return $this->shell->getType() === Shell::TYPE_UNIX && parent::canBeUsed(); + return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed(); } /** diff --git a/src/Symfony/Component/Finder/Expression/Regex.php b/src/Symfony/Component/Finder/Expression/Regex.php index e3c404b6d7..531a3e2e78 100644 --- a/src/Symfony/Component/Finder/Expression/Regex.php +++ b/src/Symfony/Component/Finder/Expression/Regex.php @@ -67,8 +67,8 @@ class Regex implements ValueInterface if ( ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start)) - || ($start === '{' && $end === '}') - || ($start === '(' && $end === ')') + || ('{' === $start && '}' === $end) + || ('(' === $start && ')' === $end) ) { return new self(substr($m[1], 1, -1), $m[2], $end); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index 4750f250d7..444654a28f 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -58,9 +58,9 @@ class SortableIteratorTest extends RealIteratorTestCase $iterator = new SortableIterator($inner, $mode); - if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME - || $mode === SortableIterator::SORT_BY_CHANGED_TIME - || $mode === SortableIterator::SORT_BY_MODIFIED_TIME + if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode + || SortableIterator::SORT_BY_CHANGED_TIME === $mode + || SortableIterator::SORT_BY_MODIFIED_TIME === $mode ) { if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) { $this->markTestSkipped('Sorting by atime or ctime is not supported on Windows'); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php index 89f13b6cb2..640af6e1ff 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php @@ -109,7 +109,7 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface foreach ($values as $i => $selected) { if ($selected) { if (isset($choices[$i])) { - return $choices[$i] === '' ? null : $choices[$i]; + return '' === $choices[$i] ? null : $choices[$i]; } elseif ($this->placeholderPresent && 'placeholder' === $i) { return; } else { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index bc8f64dffa..ff2fa75949 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -90,7 +90,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer $value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp()); - if (intl_get_error_code() != 0) { + if (0 != intl_get_error_code()) { throw new TransformationFailedException(intl_get_error_message()); } @@ -123,7 +123,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer $timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value); - if (intl_get_error_code() != 0) { + if (0 != intl_get_error_code()) { throw new TransformationFailedException(intl_get_error_message()); } diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index 034f30612d..b232e4f3b7 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -101,7 +101,7 @@ class CsrfValidationListener implements EventSubscriberInterface public function preSubmit(FormEvent $event) { $form = $event->getForm(); - $postRequestSizeExceeded = $form->getConfig()->getMethod() === 'POST' && $this->serverParams->hasPostMaxSizeBeenExceeded(); + $postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded(); if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) { $data = $event->getData(); diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php index 54c96959c4..09d578ea35 100644 --- a/src/Symfony/Component/Form/ResolvedFormType.php +++ b/src/Symfony/Component/Form/ResolvedFormType.php @@ -202,10 +202,10 @@ class ResolvedFormType implements ResolvedFormTypeInterface if (method_exists($this->innerType, 'configureOptions')) { $reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions'); - $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; + $isOldOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName(); $reflector = new \ReflectionMethod($this->innerType, 'configureOptions'); - $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; + $isNewOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName(); if ($isOldOverwritten && !$isNewOverwritten) { @trigger_error(get_class($this->innerType).': The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); @@ -219,10 +219,10 @@ class ResolvedFormType implements ResolvedFormTypeInterface if (method_exists($extension, 'configureOptions')) { $reflector = new \ReflectionMethod($extension, 'setDefaultOptions'); - $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension'; + $isOldOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName(); $reflector = new \ReflectionMethod($extension, 'configureOptions'); - $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension'; + $isNewOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName(); if ($isOldOverwritten && !$isNewOverwritten) { @trigger_error(get_class($extension).': The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php index 75ddba6212..dfb4ffaa01 100644 --- a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php +++ b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php @@ -35,7 +35,7 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase parent::runTest(); $time = microtime(true) - $s; - if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) { + if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) { $this->fail( sprintf( 'expected running time: <= %s but was: %s', diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 411a8196cc..52aaacd15a 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -78,8 +78,8 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase $this->fail(sprintf( "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s", $expression, - $count == 1 ? 'once' : $count.' times', - $nodeList->length == 1 ? 'once' : $nodeList->length.' times', + 1 == $count ? 'once' : $count.' times', + 1 == $nodeList->length ? 'once' : $nodeList->length.' times', // strip away and substr($dom->saveHTML(), 6, -8) )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index dd70b23bda..f874e5a439 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -1260,7 +1260,7 @@ class ViolationMapperTest extends TestCase // Only add it if we expect the error to come up on a different // level than LEVEL_0, because in this case the error would // (correctly) be mapped to the distraction field - if ($target !== self::LEVEL_0) { + if (self::LEVEL_0 !== $target) { $mapFromPath = new PropertyPath($mapFrom); $mapFromPrefix = $mapFromPath->isIndex(0) ? '['.$mapFromPath->getElement(0).']' @@ -1274,7 +1274,7 @@ class ViolationMapperTest extends TestCase $this->mapper->mapViolation($violation, $parent); - if ($target !== self::LEVEL_0) { + if (self::LEVEL_0 !== $target) { $this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one'); } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php b/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php index ee7d135339..738d51dc48 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php @@ -15,7 +15,7 @@ class AlternatingRowType extends AbstractType $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { $form = $event->getForm(); - $type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; + $type = 0 === $form->getName() % 2 ? 'text' : 'textarea'; $form->add('title', $type); }); } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php b/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php index f7fba56c42..e768b1d7cf 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php @@ -36,7 +36,7 @@ class FixedDataTransformer implements DataTransformerInterface { $result = array_search($value, $this->mapping, true); - if ($result === false) { + if (false === $result) { throw new TransformationFailedException(sprintf('No reverse mapping for value "%s"', $value)); } diff --git a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php index fb54b4935a..06582b677e 100644 --- a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -67,7 +67,7 @@ class AcceptHeaderItem $lastNullAttribute = null; foreach ($bits as $bit) { - if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ($start === '"' || $start === '\'')) { + if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1)) && ('"' === $start || '\'' === $start)) { $attributes[$lastNullAttribute] = substr($bit, 1, -1); } elseif ('=' === $end) { $lastNullAttribute = $bit = substr($bit, 0, -1); @@ -78,7 +78,7 @@ class AcceptHeaderItem } } - return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'') ? substr($value, 1, -1) : $value, $attributes); + return new self(($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ('"' === $start || '\'' === $start) ? substr($value, 1, -1) : $value, $attributes); } /** diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 177b708e8f..0cac313ddc 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -157,7 +157,7 @@ class BinaryFileResponse extends Response */ public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') { - if ($filename === '') { + if ('' === $filename) { $filename = $this->file->getFilename(); } @@ -214,7 +214,7 @@ class BinaryFileResponse extends Response if (false === $path) { $path = $this->file->getPathname(); } - if (strtolower($type) === 'x-accel-redirect') { + if ('x-accel-redirect' === strtolower($type)) { // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { @@ -254,7 +254,7 @@ class BinaryFileResponse extends Response if ($start < 0 || $end > $fileSize - 1) { $this->setStatusCode(416); $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); - } elseif ($start !== 0 || $end !== $fileSize - 1) { + } elseif (0 !== $start || $end !== $fileSize - 1) { $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->offset = $start; diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 10837726cd..d32ec176cc 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -198,7 +198,7 @@ class UploadedFile extends File */ public function isValid() { - $isOk = $this->error === UPLOAD_ERR_OK; + $isOk = UPLOAD_ERR_OK === $this->error; return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); } @@ -285,7 +285,7 @@ class UploadedFile extends File ); $errorCode = $this->error; - $maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0; + $maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; return sprintf($message, $this->getClientOriginalName(), $maxFilesize); diff --git a/src/Symfony/Component/HttpFoundation/IpUtils.php b/src/Symfony/Component/HttpFoundation/IpUtils.php index eba603b15d..dc6d3ec818 100644 --- a/src/Symfony/Component/HttpFoundation/IpUtils.php +++ b/src/Symfony/Component/HttpFoundation/IpUtils.php @@ -75,7 +75,7 @@ class IpUtils if (false !== strpos($ip, '/')) { list($address, $netmask) = explode('/', $ip, 2); - if ($netmask === '0') { + if ('0' === $netmask) { return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 0c11adab6a..f1aff0f87e 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -427,22 +427,22 @@ class Request public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) { $dup = clone $this; - if ($query !== null) { + if (null !== $query) { $dup->query = new ParameterBag($query); } - if ($request !== null) { + if (null !== $request) { $dup->request = new ParameterBag($request); } - if ($attributes !== null) { + if (null !== $attributes) { $dup->attributes = new ParameterBag($attributes); } - if ($cookies !== null) { + if (null !== $cookies) { $dup->cookies = new ParameterBag($cookies); } - if ($files !== null) { + if (null !== $files) { $dup->files = new FileBag($files); } - if ($server !== null) { + if (null !== $server) { $dup->server = new ServerBag($server); $dup->headers = new HeaderBag($dup->server->getHeaders()); } @@ -971,7 +971,7 @@ class Request } if ($host = $this->headers->get('HOST')) { - if ($host[0] === '[') { + if ('[' === $host[0]) { $pos = strpos($host, ':', strrpos($host, ']')); } else { $pos = strrpos($host, ':'); @@ -1036,7 +1036,7 @@ class Request $scheme = $this->getScheme(); $port = $this->getPort(); - if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { + if (('http' == $scheme && 80 == $port) || ('https' == $scheme && 443 == $port)) { return $this->getHost(); } @@ -1618,7 +1618,7 @@ class Request } } else { for ($i = 0, $max = count($codes); $i < $max; ++$i) { - if ($i === 0) { + if (0 === $i) { $lang = strtolower($codes[0]); } else { $lang .= '_'.strtoupper($codes[$i]); @@ -1713,7 +1713,7 @@ class Request // IIS with ISAPI_Rewrite $requestUri = $this->headers->get('X_REWRITE_URL'); $this->headers->remove('X_REWRITE_URL'); - } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { + } elseif ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) { // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem) $requestUri = $this->server->get('UNENCODED_URL'); $this->server->remove('UNENCODED_URL'); @@ -1722,7 +1722,7 @@ class Request $requestUri = $this->server->get('REQUEST_URI'); // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path $schemeAndHttpHost = $this->getSchemeAndHttpHost(); - if (strpos($requestUri, $schemeAndHttpHost) === 0) { + if (0 === strpos($requestUri, $schemeAndHttpHost)) { $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); } } elseif ($this->server->has('ORIG_PATH_INFO')) { @@ -1774,7 +1774,7 @@ class Request // Does the baseUrl have anything in common with the request_uri? $requestUri = $this->getRequestUri(); - if ($requestUri !== '' && $requestUri[0] !== '/') { + if ('' !== $requestUri && '/' !== $requestUri[0]) { $requestUri = '/'.$requestUri; } @@ -1802,7 +1802,7 @@ class Request // If using mod_rewrite or ISAPI_Rewrite strip the script filename // out of baseUrl. $pos !== 0 makes sure it is not matching a value // from PATH_INFO or QUERY_STRING - if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) { + if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) { $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); } @@ -1852,7 +1852,7 @@ class Request if (false !== $pos = strpos($requestUri, '?')) { $requestUri = substr($requestUri, 0, $pos); } - if ($requestUri !== '' && $requestUri[0] !== '/') { + if ('' !== $requestUri && '/' !== $requestUri[0]) { $requestUri = '/'.$requestUri; } diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index aa4f67b58b..076d077c7d 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -173,6 +173,6 @@ class RequestMatcher implements RequestMatcherInterface // Note to future implementors: add additional checks above the // foreach above or else your check might not be run! - return count($this->ips) === 0; + return 0 === count($this->ips); } } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 074c896ff7..860906c3d8 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1151,7 +1151,7 @@ class Response $level = count($status); $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; - while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { + while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) { if ($flush) { ob_end_flush(); } else { @@ -1167,7 +1167,7 @@ class Response */ protected function ensureIEOverSSLCompatibility(Request $request) { - if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { + if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) { if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { $this->headers->remove('Cache-Control'); } diff --git a/src/Symfony/Component/HttpFoundation/ServerBag.php b/src/Symfony/Component/HttpFoundation/ServerBag.php index 0d38c08ac0..19d2022ef7 100644 --- a/src/Symfony/Component/HttpFoundation/ServerBag.php +++ b/src/Symfony/Component/HttpFoundation/ServerBag.php @@ -68,7 +68,7 @@ class ServerBag extends ParameterBag if (0 === stripos($authorizationHeader, 'basic ')) { // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); - if (count($exploded) == 2) { + if (2 == count($exploded)) { list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; } } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php index d797a6f238..7301f9528a 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -109,7 +109,7 @@ class NamespacedAttributeBag extends AttributeBag protected function &resolveAttributePath($name, $writeContext = false) { $array = &$this->attributes; - $name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name; + $name = (0 === strpos($name, $this->namespaceCharacter)) ? substr($name, 1) : $name; // Check if there is anything to do, else return if (!$name) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index 67a49ad6f5..dfe2fee0d4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -103,7 +103,7 @@ class MemcachedSessionHandler implements \SessionHandlerInterface { $result = $this->memcached->delete($this->prefix.$sessionId); - return $result || $this->memcached->getResultCode() == \Memcached::RES_NOTFOUND; + return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode(); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php index 5a2b7a21c3..b3f1f026a5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php @@ -71,7 +71,7 @@ class MimeTypeTest extends TestCase touch($path); @chmod($path, 0333); - if (substr(sprintf('%o', fileperms($path)), -4) == '0333') { + if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) { $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); MimeTypeGuesser::getInstance()->guess($path); } else { diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index bb7a3f4800..ed4224c4fd 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1008,7 +1008,7 @@ class RequestTest extends TestCase $req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent'); $resource = $req->getContent(true); - $this->assertTrue(is_resource($resource)); + $this->assertInternalType('resource', $resource); $this->assertEquals('MyContent', stream_get_contents($resource)); } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index c4d961e68f..bea7e1d844 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -210,7 +210,7 @@ class Store implements StoreInterface $entry[1]['vary'] = array(''); } - if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { + if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { $entries[] = $entry; } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 0fcbbe47fd..4636e29908 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -728,7 +728,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface do { $token = $tokens[++$i]; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; - } while ($token[0] !== T_END_HEREDOC); + } while (T_END_HEREDOC !== $token[0]); $rawChunk = ''; } elseif (T_WHITESPACE === $token[0]) { if ($ignoreSpace) { diff --git a/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php index c6395bd67a..dc48009ce3 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php @@ -53,11 +53,11 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface $result = array(); foreach ($profileList as $item) { - if ($limit === 0) { + if (0 === $limit) { break; } - if ($item == '') { + if ('' == $item) { continue; } @@ -119,7 +119,7 @@ abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface $profileList = explode("\n", $indexContent); foreach ($profileList as $item) { - if ($item == '') { + if ('' == $item) { continue; } diff --git a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php index b0e14ea456..257ca4c684 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php @@ -63,11 +63,11 @@ class RedisProfilerStorage implements ProfilerStorageInterface $result = array(); foreach ($profileList as $item) { - if ($limit === 0) { + if (0 === $limit) { break; } - if ($item == '') { + if ('' == $item) { continue; } @@ -123,7 +123,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface $result = array(); foreach ($profileList as $item) { - if ($item == '') { + if ('' == $item) { continue; } @@ -209,7 +209,7 @@ class RedisProfilerStorage implements ProfilerStorageInterface if (null === $this->redis) { $data = parse_url($this->dsn); - if (false === $data || !isset($data['scheme']) || $data['scheme'] !== 'redis' || !isset($data['host']) || !isset($data['port'])) { + if (false === $data || !isset($data['scheme']) || 'redis' !== $data['scheme'] || !isset($data['host']) || !isset($data['port'])) { throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn)); } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php index 8db6890c7c..b3df7387c2 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php @@ -61,7 +61,7 @@ class GenrbCompiler implements BundleCompilerInterface exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); - if ($status !== 0) { + if (0 !== $status) { throw new RuntimeException(sprintf( 'genrb failed with status %d while compiling %s to %s.', $status, diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php index 5170bb788e..79b4b3ad7c 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php @@ -101,7 +101,7 @@ class TimeZoneTransformer extends Transformer if (preg_match('/GMT(?P[+-])(?P\d{2}):?(?P\d{2})/', $formattedTimeZone, $matches)) { $hours = (int) $matches['hours']; $minutes = (int) $matches['minutes']; - $signal = $matches['signal'] == '-' ? '+' : '-'; + $signal = '-' == $matches['signal'] ? '+' : '-'; if (0 < $minutes) { throw new NotImplementedException(sprintf( @@ -110,7 +110,7 @@ class TimeZoneTransformer extends Transformer )); } - return 'Etc/GMT'.($hours !== 0 ? $signal.$hours : ''); + return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : ''); } throw new \InvalidArgumentException(sprintf('The GMT time zone "%s" does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.', $formattedTimeZone)); diff --git a/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php b/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php index 3193483dfe..59b068f0f9 100644 --- a/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php +++ b/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php @@ -31,7 +31,7 @@ class MethodArgumentValueNotImplementedException extends NotImplementedException $methodName, $argName, var_export($argValue, true), - $additionalMessage !== '' ? ' '.$additionalMessage.'. ' : '' + '' !== $additionalMessage ? ' '.$additionalMessage.'. ' : '' ); parent::__construct($message); diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index b5aa050a4e..42298e48c3 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -330,7 +330,7 @@ class NumberFormatter */ public function formatCurrency($value, $currency) { - if ($this->style == self::DECIMAL) { + if (self::DECIMAL == $this->style) { return $this->format($value); } @@ -369,13 +369,13 @@ class NumberFormatter public function format($value, $type = self::TYPE_DEFAULT) { // The original NumberFormatter does not support this format type - if ($type == self::TYPE_CURRENCY) { + if (self::TYPE_CURRENCY == $type) { trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); return false; } - if ($this->style == self::CURRENCY) { + if (self::CURRENCY == $this->style) { throw new NotImplementedException(sprintf( '%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE @@ -383,7 +383,7 @@ class NumberFormatter } // Only the default type is supported. - if ($type != self::TYPE_DEFAULT) { + if (self::TYPE_DEFAULT != $type) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported'); } @@ -526,7 +526,7 @@ class NumberFormatter */ public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0) { - if ($type == self::TYPE_DEFAULT || $type == self::TYPE_CURRENCY) { + if (self::TYPE_DEFAULT == $type || self::TYPE_CURRENCY == $type) { trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING); return false; @@ -773,7 +773,7 @@ class NumberFormatter */ private function getUninitializedPrecision($value, $precision) { - if ($this->style == self::CURRENCY) { + if (self::CURRENCY == $this->style) { return $precision; } @@ -809,11 +809,11 @@ class NumberFormatter */ private function convertValueDataType($value, $type) { - if ($type == self::TYPE_DOUBLE) { + if (self::TYPE_DOUBLE == $type) { $value = (float) $value; - } elseif ($type == self::TYPE_INT32) { + } elseif (self::TYPE_INT32 == $type) { $value = $this->getInt32Value($value); - } elseif ($type == self::TYPE_INT64) { + } elseif (self::TYPE_INT64 == $type) { $value = $this->getInt64Value($value); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php index 3e71ed78a4..7387e0e47d 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php @@ -676,7 +676,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest */ public function testGetFractionDigits($currency) { - $this->assertTrue(is_numeric($this->dataProvider->getFractionDigits($currency))); + $this->assertInternalType('numeric', $this->dataProvider->getFractionDigits($currency)); } /** @@ -684,7 +684,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest */ public function testGetRoundingIncrement($currency) { - $this->assertTrue(is_numeric($this->dataProvider->getRoundingIncrement($currency))); + $this->assertInternalType('numeric', $this->dataProvider->getRoundingIncrement($currency)); } public function provideCurrenciesWithNumericEquivalent() diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index a3f86e2b51..0822fb1275 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -621,7 +621,7 @@ abstract class AbstractNumberFormatterTest extends TestCase $this->assertSame($expected, $parsedValue, $message); $this->assertSame($expectedPosition, $position, $message); - if ($expected === false) { + if (false === $expected) { $errorCode = IntlGlobals::U_PARSE_ERROR; $errorMessage = 'Number parsing failed: U_PARSE_ERROR'; } else { @@ -631,10 +631,10 @@ abstract class AbstractNumberFormatterTest extends TestCase $this->assertSame($errorMessage, $this->getIntlErrorMessage()); $this->assertSame($errorCode, $this->getIntlErrorCode()); - $this->assertSame($errorCode !== 0, $this->isIntlFailure($this->getIntlErrorCode())); + $this->assertSame(0 !== $errorCode, $this->isIntlFailure($this->getIntlErrorCode())); $this->assertSame($errorMessage, $formatter->getErrorMessage()); $this->assertSame($errorCode, $formatter->getErrorCode()); - $this->assertSame($errorCode !== 0, $this->isIntlFailure($formatter->getErrorCode())); + $this->assertSame(0 !== $errorCode, $this->isIntlFailure($formatter->getErrorCode())); } public function parseProvider() diff --git a/src/Symfony/Component/Intl/Util/SvnRepository.php b/src/Symfony/Component/Intl/Util/SvnRepository.php index 3732cbb392..9716a5425e 100644 --- a/src/Symfony/Component/Intl/Util/SvnRepository.php +++ b/src/Symfony/Component/Intl/Util/SvnRepository.php @@ -50,7 +50,7 @@ class SvnRepository { exec('which svn', $output, $result); - if ($result !== 0) { + if (0 !== $result) { throw new RuntimeException('The command "svn" is not installed.'); } @@ -62,7 +62,7 @@ class SvnRepository exec('svn checkout '.$url.' '.$targetDir, $output, $result); - if ($result !== 0) { + if (0 !== $result) { throw new RuntimeException('The SVN checkout of '.$url.'failed.'); } } @@ -128,7 +128,7 @@ class SvnRepository $svnInfo = simplexml_load_string(implode("\n", $output)); - if ($result !== 0) { + if (0 !== $result) { throw new RuntimeException('svn info failed'); } diff --git a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php index d45114696f..fef4a8ae86 100644 --- a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php +++ b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php @@ -45,12 +45,12 @@ class ProcessTimedOutException extends RuntimeException public function isGeneralTimeout() { - return $this->timeoutType === self::TYPE_GENERAL; + return self::TYPE_GENERAL === $this->timeoutType; } public function isIdleTimeout() { - return $this->timeoutType === self::TYPE_IDLE; + return self::TYPE_IDLE === $this->timeoutType; } public function getExceededTimeout() diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index b31230d293..c3447c4eb2 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -713,7 +713,7 @@ class Process */ public function isStarted() { - return $this->status != self::STATUS_READY; + return self::STATUS_READY != $this->status; } /** @@ -725,7 +725,7 @@ class Process { $this->updateStatus(false); - return $this->status == self::STATUS_TERMINATED; + return self::STATUS_TERMINATED == $this->status; } /** @@ -1187,7 +1187,7 @@ class Process */ public function checkTimeout() { - if ($this->status !== self::STATUS_STARTED) { + if (self::STATUS_STARTED !== $this->status) { return; } @@ -1368,7 +1368,7 @@ class Process $callback = $this->callback; foreach ($result as $type => $data) { if (3 !== $type) { - $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); + $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data); } elseif (!isset($this->fallbackStatus['signaled'])) { $this->fallbackStatus['exitcode'] = (int) $data; } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 90689c88cb..3240aa7954 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -336,7 +336,7 @@ class ProcessTest extends TestCase $called = false; $p->run(function ($type, $buffer) use (&$called) { - $called = $buffer === 'foo'; + $called = 'foo' === $buffer; }); $this->assertTrue($called, 'The callback should be executed with the output'); @@ -731,8 +731,8 @@ class ProcessTest extends TestCase // Ensure that both processed finished and the output is numeric $this->assertFalse($process1->isRunning()); $this->assertFalse($process2->isRunning()); - $this->assertTrue(is_numeric($process1->getOutput())); - $this->assertTrue(is_numeric($process2->getOutput())); + $this->assertInternalType('numeric', $process1->getOutput()); + $this->assertInternalType('numeric', $process2->getOutput()); // Ensure that restart returned a new process by check that the output is different $this->assertNotEquals($process1->getOutput(), $process2->getOutput()); diff --git a/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php b/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php index 3bf8fa4b5e..20e5962d5b 100644 --- a/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php @@ -27,7 +27,7 @@ class UnexpectedTypeException extends RuntimeException */ public function __construct($value, $path, $pathIndex = null) { - if (func_num_args() === 3 && $path instanceof PropertyPathInterface) { + if (3 === func_num_args() && $path instanceof PropertyPathInterface) { $message = sprintf( 'PropertyAccessor requires a graph of objects or arrays to operate on, '. 'but it found type "%s" while trying to traverse path "%s" at property "%s".', diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index aa7df8a78b..881dcd0331 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -225,11 +225,11 @@ EOF; $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P.*?)\$\1#', $compiledRoute->getRegex(), $m)) { - if ($supportsTrailingSlash && substr($m['url'], -1) === '/') { - $conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); + if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) { + $conditions[] = sprintf("%s === rtrim(\$pathinfo, '/')", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); $hasTrailingSlash = true; } else { - $conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true)); + $conditions[] = sprintf('%s === $pathinfo', var_export(str_replace('\\', '', $m['url']), true)); } } else { if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index 4ea0b8a1a3..be36a1b393 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -60,17 +60,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/test')) { if (0 === strpos($pathinfo, '/test/baz')) { // baz - if ($pathinfo === '/test/baz') { + if ('/test/baz' === $pathinfo) { return array('_route' => 'baz'); } // baz2 - if ($pathinfo === '/test/baz.html') { + if ('/test/baz.html' === $pathinfo) { return array('_route' => 'baz2'); } // baz3 - if ($pathinfo === '/test/baz3/') { + if ('/test/baz3/' === $pathinfo) { return array('_route' => 'baz3'); } @@ -106,7 +106,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // foofoo - if ($pathinfo === '/foofoo') { + if ('/foofoo' === $pathinfo) { return array ( 'def' => 'test', '_route' => 'foofoo',); } @@ -116,7 +116,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // space - if ($pathinfo === '/spa ce') { + if ('/spa ce' === $pathinfo) { return array('_route' => 'space'); } @@ -161,12 +161,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // overridden2 - if ($pathinfo === '/multi/new') { + if ('/multi/new' === $pathinfo) { return array('_route' => 'overridden2'); } // hey - if ($pathinfo === '/multi/hey/') { + if ('/multi/hey/' === $pathinfo) { return array('_route' => 'hey'); } @@ -184,7 +184,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/aba')) { // ababa - if ($pathinfo === '/ababa') { + if ('/ababa' === $pathinfo) { return array('_route' => 'ababa'); } @@ -199,12 +199,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { // route1 - if ($pathinfo === '/route1') { + if ('/route1' === $pathinfo) { return array('_route' => 'route1'); } // route2 - if ($pathinfo === '/c2/route2') { + if ('/c2/route2' === $pathinfo) { return array('_route' => 'route2'); } @@ -212,7 +212,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { // route3 - if ($pathinfo === '/c2/route3') { + if ('/c2/route3' === $pathinfo) { return array('_route' => 'route3'); } @@ -220,7 +220,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { // route4 - if ($pathinfo === '/route4') { + if ('/route4' === $pathinfo) { return array('_route' => 'route4'); } @@ -228,26 +228,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { // route5 - if ($pathinfo === '/route5') { + if ('/route5' === $pathinfo) { return array('_route' => 'route5'); } } // route6 - if ($pathinfo === '/route6') { + if ('/route6' === $pathinfo) { return array('_route' => 'route6'); } if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { if (0 === strpos($pathinfo, '/route1')) { // route11 - if ($pathinfo === '/route11') { + if ('/route11' === $pathinfo) { return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); } // route12 - if ($pathinfo === '/route12') { + if ('/route12' === $pathinfo) { return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); } @@ -280,7 +280,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // route17 - if ($pathinfo === '/route17') { + if ('/route17' === $pathinfo) { return array('_route' => 'route17'); } @@ -288,7 +288,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/a')) { // a - if ($pathinfo === '/a/a...') { + if ('/a/a...' === $pathinfo) { return array('_route' => 'a'); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index f9d3fa2d82..afdba317b3 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -60,17 +60,17 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/test')) { if (0 === strpos($pathinfo, '/test/baz')) { // baz - if ($pathinfo === '/test/baz') { + if ('/test/baz' === $pathinfo) { return array('_route' => 'baz'); } // baz2 - if ($pathinfo === '/test/baz.html') { + if ('/test/baz.html' === $pathinfo) { return array('_route' => 'baz2'); } // baz3 - if (rtrim($pathinfo, '/') === '/test/baz3') { + if ('/test/baz3' === rtrim($pathinfo, '/')) { if (substr($pathinfo, -1) !== '/') { return $this->redirect($pathinfo.'/', 'baz3'); } @@ -114,7 +114,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // foofoo - if ($pathinfo === '/foofoo') { + if ('/foofoo' === $pathinfo) { return array ( 'def' => 'test', '_route' => 'foofoo',); } @@ -124,7 +124,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // space - if ($pathinfo === '/spa ce') { + if ('/spa ce' === $pathinfo) { return array('_route' => 'space'); } @@ -169,12 +169,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // overridden2 - if ($pathinfo === '/multi/new') { + if ('/multi/new' === $pathinfo) { return array('_route' => 'overridden2'); } // hey - if (rtrim($pathinfo, '/') === '/multi/hey') { + if ('/multi/hey' === rtrim($pathinfo, '/')) { if (substr($pathinfo, -1) !== '/') { return $this->redirect($pathinfo.'/', 'hey'); } @@ -196,7 +196,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/aba')) { // ababa - if ($pathinfo === '/ababa') { + if ('/ababa' === $pathinfo) { return array('_route' => 'ababa'); } @@ -211,12 +211,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { // route1 - if ($pathinfo === '/route1') { + if ('/route1' === $pathinfo) { return array('_route' => 'route1'); } // route2 - if ($pathinfo === '/c2/route2') { + if ('/c2/route2' === $pathinfo) { return array('_route' => 'route2'); } @@ -224,7 +224,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { // route3 - if ($pathinfo === '/c2/route3') { + if ('/c2/route3' === $pathinfo) { return array('_route' => 'route3'); } @@ -232,7 +232,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { // route4 - if ($pathinfo === '/route4') { + if ('/route4' === $pathinfo) { return array('_route' => 'route4'); } @@ -240,26 +240,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { // route5 - if ($pathinfo === '/route5') { + if ('/route5' === $pathinfo) { return array('_route' => 'route5'); } } // route6 - if ($pathinfo === '/route6') { + if ('/route6' === $pathinfo) { return array('_route' => 'route6'); } if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { if (0 === strpos($pathinfo, '/route1')) { // route11 - if ($pathinfo === '/route11') { + if ('/route11' === $pathinfo) { return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); } // route12 - if ($pathinfo === '/route12') { + if ('/route12' === $pathinfo) { return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); } @@ -292,7 +292,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // route17 - if ($pathinfo === '/route17') { + if ('/route17' === $pathinfo) { return array('_route' => 'route17'); } @@ -300,7 +300,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec if (0 === strpos($pathinfo, '/a')) { // a - if ($pathinfo === '/a/a...') { + if ('/a/a...' === $pathinfo) { return array('_route' => 'a'); } @@ -320,7 +320,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // secure - if ($pathinfo === '/secure') { + if ('/secure' === $pathinfo) { $requiredSchemes = array ( 'https' => 0,); if (!isset($requiredSchemes[$this->context->getScheme()])) { return $this->redirect($pathinfo, 'secure', key($requiredSchemes)); @@ -330,7 +330,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec } // nonsecure - if ($pathinfo === '/nonsecure') { + if ('/nonsecure' === $pathinfo) { $requiredSchemes = array ( 'http' => 0,); if (!isset($requiredSchemes[$this->context->getScheme()])) { return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes)); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index d9da7b02d4..bc8bf513c4 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -29,7 +29,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher if (0 === strpos($pathinfo, '/rootprefix')) { // static - if ($pathinfo === '/rootprefix/test') { + if ('/rootprefix/test' === $pathinfo) { return array('_route' => 'static'); } @@ -41,7 +41,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher } // with-condition - if ($pathinfo === '/with-condition' && ($context->getMethod() == "GET")) { + if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) { return array('_route' => 'with-condition'); } diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index ba50d48fa2..2555c15044 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -315,7 +315,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf foreach ($this->loadedAcls[$acl->getObjectIdentity()->getType()] as $sameTypeAcl) { if (isset($sharedPropertyChanges['classAces'])) { - if ($acl !== $sameTypeAcl && $classAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classAces'][0]) { + if ($acl !== $sameTypeAcl && $sharedPropertyChanges['classAces'][0] !== $classAcesProperty->getValue($sameTypeAcl)) { throw new ConcurrentModificationException('The "classAces" property has been modified concurrently.'); } @@ -323,7 +323,7 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf } if (isset($sharedPropertyChanges['classFieldAces'])) { - if ($acl !== $sameTypeAcl && $classFieldAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classFieldAces'][0]) { + if ($acl !== $sameTypeAcl && $sharedPropertyChanges['classFieldAces'][0] !== $classFieldAcesProperty->getValue($sameTypeAcl)) { throw new ConcurrentModificationException('The "classFieldAces" property has been modified concurrently.'); } @@ -870,7 +870,7 @@ QUERY; $classId = $this->createOrRetrieveClassId($oid->getType()); } - $objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId(); + $objectIdentityId = 'classFieldAces' === $name ? null : $ace->getAcl()->getId(); $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn(); @@ -944,7 +944,7 @@ QUERY; $classId = $this->createOrRetrieveClassId($oid->getType()); } - $objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId(); + $objectIdentityId = 'classAces' === $name ? null : $ace->getAcl()->getId(); $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))->fetchColumn(); diff --git a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php index b5b4dab95f..6341401c24 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Dbal/AclProviderBenchmarkTest.php @@ -121,7 +121,7 @@ class AclProviderBenchmarkTest extends TestCase { static $id = 1000; - if ($id === 1000 || ($id < 1500 && rand(0, 1))) { + if (1000 === $id || ($id < 1500 && rand(0, 1))) { $this->insertClassStmt->execute(array($id, $this->getRandomString(rand(20, 100), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\_'))); ++$id; @@ -158,7 +158,7 @@ class AclProviderBenchmarkTest extends TestCase { static $id = 1000; - if ($id === 1000 || ($id < 11000 && rand(0, 1))) { + if (1000 === $id || ($id < 11000 && rand(0, 1))) { $this->insertSidStmt->execute(array( $id, $this->getRandomString(rand(5, 30)), @@ -193,9 +193,9 @@ class AclProviderBenchmarkTest extends TestCase $sids[$sid][] = $fieldName; $strategy = rand(0, 2); - if ($strategy === 0) { + if (0 === $strategy) { $strategy = PermissionGrantingStrategy::ALL; - } elseif ($strategy === 1) { + } elseif (1 === $strategy) { $strategy = PermissionGrantingStrategy::ANY; } else { $strategy = PermissionGrantingStrategy::EQUAL; diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index c18c2cbf09..55c65dd7a5 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -172,7 +172,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface return false; } - if ($grant == $deny && $grant != 0) { + if ($grant == $deny && 0 != $grant) { return $this->allowIfEqualGrantedDeniedDecisions; } diff --git a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php index cde4454e9b..6fde611aef 100644 --- a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php @@ -91,7 +91,7 @@ class InMemoryUserProvider implements UserProviderInterface */ public function supportsClass($class) { - return $class === 'Symfony\Component\Security\Core\User\User'; + return 'Symfony\Component\Security\Core\User\User' === $class; } /** diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index c6397e8ca1..0012d36a1f 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -49,7 +49,7 @@ class AuthenticationUtils if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $request->attributes->get(Security::AUTHENTICATION_ERROR); - } elseif ($session !== null && $session->has(Security::AUTHENTICATION_ERROR)) { + } elseif (null !== $session && $session->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $session->get(Security::AUTHENTICATION_ERROR); if ($clearSession) { diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index 56add79926..1a8b4f3ced 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -41,7 +41,7 @@ class HttpUtils public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatcher = null) { $this->urlGenerator = $urlGenerator; - if ($urlMatcher !== null && !$urlMatcher instanceof UrlMatcherInterface && !$urlMatcher instanceof RequestMatcherInterface) { + if (null !== $urlMatcher && !$urlMatcher instanceof UrlMatcherInterface && !$urlMatcher instanceof RequestMatcherInterface) { throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); } $this->urlMatcher = $urlMatcher; diff --git a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php index 4ab3465c66..675afe7eed 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php @@ -318,6 +318,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface $this->logger->debug('Did not send remember-me cookie.', array('parameter' => $this->options['remember_me_parameter'])); } - return $parameter === 'true' || $parameter === 'on' || $parameter === '1' || $parameter === 'yes' || $parameter === true; + return 'true' === $parameter || 'on' === $parameter || '1' === $parameter || 'yes' === $parameter || true === $parameter; } } diff --git a/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php index cbbbb23519..c294067377 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php @@ -72,7 +72,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices // Delete cookie from the tokenProvider if (null !== ($cookie = $request->cookies->get($this->options['name'])) - && count($parts = $this->decodeCookie($cookie)) === 2 + && 2 === count($parts = $this->decodeCookie($cookie)) ) { list($series) = $parts; $this->tokenProvider->deleteTokenBySeries($series); @@ -84,7 +84,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices */ protected function processAutoLoginCookie(array $cookieParts, Request $request) { - if (count($cookieParts) !== 2) { + if (2 !== count($cookieParts)) { throw new AuthenticationException('The cookie is invalid.'); } diff --git a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php index d68ada5211..25d2bd5a4b 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php @@ -32,7 +32,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices */ protected function processAutoLoginCookie(array $cookieParts, Request $request) { - if (count($cookieParts) !== 4) { + if (4 !== count($cookieParts)) { throw new AuthenticationException('The cookie is invalid.'); } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index ba8edc3b17..e3bb11caa9 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -283,7 +283,7 @@ class ContextListenerTest extends TestCase { $session = new Session(new MockArraySessionStorage()); - if ($original !== null) { + if (null !== $original) { $session->set('_security_session', $original); } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 42649ef5f6..bc10698f0f 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -96,7 +96,7 @@ class ResponseListenerTest extends TestCase ->getMock(); $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); - $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue($type === HttpKernelInterface::MASTER_REQUEST)); + $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST === $type)); $event->expects($this->any())->method('getResponse')->will($this->returnValue($response)); return $event; diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index e8a24a39d6..b363401f23 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -94,10 +94,10 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec $rootNode = null; foreach ($dom->childNodes as $child) { - if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { + if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { throw new UnexpectedValueException('Document types are not allowed.'); } - if (!$rootNode && $child->nodeType !== XML_PI_NODE) { + if (!$rootNode && XML_PI_NODE !== $child->nodeType) { $rootNode = $child; } } @@ -339,7 +339,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec $value = array(); foreach ($node->childNodes as $subnode) { - if ($subnode->nodeType === XML_PI_NODE) { + if (XML_PI_NODE === $subnode->nodeType) { continue; } @@ -388,7 +388,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec $data = $this->serializer->normalize($data, $this->format, $this->context); } $parentNode->setAttribute($attributeName, $data); - } elseif ($key === '#') { + } elseif ('#' === $key) { $append = $this->selectNodeType($parentNode, $data); } elseif (is_array($data) && false === is_numeric($key)) { // Is this array fully numeric keys? diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 5149d0dbc7..85b9c83d52 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -325,7 +325,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N $paramName = $constructorParameter->name; $key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName; - $allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes); + $allowed = false === $allowedAttributes || in_array($paramName, $allowedAttributes); $ignored = in_array($paramName, $this->ignoredAttributes); if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) { if ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index a5e5dbf848..2b054dfc9d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -108,7 +108,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer $attribute = $this->nameConverter->denormalize($attribute); } - $allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes); + $allowed = false === $allowedAttributes || in_array($attribute, $allowedAttributes); $ignored = in_array($attribute, $this->ignoredAttributes); if ($allowed && !$ignored) { diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index fe1676fbf3..fbd771dbd7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -75,10 +75,10 @@ class ObjectNormalizer extends AbstractNormalizer ) { $name = $reflMethod->getName(); - if (strpos($name, 'get') === 0 || strpos($name, 'has') === 0) { + if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) { // getters and hassers $attributes[lcfirst(substr($name, 3))] = true; - } elseif (strpos($name, 'is') === 0) { + } elseif (0 === strpos($name, 'is')) { // issers $attributes[lcfirst(substr($name, 2))] = true; } @@ -148,7 +148,7 @@ class ObjectNormalizer extends AbstractNormalizer $attribute = $this->nameConverter->denormalize($attribute); } - $allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes); + $allowed = false === $allowedAttributes || in_array($attribute, $allowedAttributes); $ignored = in_array($attribute, $this->ignoredAttributes); if ($allowed && !$ignored) { diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php index abbc74f27c..a5764244fe 100644 --- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php @@ -105,7 +105,7 @@ class PropertyNormalizer extends AbstractNormalizer $propertyName = $this->nameConverter->denormalize($propertyName); } - $allowed = $allowedAttributes === false || in_array($propertyName, $allowedAttributes); + $allowed = false === $allowedAttributes || in_array($propertyName, $allowedAttributes); $ignored = in_array($propertyName, $this->ignoredAttributes); if ($allowed && !$ignored && $reflectionClass->hasProperty($propertyName)) { $property = $reflectionClass->getProperty($propertyName); diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/ScalarDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/ScalarDummy.php index e9db23882b..598e76fda8 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/ScalarDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/ScalarDummy.php @@ -23,12 +23,12 @@ class ScalarDummy implements NormalizableInterface, DenormalizableInterface public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array()) { - return $format === 'xml' ? $this->xmlFoo : $this->foo; + return 'xml' === $format ? $this->xmlFoo : $this->foo; } public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array()) { - if ($format === 'xml') { + if ('xml' === $format) { $this->xmlFoo = $data; } else { $this->foo = $data; diff --git a/src/Symfony/Component/Templating/Loader/FilesystemLoader.php b/src/Symfony/Component/Templating/Loader/FilesystemLoader.php index 0d102a6326..a190f887aa 100644 --- a/src/Symfony/Component/Templating/Loader/FilesystemLoader.php +++ b/src/Symfony/Component/Templating/Loader/FilesystemLoader.php @@ -111,10 +111,10 @@ class FilesystemLoader extends Loader */ protected static function isAbsolutePath($file) { - if ($file[0] == '/' || $file[0] == '\\' + if ('/' == $file[0] || '\\' == $file[0] || (strlen($file) > 3 && ctype_alpha($file[0]) - && $file[1] == ':' - && ($file[2] == '\\' || $file[2] == '/') + && ':' == $file[1] + && ('\\' == $file[2] || '/' == $file[2]) ) || null !== parse_url($file, PHP_URL_SCHEME) ) { diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index 3a0c80f1c9..50811d01aa 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -96,9 +96,9 @@ class MoFileLoader extends ArrayLoader $magic = unpack('V1', fread($stream, 4)); $magic = hexdec(substr(dechex(current($magic)), -8)); - if ($magic == self::MO_LITTLE_ENDIAN_MAGIC) { + if (self::MO_LITTLE_ENDIAN_MAGIC == $magic) { $isBigEndian = false; - } elseif ($magic == self::MO_BIG_ENDIAN_MAGIC) { + } elseif (self::MO_BIG_ENDIAN_MAGIC == $magic) { $isBigEndian = true; } else { throw new InvalidResourceException('MO stream content has an invalid format.'); @@ -132,7 +132,7 @@ class MoFileLoader extends ArrayLoader fseek($stream, $offset); $singularId = fread($stream, $length); - if (strpos($singularId, "\000") !== false) { + if (false !== strpos($singularId, "\000")) { list($singularId, $pluralId) = explode("\000", $singularId); } @@ -147,7 +147,7 @@ class MoFileLoader extends ArrayLoader fseek($stream, $offset); $translated = fread($stream, $length); - if (strpos($translated, "\000") !== false) { + if (false !== strpos($translated, "\000")) { $translated = explode("\000", $translated); } diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 29e898cc47..c2d0ce2b99 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -113,24 +113,24 @@ class PoFileLoader extends ArrayLoader while ($line = fgets($stream)) { $line = trim($line); - if ($line === '') { + if ('' === $line) { // Whitespace indicated current item is done if (!in_array('fuzzy', $flags)) { $this->addMessage($messages, $item); } $item = $defaults; $flags = array(); - } elseif (substr($line, 0, 2) === '#,') { + } elseif ('#,' === substr($line, 0, 2)) { $flags = array_map('trim', explode(',', substr($line, 2))); - } elseif (substr($line, 0, 7) === 'msgid "') { + } elseif ('msgid "' === substr($line, 0, 7)) { // We start a new msg so save previous // TODO: this fails when comments or contexts are added $this->addMessage($messages, $item); $item = $defaults; $item['ids']['singular'] = substr($line, 7, -1); - } elseif (substr($line, 0, 8) === 'msgstr "') { + } elseif ('msgstr "' === substr($line, 0, 8)) { $item['translated'] = substr($line, 8, -1); - } elseif ($line[0] === '"') { + } elseif ('"' === $line[0]) { $continues = isset($item['translated']) ? 'translated' : 'ids'; if (is_array($item[$continues])) { @@ -139,9 +139,9 @@ class PoFileLoader extends ArrayLoader } else { $item[$continues] .= substr($line, 1, -1); } - } elseif (substr($line, 0, 14) === 'msgid_plural "') { + } elseif ('msgid_plural "' === substr($line, 0, 14)) { $item['ids']['plural'] = substr($line, 14, -1); - } elseif (substr($line, 0, 7) === 'msgstr[') { + } elseif ('msgstr[' === substr($line, 0, 7)) { $size = strpos($line, ']'); $item['translated'][(int) substr($line, 7, 1)] = substr($line, $size + 3, -1); } diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index 657bd6eb53..22536aa866 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -50,7 +50,7 @@ class QtFileLoader implements LoaderInterface $nodes = $xpath->evaluate('//TS/context/name[text()="'.$domain.'"]'); $catalogue = new MessageCatalogue($locale); - if ($nodes->length == 1) { + if (1 == $nodes->length) { $translations = $nodes->item(0)->nextSibling->parentNode->parentNode->getElementsByTagName('message'); foreach ($translations as $translation) { $translationValue = (string) $translation->getElementsByTagName('translation')->item(0)->nodeValue; diff --git a/src/Symfony/Component/Translation/PluralizationRules.php b/src/Symfony/Component/Translation/PluralizationRules.php index 09748211b1..847ffe3c44 100644 --- a/src/Symfony/Component/Translation/PluralizationRules.php +++ b/src/Symfony/Component/Translation/PluralizationRules.php @@ -123,7 +123,7 @@ class PluralizationRules case 'tk': case 'ur': case 'zu': - return ($number == 1) ? 0 : 1; + return (1 == $number) ? 0 : 1; case 'am': case 'bh': @@ -138,7 +138,7 @@ class PluralizationRules case 'xbr': case 'ti': case 'wa': - return (($number == 0) || ($number == 1)) ? 0 : 1; + return ((0 == $number) || (1 == $number)) ? 0 : 1; case 'be': case 'bs': @@ -146,41 +146,41 @@ class PluralizationRules case 'ru': case 'sr': case 'uk': - return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); + return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); case 'cs': case 'sk': - return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2); + return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2); case 'ga': - return ($number == 1) ? 0 : (($number == 2) ? 1 : 2); + return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2); case 'lt': - return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); + return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); case 'sl': - return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3)); + return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3)); case 'mk': - return ($number % 10 == 1) ? 0 : 1; + return (1 == $number % 10) ? 0 : 1; case 'mt': - return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3)); + return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3)); case 'lv': - return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2); + return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2); case 'pl': - return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2); + return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2); case 'cy': - return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3)); + return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3)); case 'ro': - return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2); + return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2); case 'ar': - return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5)))); + return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5)))); default: return 0; diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 816cfd28f9..a8371f0102 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -443,7 +443,7 @@ EOF $locales[] = $fallback; } - if (strrchr($locale, '_') !== false) { + if (false !== strrchr($locale, '_')) { array_unshift($locales, substr($locale, 0, -strlen(strrchr($locale, '_')))); } diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index fc9d8ae563..bac99dcfcf 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -141,7 +141,7 @@ abstract class Constraint $invalidOptions[] = $option; } } - } elseif (null !== $options && !(is_array($options) && count($options) === 0)) { + } elseif (null !== $options && !(is_array($options) && 0 === count($options))) { $option = $this->getDefaultOption(); if (null === $option) { diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 83cfc6e778..c1b11599d0 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -81,7 +81,7 @@ class ChoiceValidator extends ConstraintValidator $count = count($value); - if ($constraint->min !== null && $count < $constraint->min) { + if (null !== $constraint->min && $count < $constraint->min) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->minMessage) ->setParameter('{{ limit }}', $constraint->min) @@ -99,7 +99,7 @@ class ChoiceValidator extends ConstraintValidator return; } - if ($constraint->max !== null && $count > $constraint->max) { + if (null !== $constraint->max && $count > $constraint->max) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->maxMessage) ->setParameter('{{ limit }}', $constraint->max) diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index ae55366cc9..afb0f03e35 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -63,7 +63,7 @@ class Collection extends Composite foreach ($this->fields as $fieldName => $field) { // the XmlFileLoader and YamlFileLoader pass the field Optional // and Required constraint as an array with exactly one element - if (is_array($field) && count($field) == 1) { + if (is_array($field) && 1 == count($field)) { $this->fields[$fieldName] = $field = $field[0]; } diff --git a/src/Symfony/Component/Validator/Constraints/ImageValidator.php b/src/Symfony/Component/Validator/Constraints/ImageValidator.php index a5165e2553..4ff9e00c2f 100644 --- a/src/Symfony/Component/Validator/Constraints/ImageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ImageValidator.php @@ -53,7 +53,7 @@ class ImageValidator extends FileValidator $size = @getimagesize($value); - if (empty($size) || ($size[0] === 0) || ($size[1] === 0)) { + if (empty($size) || (0 === $size[0]) || (0 === $size[1])) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->sizeNotDetectedMessage) ->setCode(Image::SIZE_NOT_DETECTED_ERROR) diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index 592f122502..e5ae85e542 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -35,7 +35,7 @@ class TypeValidator extends ConstraintValidator } $type = strtolower($constraint->type); - $type = $type == 'boolean' ? 'bool' : $constraint->type; + $type = 'boolean' == $type ? 'bool' : $constraint->type; $isFunction = 'is_'.$type; $ctypeFunction = 'ctype_'.$type; diff --git a/src/Symfony/Component/Validator/Constraints/UuidValidator.php b/src/Symfony/Component/Validator/Constraints/UuidValidator.php index d025a560d2..6dcda078a4 100644 --- a/src/Symfony/Component/Validator/Constraints/UuidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UuidValidator.php @@ -327,7 +327,7 @@ class UuidValidator extends ConstraintValidator // 0b10xx // & 0b1100 (12) // = 0b1000 (8) - if ((hexdec($value[self::STRICT_VARIANT_POSITION]) & 12) !== 8) { + if (8 !== (hexdec($value[self::STRICT_VARIANT_POSITION]) & 12)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 2ae89886c8..0d61e9aa43 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -72,9 +72,9 @@ abstract class AbstractLoader implements LoaderInterface */ protected function newConstraint($name, $options = null) { - if (strpos($name, '\\') !== false && class_exists($name)) { + if (false !== strpos($name, '\\') && class_exists($name)) { $className = (string) $name; - } elseif (strpos($name, ':') !== false) { + } elseif (false !== strpos($name, ':')) { list($prefix, $className) = explode(':', $name, 2); if (!isset($this->namespaces[$prefix])) { diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index d50419f624..8358372661 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -33,7 +33,7 @@ class SplCaster $prefix.'storage' => $c->getArrayCopy(), ); - if ($class === 'ArrayObject') { + if ('ArrayObject' === $class) { $a = $b; } else { if (!($flags & \ArrayObject::STD_PROP_LIST)) { diff --git a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php index 6e98d6ecbc..a1c69224b9 100644 --- a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php +++ b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php @@ -138,7 +138,7 @@ EOTXT; public function testJsonCast() { - if (ini_get('xdebug.overload_var_dump') == 2) { + if (2 == ini_get('xdebug.overload_var_dump')) { $this->markTestSkipped('xdebug is active'); } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 06268a2bc6..6d5ac1cd80 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -481,7 +481,7 @@ class Inline case 'false' === $scalarLower: return false; // Optimise for returning strings. - case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || $scalar[0] === '!' || is_numeric($scalar[0]): + case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || '!' === $scalar[0] || is_numeric($scalar[0]): switch (true) { case 0 === strpos($scalar, '!str'): return (string) substr($scalar, 5); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 90a2f34e02..fb3e205d29 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -200,7 +200,7 @@ class Parser $data += $refValue; // array union } else { - if (isset($values['value']) && $values['value'] !== '') { + if (isset($values['value']) && '' !== $values['value']) { $value = $values['value']; } else { $value = $this->getNextEmbedBlock(); @@ -406,7 +406,7 @@ class Parser $indent = $this->getCurrentLineIndentation(); // terminate all block scalars that are more indented than the current line - if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') { + if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) { foreach ($blockScalarIndentations as $key => $blockScalarIndentation) { if ($blockScalarIndentation >= $this->getCurrentLineIndentation()) { unset($blockScalarIndentations[$key]); @@ -699,7 +699,7 @@ class Parser //checking explicitly the first char of the trim is faster than loops or strpos $ltrimmedLine = ltrim($this->currentLine, ' '); - return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#'; + return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0]; } private function isCurrentLineLastLineInDocument() @@ -725,7 +725,7 @@ class Parser // remove leading comments $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count); - if ($count == 1) { + if (1 == $count) { // items have been removed, update the offset $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); $value = $trimmedValue; @@ -733,7 +733,7 @@ class Parser // remove start of the document marker (---) $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count); - if ($count == 1) { + if (1 == $count) { // items have been removed, update the offset $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); $value = $trimmedValue; diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 6fc4e9273d..62901ec075 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -48,7 +48,7 @@ class Yaml { // if input is a file, process it $file = ''; - if (strpos($input, "\n") === false && is_file($input)) { + if (false === strpos($input, "\n") && is_file($input)) { @trigger_error('The ability to pass file names to the '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.', E_USER_DEPRECATED); if (false === is_readable($input)) {