forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2.3: [Debug] ErrorHandler: remove $GLOBALS from context in PHP5.3 fix symfony#10292 Allow File instance to be passed to BinaryFileResponse Add upgrade instructions for the LoggerInterface fixed CS Removed strict check when found variables inside a translation
- Loading branch information
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bridge\Twig\Tests\Node; | ||
|
||
use Symfony\Bridge\Twig\Node\TransNode; | ||
|
||
/** | ||
* @author Asmir Mustafic <[email protected]> | ||
*/ | ||
class TransNodeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testCompileStrict() | ||
{ | ||
$body = new \Twig_Node_Text('trans %var%', 0); | ||
$vars = new \Twig_Node_Expression_Name('foo', 0); | ||
$node = new TransNode($body, null, null, $vars); | ||
|
||
$env = new \Twig_Environment(null, array('strict_variables' => true)); | ||
$compiler = new \Twig_Compiler($env); | ||
|
||
$this->assertEquals( | ||
sprintf( | ||
'echo $this->env->getExtension(\'translator\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");', | ||
$this->getVariableGetterWithoutStrictCheck('var'), | ||
$this->getVariableGetterWithStrictCheck('foo') | ||
), | ||
trim($compiler->compile($node)->getSource()) | ||
); | ||
} | ||
protected function getVariableGetterWithoutStrictCheck($name) | ||
{ | ||
if (version_compare(phpversion(), '5.4.0RC1', '>=')) { | ||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); | ||
} | ||
|
||
return sprintf('$this->getContext($context, "%s", true)', $name); | ||
} | ||
|
||
protected function getVariableGetterWithStrictCheck($name) | ||
{ | ||
if (version_compare(phpversion(), '5.4.0RC1', '>=')) { | ||
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); | ||
} | ||
|
||
return sprintf('$this->getContext($context, "%s")', $name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters