Skip to content

Commit b35a787

Browse files
SpacePossumnicolas-grekas
authored andcommitted
[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
1 parent 8e7d8f3 commit b35a787

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function reverseTransform($values)
109109
foreach ($values as $i => $selected) {
110110
if ($selected) {
111111
if (isset($choices[$i])) {
112-
return $choices[$i] === '' ? null : $choices[$i];
112+
return '' === $choices[$i] ? null : $choices[$i];
113113
} elseif ($this->placeholderPresent && 'placeholder' === $i) {
114114
return;
115115
} else {

Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function transform($dateTime)
9090

9191
$value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp());
9292

93-
if (intl_get_error_code() != 0) {
93+
if (0 != intl_get_error_code()) {
9494
throw new TransformationFailedException(intl_get_error_message());
9595
}
9696

@@ -123,7 +123,7 @@ public function reverseTransform($value)
123123

124124
$timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value);
125125

126-
if (intl_get_error_code() != 0) {
126+
if (0 != intl_get_error_code()) {
127127
throw new TransformationFailedException(intl_get_error_message());
128128
}
129129

Extension/Csrf/EventListener/CsrfValidationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function __construct($fieldName, $tokenManager, $tokenId, $errorMessage,
101101
public function preSubmit(FormEvent $event)
102102
{
103103
$form = $event->getForm();
104-
$postRequestSizeExceeded = $form->getConfig()->getMethod() === 'POST' && $this->serverParams->hasPostMaxSizeBeenExceeded();
104+
$postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded();
105105

106106
if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) {
107107
$data = $event->getData();

ResolvedFormType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ public function getOptionsResolver()
202202

203203
if (method_exists($this->innerType, 'configureOptions')) {
204204
$reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions');
205-
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';
205+
$isOldOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName();
206206

207207
$reflector = new \ReflectionMethod($this->innerType, 'configureOptions');
208-
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType';
208+
$isNewOverwritten = 'Symfony\Component\Form\AbstractType' !== $reflector->getDeclaringClass()->getName();
209209

210210
if ($isOldOverwritten && !$isNewOverwritten) {
211211
@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 @@ public function getOptionsResolver()
219219

220220
if (method_exists($extension, 'configureOptions')) {
221221
$reflector = new \ReflectionMethod($extension, 'setDefaultOptions');
222-
$isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension';
222+
$isOldOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName();
223223

224224
$reflector = new \ReflectionMethod($extension, 'configureOptions');
225-
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension';
225+
$isNewOverwritten = 'Symfony\Component\Form\AbstractTypeExtension' !== $reflector->getDeclaringClass()->getName();
226226

227227
if ($isOldOverwritten && !$isNewOverwritten) {
228228
@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);

Test/FormPerformanceTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function runTest()
3535
parent::runTest();
3636
$time = microtime(true) - $s;
3737

38-
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
38+
if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) {
3939
$this->fail(
4040
sprintf(
4141
'expected running time: <= %s but was: %s',

Tests/AbstractLayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ protected function assertMatchesXpath($html, $expression, $count = 1)
7878
$this->fail(sprintf(
7979
"Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
8080
$expression,
81-
$count == 1 ? 'once' : $count.' times',
82-
$nodeList->length == 1 ? 'once' : $nodeList->length.' times',
81+
1 == $count ? 'once' : $count.' times',
82+
1 == $nodeList->length ? 'once' : $nodeList->length.' times',
8383
// strip away <root> and </root>
8484
substr($dom->saveHTML(), 6, -8)
8585
));

Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName
12601260
// Only add it if we expect the error to come up on a different
12611261
// level than LEVEL_0, because in this case the error would
12621262
// (correctly) be mapped to the distraction field
1263-
if ($target !== self::LEVEL_0) {
1263+
if (self::LEVEL_0 !== $target) {
12641264
$mapFromPath = new PropertyPath($mapFrom);
12651265
$mapFromPrefix = $mapFromPath->isIndex(0)
12661266
? '['.$mapFromPath->getElement(0).']'
@@ -1274,7 +1274,7 @@ public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName
12741274

12751275
$this->mapper->mapViolation($violation, $parent);
12761276

1277-
if ($target !== self::LEVEL_0) {
1277+
if (self::LEVEL_0 !== $target) {
12781278
$this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one');
12791279
}
12801280

Tests/Fixtures/AlternatingRowType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
1515

1616
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) {
1717
$form = $event->getForm();
18-
$type = $form->getName() % 2 === 0 ? 'text' : 'textarea';
18+
$type = 0 === $form->getName() % 2 ? 'text' : 'textarea';
1919
$form->add('title', $type);
2020
});
2121
}

Tests/Fixtures/FixedDataTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function reverseTransform($value)
3636
{
3737
$result = array_search($value, $this->mapping, true);
3838

39-
if ($result === false) {
39+
if (false === $result) {
4040
throw new TransformationFailedException(sprintf('No reverse mapping for value "%s"', $value));
4141
}
4242

0 commit comments

Comments
 (0)