Augmentation vers version 3.3.0
This commit is contained in:
@@ -17,10 +17,10 @@ namespace Symfony\Bridge\Twig\NodeVisitor;
|
||||
class Scope
|
||||
{
|
||||
private $parent;
|
||||
private $data = array();
|
||||
private $data = [];
|
||||
private $left = false;
|
||||
|
||||
public function __construct(Scope $parent = null)
|
||||
public function __construct(self $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class Scope
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
if (\array_key_exists($key, $this->data)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class Scope
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
if (\array_key_exists($key, $this->data)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
$name = new AssignNameExpression($var, $node->getTemplateLine());
|
||||
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));
|
||||
|
||||
return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
|
||||
return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
return $node;
|
||||
}
|
||||
|
||||
if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) {
|
||||
if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), ['trans', 'transchoice'])) {
|
||||
$arguments = $node->getNode('arguments');
|
||||
$ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2;
|
||||
if ($this->isNamedArguments($arguments)) {
|
||||
@@ -74,7 +74,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
} else {
|
||||
if (!$arguments->hasNode($ind)) {
|
||||
if (!$arguments->hasNode($ind - 1)) {
|
||||
$arguments->setNode($ind - 1, new ArrayExpression(array(), $node->getTemplateLine()));
|
||||
$arguments->setNode($ind - 1, new ArrayExpression([], $node->getTemplateLine()));
|
||||
}
|
||||
|
||||
$arguments->setNode($ind, $this->scope->get('domain'));
|
||||
@@ -95,7 +95,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
protected function doLeaveNode(Node $node, Environment $env)
|
||||
{
|
||||
if ($node instanceof TransDefaultDomainNode) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
|
||||
@@ -107,6 +107,8 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
|
||||
@@ -28,18 +28,18 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
const UNDEFINED_DOMAIN = '_undefined';
|
||||
|
||||
private $enabled = false;
|
||||
private $messages = array();
|
||||
private $messages = [];
|
||||
|
||||
public function enable()
|
||||
{
|
||||
$this->enabled = true;
|
||||
$this->messages = array();
|
||||
$this->messages = [];
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
$this->enabled = false;
|
||||
$this->messages = array();
|
||||
$this->messages = [];
|
||||
}
|
||||
|
||||
public function getMessages()
|
||||
@@ -62,26 +62,26 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
$node->getNode('node') instanceof ConstantExpression
|
||||
) {
|
||||
// extract constant nodes with a trans filter
|
||||
$this->messages[] = array(
|
||||
$this->messages[] = [
|
||||
$node->getNode('node')->getAttribute('value'),
|
||||
$this->getReadDomainFromArguments($node->getNode('arguments'), 1),
|
||||
);
|
||||
];
|
||||
} elseif (
|
||||
$node instanceof FilterExpression &&
|
||||
'transchoice' === $node->getNode('filter')->getAttribute('value') &&
|
||||
$node->getNode('node') instanceof ConstantExpression
|
||||
) {
|
||||
// extract constant nodes with a trans filter
|
||||
$this->messages[] = array(
|
||||
$this->messages[] = [
|
||||
$node->getNode('node')->getAttribute('value'),
|
||||
$this->getReadDomainFromArguments($node->getNode('arguments'), 2),
|
||||
);
|
||||
];
|
||||
} elseif ($node instanceof TransNode) {
|
||||
// extract trans nodes
|
||||
$this->messages[] = array(
|
||||
$this->messages[] = [
|
||||
$node->getNode('body')->getAttribute('data'),
|
||||
$node->hasNode('domain') ? $this->getReadDomainFromNode($node->getNode('domain')) : null,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $node;
|
||||
@@ -97,6 +97,8 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
@@ -104,8 +106,7 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $arguments
|
||||
* @param int $index
|
||||
* @param int $index
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
@@ -116,7 +117,7 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
||||
} elseif ($arguments->hasNode($index)) {
|
||||
$argument = $arguments->getNode($index);
|
||||
} else {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getReadDomainFromNode($argument);
|
||||
|
||||
Reference in New Issue
Block a user