From 3dca549b95a7f3a3f64efa902c461996e35460bd Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 21 Dec 2015 12:01:57 +0100 Subject: [PATCH 1/8] use nowdoc instead of heredoc --- .php_cs | 2 + .../Command/AssetsInstallCommand.php | 2 +- .../Command/CacheClearCommand.php | 2 +- .../Command/CacheWarmupCommand.php | 2 +- .../Command/ConfigDumpReferenceCommand.php | 2 +- .../Command/ContainerDebugCommand.php | 2 +- .../Command/RouterApacheDumperCommand.php | 2 +- .../Command/RouterDebugCommand.php | 2 +- .../Command/RouterMatchCommand.php | 2 +- .../Command/ServerRunCommand.php | 2 +- .../Command/TranslationUpdateCommand.php | 2 +- .../Translation/Translator.php | 6 +-- .../SecurityBundle/Command/InitAclCommand.php | 2 +- .../Bundle/TwigBundle/Command/LintCommand.php | 2 +- .../Command/ExportCommand.php | 2 +- .../Command/ImportCommand.php | 2 +- .../Tests/ClassCollectionLoaderTest.php | 16 +++---- .../Tests/Definition/ReferenceDumperTest.php | 2 +- .../Component/Console/Command/HelpCommand.php | 2 +- .../Component/Console/Command/ListCommand.php | 2 +- src/Symfony/Component/Console/Shell.php | 2 +- .../Console/Tests/Command/ListCommandTest.php | 8 ++-- .../Tests/Formatter/OutputFormatterTest.php | 8 ++-- .../Console/Tests/Helper/TableHelperTest.php | 18 ++++---- .../Component/Debug/ExceptionHandler.php | 4 +- .../DependencyInjection/Dumper/PhpDumper.php | 44 +++++++++--------- .../DomCrawler/Tests/CrawlerTest.php | 10 ++-- .../Data/Bundle/Writer/PhpBundleWriter.php | 2 +- .../Intl/Resources/bin/update-data.php | 2 +- .../Process/Tests/PhpProcessTest.php | 2 +- .../Generator/Dumper/PhpGeneratorDumper.php | 12 ++--- .../Security/Acl/Dbal/AclProvider.php | 2 +- .../Security/Acl/Dbal/MutableAclProvider.php | 4 +- .../Tests/ConstraintViolationListTest.php | 2 +- .../Tests/ConstraintViolationTest.php | 4 +- .../Component/Yaml/Tests/DumperTest.php | 12 ++--- .../Component/Yaml/Tests/ParserTest.php | 46 +++++++++---------- 37 files changed, 121 insertions(+), 119 deletions(-) diff --git a/.php_cs b/.php_cs index 11d42d1287..290e9bf5fb 100644 --- a/.php_cs +++ b/.php_cs @@ -24,5 +24,7 @@ return Symfony\CS\Config\Config::create() ->notPath('src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml') // test template ->notPath('src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php') + // explicit heredoc test + ->notPath('src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php') ) ; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 61182fa71e..643368976f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -37,7 +37,7 @@ class AssetsInstallCommand extends ContainerAwareCommand ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks') ->setDescription('Installs bundles web assets under a public web directory') - ->setHelp(<<setHelp(<<<'EOT' The %command.name% command installs bundle assets into a given directory (e.g. the web directory). diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index 049179075a..2b0d1bb9c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -37,7 +37,7 @@ class CacheClearCommand extends ContainerAwareCommand new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Clears the cache') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command clears the application cache for a given environment and debug mode: diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php index 71f071105b..ea82751d84 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php @@ -33,7 +33,7 @@ class CacheWarmupCommand extends ContainerAwareCommand new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Warms up an empty cache') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command warms up the cache. Before running this command, the cache must be empty. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 9376b08473..fa978b3ba9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -35,7 +35,7 @@ class ConfigDumpReferenceCommand extends ContainerDebugCommand new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle or extension alias'), )) ->setDescription('Dumps default configuration for an extension') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command dumps the default configuration for an extension/bundle. The extension alias or bundle name can be used: diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index a10760a1b9..67d7451fb5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -49,7 +49,7 @@ class ContainerDebugCommand extends ContainerAwareCommand new InputOption('parameters', null, InputOption::VALUE_NONE, 'Displays parameters for an application'), )) ->setDescription('Displays current services for an application') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command displays all configured public services: php %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php index 904a08d253..0355dd6627 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php @@ -53,7 +53,7 @@ class RouterApacheDumperCommand extends ContainerAwareCommand new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'), )) ->setDescription('Dumps all routes as Apache rewrite rules') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% dumps all routes as Apache rewrite rules. These can then be used with the ApacheUrlMatcher to use Apache for route matching. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 67c5bc9444..84172218aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -51,7 +51,7 @@ class RouterDebugCommand extends ContainerAwareCommand new InputArgument('name', InputArgument::OPTIONAL, 'A route name'), )) ->setDescription('Displays current routes for an application') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% displays the configured routes: php %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index a54f18294f..5ad347ce59 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -52,7 +52,7 @@ class RouterMatchCommand extends ContainerAwareCommand new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'), )) ->setDescription('Helps debug routes by simulating a path info match') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% simulates a path info match: php %command.full_name% /foo diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index d417357cf3..573b67020d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -54,7 +54,7 @@ class ServerRunCommand extends ContainerAwareCommand )) ->setName('server:run') ->setDescription('Runs PHP built-in web server') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% runs PHP built-in web server: %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index bdea20fdf7..5bdc2f86e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -43,7 +43,7 @@ class TranslationUpdateCommand extends ContainerAwareCommand new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), )) ->setDescription('Updates the translation file') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command extract translation strings from templates of a given bundle. It can display them or merge the new ones into the translation files. When new translation strings are found it can automatically add a prefix to the translation diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index f791a63509..75b995dacb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -108,9 +108,9 @@ class Translator extends BaseTranslator $fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback)); $currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current)); - $fallbackContent .= sprintf(<<addFallbackCatalogue(\$catalogue%s); + $fallbackContent .= sprintf(<<<'EOF' +$catalogue%s = new MessageCatalogue('%s', %s); +$catalogue%s->addFallbackCatalogue($catalogue%s); EOF diff --git a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php index 14271dc459..e128596612 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php @@ -43,7 +43,7 @@ class InitAclCommand extends ContainerAwareCommand $this ->setName('init:acl') ->setDescription('Mounts ACL tables in the database') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command mounts ACL tables in the database. php %command.full_name% diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index f164c03847..997f29fefa 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -29,7 +29,7 @@ class LintCommand extends ContainerAwareCommand ->setName('twig:lint') ->setDescription('Lints a template and outputs encountered errors') ->addArgument('filename') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command lints a template and outputs to stdout the first encountered syntax error. diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php index cf405530e2..aef4973090 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php @@ -53,7 +53,7 @@ class ExportCommand extends Command ->setDefinition(array( new InputArgument('token', InputArgument::REQUIRED, 'The profile token'), )) - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command exports a profile to the standard output: php %command.full_name% profile_token diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php index 4862e9c27a..5add381c6a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php @@ -53,7 +53,7 @@ class ImportCommand extends Command ->setDefinition(array( new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'), )) - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command imports a profile: php %command.full_name% profile_filepath diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 5019f26ee8..fb91fadae7 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -241,26 +241,26 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase spl_autoload_unregister($r); - $this->assertEquals(<<assertEquals(<<<'EOF' namespace Namespaced { class WithComments { -public static \$loaded = true; +public static $loaded = true; } -\$string ='string should not be modified {\$string}'; -\$heredoc = (<<setDescription('Displays help for a command') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command displays help for a given command: php %command.full_name% list diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index f3d7438d09..6bd3026ef0 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -34,7 +34,7 @@ class ListCommand extends Command ->setName('list') ->setDefinition($this->createDefinition()) ->setDescription('Lists commands') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command lists all commands: php %command.full_name% diff --git a/src/Symfony/Component/Console/Shell.php b/src/Symfony/Component/Console/Shell.php index d0bcb7ee8a..f95b9a07a9 100644 --- a/src/Symfony/Component/Console/Shell.php +++ b/src/Symfony/Component/Console/Shell.php @@ -68,7 +68,7 @@ class Shell if ($this->processIsolation) { $finder = new PhpExecutableFinder(); $php = $finder->find(); - $this->output->writeln(<<output->writeln(<<<'EOF' Running with process isolation, you should consider this: * each command is executed as separate process, * commands don't support interactivity, all params must be passed explicitly, diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index d5b5bfbdbb..c29ec6b876 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -38,7 +38,7 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); - $output = <<add(new \FooCommand()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true)); - $output = <<add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); - $output = <<add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); - $output = <<format(<<format(<<<'EOF' some text EOF @@ -230,7 +230,7 @@ EOF \033[32msome text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text EOF @@ -241,7 +241,7 @@ EOF some text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text @@ -254,7 +254,7 @@ some text more text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text more text diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php index d862929a0e..c39f04464f 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php @@ -91,7 +91,7 @@ class TableHelperTest extends \PHPUnit_Framework_TestCase array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), ), TableHelper::LAYOUT_DEFAULT, -<<Charles Dickens'), ), TableHelper::LAYOUT_DEFAULT, -<<
render($output = $this->getOutputStream()); $expected = -<<
render($output = $this->getOutputStream()); $expected = - <<
abbrClass($e['class']); $message = nl2br(htmlspecialchars($e['message'], $flags, $this->charset)); - $content .= sprintf(<<

%d/%d %s: %s

@@ -196,7 +196,7 @@ EOF; */ public function getStylesheet(FlattenException $exception) { - return <<isPublic()) { - $doc .= <<addMethodMap(); $code .= $this->addAliases(); - $code .= <<services = - \$this->scopedServices = - \$this->scopeStacks = array(); + $this->services = + $this->scopedServices = + $this->scopeStacks = array(); EOF; $code .= "\n"; @@ -853,7 +853,7 @@ EOF; $code .= $this->addMethodMap(); $code .= $this->addAliases(); - $code .= <<container->isFrozen()) { - $code .= <<parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) { - throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name)); + if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) { + throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } - return \$this->parameters[\$name]; + return $this->parameters[$name]; } /** * {@inheritdoc} */ - public function hasParameter(\$name) + public function hasParameter($name) { - \$name = strtolower(\$name); + $name = strtolower($name); - return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters); + return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters); } /** * {@inheritdoc} */ - public function setParameter(\$name, \$value) + public function setParameter($name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } @@ -963,11 +963,11 @@ EOF; */ public function getParameterBag() { - if (null === \$this->parameterBag) { - \$this->parameterBag = new FrozenParameterBag(\$this->parameters); + if (null === $this->parameterBag) { + $this->parameterBag = new FrozenParameterBag($this->parameters); } - return \$this->parameterBag; + return $this->parameterBag; } EOF; } @@ -1029,7 +1029,7 @@ EOF; */ private function endClass() { - return <<addHtmlContent(<<addHtmlContent(<<<'EOF' @@ -158,7 +158,7 @@ EOF $internalErrors = libxml_use_internal_errors(true); $crawler = new Crawler(); - $crawler->addXmlContent(<<addXmlContent(<<<'EOF' @@ -518,7 +518,7 @@ EOF public function testSelectButtonWithSingleQuotesInNameAttribute() { - $html = << @@ -539,7 +539,7 @@ HTML; public function testSelectButtonWithDoubleQuotesInNameAttribute() { - $html = << @@ -578,7 +578,7 @@ HTML; public function testSelectLinkAndLinkFiltered() { - $html = << diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php index a29972cd02..53d943dcfe 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php @@ -25,7 +25,7 @@ class PhpBundleWriter implements BundleWriterInterface */ public function write($path, $locale, $data) { - $template = <<