8000 CS: use nowdoc instead of heredoc by gharlan · Pull Request #17086 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

CS: use nowdoc instead of heredoc #17086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
)
;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure()
->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(<<<EOT
->setHelp(<<<'EOT'
The <info>%command.name%</info> command installs bundle assets into a given
directory (e.g. the <comment>web</comment> directory).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure()
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
))
->setDescription('Clears the cache')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command clears the application cache for a given environment
and debug mode:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function configure()
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
))
->setDescription('Warms up an empty cache')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command warms up the cache.

Before running this command, the cache must be empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function configure()
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle or extension alias'),
))
->setDescription('Dumps default configuration for an extension')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command dumps the default configuration for an extension/bundle.

The extension alias or bundle name can be used:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function configure()
new InputOption('parameters', null, InputOption::VALUE_NONE, 'Displays parameters for an application'),
))
->setDescription('Displays current services for an application')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command displays all configured <comment>public</comment> services:

<info>php %command.full_name%</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function configure()
new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'),
))
->setDescription('Dumps all routes as Apache rewrite rules')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> dumps all routes as Apache rewrite rules.
These can then be used with the ApacheUrlMatcher to use Apache for route
matching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function configure()
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
))
->setDescription('Displays current routes for an application')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> displays the configured routes:

<info>php %command.full_name%</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function configure()
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
))
->setDescription('Helps debug routes by simulating a path info match')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> simulates a path info match:

<info>php %command.full_name% /foo</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function configure()
))
->setName('server:run')
->setDescription('Runs PHP built-in web server')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> runs PHP built-in web server:

<info>%command.full_name%</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function configure()
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
))
->setDescription('Updates the translation file')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> 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
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ protected function loadCatalogue($locale)
$fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback));
$currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current));

$fallbackContent .= sprintf(<<<EOF
\$catalogue%s = new MessageCatalogue('%s', %s);
\$catalogue%s->addFallbackCatalogue(\$catalogue%s);
$fallbackContent .= sprintf(<<<'EOF'
$catalogue%s = new MessageCatalogue('%s', %s);
$catalogue%s->addFallbackCatalogue($catalogue%s);


EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function configure()
$this
->setName('init:acl')
->setDescription('Mounts ACL tables in the database')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command mounts ACL tables in the database.

<info>php %command.full_name%</info>
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure()
->setName('twig:lint')
->setDescription('Lints a template and outputs encountered errors')
->addArgument('filename')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command lints a template and outputs to stdout
the first encountered syntax error.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function configure()
->setDefinition(array(
new InputArgument('token', InputArgument::REQUIRED, 'The profile token'),
))
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command exports a profile to the standard output:

<info>php %command.full_name% profile_token</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function configure()
->setDefinition(array(
new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'),
))
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command imports a profile:

<info>php %command.full_name% profile_filepath</info>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,26 @@ public function testCommentStripping()

spl_autoload_unregister($r);

$this->assertEquals(<<<EOF
$this->assertEquals(<<<'EOF'
namespace Namespaced
{
class WithComments
{
public static \$loaded = true;
public static $loaded = true;
}
\$string ='string should not be modified {\$string}';
\$heredoc = (<<<HD
$string ='string should not be modified {$string}';
$heredoc = (<<<HD


Heredoc should not be modified {\$string}
Heredoc should not be modified {$string}


HD
);
\$nowdoc =<<<'ND'
$nowdoc =<<<'ND'


Nowdoc should not be modified {\$string}
Nowdoc should not be modified {$string}


ND
Expand All @@ -270,7 +270,7 @@ class WithComments
{
class Pearlike_WithComments
{
public static \$loaded = true;
public static $loaded = true;
}
}
EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testDumper()

private function getConfigurationAsString()
{
return <<<EOL
return <<<'EOL'
root:
boolean: true
scalar_empty: ~
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function configure()
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
))
->setDescription('Displays help for a command')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command displays help for a given command:

<info>php %command.full_name% list</info>
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure()
->setName('list')
->setDefinition($this->createDefinition())
->setDescription('Lists commands')
->setHelp(<<<EOF
->setHelp(<<<'EOF'
The <info>%command.name%</info> command lists all commands:

<info>php %command.full_name%</info>
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function run()
if ($this->processIsolation) {
$finder = new PhpExecutableFinder();
$php = $finder->find();
$this->output->writeln(<<<EOF
$this->output->writeln(<<<'EOF'
<info>Running with process isolation, you should consider this:</info>
* each command is executed as separate process,
* commands don't support interactivity, all params must be passed explicitly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testExecuteListsCommandsWithRawOption()
$application = new Application();
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), '--raw' => true));
$output = <<<EOF
$output = <<<'EOF'
help Displays help for a command
list Lists commands

Expand All @@ -54,7 +54,7 @@ public function testExecuteListsCommandsWithNamespaceArgument()
$application->add(new \FooCommand());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
$output = <<<EOF
$output = <<<'EOF'
foo:bar The foo:bar command

EOF;
Expand All @@ -69,7 +69,7 @@ public function testExecuteListsCommandsOrder()
$application->add(new \Foo6Command());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
$output = <<<EOF
$output = <<<'EOF'
Console Tool

Usage:
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testExecuteListsCommandsOrderRaw()
$application->add(new \Foo6Command());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), '--raw' => true));
$output = <<<EOF
$output = <<<'EOF'
help Displays help for a command
list Lists commands
0foo:bar 0foo:bar command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function testContentWithLineBreaks()
\033[32m
some text\033[0m
EOF
, $formatter->format(<<<EOF
, $formatter->format(<<<'EOF'
<info>
some text</info>
EOF
Expand All @@ -230,7 +230,7 @@ public function testContentWithLineBreaks()
\033[32msome text
\033[0m
EOF
, $formatter->format(<<<EOF
, $formatter->format(<<<'EOF'
<info>some text
</info>
EOF
Expand All @@ -241,7 +241,7 @@ public function testContentWithLineBreaks()
some text
\033[0m
EOF
, $formatter->format(<<<EOF
, $formatter->format(<<<'EOF'
<info>
some text
</info>
Expand All @@ -254,7 +254,7 @@ public function testContentWithLineBreaks()
more text
\033[0m
EOF
, $formatter->format(<<<EOF
, $formatter->format(<<<'EOF'
<info>
some text
more text
Expand Down
18 changes: 9 additions & 9 deletions src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testRenderProvider()
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+---------------+--------------------------+------------------+
| ISBN | Title | Author |
+---------------+--------------------------+------------------+
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testRenderProvider()
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+---------------+--------------------------+------------------+
| ISBN | Title | |
+---------------+--------------------------+------------------+
Expand All @@ -144,7 +144,7 @@ public function testRenderProvider()
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+---------------+--------------------------+------------------+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
| 9971-5-0210-0 | | |
Expand All @@ -163,7 +163,7 @@ public function testRenderProvider()
array('960-425-059-0', 'The Lord of the Rings', "J. R. R.\nTolkien"),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+---------------+----------------------------+-----------------+
| ISBN | Title | Author |
+---------------+----------------------------+-----------------+
Expand All @@ -183,7 +183,7 @@ public function testRenderProvider()
array('ISBN', 'Title'),
array(),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+------+-------+
| ISBN | Title |
+------+-------+
Expand All @@ -203,7 +203,7 @@ public function testRenderProvider()
array('9971-5-0210-0', 'A Tale of Two Cities', '<info>Charles Dickens</>'),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+---------------+----------------------+-----------------+
| ISBN | Title | Author |
+---------------+----------------------+-----------------+
Expand All @@ -220,7 +220,7 @@ public function testRenderProvider()
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
),
TableHelper::LAYOUT_DEFAULT,
<<<TABLE
<<<'TABLE'
+----------------------------------+----------------------+-----------------+
| ISBN | Title | Author |
+----------------------------------+----------------------+-----------------+
Expand All @@ -247,7 +247,7 @@ public function testRenderMultiByte()
$table->render($output = $this->getOutputStream());

$expected =
<<<TABLE
<<<'TABLE'
+------+
| ■■ |
+------+
Expand All @@ -273,7 +273,7 @@ public function testRenderFullWidthCharacters()
$table->render($output = $this->getOutputStream());

$expected =
<<<TABLE
<<<'TABLE'
+------------+
| あいうえお |
+------------+
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Debug/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getContent(FlattenException $exception)
$ind = $count - $position + 1;
$class = $this->abbrClass($e['class']);
$message = nl2br(htmlspecialchars($e['message'], $flags, $this->charset));
$content .= sprintf(<<<EOF
$content .= sprintf(<<<'EOF'
<div class="block_exception clear_fix">
<h2><span>%d/%d</span> %s: %s</h2>
</div>
Expand Down Expand Up @@ -196,7 +196,7 @@ public function getContent(FlattenException $exception)
*/
public function getStylesheet(FlattenException $exception)
{
return <<<EOF
return <<<'EOF'
.sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
.sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
.sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
Expand Down
Loading
0