Skip to content
Browse files

Folded all curly brackets of control structures to conform to PEAR/ZF CS

  • Loading branch information...
1 parent e799768 commit 2684de0d8e0956de3279f996c5f825b9167fb07c @Seldaek Seldaek committed with fabpot May 7, 2010
Showing with 1,916 additions and 4,272 deletions.
  1. +14 −30 src/Symfony/Components/BrowserKit/Client.php
  2. +5 −10 src/Symfony/Components/BrowserKit/CookieJar.php
  3. +3 −6 src/Symfony/Components/BrowserKit/History.php
  4. +3 −6 src/Symfony/Components/BrowserKit/Response.php
  5. +54 −116 src/Symfony/Components/Console/Application.php
  6. +16 −36 src/Symfony/Components/Console/Command/Command.php
  7. +3 −7 src/Symfony/Components/Console/Command/HelpCommand.php
  8. +2 −5 src/Symfony/Components/Console/Command/ListCommand.php
  9. +6 −14 src/Symfony/Components/Console/Helper/DialogHelper.php
  10. +5 −10 src/Symfony/Components/Console/Helper/FormatterHelper.php
  11. +3 −6 src/Symfony/Components/Console/Helper/HelperSet.php
  12. +22 −51 src/Symfony/Components/Console/Input/ArgvInput.php
  13. +11 −24 src/Symfony/Components/Console/Input/ArrayInput.php
  14. +7 −15 src/Symfony/Components/Console/Input/Input.php
  15. +5 −12 src/Symfony/Components/Console/Input/InputArgument.php
  16. +34 −73 src/Symfony/Components/Console/Input/InputDefinition.php
  17. +9 −20 src/Symfony/Components/Console/Input/InputOption.php
  18. +5 −14 src/Symfony/Components/Console/Input/StringInput.php
  19. +9 −18 src/Symfony/Components/Console/Output/Output.php
  20. +5 −11 src/Symfony/Components/Console/Output/StreamOutput.php
  21. +9 −19 src/Symfony/Components/Console/Shell.php
  22. +3 −6 src/Symfony/Components/Console/Tester/ApplicationTester.php
  23. +3 −6 src/Symfony/Components/Console/Tester/CommandTester.php
  24. +15 −40 src/Symfony/Components/CssSelector/Node/AttribNode.php
  25. +1 −2 src/Symfony/Components/CssSelector/Node/CombinedSelectorNode.php
  26. +3 −7 src/Symfony/Components/CssSelector/Node/ElementNode.php
  27. +28 −63 src/Symfony/Components/CssSelector/Node/FunctionNode.php
  28. +1 −2 src/Symfony/Components/CssSelector/Node/OrNode.php
  29. +6 −12 src/Symfony/Components/CssSelector/Node/PseudoNode.php
  30. +41 −96 src/Symfony/Components/CssSelector/Parser.php
  31. +3 −6 src/Symfony/Components/CssSelector/TokenStream.php
  32. +17 −36 src/Symfony/Components/CssSelector/Tokenizer.php
  33. +17 −39 src/Symfony/Components/CssSelector/XPathExpr.php
  34. +1 −2 src/Symfony/Components/CssSelector/XPathExprOr.php
  35. +33 −74 src/Symfony/Components/DependencyInjection/Builder.php
  36. +9 −18 src/Symfony/Components/DependencyInjection/BuilderConfiguration.php
  37. +9 −19 src/Symfony/Components/DependencyInjection/Container.php
  38. +3 −6 src/Symfony/Components/DependencyInjection/Definition.php
  39. +16 −34 src/Symfony/Components/DependencyInjection/Dumper/GraphvizDumper.php
  40. +43 −98 src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php
  41. +23 −52 src/Symfony/Components/DependencyInjection/Dumper/XmlDumper.php
  42. +28 −65 src/Symfony/Components/DependencyInjection/Dumper/YamlDumper.php
  43. +1 −2 src/Symfony/Components/DependencyInjection/FileResource.php
  44. +6 −14 src/Symfony/Components/DependencyInjection/Loader/FileLoader.php
  45. +2 −4 src/Symfony/Components/DependencyInjection/Loader/IniFileLoader.php
  46. +1 −2 src/Symfony/Components/DependencyInjection/Loader/LoaderExtension.php
  47. +39 −84 src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
  48. +28 −60 src/Symfony/Components/DependencyInjection/Loader/YamlFileLoader.php
  49. +6 −13 src/Symfony/Components/DependencyInjection/SimpleXMLElement.php
  50. +43 −92 src/Symfony/Components/DomCrawler/Crawler.php
  51. +23 −52 src/Symfony/Components/DomCrawler/Field/ChoiceFormField.php
  52. +5 −11 src/Symfony/Components/DomCrawler/Field/FileFormField.php
  53. +3 −6 src/Symfony/Components/DomCrawler/Field/InputFormField.php
  54. +2 −4 src/Symfony/Components/DomCrawler/Field/TextareaFormField.php
  55. +23 −53 src/Symfony/Components/DomCrawler/Form.php
  56. +3 −6 src/Symfony/Components/DomCrawler/Link.php
  57. +2 −4 src/Symfony/Components/EventDispatcher/Event.php
  58. +8 −16 src/Symfony/Components/EventDispatcher/EventDispatcher.php
  59. +14 −28 src/Symfony/Components/Finder/Finder.php
  60. +14 −36 src/Symfony/Components/Finder/Glob.php
  61. +1 −2 src/Symfony/Components/Finder/Iterator/CustomFilterIterator.php
  62. +4 −8 src/Symfony/Components/Finder/Iterator/ExcludeDirectoryFilterIterator.php
  63. +2 −5 src/Symfony/Components/Finder/Iterator/FileTypeFilterIterator.php
  64. +9 −20 src/Symfony/Components/Finder/Iterator/FilenameFilterIterator.php
  65. +2 −4 src/Symfony/Components/Finder/Iterator/SizeRangeFilterIterator.php
  66. +5 −13 src/Symfony/Components/Finder/Iterator/SortableIterator.php
  67. +6 −12 src/Symfony/Components/Finder/NumberCompare.php
  68. +7 −16 src/Symfony/Components/HttpKernel/CacheControl.php
  69. +1 −2 src/Symfony/Components/HttpKernel/Exception/ForbiddenHttpException.php
  70. +1 −2 src/Symfony/Components/HttpKernel/Exception/NotFoundHttpException.php
  71. +1 −2 src/Symfony/Components/HttpKernel/Exception/UnauthorizedHttpException.php
  72. +4 −8 src/Symfony/Components/HttpKernel/HeaderBag.php
  73. +13 −29 src/Symfony/Components/HttpKernel/HttpKernel.php
  74. +2 −4 src/Symfony/Components/HttpKernel/ParameterBag.php
  75. +63 −140 src/Symfony/Components/HttpKernel/Request.php
  76. +27 −59 src/Symfony/Components/HttpKernel/Response.php
  77. +6 −12 src/Symfony/Components/HttpKernel/Test/Client.php
  78. +3 −6 src/Symfony/Components/HttpKernel/Test/RequestTester.php
  79. +14 −29 src/Symfony/Components/HttpKernel/Test/ResponseTester.php
  80. +16 −32 src/Symfony/Components/OutputEscaper/Escaper.php
  81. +1 −2 src/Symfony/Components/OutputEscaper/GetterDecorator.php
  82. +5 −12 src/Symfony/Components/OutputEscaper/ObjectDecorator.php
  83. +1 −2 src/Symfony/Components/OutputEscaper/SafeDecorator.php
  84. +3 −6 src/Symfony/Components/Process/PhpProcess.php
  85. +17 −37 src/Symfony/Components/Process/Process.php
  86. +1 −2 src/Symfony/Components/Routing/FileResource.php
  87. +2 −4 src/Symfony/Components/Routing/Generator/Dumper/PhpGeneratorDumper.php
  88. +12 −26 src/Symfony/Components/Routing/Generator/UrlGenerator.php
  89. +6 −14 src/Symfony/Components/Routing/Loader/FileLoader.php
  90. +10 −21 src/Symfony/Components/Routing/Loader/XmlFileLoader.php
  91. +8 −19 src/Symfony/Components/Routing/Loader/YamlFileLoader.php
  92. +2 −4 src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php
  93. +5 −10 src/Symfony/Components/Routing/Matcher/Dumper/ApacheMatcherDumper.php
  94. +3 −6 src/Symfony/Components/Routing/Matcher/Dumper/PhpMatcherDumper.php
  95. +7 −14 src/Symfony/Components/Routing/Matcher/UrlMatcher.php
  96. +5 −10 src/Symfony/Components/Routing/Route.php
  97. +4 −8 src/Symfony/Components/Routing/RouteCollection.php
  98. +14 −34 src/Symfony/Components/Routing/RouteCompiler.php
  99. +15 −30 src/Symfony/Components/Routing/Router.php
  100. +13 −28 src/Symfony/Components/Templating/Engine.php
  101. +7 −14 src/Symfony/Components/Templating/Helper/AssetsHelper.php
  102. +2 −4 src/Symfony/Components/Templating/Helper/JavascriptsHelper.php
  103. +3 −6 src/Symfony/Components/Templating/Helper/SlotsHelper.php
  104. +2 −4 src/Symfony/Components/Templating/Helper/StylesheetsHelper.php
  105. +6 −12 src/Symfony/Components/Templating/Loader/CacheLoader.php
  106. +2 −4 src/Symfony/Components/Templating/Loader/ChainLoader.php
  107. +7 −14 src/Symfony/Components/Templating/Loader/FilesystemLoader.php
  108. +2 −5 src/Symfony/Components/Templating/Renderer/PhpRenderer.php
  109. +3 −7 src/Symfony/Components/Yaml/Dumper.php
  110. +24 −53 src/Symfony/Components/Yaml/Inline.php
  111. +62 −144 src/Symfony/Components/Yaml/Parser.php
  112. +5 −11 src/Symfony/Components/Yaml/Yaml.php
  113. +4 −8 src/Symfony/Foundation/Bundle/Bundle.php
  114. +2 −4 src/Symfony/Foundation/Bundle/KernelBundle.php
  115. +5 −11 src/Symfony/Foundation/Bundle/KernelExtension.php
  116. +12 −26 src/Symfony/Foundation/ClassCollectionLoader.php
  117. +2 −4 src/Symfony/Foundation/Debug/ErrorHandler.php
  118. +7 −14 src/Symfony/Foundation/Debug/EventDispatcher.php
  119. +4 −8 src/Symfony/Foundation/EventDispatcher.php
  120. +29 −62 src/Symfony/Foundation/Kernel.php
  121. +2 −4 src/Symfony/Foundation/Test/Client.php
  122. +6 −13 src/Symfony/Foundation/UniversalClassLoader.php
  123. +57 −121 src/Symfony/Foundation/bootstrap.php
  124. +3 −6 src/Symfony/Framework/DoctrineBundle/Bundle.php
  125. +9 −20 src/Symfony/Framework/DoctrineBundle/Command/ConvertDoctrine1SchemaDoctrineCommand.php
  126. +4 −8 src/Symfony/Framework/DoctrineBundle/Command/CreateDatabaseDoctrineCommand.php
  127. +11 −23 src/Symfony/Framework/DoctrineBundle/Command/DoctrineCommand.php
  128. +4 −8 src/Symfony/Framework/DoctrineBundle/Command/DropDatabaseDoctrineCommand.php
  129. +4 −8 src/Symfony/Framework/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php
  130. +5 −10 src/Symfony/Framework/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php
  131. +4 −8 src/Symfony/Framework/DoctrineBundle/Command/GenerateRepositoriesDoctrineCommand.php
  132. +9 −20 src/Symfony/Framework/DoctrineBundle/Command/ImportMappingDoctrineCommand.php
  133. +16 −32 src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php
  134. +4 −10 src/Symfony/Framework/DoctrineBundle/Controller/DoctrineController.php
  135. +1 −2 src/Symfony/Framework/DoctrineBundle/DataCollector/DoctrineDataCollector.php
  136. +18 −37 src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php
  137. +1 −2 src/Symfony/Framework/DoctrineBundle/Logger/DbalLogger.php
  138. +1 −2 src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollector.php
  139. +7 −16 src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php
  140. +1 −2 src/Symfony/Framework/ProfilerBundle/DependencyInjection/ProfilerExtension.php
  141. +3 −6 src/Symfony/Framework/ProfilerBundle/Listener/WebDebugToolbar.php
  142. +10 −23 src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php
  143. +9 −20 src/Symfony/Framework/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php
  144. +2 −4 src/Symfony/Framework/WebBundle/Bundle.php
  145. +3 −6 src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php
  146. +3 −6 src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php
  147. +15 −33 src/Symfony/Framework/WebBundle/Command/RouterDebugCommand.php
  148. +3 −6 src/Symfony/Framework/WebBundle/Console/Application.php
  149. +3 −6 src/Symfony/Framework/WebBundle/Controller.php
  150. +4 −7 src/Symfony/Framework/WebBundle/Controller/ExceptionController.php
  151. +1 −2 src/Symfony/Framework/WebBundle/Controller/RedirectController.php
  152. +13 −31 src/Symfony/Framework/WebBundle/Debug/ExceptionFormatter.php
  153. +13 −28 src/Symfony/Framework/WebBundle/DependencyInjection/WebExtension.php
  154. +11 −25 src/Symfony/Framework/WebBundle/Listener/ControllerLoader.php
  155. +4 −9 src/Symfony/Framework/WebBundle/Listener/ExceptionHandler.php
  156. +4 −9 src/Symfony/Framework/WebBundle/Listener/RequestParser.php
  157. +2 −4 src/Symfony/Framework/WebBundle/Listener/ResponseFilter.php
  158. +1 −2 src/Symfony/Framework/WebBundle/Resources/skeleton/application/xml/Kernel.php
  159. +1 −2 src/Symfony/Framework/WebBundle/Resources/skeleton/application/yaml/Kernel.php
  160. +5 −10 src/Symfony/Framework/WebBundle/Session/NativeSession.php
  161. +11 −27 src/Symfony/Framework/WebBundle/Session/PdoSession.php
  162. +1 −2 src/Symfony/Framework/WebBundle/Templating/Debugger.php
  163. +8 −17 src/Symfony/Framework/WebBundle/Templating/Engine.php
  164. +1 −2 src/Symfony/Framework/WebBundle/User.php
  165. +25 −55 src/Symfony/Framework/WebBundle/Util/Filesystem.php
  166. +1 −2 src/Symfony/Framework/WebBundle/Util/Mustache.php
  167. +2 −4 src/Symfony/Framework/ZendBundle/DependencyInjection/ZendExtension.php
  168. +6 −15 tests/Symfony/Tests/Components/BrowserKit/ClientTest.php
  169. +6 −15 tests/Symfony/Tests/Components/BrowserKit/HistoryTest.php
  170. +14 −35 tests/Symfony/Tests/Components/Console/ApplicationTest.php
  171. +10 −25 tests/Symfony/Tests/Components/Console/Command/CommandTest.php
  172. +12 −30 tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php
  173. +8 −20 tests/Symfony/Tests/Components/Console/Input/ArrayInputTest.php
  174. +6 −15 tests/Symfony/Tests/Components/Console/Input/InputArgumentTest.php
  175. +18 −45 tests/Symfony/Tests/Components/Console/Input/InputDefinitionTest.php
  176. +8 −20 tests/Symfony/Tests/Components/Console/Input/InputOptionTest.php
  177. +12 −30 tests/Symfony/Tests/Components/Console/Input/InputTest.php
  178. +4 −10 tests/Symfony/Tests/Components/Console/Output/OutputTest.php
  179. +2 −5 tests/Symfony/Tests/Components/Console/Output/StreamOutputTest.php
  180. +1 −2 tests/Symfony/Tests/Components/CssSelector/Node/AttribNodeTest.php
  181. +1 −2 tests/Symfony/Tests/Components/CssSelector/Node/CombinedSelectorNodeTest.php
  182. +2 −5 tests/Symfony/Tests/Components/CssSelector/ParserTest.php
  183. +1 −2 tests/Symfony/Tests/Components/CssSelector/TokenizerTest.php
  184. +6 −15 tests/Symfony/Tests/Components/DependencyInjection/BuilderConfigurationTest.php
  185. +14 −35 tests/Symfony/Tests/Components/DependencyInjection/BuilderTest.php
  186. +14 −35 tests/Symfony/Tests/Components/DependencyInjection/ContainerTest.php
  187. +2 −4 tests/Symfony/Tests/Components/DependencyInjection/CrossCheckTest.php
  188. +2 −5 tests/Symfony/Tests/Components/DependencyInjection/Dumper/DumperTest.php
  189. +2 −5 tests/Symfony/Tests/Components/DependencyInjection/Dumper/PhpDumperTest.php
  190. +2 −5 tests/Symfony/Tests/Components/DependencyInjection/Dumper/XmlDumperTest.php
  191. +2 −5 tests/Symfony/Tests/Components/DependencyInjection/Dumper/YamlDumperTest.php
  192. +4 −10 tests/Symfony/Tests/Components/DependencyInjection/Loader/IniFileLoaderTest.php
  193. +2 −5 tests/Symfony/Tests/Components/DependencyInjection/Loader/LoaderExtensionTest.php
  194. +10 −25 tests/Symfony/Tests/Components/DependencyInjection/Loader/XmlFileLoaderTest.php
  195. +10 −25 tests/Symfony/Tests/Components/DependencyInjection/Loader/YamlFileLoaderTest.php
  196. +20 −49 tests/Symfony/Tests/Components/DomCrawler/CrawlerTest.php
  197. +19 −46 tests/Symfony/Tests/Components/DomCrawler/Field/ChoiceFormFieldTest.php
  198. +6 −15 tests/Symfony/Tests/Components/DomCrawler/Field/FileFormFieldTest.php
  199. +1 −2 tests/Symfony/Tests/Components/DomCrawler/Field/FormFieldTestCase.php
  200. +6 −15 tests/Symfony/Tests/Components/DomCrawler/Field/InputFormFieldTest.php
  201. +2 −5 tests/Symfony/Tests/Components/DomCrawler/Field/TextareaFormFieldTest.php
  202. +12 −30 tests/Symfony/Tests/Components/DomCrawler/FormTest.php
  203. +2 −5 tests/Symfony/Tests/Components/DomCrawler/LinkTest.php
  204. +4 −10 tests/Symfony/Tests/Components/EventDispatcher/EventTest.php
  205. +7 −16 tests/Symfony/Tests/Components/Finder/FinderTest.php
  206. +2 −4 tests/Symfony/Tests/Components/Finder/GlobTest.php
  207. +1 −2 tests/Symfony/Tests/Components/Finder/Iterator/Iterator.php
  208. +5 −12 tests/Symfony/Tests/Components/Finder/Iterator/RealIteratorTestCase.php
  209. +2 −5 tests/Symfony/Tests/Components/Finder/Iterator/SortableIteratorTest.php
  210. +4 −9 tests/Symfony/Tests/Components/Finder/NumberCompareTest.php
  211. +8 −20 tests/Symfony/Tests/Components/HttpKernel/Test/ClientTest.php
  212. +5 −12 tests/Symfony/Tests/Components/OutputEscaper/ArrayDecoratorTest.php
  213. +2 −5 tests/Symfony/Tests/Components/OutputEscaper/EscaperTest.php
  214. +1 −2 tests/Symfony/Tests/Components/OutputEscaper/SafeDecoratorTest.php
  215. +9 −22 tests/Symfony/Tests/Components/Templating/EngineTest.php
  216. +1 −2 tests/Symfony/Tests/Components/Templating/Helper/AssetsTest.php
  217. +4 −10 tests/Symfony/Tests/Components/Templating/Helper/SlotsHelperTest.php
  218. +1 −2 tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php
  219. +5 −12 tests/Symfony/Tests/Components/Yaml/DumperTest.php
  220. +4 −8 tests/Symfony/Tests/Components/Yaml/InlineTest.php
  221. +6 −14 tests/Symfony/Tests/Components/Yaml/ParserTest.php
  222. +2 −4 tests/fixtures/Symfony/Components/DependencyInjection/php/services9.php
  223. +1 −2 tests/lib/SymfonyTests/Components/Templating/ProjectTemplateDebugger.php
View
44 src/Symfony/Components/BrowserKit/Client.php
@@ -75,8 +75,7 @@ public function followRedirects($followRedirect = true)
*/
public function insulate($insulated = true)
{
- if (!class_exists('Symfony\\Components\\Process\\Process'))
- {
+ if (!class_exists('Symfony\\Components\\Process\\Process')) {
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.');
// @codeCoverageIgnoreEnd
@@ -189,8 +188,7 @@ public function request($method, $uri, $parameters = array(), $headers = array()
$uri = $this->getAbsoluteUri($uri);
$server = array_merge($this->server, $server);
- if (!$this->history->isEmpty())
- {
+ if (!$this->history->isEmpty()) {
$server['HTTP_REFERER'] = $this->history->current()->getUri();
}
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
@@ -200,17 +198,13 @@ public function request($method, $uri, $parameters = array(), $headers = array()
$this->request = $this->filterRequest($request);
- if (true === $changeHistory)
- {
+ if (true === $changeHistory) {
$this->history->add($request);
}
- if ($this->insulated)
- {
+ if ($this->insulated) {
$this->response = $this->doRequestInProcess($this->request);
- }
- else
- {
+ } else {
$this->response = $this->doRequest($this->request);
}
@@ -220,8 +214,7 @@ public function request($method, $uri, $parameters = array(), $headers = array()
$this->redirect = $response->getHeader('Location');
- if ($this->followRedirects && $this->redirect)
- {
+ if ($this->followRedirects && $this->redirect) {
return $this->crawler = $this->followRedirect();
}
@@ -242,8 +235,7 @@ protected function doRequestInProcess($request)
$process = new PhpProcess($this->getScript($request));
$process->run();
- if ($process->getExitCode() > 0)
- {
+ if ($process->getExitCode() > 0) {
throw new \RuntimeException($process->getErrorOutput());
}
@@ -324,8 +316,7 @@ public function reload()
*/
public function followRedirect()
{
- if (empty($this->redirect))
- {
+ if (empty($this->redirect)) {
throw new \LogicException('The request was not redirected.');
}
@@ -346,35 +337,28 @@ public function restart()
protected function getAbsoluteUri($uri)
{
// already absolute?
- if ('http' === substr($uri, 0, 4))
- {
+ if ('http' === substr($uri, 0, 4)) {
return $uri;
}
- if (!$this->history->isEmpty())
- {
+ if (!$this->history->isEmpty()) {
$currentUri = $this->history->current()->getUri();
- }
- else
- {
+ } else {
$currentUri = sprintf('http%s://%s/',
isset($this->server['HTTPS']) ? 's' : '',
isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost'
);
}
// anchor?
- if (!$uri || '#' == $uri[0])
- {
+ if (!$uri || '#' == $uri[0]) {
return preg_replace('/#.*?$/', '', $currentUri).$uri;
}
- if ('/' !== $uri[0])
- {
+ if ('/' !== $uri[0]) {
$path = parse_url($currentUri, PHP_URL_PATH);
- if ('/' !== substr($path, -1))
- {
+ if ('/' !== substr($path, -1)) {
$path = substr($path, 0, strrpos($path, '/') + 1);
}
View
15 src/Symfony/Components/BrowserKit/CookieJar.php
@@ -71,8 +71,7 @@ public function clear()
*/
public function updateFromResponse(Response $response)
{
- foreach ($response->getCookies() as $name => $cookie)
- {
+ foreach ($response->getCookies() as $name => $cookie) {
$this->set(new Cookie(
$name,
isset($cookie['value']) ? $cookie['value'] : '',
@@ -110,20 +109,17 @@ public function getValues($uri)
$parts = parse_url($uri);
$cookies = array();
- foreach ($this->cookieJar as $cookie)
- {
+ foreach ($this->cookieJar as $cookie) {
if ($cookie->getDomain() && $cookie->getDomain() != substr($parts['host'], -strlen($cookie->getDomain())))
{
continue;
}
- if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath())))
- {
+ if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath()))) {
continue;
}
- if ($cookie->isSecure() && 'https' != $parts['scheme'])
- {
+ if ($cookie->isSecure() && 'https' != $parts['scheme']) {
continue;
}
@@ -139,8 +135,7 @@ public function getValues($uri)
public function flushExpiredCookies()
{
$cookies = $this->cookieJar;
- foreach ($cookies as $name => $cookie)
- {
+ foreach ($cookies as $name => $cookie) {
if ($cookie->isExpired())
{
unset($this->cookieJar[$name]);
View
9 src/Symfony/Components/BrowserKit/History.php
@@ -71,8 +71,7 @@ public function isEmpty()
*/
public function back()
{
- if ($this->position < 1)
- {
+ if ($this->position < 1) {
throw new \LogicException('You are already on the first page.');
}
@@ -88,8 +87,7 @@ public function back()
*/
public function forward()
{
- if ($this->position > count($this->stack) - 2)
- {
+ if ($this->position > count($this->stack) - 2) {
throw new \LogicException('You are already on the last page.');
}
@@ -105,8 +103,7 @@ public function forward()
*/
public function current()
{
- if (-1 == $this->position)
- {
+ if (-1 == $this->position) {
throw new \LogicException('The page history is empty.');
}
View
9 src/Symfony/Components/BrowserKit/Response.php
@@ -44,12 +44,10 @@ public function __construct($content = '', $status = 200, $headers = array(), $c
public function __toString()
{
$headers = '';
- foreach ($this->headers as $name => $value)
- {
+ foreach ($this->headers as $name => $value) {
$headers .= sprintf("%s: %s\n", $name, $value);
}
- foreach ($this->cookies as $name => $cookie)
- {
+ foreach ($this->cookies as $name => $cookie) {
$headers .= sprintf("Set-Cookie: %s=%s\n", $name, $cookie['value']);
}
@@ -95,8 +93,7 @@ public function getHeaders()
*/
public function getHeader($header)
{
- foreach ($this->headers as $key => $value)
- {
+ foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header)))
{
return $value;
View
170 src/Symfony/Components/Console/Application.php
@@ -104,22 +104,17 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
- if (null === $input)
- {
+ if (null === $input) {
$input = new ArgvInput();
}
- if (null === $output)
- {
+ if (null === $output) {
$output = new ConsoleOutput();
}
- try
- {
+ try {
$statusCode = $this->doRun($input, $output);
- }
- catch (\Exception $e)
- {
+ } catch (\Exception $e) {
if (!$this->catchExceptions)
{
throw $e;
@@ -131,14 +126,11 @@ public function run(InputInterface $input = null, OutputInterface $output = null
$statusCode = is_numeric($statusCode) && $statusCode ? $statusCode : 1;
}
- if ($this->autoExit)
- {
+ if ($this->autoExit) {
// @codeCoverageIgnoreStart
exit($statusCode);
// @codeCoverageIgnoreEnd
- }
- else
- {
+ } else {
return $statusCode;
}
}
@@ -155,47 +147,37 @@ public function doRun(InputInterface $input, OutputInterface $output)
{
$name = $input->getFirstArgument('command');
- if (true === $input->hasParameterOption(array('--color', '-c')))
- {
+ if (true === $input->hasParameterOption(array('--color', '-c'))) {
$output->setDecorated(true);
}
- if (true === $input->hasParameterOption(array('--help', '-H')))
- {
+ if (true === $input->hasParameterOption(array('--help', '-H'))) {
if (!$name)
{
$name = 'help';
$input = new ArrayInput(array('command' => 'help'));
- }
- else
- {
+ } else {
$this->wantHelps = true;
}
}
- if (true === $input->hasParameterOption(array('--no-interaction', '-n')))
- {
+ if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
$input->setInteractive(false);
}
- if (true === $input->hasParameterOption(array('--quiet', '-q')))
- {
+ if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
$output->setVerbosity(Output::VERBOSITY_QUIET);
- }
- elseif (true === $input->hasParameterOption(array('--verbose', '-v')))
- {
+ } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
}
- if (true === $input->hasParameterOption(array('--version', '-V')))
- {
+ if (true === $input->hasParameterOption(array('--version', '-V'))) {
$output->writeln($this->getLongVersion());
return 0;
}
- if (!$name)
- {
+ if (!$name) {
$name = 'list';
$input = new ArrayInput(array('command' => 'list'));
}
@@ -255,8 +237,7 @@ public function getHelp()
'<comment>Options:</comment>',
);
- foreach ($this->definition->getOptions() as $option)
- {
+ foreach ($this->definition->getOptions() as $option) {
$messages[] = sprintf(' %-29s %s %s',
'<info>--'.$option->getName().'</info>',
$option->getShortcut() ? '<info>-'.$option->getShortcut().'</info>' : ' ',
@@ -334,12 +315,9 @@ public function setVersion($version)
*/
public function getLongVersion()
{
- if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion())
- {
+ if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {
return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
- }
- else
- {
+ } else {
return '<info>Console Tool</info>';
}
}
@@ -363,8 +341,7 @@ public function register($name)
*/
public function addCommands(array $commands)
{
- foreach ($commands as $command)
- {
+ foreach ($commands as $command) {
$this->addCommand($command);
}
}
@@ -384,8 +361,7 @@ public function addCommand(Command $command)
$this->commands[$command->getFullName()] = $command;
- foreach ($command->getAliases() as $alias)
- {
+ foreach ($command->getAliases() as $alias) {
$this->aliases[$alias] = $command;
}
@@ -403,15 +379,13 @@ public function addCommand(Command $command)
*/
public function getCommand($name)
{
- if (!isset($this->commands[$name]) && !isset($this->aliases[$name]))
- {
+ if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name));
}
$command = isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
- if ($this->wantHelps)
- {
+ if ($this->wantHelps) {
$this->wantHelps = false;
$helpCommand = $this->getCommand('help');
@@ -445,8 +419,7 @@ public function hasCommand($name)
public function getNamespaces()
{
$namespaces = array();
- foreach ($this->commands as $command)
- {
+ foreach ($this->commands as $command) {
if ($command->getNamespace())
{
$namespaces[$command->getNamespace()] = true;
@@ -467,13 +440,11 @@ public function findNamespace($namespace)
{
$abbrevs = static::getAbbreviations($this->getNamespaces());
- if (!isset($abbrevs[$namespace]))
- {
+ if (!isset($abbrevs[$namespace])) {
throw new \InvalidArgumentException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
}
- if (count($abbrevs[$namespace]) > 1)
- {
+ if (count($abbrevs[$namespace]) > 1) {
throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$namespace])));
}
@@ -496,8 +467,7 @@ public function findCommand($name)
{
// namespace
$namespace = '';
- if (false !== $pos = strrpos($name, ':'))
- {
+ if (false !== $pos = strrpos($name, ':')) {
$namespace = $this->findNamespace(substr($name, 0, $pos));
$name = substr($name, $pos + 1);
}
@@ -506,36 +476,31 @@ public function findCommand($name)
// name
$commands = array();
- foreach ($this->commands as $command)
- {
+ foreach ($this->commands as $command) {
if ($command->getNamespace() == $namespace)
{
$commands[] = $command->getName();
}
}
$abbrevs = static::getAbbreviations($commands);
- if (isset($abbrevs[$name]) && 1 == count($abbrevs[$name]))
- {
+ if (isset($abbrevs[$name]) && 1 == count($abbrevs[$name])) {
return $this->getCommand($namespace ? $namespace.':'.$abbrevs[$name][0] : $abbrevs[$name][0]);
}
- if (isset($abbrevs[$name]) && count($abbrevs[$name]) > 1)
- {
+ if (isset($abbrevs[$name]) && count($abbrevs[$name]) > 1) {
$suggestions = $this->getAbbreviationSuggestions(array_map(function ($command) use ($namespace) { return $namespace.':'.$command; }, $abbrevs[$name]));
throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $suggestions));
}
// aliases
$abbrevs = static::getAbbreviations(array_keys($this->aliases));
- if (!isset($abbrevs[$fullName]))
- {
+ if (!isset($abbrevs[$fullName])) {
throw new \InvalidArgumentException(sprintf('Command "%s" is not defined.', $fullName));
}
- if (count($abbrevs[$fullName]) > 1)
- {
+ if (count($abbrevs[$fullName]) > 1) {
throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $this->getAbbreviationSuggestions($abbrevs[$fullName])));
}
@@ -553,14 +518,12 @@ public function findCommand($name)
*/
public function getCommands($namespace = null)
{
- if (null === $namespace)
- {
+ if (null === $namespace) {
return $this->commands;
}
$commands = array();
- foreach ($this->commands as $name => $command)
- {
+ foreach ($this->commands as $name => $command) {
if ($namespace === $command->getNamespace())
{
$commands[$name] = $command;
@@ -580,25 +543,20 @@ public function getCommands($namespace = null)
static public function getAbbreviations($names)
{
$abbrevs = array();
- foreach ($names as $name)
- {
+ foreach ($names as $name) {
for ($len = strlen($name) - 1; $len > 0; --$len)
{
$abbrev = substr($name, 0, $len);
- if (!isset($abbrevs[$abbrev]))
- {
+ if (!isset($abbrevs[$abbrev])) {
$abbrevs[$abbrev] = array($name);
- }
- else
- {
+ } else {
$abbrevs[$abbrev][] = $name;
}
}
}
// Non-abbreviations always get entered, even if they aren't unique
- foreach ($names as $name)
- {
+ foreach ($names as $name) {
$abbrevs[$name] = array($name);
}
@@ -617,32 +575,26 @@ public function asText($namespace = null)
$commands = $namespace ? $this->getCommands($this->findNamespace($namespace)) : $this->commands;
$messages = array($this->getHelp(), '');
- if ($namespace)
- {
+ if ($namespace) {
$messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $namespace);
- }
- else
- {
+ } else {
$messages[] = '<comment>Available commands:</comment>';
}
$width = 0;
- foreach ($commands as $command)
- {
+ foreach ($commands as $command) {
$width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
}
$width += 2;
// add commands by namespace
- foreach ($this->sortCommands($commands) as $space => $commands)
- {
+ foreach ($this->sortCommands($commands) as $space => $commands) {
if (!$namespace && '_global' !== $space)
{
$messages[] = '<comment>'.$space.'</comment>';
}
- foreach ($commands as $command)
- {
+ foreach ($commands as $command) {
$aliases = $command->getAliases() ? '<comment> ('.implode(', ', $command->getAliases()).')</comment>' : '';
$messages[] = sprintf(" <info>%-${width}s</info> %s%s", ($command->getNamespace() ? ':' : '').$command->getName(), $command->getDescription(), $aliases);
@@ -670,26 +622,21 @@ public function asXml($namespace = null, $asDom = false)
$xml->appendChild($commandsXML = $dom->createElement('commands'));
- if ($namespace)
- {
+ if ($namespace) {
$commandsXML->setAttribute('namespace', $namespace);
- }
- else
- {
+ } else {
$xml->appendChild($namespacesXML = $dom->createElement('namespaces'));
}
// add commands by namespace
- foreach ($this->sortCommands($commands) as $space => $commands)
- {
+ foreach ($this->sortCommands($commands) as $space => $commands) {
if (!$namespace)
{
$namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
$namespaceArrayXML->setAttribute('id', $space);
}
- foreach ($commands as $command)
- {
+ foreach ($commands as $command) {
if (!$namespace)
{
$namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
@@ -725,36 +672,31 @@ public function renderException($e, $output)
$title = sprintf(' [%s] ', get_class($e));
$len = $strlen($title);
$lines = array();
- foreach (explode("\n", $e->getMessage()) as $line)
- {
+ foreach (explode("\n", $e->getMessage()) as $line) {
$lines[] = sprintf(' %s ', $line);
$len = max($strlen($line) + 4, $len);
}
$messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title)));
- foreach ($lines as $line)
- {
+ foreach ($lines as $line) {
$messages[] = $line.str_repeat(' ', $len - $strlen($line));
}
$messages[] = str_repeat(' ', $len);
$output->writeln("\n");
- foreach ($messages as $message)
- {
+ foreach ($messages as $message) {
$output->writeln('<error>'.$message.'</error>');
}
$output->writeln("\n");
- if (null !== $this->runningCommand)
- {
+ if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
$output->writeln("\n");
}
- if (Output::VERBOSITY_VERBOSE === $output->getVerbosity())
- {
+ if (Output::VERBOSITY_VERBOSE === $output->getVerbosity()) {
$output->writeln('</comment>Exception trace:</comment>');
// exception related properties
@@ -766,8 +708,7 @@ public function renderException($e, $output)
'args' => array(),
));
- for ($i = 0, $count = count($trace); $i < $count; $i++)
- {
+ for ($i = 0, $count = count($trace); $i < $count; $i++) {
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
$function = $trace[$i]['function'];
@@ -784,21 +725,18 @@ public function renderException($e, $output)
private function sortCommands($commands)
{
$namespacedCommands = array();
- foreach ($commands as $name => $command)
- {
+ foreach ($commands as $name => $command) {
$key = $command->getNamespace() ? $command->getNamespace() : '_global';
- if (!isset($namespacedCommands[$key]))
- {
+ if (!isset($namespacedCommands[$key])) {
$namespacedCommands[$key] = array();
}
$namespacedCommands[$key][$name] = $command;
}
ksort($namespacedCommands);
- foreach ($namespacedCommands as $name => &$commands)
- {
+ foreach ($namespacedCommands as $name => &$commands) {
ksort($commands);
}
View
52 src/Symfony/Components/Console/Command/Command.php
@@ -53,15 +53,13 @@ public function __construct($name = null)
$this->applicationDefinitionMerged = false;
$this->aliases = array();
- if (null !== $name)
- {
+ if (null !== $name) {
$this->setName($name);
}
$this->configure();
- if (!$this->name)
- {
+ if (!$this->name) {
throw new \LogicException('The command name cannot be empty.');
}
}
@@ -133,12 +131,9 @@ public function run(InputInterface $input, OutputInterface $output)
$this->mergeApplicationDefinition();
// bind the input against the command specific arguments/options
- try
- {
+ try {
$input->bind($this->definition);
- }
- catch (\Exception $e)
- {
+ } catch (\Exception $e) {
if (!$this->ignoreValidationErrors)
{
throw $e;
@@ -147,19 +142,15 @@ public function run(InputInterface $input, OutputInterface $output)
$this->initialize($input, $output);
- if ($input->isInteractive())
- {
+ if ($input->isInteractive()) {
$this->interact($input, $output);
}
$input->validate();
- if ($this->code)
- {
+ if ($this->code) {
return call_user_func($this->code, $input, $output);
- }
- else
- {
+ } else {
return $this->execute($input, $output);
}
}
@@ -183,8 +174,7 @@ public function setCode(\Closure $code)
*/
protected function mergeApplicationDefinition()
{
- if (null === $this->application || true === $this->applicationDefinitionMerged)
- {
+ if (null === $this->application || true === $this->applicationDefinitionMerged) {
return;
}
@@ -207,12 +197,9 @@ protected function mergeApplicationDefinition()
*/
public function setDefinition($definition)
{
- if ($definition instanceof InputDefinition)
- {
+ if ($definition instanceof InputDefinition) {
$this->definition = $definition;
- }
- else
- {
+ } else {
$this->definition->setDefinition($definition);
}
@@ -282,18 +269,14 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
*/
public function setName($name)
{
- if (false !== $pos = strrpos($name, ':'))
- {
+ if (false !== $pos = strrpos($name, ':')) {
$namespace = substr($name, 0, $pos);
$name = substr($name, $pos + 1);
- }
- else
- {
+ } else {
$namespace = $this->namespace;
}
- if (!$name)
- {
+ if (!$name) {
throw new \InvalidArgumentException('A command name cannot be empty.');
}
@@ -478,15 +461,13 @@ public function asText()
'',
);
- if ($this->getAliases())
- {
+ if ($this->getAliases()) {
$messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
}
$messages[] = $this->definition->asText();
- if ($help = $this->getProcessedHelp())
- {
+ if ($help = $this->getProcessedHelp()) {
$messages[] = '<comment>Help:</comment>';
$messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
}
@@ -521,8 +502,7 @@ public function asXml($asDom = false)
$helpXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $help))));
$commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
- foreach ($this->getAliases() as $alias)
- {
+ foreach ($this->getAliases() as $alias) {
$aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
$aliasXML->appendChild($dom->createTextNode($alias));
}
View
10 src/Symfony/Components/Console/Command/HelpCommand.php
@@ -66,17 +66,13 @@ public function setCommand(Command $command)
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- if (null === $this->command)
- {
+ if (null === $this->command) {
$this->command = $this->application->getCommand($input->getArgument('command_name'));
}
- if ($input->getOption('xml'))
- {
+ if ($input->getOption('xml')) {
$output->writeln($this->command->asXml(), Output::OUTPUT_RAW);
- }
- else
- {
+ } else {
$output->writeln($this->command->asText());
}
}
View
7 src/Symfony/Components/Console/Command/ListCommand.php
@@ -60,12 +60,9 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- if ($input->getOption('xml'))
- {
+ if ($input->getOption('xml')) {
$output->writeln($this->application->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW);
- }
- else
- {
+ } else {
$output->writeln($this->application->asText($input->getArgument('namespace')));
}
}
View
20 src/Symfony/Components/Console/Helper/DialogHelper.php
@@ -57,17 +57,13 @@ public function askConfirmation(OutputInterface $output, $question, $default = t
{
// @codeCoverageIgnoreStart
$answer = 'z';
- while ($answer && !in_array(strtolower($answer[0]), array('y', 'n')))
- {
+ while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {
$answer = $this->ask($output, $question);
}
- if (false === $default)
- {
+ if (false === $default) {
return $answer && 'y' == strtolower($answer[0]);
- }
- else
- {
+ } else {
return !$answer || 'y' == strtolower($answer[0]);
}
// @codeCoverageIgnoreEnd
@@ -89,21 +85,17 @@ public function askAndValidate(OutputInterface $output, $question, \Closure $val
{
// @codeCoverageIgnoreStart
$error = null;
- while (false === $attempts || $attempts--)
- {
+ while (false === $attempts || $attempts--) {
if (null !== $error)
{
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
}
$value = $this->ask($output, $question, null);
- try
- {
+ try {
return $validator($value);
- }
- catch (\Exception $error)
- {
+ } catch (\Exception $error) {
}
}
View
15 src/Symfony/Components/Console/Helper/FormatterHelper.php
@@ -43,31 +43,26 @@ public function formatSection($section, $message, $style = 'info')
*/
public function formatBlock($messages, $style, $large = false)
{
- if (!is_array($messages))
- {
+ if (!is_array($messages)) {
$messages = array($messages);
}
$len = 0;
$lines = array();
- foreach ($messages as $message)
- {
+ foreach ($messages as $message) {
$lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
$len = max($this->strlen($message) + ($large ? 4 : 2), $len);
}
$messages = $large ? array(str_repeat(' ', $len)) : array();
- foreach ($lines as $line)
- {
+ foreach ($lines as $line) {
$messages[] = $line.str_repeat(' ', $len - $this->strlen($line));
}
- if ($large)
- {
+ if ($large) {
$messages[] = str_repeat(' ', $len);
}
- foreach ($messages as &$message)
- {
+ foreach ($messages as &$message) {
$message = sprintf('<%s>%s</%s>', $style, $message, $style);
}
View
9 src/Symfony/Components/Console/Helper/HelperSet.php
@@ -31,8 +31,7 @@ class HelperSet
*/
public function __construct(array $helpers = array())
{
- foreach ($helpers as $alias => $helper)
- {
+ foreach ($helpers as $alias => $helper) {
$this->set($helper, is_int($alias) ? null : $alias);
}
}
@@ -46,8 +45,7 @@ public function __construct(array $helpers = array())
public function set(HelperInterface $helper, $alias = null)
{
$this->helpers[$helper->getName()] = $helper;
- if (null !== $alias)
- {
+ if (null !== $alias) {
$this->helpers[$alias] = $helper;
}
@@ -77,8 +75,7 @@ public function has($name)
*/
public function get($name)
{
- if (!$this->has($name))
- {
+ if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
}
View
73 src/Symfony/Components/Console/Input/ArgvInput.php
@@ -51,8 +51,7 @@ class ArgvInput extends Input
*/
public function __construct(array $argv = null, InputDefinition $definition = null)
{
- if (null === $argv)
- {
+ if (null === $argv) {
$argv = $_SERVER['argv'];
}
@@ -70,18 +69,13 @@ public function __construct(array $argv = null, InputDefinition $definition = nu
protected function parse()
{
$this->parsed = $this->tokens;
- while (null !== $token = array_shift($this->parsed))
- {
+ while (null !== $token = array_shift($this->parsed)) {
if ('--' === substr($token, 0, 2))
{
$this->parseLongOption($token);
- }
- elseif ('-' === $token[0])
- {
+ } elseif ('-' === $token[0]) {
$this->parseShortOption($token);
- }
- else
- {
+ } else {
$this->parseArgument($token);
}
}
@@ -96,20 +90,15 @@ protected function parseShortOption($token)
{
$name = substr($token, 1);
- if (strlen($name) > 1)
- {
+ if (strlen($name) > 1) {
if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptParameter())
{
// an option with a value (with no space)
$this->addShortOption($name[0], substr($name, 1));
- }
- else
- {
+ } else {
$this->parseShortOptionSet($name);
}
- }
- else
- {
+ } else {
$this->addShortOption($name, null);
}
}
@@ -124,22 +113,18 @@ protected function parseShortOption($token)
protected function parseShortOptionSet($name)
{
$len = strlen($name);
- for ($i = 0; $i < $len; $i++)
- {
+ for ($i = 0; $i < $len; $i++) {
if (!$this->definition->hasShortcut($name[$i]))
{
throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i]));
}
$option = $this->definition->getOptionForShortcut($name[$i]);
- if ($option->acceptParameter())
- {
+ if ($option->acceptParameter()) {
$this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
break;
- }
- else
- {
+ } else {
$this->addLongOption($option->getName(), true);
}
}
@@ -154,12 +139,9 @@ protected function parseLongOption($token)
{
$name = substr($token, 2);
- if (false !== $pos = strpos($name, '='))
- {
+ if (false !== $pos = strpos($name, '=')) {
$this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1));
- }
- else
- {
+ } else {
$this->addLongOption($name, null);
}
}
@@ -173,8 +155,7 @@ protected function parseLongOption($token)
*/
protected function parseArgument($token)
{
- if (!$this->definition->hasArgument(count($this->arguments)))
- {
+ if (!$this->definition->hasArgument(count($this->arguments))) {
throw new \RuntimeException('Too many arguments.');
}
@@ -191,8 +172,7 @@ protected function parseArgument($token)
*/
protected function addShortOption($shortcut, $value)
{
- if (!$this->definition->hasShortcut($shortcut))
- {
+ if (!$this->definition->hasShortcut($shortcut)) {
throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
}
@@ -209,30 +189,24 @@ protected function addShortOption($shortcut, $value)
*/
protected function addLongOption($name, $value)
{
- if (!$this->definition->hasOption($name))
- {
+ if (!$this->definition->hasOption($name)) {
throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name));
}
$option = $this->definition->getOption($name);
- if (null === $value && $option->acceptParameter())
- {
+ if (null === $value && $option->acceptParameter()) {
// if option accepts an optional or mandatory argument
// let's see if there is one provided
$next = array_shift($this->parsed);
- if ('-' !== $next[0])
- {
+ if ('-' !== $next[0]) {
$value = $next;
- }
- else
- {
+ } else {
array_unshift($this->parsed, $next);
}
}
- if (null === $value)
- {
+ if (null === $value) {
if ($option->isParameterRequired())
{
throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name));
@@ -251,8 +225,7 @@ protected function addLongOption($name, $value)
*/
public function getFirstArgument()
{
- foreach ($this->tokens as $token)
- {
+ foreach ($this->tokens as $token) {
if ($token && '-' === $token[0])
{
continue;
@@ -274,13 +247,11 @@ public function getFirstArgument()
*/
public function hasParameterOption($values)
{
- if (!is_array($values))
- {
+ if (!is_array($values)) {
$values = array($values);
}
- foreach ($this->tokens as $v)
- {
+ foreach ($this->tokens as $v) {
if (in_array($v, $values))
{
return true;
View
35 src/Symfony/Components/Console/Input/ArrayInput.php
@@ -46,8 +46,7 @@ public function __construct(array $parameters, InputDefinition $definition = nul
*/
public function getFirstArgument()
{
- foreach ($this->parameters as $key => $value)
- {
+ foreach ($this->parameters as $key => $value) {
if ($key && '-' === $key[0])
{
continue;
@@ -69,20 +68,17 @@ public function getFirstArgument()
*/
public function hasParameterOption($values)
{
- if (!is_array($values))
- {
+ if (!is_array($values)) {
$values = array($values);
}
- foreach ($this->parameters as $k => $v)
- {
+ foreach ($this->parameters as $k => $v) {
if (!is_int($k))
{
$v = $k;
}
- if (in_array($v, $values))
- {
+ if (in_array($v, $values)) {
return true;
}
}
@@ -95,18 +91,13 @@ public function hasParameterOption($values)
*/
protected function parse()
{
- foreach ($this->parameters as $key => $value)
- {
+ foreach ($this->parameters as $key => $value) {
if ('--' === substr($key, 0, 2))
{
$this->addLongOption(substr($key, 2), $value);
- }
- elseif ('-' === $key[0])
- {
+ } elseif ('-' === $key[0]) {
$this->addShortOption(substr($key, 1), $value);
- }
- else
- {
+ } else {
$this->addArgument($key, $value);
}
}
@@ -122,8 +113,7 @@ protected function parse()
*/
protected function addShortOption($shortcut, $value)
{
- if (!$this->definition->hasShortcut($shortcut))
- {
+ if (!$this->definition->hasShortcut($shortcut)) {
throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
}
@@ -141,15 +131,13 @@ protected function addShortOption($shortcut, $value)
*/
protected function addLongOption($name, $value)
{
- if (!$this->definition->hasOption($name))
- {
+ if (!$this->definition->hasOption($name)) {
throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
}
$option = $this->definition->getOption($name);
- if (null === $value)
- {
+ if (null === $value) {
if ($option->isParameterRequired())
{
throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name));
@@ -171,8 +159,7 @@ protected function addLongOption($name, $value)
*/
protected function addArgument($name, $value)
{
- if (!$this->definition->hasArgument($name))
- {
+ if (!$this->definition->hasArgument($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
View
22 src/Symfony/Components/Console/Input/Input.php
@@ -38,12 +38,9 @@
*/
public function __construct(InputDefinition $definition = null)
{
- if (null === $definition)
- {
+ if (null === $definition) {
$this->definition = new InputDefinition();
- }
- else
- {
+ } else {
$this->bind($definition);
$this->validate();
}
@@ -73,8 +70,7 @@ public function bind(InputDefinition $definition)
*/
public function validate()
{
- if (count($this->arguments) < $this->definition->getArgumentRequiredCount())
- {
+ if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) {
throw new \RuntimeException('Not enough arguments.');
}
}
@@ -110,8 +106,7 @@ public function getArguments()
*/
public function getArgument($name)
{
- if (!$this->definition->hasArgument($name))
- {
+ if (!$this->definition->hasArgument($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
@@ -128,8 +123,7 @@ public function getArgument($name)
*/
public function setArgument($name, $value)
{
- if (!$this->definition->hasArgument($name))
- {
+ if (!$this->definition->hasArgument($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
@@ -169,8 +163,7 @@ public function getOptions()
*/
public function getOption($name)
{
- if (!$this->definition->hasOption($name))
- {
+ if (!$this->definition->hasOption($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
}
@@ -187,8 +180,7 @@ public function getOption($name)
*/
public function setOption($name, $value)
{
- if (!$this->definition->hasOption($name))
- {
+ if (!$this->definition->hasOption($name)) {
throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
}
View
17 src/Symfony/Components/Console/Input/InputArgument.php
@@ -41,12 +41,9 @@ class InputArgument
*/
public function __construct($name, $mode = null, $description = '', $default = null)
{
- if (null === $mode)
- {
+ if (null === $mode) {
$mode = self::OPTIONAL;
- }
- else if (is_string($mode) || $mode > 7)
- {
+ } else if (is_string($mode) || $mode > 7) {
throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
}
@@ -96,19 +93,15 @@ public function isArray()
*/
public function setDefault($default = null)
{
- if (self::REQUIRED === $this->mode && null !== $default)
- {
+ if (self::REQUIRED === $this->mode && null !== $default) {
throw new \LogicException('Cannot set a default value except for Parameter::OPTIONAL mode.');
}
- if ($this->isArray())
- {
+ if ($this->isArray()) {
if (null === $default)
{
$default = array();
- }
- else if (!is_array($default))
- {
+ } else if (!is_array($default)) {
throw new \LogicException('A default value for an array argument must be an array.');
}
}
View
107 src/Symfony/Components/Console/Input/InputDefinition.php
@@ -48,14 +48,11 @@ public function setDefinition(array $definition)
{
$arguments = array();
$options = array();
- foreach ($definition as $item)
- {
+ foreach ($definition as $item) {
if ($item instanceof InputOption)
{
$options[] = $item;
- }
- else
- {
+ } else {
$arguments[] = $item;
}
}
@@ -84,8 +81,7 @@ public function setArguments($arguments = array())
*/
public function addArguments($arguments = array())
{
- if (null !== $arguments)
- {
+ if (null !== $arguments) {
foreach ($arguments as $argument)
{
$this->addArgument($argument);
@@ -102,32 +98,25 @@ public function addArguments($arguments = array())
*/
public function addArgument(InputArgument $argument)
{
- if (isset($this->arguments[$argument->getName()]))
- {
+ if (isset($this->arguments[$argument->getName()])) {
throw new \LogicException(sprintf('An argument with name "%s" already exist.', $argument->getName()));
}
- if ($this->hasAnArrayArgument)
- {
+ if ($this->hasAnArrayArgument) {
throw new \LogicException('Cannot add an argument after an array argument.');
}
- if ($argument->isRequired() && $this->hasOptional)
- {
+ if ($argument->isRequired() && $this->hasOptional) {
throw new \LogicException('Cannot add a required argument after an optional one.');
}
- if ($argument->isArray())
- {
+ if ($argument->isArray()) {
$this->hasAnArrayArgument = true;
}
- if ($argument->isRequired())
- {