8000 yoda_style · symfony/symfony@ef37174 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef37174

Browse files
committed
yoda_style
1 parent 4d5ad85 commit ef37174

File tree

125 files changed

+250
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+250
-250
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont
199199
if ($container->hasDefinition($mappingService)) {
200200
$mappingDriverDef = $container->getDefinition($mappingService);
201201
$args = $mappingDriverDef->getArguments();
202-
if ($driverType == 'annotation') {
202+
if ('annotation' == $driverType) {
203203
$args[1] = array_merge(array_values($driverPaths), $args[1]);
204204
} else {
205205
$args[0] = array_merge(array_values($driverPaths), $args[0]);
206206
}
207207
$mappingDriverDef->setArguments($args);
208-
} elseif ($driverType == 'annotation') {
208+
} elseif ('annotation' == $driverType) {
209209
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
210210
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
211211
array_values($driverPaths),
@@ -333,7 +333,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
333333
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%';
334334
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%';
335335
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%';
336-
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
336+
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && 0 === $cacheDriver['port']) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
337337
$cacheDef = new Definition($memcacheClass);
338338
$memcacheInstance = new Definition($memcacheInstanceClass);
339339
$memcacheInstance->addMethodCall('connect', array(

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getEntitiesByIds($identifier, array $values)
111111

112112
// Like above, but we just filter out empty strings.
113113
$values = array_values(array_filter($values, function ($v) {
114-
return (string) $v !== '';
114+
return '' !== (string) $v;
115115
}));
116116
} else {
117117
$parameterType = Connection::PARAM_STR_ARRAY;

src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function onBind(FormEvent $event)
4141

4242
// If all items were removed, call clear which has a higher
4343
// performance on persistent collections
44-
if ($collection instanceof Collection && count($data) === 0) {
44+
if ($collection instanceof Collection && 0 === count($data)) {
4545
$collection->clear();
4646
}
4747
}

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function configureOptions(OptionsResolver $resolver)
176176
$entityLoader
177177
);
178178

179-
if ($hash !== null) {
179+
if (null !== $hash) {
180180
$choiceLoaders[$hash] = $doctrineChoiceLoader;
181181
}
182182

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8888

8989
$types = array('functions', 'filters', 'tests', 'globals');
9090

91-
if ($input->getOption('format') === 'json') {
91+
if ('json' === $input->getOption('format')) {
9292
$data = array();
9393
foreach ($types as $type) {
9494
foreach ($twig->{'get'.ucfirst($type)}() as $name => $entity) {
@@ -129,13 +129,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
129129

130130
private function getMetadata($type, $entity)
131131
{
132-
if ($type === 'globals') {
132+
if ('globals' === $type) {
133133
return $entity;
134134
}
135-
if ($type === 'tests') {
135+
if ('tests' === $type) {
136136
return;
137137
}
138-
if ($type === 'functions' || $type === 'filters') {
138+
if ('functions' === $type || 'filters' === $type) {
139139
$cb = $entity->getCallable();
140140
if (null === $cb) {
141141
return;
@@ -165,7 +165,7 @@ private function getMetadata($type, $entity)
165165
array_shift($args);
166166
}
167167

168-
if ($type === 'filters') {
168+
if ('filters' === $type) {
169169
// remove the value the filter is applied on
170170
array_shift($args);
171171
}
@@ -185,32 +185,32 @@ private function getMetadata($type, $entity)
185185

186186
private function getPrettyMetadata($type, $entity)
187187
{
188-
if ($type === 'tests') {
188+
if ('tests' === $type) {
189189
return '';
190190
}
191191

192192
try {
193193
$meta = $this->getMetadata($type, $entity);
194-
if ($meta === null) {
194+
if (null === $meta) {
195195
return '(unknown?)';
196196
}
197197
} catch (\UnexpectedValueException $e) {
198198
return ' <error>'.$e->getMessage().'</error>';
199199
}
200200

201-
if ($type === 'globals') {
201+
if ('globals' === $type) {
202202
if (is_object($meta)) {
203203
return ' = object('.get_class($meta).')';
204204
}
205205

206206
return ' = '.substr(@json_encode($meta), 0, 50);
207207
}
208208

209-
if ($type === 'functions') {
209+
if ('functions' === $type) {
210210
return '('.implode(', ', $meta).')';
211211
}
212212

213-
if ($type === 'filters') {
213+
if ('filters' === $type) {
214214
return $meta ? '('.implode(', ', $meta).')' : '';
215215
}
216216
}

src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getTokenParsers()
4848
* Some stuff which will be recorded on the timeline
4949
* {% endstopwatch %}
5050
*/
51-
new StopwatchTokenParser($this->stopwatch !== null && $this->enabled),
51+
new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled),
5252
);
5353
}
5454

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function renderEnctype(FormView $view)
7575

7676
protected function renderLabel(FormView $view, $label = null, array $vars = array())
7777
{
78-
if ($label !== null) {
78+
if (null !== $label) {
7979
$vars += array('label' => $label);
8080
}
8181

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function renderEnctype(FormView $view)
7575

7676
protected function renderLabel(FormView $view, $label = null, array $vars = array())
7777
{
78-
if ($label !== null) {
78+
if (null !== $label) {
7979
$vars += array('label' => $label);
8080
}
8181

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 1 addition & 1 deletion
< 10000 /tr>
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function renderEnctype(FormView $view)
158158

159159
protected function renderLabel(FormView $view, $label = null, array $vars = array())
160160
{
161-
if ($label !== null) {
161+
if (null !== $label) {
162162
$vars += array('label' => $label);
163163
}
164164

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function renderEnctype(FormView $view)
7676

7777
protected function renderLabel(FormView $view, $label = null, array $vars = array())
7878
{
79-
if ($label !== null) {
79+
if (null !== $label) {
8080
$vars += array('label' => $label);
8181
}
8282

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7272
$output = new SymfonyStyle($input, $output);
7373

7474
// check presence of force or dump-message
75-
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
75+
if (true !== $input->getOption('force') && true !== $input->getOption('dump-messages')) {
7676
$output->error('You must choose one of --force or --dump-messages');
7777

7878
return 1;
@@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
151151
}
152152

153153
// show compiled list of messages
154-
if ($input->getOption('dump-messages') === true) {
154+
if (true === $input->getOption('dump-messages')) {
155155
$output->newLine();
156156
foreach ($operation->getDomains() as $domain) {
157157
$output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain));
@@ -168,17 +168,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
168168
));
169169
}
170170

171-
if ($input->getOption('output-format') == 'xlf') {
171+
if ('xlf' == $input->getOption('output-format')) {
172172
$output->writeln('Xliff output version is <info>1.2</info>');
173173
}
174174
}
175175

176-
if ($input->getOption('no-backup') === true) {
176+
if (true === $input->getOption('no-backup')) {
177177
$writer->disableBackup();
178178
}
179179

180180
// save the files
181-
if ($input->getOption('force') === true) {
181+
if (true === $input->getOption('force')) {
182182
$output->text('Writing files');
183183

184184
$bundleTransPath = false;

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private function findAlternative($nonExistentBundleName)
141141
}
142142

143143
$lev = levenshtein($nonExistentBundleName, $bundleName);
144-
if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) {
144+
if ($lev <= strlen($nonExistentBundleName) / 3 && (null === $alternative || $lev < $shortest)) {
145145
$alternative = $bundleName;
146146
$shortest = $lev;
147147
}

src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function urlRedirectAction(Request $request, $path, $permanent = false, $
100100

101101
$qs = $request->getQueryString();
102102
if ($qs) {
103-
if (strpos($path, '?') === false) {
103+
if (false === strpos($path, '?')) {
104104
$qs = '?'.$qs;
105105
} else {
106106
$qs = '&'.$qs;

src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function templateAction($template, $maxAge = null, $sharedAge = null, $pr
4646

4747
if ($private) {
4848
$response->setPrivate();
49-
} elseif ($private === false || (null === $private && ($maxAge || $sharedAge))) {
49+
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
5050
$response->setPublic();
5151
}
5252

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static function getPhpUnitCliConfigArgument()
7777
$dir = null;
7878
$reversedArgs = array_reverse($_SERVER['argv']);
7979
foreach ($reversedArgs as $argIndex => $testArg) {
80-
if (preg_match('/^-[^ \-]*c$/', $testArg) || $testArg === '--configuration') {
80+
if (preg_match('/^-[^ \-]*c$/', $testArg) || '--configuration' === $testArg) {
8181
$dir = realpath($reversedArgs[$argIndex - 1]);
8282
break;
8383
} elseif (0 === strpos($testArg, '--configuration=')) {

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public function parse($name)
3030
{
3131
list($bundle, $controller, $template) = explode(':', $name, 3);
3232

33-
if ($template[0] == '_') {
33+
if ('_' == $template[0]) {
3434
$path = $this->rootTheme.'/Custom/'.$template;
35-
} elseif ($bundle === 'TestBundle') {
35+
} elseif ('TestBundle' === $bundle) {
3636
$path = $this->rootTheme.'/'.$controller.'/'.$template;
3737
} else {
3838
$path = $this->root.'/'.$controller.'/'.$template;

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testParseFromFilename($file, $ref)
3636
{
3737
$template = $this->parser->parse($file);
3838

39-
if ($ref === false) {
39+
if (false === $ref) {
4040
$this->assertFalse($template);
4141
} else {
4242
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());

src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
120120
foreach ($userOption as $user) {
121121
$data = explode(':', $user, 2);
122122

123-
if (count($data) === 1) {
123+
if (1 === count($data)) {
124124
throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
125125
}
126126

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ private function addProvidersSection(ArrayNodeDefinition $rootNode)
394394
->thenInvalid('You cannot set multiple provider types for the same provider')
395395
->end()
396396
->validate()
397-
->ifTrue(function ($v) { return count($v) === 0; })
397+
->ifTrue(function ($v) { return 0 === count($v); })
398398
->thenInvalid('You must set a provider definition for the provider.')
399399
->end()
400400
;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
9393
$userProviders[] = new Reference('security.user.provider.concrete.'.$providerName);
9494
}
9595
}
96-
if (count($userProviders) === 0) {
96+
if (0 === count($userProviders)) {
9797
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.');
9898
}
9999

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function testAccess()
133133

134134
$rules = array();
135135
foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) {
136-
if ($call[0] == 'add') {
136+
if ('add' == $call[0]) {
137137
$rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]);
138138
}
139139
}

src/Symfony/Component/BrowserKit/History.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function add(Request $request)
4949
*/
5050
public function isEmpty()
5151
{
52-
return count($this->stack) == 0;
52+
return 0 == count($this->stack);
5353
}
5454

5555
/**

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static function fixNamespaceDeclarations($source)
215215
do {
216216
$token = $tokens[++$i];
217217
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
218-
} while ($token[0] !== T_END_HEREDOC);
218+
} while (T_END_HEREDOC !== $token[0]);
219219
$output .= "\n";
220220
$rawChunk = '';
221221
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {

src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function createMap($dir)
6666

6767
$path = $file->getRealPath() ?: $file->getPathname();
6868

69-
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
69+
if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
7070
continue;
7171
}
7272

src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function writeNode(NodeInterface $node, $depth = 0)
117117
$comments[] = 'Example: '.$example;
118118
}
119119

120-
$default = (string) $default != '' ? ' '.$default : '';
120+
$default = '' != (string) $default ? ' '.$default : '';
121121
$comments = count($comments) ? '# '.implode(', ', $comments) : '';
122122

123123
$text = rtrim(sprintf('%-21s%s %s', $node->getName().':', $default, $comments), ' ');

src/Symfony/Component/Config/FileLocator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public function locate($name, $currentPath = null, $first = true)
8181
*/
8282
private function isAbsolutePath($file)
8383
{
84-
if ($file[0] === '/' || $file[0] === '\\'
84+
if ('/' === $file[0] || '\\' === $file[0]
8585
|| (strlen($file) > 3 && ctype_alpha($file[0])
86-
&& $file[1] === ':'
87-
&& ($file[2] === '\\' || $file[2] === '/')
86+
&& ':' === $file[1]
87+
&& ('\\' === $file[2] || '/' === $file[2])
8888
)
8989
|| null !== parse_url($file, PHP_URL_SCHEME)
9090
) {

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function loadFile($file, $schemaOrCallable = null)
6868
libxml_disable_entity_loader($disableEntities);
6969

7070
foreach ($dom->childNodes as $child) {
71-
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
71+
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
7272
throw new \InvalidArgumentException('Document types are not allowed.');
7373
}
7474
}

src/Symfony/Component/Console/Application.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,8 @@ public function renderException($e, $output)
709709
$trace = $e->getTrace();
710710
array_unshift($trace, array(
711711
'function' => '',
712-
'file' => $e->getFile() !== null ? $e->getFile() : 'n/a',
713-
'line' => $e->getLine() !== null ? $e->getLine() : 'n/a',
712+
'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
713+
'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
714714
'args' => array(),
715715
));
716716

@@ -838,9 +838,9 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
838838
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
839839
$input->setInteractive(false);
840840
} else {
841-
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) {
841+
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
842842
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
843-
} elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) {
843+
} elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
844844
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
845845
} elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
846846
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);

src/Symfony/Component/Console/Descriptor/XmlDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public function getApplicationDocument(Application $application, $namespace = nu
9494
$dom = new \DOMDocument('1.0', 'UTF-8');
9595
$dom->appendChild($rootXml = $dom->createElement('symfony'));
9696

97-
if ($application->getName() !== 'UNKNOWN') {
97+
if ('UNKNOWN' !== $application->getName()) {
9898
$rootXml->setAttribute('name', $application->getName());
99-
if ($application->getVersion() !== 'UNKNOWN') {
99+
if ('UNKNOWN' !== $application->getVersion()) {
100100
$rootXml->setAttribute('version', $application->getVersion());
101101
}
102102
}

0 commit comments

Comments
 (0)
0