Browse Source

Merge pull request #1672 from peterkokot/patch-2

CS fixes in code
Thomas 11 years ago
parent
commit
6c4dbbae5c

+ 1 - 1
Datagrid/ListMapper.php

@@ -68,7 +68,7 @@ class ListMapper extends BaseMapper
      */
     public function add($name, $type = null, array $fieldDescriptionOptions = array())
     {
-        //Change deprecated inline action "view" to "show"
+        // Change deprecated inline action "view" to "show"
         if ($name == '_action' && $type == 'actions') {
             if (isset($fieldDescriptionOptions['actions']['view'])) {
                 trigger_error('Inline action "view" is deprecated since version 2.2.4. Use inline action "show" instead.', E_USER_DEPRECATED);

+ 2 - 2
Form/FormMapper.php

@@ -74,7 +74,7 @@ class FormMapper extends BaseGroupedMapper
             $fieldDescriptionOptions
         );
 
-        //Note that the builder var is actually the formContractor:
+        // Note that the builder var is actually the formContractor:
         $this->builder->fixFieldDescription($this->admin, $fieldDescription, $fieldDescriptionOptions);
 
         $this->admin->addFormFieldDescription($name instanceof FormBuilder ? $name->getName() : $name, $fieldDescription);
@@ -82,7 +82,7 @@ class FormMapper extends BaseGroupedMapper
         if ($name instanceof FormBuilder) {
             $this->formBuilder->add($name);
         } else {
-            //Note that the builder var is actually the formContractor:
+            // Note that the builder var is actually the formContractor:
             $options = array_replace_recursive($this->builder->getDefaultOptions($type, $fieldDescription), $options);
 
             if (!isset($options['label'])) {

+ 4 - 4
Generator/AbstractBcGenerator.php

@@ -81,11 +81,11 @@ abstract class AbstractBcGenerator extends Generator
     protected function renderBc($template, $parameters)
     {
         if ($this->bcEnabled) {
-            //Sensio Generator 2.2
+            // Sensio Generator 2.2
             return $this->render($this->skeletonDirs, $template, $parameters);
         }
 
-        //Sensio Generator >=2.3
+        // Sensio Generator >=2.3
         return $this->render($template, $parameters);
     }
 
@@ -99,11 +99,11 @@ abstract class AbstractBcGenerator extends Generator
     protected function renderFileBc($template, $target, $parameters)
     {
         if ($this->bcEnabled) {
-            //Sensio Generator 2.2
+            // Sensio Generator 2.2
             return $this->renderFile($this->skeletonDirs, $template, $target, $parameters);
         }
 
-        //Sensio Generator >=2.3
+        // Sensio Generator >=2.3
         return $this->renderFile($template, $target, $parameters);
     }
 }

+ 2 - 2
Mapper/BaseGroupedMapper.php

@@ -68,8 +68,8 @@ abstract class BaseGroupedMapper extends BaseMapper
      */
     protected function addFieldToCurrentGroup($fieldName) 
     {
-        //Note this line must happen before the next line. 
-        //See https://github.com/sonata-project/SonataAdminBundle/pull/1351
+        // Note this line must happen before the next line. 
+        // See https://github.com/sonata-project/SonataAdminBundle/pull/1351
         $currentGroup = $this->getCurrentGroupName();
         $groups = $this->getGroups();
         $groups[$currentGroup]['fields'][$fieldName] = $fieldName;

+ 16 - 16
Tests/Command/ExplainAdminCommandTest.php

@@ -117,7 +117,7 @@ class ExplainAdminCommandTest extends \PHPUnit_Framework_TestCase
             ->method('isChild')
             ->will($this->returnValue(true));
 
-        //php 5.3 BC
+        // php 5.3 BC
         $adminParent = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
         $adminParent->expects($this->any())
             ->method('getCode')
@@ -131,7 +131,7 @@ class ExplainAdminCommandTest extends \PHPUnit_Framework_TestCase
 
         $this->validatorFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $admin = $this->admin;
         $validatorMetadata = $this->validatorFactory;
 
@@ -186,13 +186,13 @@ class ExplainAdminCommandTest extends \PHPUnit_Framework_TestCase
             ->method('getModelManager')
             ->will($this->returnValue($modelManager));
 
-//@todo Mock of \Traversable is available since Phpunit 3.8. This should be completed after stable release of Phpunit 3.8.
-//@see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
-//        $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
-//
-//        $this->admin->expects($this->any())
-//            ->method('getFormBuilder')
-//            ->will($this->returnValue($formBuilder));
+        // @todo Mock of \Traversable is available since Phpunit 3.8. This should be completed after stable release of Phpunit 3.8.
+        // @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
+        // $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
+        //
+        // $this->admin->expects($this->any())
+        //     ->method('getFormBuilder')
+        //     ->will($this->returnValue($formBuilder));
 
         $datagridBuilder = $this->getMock('\Sonata\AdminBundle\Builder\DatagridBuilderInterface');
 
@@ -231,13 +231,13 @@ class ExplainAdminCommandTest extends \PHPUnit_Framework_TestCase
             ->method('getModelManager')
             ->will($this->returnValue($modelManager));
 
-//@todo Mock of \Traversable is available since Phpunit 3.8. This should be completed after stable release of Phpunit 3.8.
-//@see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
-//        $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
-//
-//        $this->admin->expects($this->any())
-//            ->method('getFormBuilder')
-//            ->will($this->returnValue($formBuilder));
+        // @todo Mock of \Traversable is available since Phpunit 3.8. This should be completed after stable release of Phpunit 3.8.
+        // @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/103
+        // $formBuilder = $this->getMock('Symfony\Component\Form\FormBuilderInterface');
+        //
+        // $this->admin->expects($this->any())
+        //     ->method('getFormBuilder')
+        //     ->will($this->returnValue($formBuilder));
 
         $datagridBuilder = $this->getMock('\Sonata\AdminBundle\Builder\DatagridBuilderInterface');
 

+ 1 - 1
Tests/Command/GenerateAdminCommandTest.php

@@ -48,7 +48,7 @@ class GenerateAdminCommandTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        //create temp dir
+        // create temp dir
         $tempfile=tempnam(sys_get_temp_dir(),'sonata_admin');
         if (file_exists($tempfile)) {
             unlink($tempfile);

+ 2 - 2
Tests/Datagrid/DatagridMapperTest.php

@@ -53,7 +53,7 @@ class DatagridMapperTest extends \PHPUnit_Framework_TestCase
 
         $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $filter = $this->getMockForAbstractClass('Sonata\AdminBundle\Filter\Filter');
 
         $filter->expects($this->any())
@@ -72,7 +72,7 @@ class DatagridMapperTest extends \PHPUnit_Framework_TestCase
 
         $modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $fieldDescription = $this->getFieldDescriptionMock();
 
         $modelManager->expects($this->any())

+ 3 - 3
Tests/Datagrid/DatagridTest.php

@@ -57,7 +57,7 @@ class DatagridTest extends \PHPUnit_Framework_TestCase
 
         $this->formTypes = array();
 
-        //php 5.3 BC
+        // php 5.3 BC
         $formTypes = &$this->formTypes;
 
         $this->formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')
@@ -74,7 +74,7 @@ class DatagridTest extends \PHPUnit_Framework_TestCase
                 return null;
             }));
 
-        //php 5.3 BC
+        // php 5.3 BC
         $eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
         $formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
 
@@ -86,7 +86,7 @@ class DatagridTest extends \PHPUnit_Framework_TestCase
                 return null;
             }));
 
-        //php 5.3 BC
+        // php 5.3 BC
         $form = $this->getMockBuilder('Symfony\Component\Form\Form')
             ->disableOriginalConstructor()
             ->getMock();

+ 2 - 2
Tests/Datagrid/ListMapperTest.php

@@ -48,7 +48,7 @@ class ListMapperTest extends \PHPUnit_Framework_TestCase
 
         $modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $fieldDescription = $this->getFieldDescriptionMock();
 
         $modelManager->expects($this->any())
@@ -163,7 +163,7 @@ class ListMapperTest extends \PHPUnit_Framework_TestCase
 
         $this->listMapper->reorder(array('fooName3', 'fooName2', 'fooName1', 'fooName4'));
 
-        //print_r is used to compare order of items in associative arrays
+        // print_r is used to compare order of items in associative arrays
         $this->assertEquals(print_r(array(
             'fooName3'=>$fieldDescription3,
             'fooName2'=>$fieldDescription2,

+ 6 - 6
Tests/Form/DataTransformer/ModelToIdTransformerTest.php

@@ -30,18 +30,18 @@ class ModelToIdTransformerTest extends \PHPUnit_Framework_TestCase
                 ->expects($this->exactly(2))
                 ->method('find');
 
-        //we pass 0 as integer
+        // we pass 0 as integer
         // this must call the model manager find method... i not care what is returned, but must be called
         $transformer->reverseTransform(0);
 
-        //we pass 0 as string
-        //this must call the model manager find method... i not care what is returned, but must be called
+        // we pass 0 as string
+        // this must call the model manager find method... i not care what is returned, but must be called
         $transformer->reverseTransform('0');
 
-        //we pass null must return null
+        // we pass null must return null
         $this->assertNull($transformer->reverseTransform(null));
 
-        //we pass false, must return null
+        // we pass false, must return null
         $this->assertNull($transformer->reverseTransform(false));
     }
 
@@ -60,4 +60,4 @@ class ModelToIdTransformerTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals(123, $transformer->transform(new \stdClass));
     }
-}
+}

+ 1 - 1
Tests/Form/DataTransformer/ModelsToArrayTransformerTest.php

@@ -36,7 +36,7 @@ class ModelsToArrayTransformerTest extends \PHPUnit_Framework_TestCase
 
         $this->modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $modelManager = $this->modelManager;
 
         $this->modelChoiceList->expects($this->any())

+ 2 - 2
Tests/Generator/AbstractBcGeneratorTest.php

@@ -24,14 +24,14 @@ class AbstractBcGeneratorTest extends \PHPUnit_Framework_TestCase
 
     public static function setUpBeforeClass()
     {
-        //Disable E_STRICT errors for this test only
+        // Disable E_STRICT errors for this test only
         self::$errorReportingBackup = error_reporting();
         error_reporting(self::$errorReportingBackup ^ E_STRICT);
     }
 
     public static function tearDownAfterClass()
     {
-        //Restore error reporting
+        // Restore error reporting
         error_reporting(self::$errorReportingBackup);
     }
 

+ 3 - 3
Tests/Show/ShowMapperTest.php

@@ -62,7 +62,7 @@ class ShowMapperTest extends \PHPUnit_Framework_TestCase
 
         $this->groups = array();
 
-        //php 5.3 BC
+        // php 5.3 BC
         $groups = & $this->groups;
 
         $this->admin->expects($this->any())
@@ -87,7 +87,7 @@ class ShowMapperTest extends \PHPUnit_Framework_TestCase
 
         $modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $fieldDescription = $this->getFieldDescriptionMock();
 
         $modelManager->expects($this->any())
@@ -202,7 +202,7 @@ class ShowMapperTest extends \PHPUnit_Framework_TestCase
 
         $this->showMapper->reorder(array('fooName3', 'fooName2', 'fooName1', 'fooName4'));
 
-        //print_r is used to compare order of items in associative arrays
+        // print_r is used to compare order of items in associative arrays
         $this->assertEquals(print_r(array(
             'Group1' =>array(
                 'collapsed' => false,

+ 2 - 2
Tests/Translator/Extractor/JMSTranslatorBundle/AdminExtractorTest.php

@@ -45,7 +45,7 @@ class AdminExtractorTest extends \PHPUnit_Framework_TestCase
         $this->fooAdmin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
         $this->barAdmin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
 
-        //php 5.3 BC
+        // php 5.3 BC
         $fooAdmin = $this->fooAdmin;
         $barAdmin = $this->barAdmin;
 
@@ -82,7 +82,7 @@ class AdminExtractorTest extends \PHPUnit_Framework_TestCase
 
     public function testExtract()
     {
-        //php 5.3 BC
+        // php 5.3 BC
         $translator = $this->adminExtractor;
 
         $this->fooAdmin->expects($this->any())

+ 9 - 9
Tests/Twig/Extension/SonataAdminExtensionTest.php

@@ -80,13 +80,13 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
         $this->environment = new \Twig_Environment($loader, array('strict_variables' => true, 'cache' => false, 'autoescape' => true, 'optimizations' => 0));
         $this->environment->addExtension($this->twigExtension);
 
-        //translation extension
+        // translation extension
         $translator = new Translator('en', new MessageSelector());
         $translator->addLoader('xlf', new XliffFileLoader());
         $translator->addResource('xlf', __DIR__.'/../../../Resources/translations/SonataAdminBundle.en.xliff', 'en', 'SonataAdminBundle');
         $this->environment->addExtension(new TranslationExtension($translator));
 
-        //routing extension
+        // routing extension
         $xmlFileLoader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../../../Resources/config/routing')));
         $routeCollection = $xmlFileLoader->load('sonata_admin.xml');
         $requestContext = new RequestContext();
@@ -95,10 +95,10 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
 
         $this->twigExtension->initRuntime($this->environment);
 
-        //initialize object
+        // initialize object
         $this->object = new \stdClass();
 
-        //initialize admin
+        // initialize admin
         $this->admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
 
         $this->admin->expects($this->any())
@@ -120,7 +120,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
                 return $id;
             }));
 
-        //for php5.3 BC
+        // for php5.3 BC
         $admin = $this->admin;
 
         $container->expects($this->any())
@@ -133,7 +133,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
                 return null;
             }));
 
-        //initialize field description
+        // initialize field description
         $this->fieldDescription = $this->getMock('Sonata\AdminBundle\Admin\FieldDescriptionInterface');
 
         $this->fieldDescription->expects($this->any())
@@ -203,7 +203,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
                     case 'trans':
                         return 'SonataAdminBundle:CRUD:list_trans.html.twig';
                     case 'nonexistent':
-                        //template doesn`t exist
+                        // template doesn`t exist
                         return 'SonataAdminBundle:CRUD:list_nonexistent_template.html.twig';
                     default:
                         return false;
@@ -333,7 +333,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
             array('<th>Data</th> <td><i class="icon-ban-circle"></i>no</td>', 'boolean', false, array()),
             array('<th>Data</th> <td> Delete </td>', 'trans', 'action_delete', array('safe'=>false, 'catalogue'=>'SonataAdminBundle')),
 
-            //NoValueException
+            // NoValueException
             array('<th>Data</th> <td></td>', 'string', new NoValueException(), array('safe' => false)),
             array('<th>Data</th> <td></td>', 'text', new NoValueException(), array('safe' => false)),
             array('<th>Data</th> <td></td>', 'textarea', new NoValueException(), array('safe' => false)),
@@ -509,7 +509,7 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
     {
         $enitity = new \stdClass();
 
-        //set admin to pool
+        // set admin to pool
         $this->pool->setAdminClasses(array('stdClass'=>'sonata_admin_foo_service'));
 
         $this->admin->expects($this->once())