Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[ClassLoader] fixed heredocs handling
The end of an hereodc must have a newline to avoid PHP syntax errors.
  • Loading branch information
fabpot committed Mar 19, 2013
1 parent 1fe171b commit 1c37a18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions ClassCollectionLoader.php
Expand Up @@ -178,6 +178,7 @@ public static function fixNamespaceDeclarations($source)
$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];
Expand Down
8 changes: 5 additions & 3 deletions Tests/ClassCollectionLoaderTest.php
Expand Up @@ -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
{
Expand Down
5 changes: 3 additions & 2 deletions Tests/Fixtures/Namespaced/WithComments.php
Expand Up @@ -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'
Expand Down

0 comments on commit 1c37a18

Please sign in to comment.