[DoctrineBridge] Add decimal form type

by @fancyweb

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

$ curl https://fabbot.io/patch/symfony/symfony/24793/5a4e42712782f7dc7520dff401773c0120a24c17/cs.diff | patch -p0
diff -ru src/Symfony/Bridge/Doctrine/Form/DataTransformer/NumberToStringTransformer.php src/Symfony/Bridge/Doctrine/Form/DataTransformer/NumberToStringTransformer.php
--- src/Symfony/Bridge/Doctrine/Form/DataTransformer/NumberToStringTransformer.php	2018-03-13 15:10:58.600832442 +0000
+++ src/Symfony/Bridge/Doctrine/Form/DataTransformer/NumberToStringTransformer.php	2018-03-13 15:10:59.860803134 +0000
@@ -27,7 +27,7 @@
     private $scale;
 
     /**
-     * @param bool $forceFullScale
+     * @param bool     $forceFullScale
      * @param int|null $scale
      */
     public function __construct($forceFullScale = false, $scale = null)
@@ -76,7 +76,7 @@
 
         if ($this->forceFullScale && is_int($this->scale)) {
             if ($valueIsInt) {
-                $value = floatval($value);
+                $value = (float) $value;
             }
 
             return number_format($value, $this->scale, '.', '');
diff -ru src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
--- src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php	2018-03-13 15:10:59.004823045 +0000
+++ src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php	2018-03-13 15:11:00.219794784 +0000
@@ -61,8 +61,8 @@
             case Type::DATETIMETZ:
             case 'vardatetime':
                 return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE);
-            case 'datetime_immutable';
-            case 'datetimetz_immutable';
+            case 'datetime_immutable':
+            case 'datetimetz_immutable':
                 return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array('input' => 'datetime_immutable'), Guess::HIGH_CONFIDENCE);
             case 'dateinterval':
                 return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE);
diff -ru src/Symfony/Bridge/Doctrine/Form/Type/DecimalType.php src/Symfony/Bridge/Doctrine/Form/Type/DecimalType.php
--- src/Symfony/Bridge/Doctrine/Form/Type/DecimalType.php	2018-03-13 15:10:59.280816625 +0000
+++ src/Symfony/Bridge/Doctrine/Form/Type/DecimalType.php	2018-03-13 15:10:59.894802343 +0000
@@ -33,10 +33,10 @@
     public function configureOptions(OptionsResolver $resolver)
     {
         $resolver->setDefaults(array(
-            'force_full_scale' => false
+            'force_full_scale' => false,
         ));
         $resolver->setAllowedTypes('force_full_scale', array(
-            'boolean'
+            'boolean',
         ));
     }
 
diff -ru src/Symfony/Bridge/Doctrine/Tests/Fixtures/Price.php src/Symfony/Bridge/Doctrine/Tests/Fixtures/Price.php
--- src/Symfony/Bridge/Doctrine/Tests/Fixtures/Price.php	2018-03-13 15:10:59.446812764 +0000
+++ src/Symfony/Bridge/Doctrine/Tests/Fixtures/Price.php	2018-03-13 15:11:00.568786666 +0000
@@ -28,7 +28,7 @@
     public $preserveFullScaleValueSimulation;
 
     /**
-     * @param int $id
+     * @param int   $id
      * @param float $value
      */
     public function __construct(int $id, float $value)
diff -ru src/Symfony/Bridge/Doctrine/Tests/Form/Type/DecimalTypeTest.php src/Symfony/Bridge/Doctrine/Tests/Form/Type/DecimalTypeTest.php
--- src/Symfony/Bridge/Doctrine/Tests/Form/Type/DecimalTypeTest.php	2018-03-13 15:10:59.598809228 +0000
+++ src/Symfony/Bridge/Doctrine/Tests/Form/Type/DecimalTypeTest.php	2018-03-13 15:11:00.537787387 +0000
@@ -39,7 +39,7 @@
 
         $schemaTool = new SchemaTool($this->em);
         $classes = array(
-            $this->em->getClassMetadata(Price::class)
+            $this->em->getClassMetadata(Price::class),
         );
 
         try {
@@ -77,15 +77,15 @@
         $fullScalePriceStringValue = $fullScalePrice->doesNotPreserveFullScaleValue;
 
         $formBuilder = $this->factory->createBuilder(FormType::class, $fullScalePrice, array(
-            'data_class' => Price::class
+            'data_class' => Price::class,
         ));
         $formBuilder->add('doesNotPreserveFullScaleValue', static::TESTED_TYPE, array(
-            'force_full_scale' => false
+            'force_full_scale' => false,
         ));
 
         $form = $formBuilder->getForm();
         $form->submit(array(
-            'doesNotPreserveFullScaleValue' => $fullScalePriceStringValue
+            'doesNotPreserveFullScaleValue' => $fullScalePriceStringValue,
         ));
 
         $this->assertSame($fullScalePriceStringValue, $fullScalePrice->doesNotPreserveFullScaleValue);
@@ -94,15 +94,15 @@
         $nonFullScalePriceStringValue = $nonFullScalePrice->doesNotPreserveFullScaleValue;
 
         $formBuilder = $this->factory->createBuilder(FormType::class, $nonFullScalePrice, array(
-            'data_class' => Price::class
+            'data_class' => Price::class,
         ));
         $formBuilder->add('doesNotPreserveFullScaleValue', static::TESTED_TYPE, array(
-            'force_full_scale' => false
+            'force_full_scale' => false,
         ));
 
         $form = $formBuilder->getForm();
         $form->submit(array(
-            'doesNotPreserveFullScaleValue' => $nonFullScalePriceStringValue
+            'doesNotPreserveFullScaleValue' => $nonFullScalePriceStringValue,
         ));
 
         $this->assertSame($nonFullScalePriceStringValue, $nonFullScalePrice->doesNotPreserveFullScaleValue);
@@ -131,16 +131,16 @@
         $fullScalePriceStringValue = $fullScalePrice->preserveFullScaleValueSimulation;
 
         $formBuilder = $this->factory->createBuilder(FormType::class, $fullScalePrice, array(
-            'data_class' => Price::class
+            'data_class' => Price::class,
         ));
         $formBuilder->add('preserveFullScaleValueSimulation', static::TESTED_TYPE, array(
             'force_full_scale' => true,
-            'scale' => 2
+            'scale' => 2,
         ));
 
         $form = $formBuilder->getForm();
         $form->submit(array(
-            'preserveFullScaleValueSimulation' => $fullScalePriceStringValue
+            'preserveFullScaleValueSimulation' => $fullScalePriceStringValue,
         ));
 
         $this->assertSame($fullScalePriceStringValue, $fullScalePrice->preserveFullScaleValueSimulation);
@@ -149,16 +149,16 @@
         $nonFullScalePriceStringValue = $nonFullScalePrice->preserveFullScaleValueSimulation;
 
         $formBuilder = $this->factory->createBuilder(FormType::class, $nonFullScalePrice, array(
-            'data_class' => Price::class
+            'data_class' => Price::class,
         ));
         $formBuilder->add('preserveFullScaleValueSimulation', static::TESTED_TYPE, array(
             'force_full_scale' => true,
-            'scale' => 2
+            'scale' => 2,
         ));
 
         $form = $formBuilder->getForm();
         $form->submit(array(
-            'preserveFullScaleValueSimulation' => $nonFullScalePriceStringValue
+            'preserveFullScaleValueSimulation' => $nonFullScalePriceStringValue,
         ));
 
         $this->assertSame($nonFullScalePriceStringValue, $nonFullScalePrice->preserveFullScaleValueSimulation);

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions