Browse Source

[DoctrineBundle] fixed CS

Fabien Potencier 14 years ago
parent
commit
6edb6447c8

+ 3 - 2
src/Symfony/Bundle/DoctrineBundle/Command/DropDatabaseDoctrineCommand.php

@@ -56,7 +56,7 @@ EOT
 
         $params = $connection->getParams();
 
-        $name = isset($params['path'])?$params['path']:(isset($params['dbname'])?$params['dbname']:false);
+        $name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
 
         if (!$name) {
             throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
@@ -71,7 +71,8 @@ EOT
                 $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
             }
         } else {
-            $output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.' . PHP_EOL);
+            $output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.');
+            $output->writeln('');
             $output->writeln(sprintf('<info>Would drop the database named <comment>%s</comment>.</info>', $name));
             $output->writeln('Please run the operation with --force to execute');
             $output->writeln('<error>All data will be lost!</error>');

+ 3 - 5
src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

@@ -65,16 +65,14 @@ EOT
                 }
 
                 if (strpos($metadata->name, $foundBundle->getNamespace()) === false) {
-                    throw new \RuntimeException(
-                        "Entity " . $metadata->name . " and bundle don't have a common namespace, ".
-                        "generation failed because the target directory cannot be detected.");
+                    throw new \RuntimeException(sprintf('Entity "%s" and bundle don\'t have a common namespace, generation failed because the target directory cannot be detected.', $metadata->name));
                 }
 
                 $output->writeln(sprintf('  > generating <comment>%s</comment>', $metadata->name));
                 $entityGenerator->generate(array($metadata), $this->findBasePathForBundle($foundBundle));
             }
         } else {
-            throw new \RuntimeException("Bundle " . $bundleName . " does not contain any mapped entities.");
+            throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundleName));
         }
     }
-}
+}

+ 2 - 4
src/Symfony/Bundle/DoctrineBundle/Command/GenerateRepositoriesDoctrineCommand.php

@@ -59,9 +59,7 @@ EOT
 
                 if ($metadata->customRepositoryClassName) {
                     if (strpos($metadata->customRepositoryClassName, $foundBundle->getNamespace()) === false) {
-                        throw new \RuntimeException(
-                            "Repository " . $metadata->customRepositoryClassName . " and bundle don't have a common namespace, ".
-                            "generation failed because the target directory cannot be detected.");
+                        throw new \RuntimeException(sprintf('Repository "%s" and bundle don\'t have a common namespace, generation failed because the target directory cannot be detected.', $metadata->customRepositoryClassName));
                     }
 
                     $output->writeln(sprintf('  > <info>OK</info> generating <comment>%s</comment>', $metadata->customRepositoryClassName));
@@ -71,7 +69,7 @@ EOT
                 }
             }
         } else {
-            throw new \RuntimeException("Bundle " . $bundleName . " does not contain any mapped entities.");
+            throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundleName));
         }
     }
 }

+ 2 - 1
src/Symfony/Bundle/DoctrineBundle/Command/ImportMappingDoctrineCommand.php

@@ -103,7 +103,8 @@ EOT
                 file_put_contents($path, $code);
             }
         } else {
-            $output->writeln('Database does not have any mapping information.'.PHP_EOL, 'ERROR');
+            $output->writeln('Database does not have any mapping information.', 'ERROR');
+            $output->writeln('', 'ERROR');
         }
     }
 }

+ 5 - 6
src/Symfony/Bundle/DoctrineBundle/Command/InfoDoctrineCommand.php

@@ -64,17 +64,16 @@ EOT
             );
         }
 
-        $output->write(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:\n",
-            count($entityClassNames), $entityManagerName), true);
+        $output->writeln(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:", count($entityClassNames), $entityManagerName));
 
         foreach ($entityClassNames as $entityClassName) {
             try {
                 $cm = $entityManager->getClassMetadata($entityClassName);
-                $output->write("<info>[OK]</info>   " . $entityClassName, true);
+                $output->writeln(sprintf("<info>[OK]</info>   %s", $entityClassName));
             } catch (MappingException $e) {
-                $output->write("<error>[FAIL]</error> " . $entityClassName, true);
-                $output->write("<comment>" . $e->getMessage()."</comment>", true);
-                $output->write("", true);
+                $output->writeln("<error>[FAIL]</error> ".$entityClassName);
+                $output->writeln(sprintf("<comment>%s</comment>", $e->getMessage()));
+                $output->writeln('');
             }
         }
     }

+ 5 - 5
src/Symfony/Bundle/DoctrineBundle/Tests/Command/InfoDoctrineCommandTest.php

@@ -16,11 +16,11 @@ class InfoDoctrineCommandTest extends TestCase
         $input = new StringInput("doctrine:mapping:info");
         $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
         $output->expects($this->at(0))
-               ->method('write')
-               ->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:\n"), $this->equalTo(true));
+               ->method('writeln')
+               ->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:"));
         $output->expects($this->at(1))
-               ->method('write')
-               ->with($this->equalTo("<info>[OK]</info>   Fixtures\Bundles\YamlBundle\Entity\Test"), $this->equalTo(true));
+               ->method('writeln')
+               ->with($this->equalTo("<info>[OK]</info>   Fixtures\Bundles\YamlBundle\Entity\Test"));
 
         $testContainer = $this->createYamlBundleTestContainer();
         $kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false);
@@ -36,4 +36,4 @@ class InfoDoctrineCommandTest extends TestCase
         $cmd->setApplication($application);
         $cmd->run($input, $output);
     }
-}
+}