merged branch fabpot/fix-heredocs (PR #7417)

This PR was merged into the 2.2 branch.

Commits
-------

601da45 [ClassLoader] fixed heredocs handling

Discussion
----------

[ClassLoader] fixed heredocs handling

The end of an hereodc must have a newline to avoid PHP syntax errors.
This commit is contained in:
Fabien Potencier 2013-03-19 09:33:24 +01:00
commit d7fa84162b
3 changed files with 9 additions and 5 deletions

View File

@ -178,6 +178,7 @@ class ClassCollectionLoader
$token = next($tokens);
$output .= is_string($token) ? $token : $token[1];
} while ($token[0] !== T_END_HEREDOC);
$output .= "\n";
$rawChunk = '';
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
$output .= self::compressCode($rawChunk).$token[1];

View File

@ -228,20 +228,22 @@ class WithComments
public static \$loaded = true;
}
\$string ='string shoult not be modified {\$string}';
\$heredoc =<<<HD
\$heredoc = (<<<HD
Heredoc should not be modified {\$string}
HD;
HD
);
\$nowdoc =<<<'ND'
Nowdoc should not be modified {\$string}
ND;
ND
;
}
namespace
{

View File

@ -19,13 +19,14 @@ class WithComments
$string = 'string shoult not be modified {$string}';
$heredoc = <<<HD
$heredoc = (<<<HD
Heredoc should not be modified {$string}
HD;
HD
);
$nowdoc = <<<'ND'