Skip to content

Commit

Permalink
replace old array with []
Browse files Browse the repository at this point in the history
  • Loading branch information
JBlond committed Feb 12, 2020
1 parent 090b2d8 commit 7a3b738
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ bindtextdomain("Web_Content", "./locale");
// choose Domain
textdomain("Web_Content");

$twigConfig = array(
$twigConfig = [
'cache' => false,
'debug' => true,
'auto_reload' => true
);
];

$twigLoader = new FilesystemLoader('./tpl/');
$twig = new Environment($twigLoader, $twigConfig);
Expand Down
4 changes: 2 additions & 2 deletions example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
// choose Domain
textdomain("Web_Content");

$twigConfig = array(
$twigConfig = [
'cache' => false,
'debug' => true,
'auto_reload' => true
);
];

$twigLoader = new FilesystemLoader('./tpl/');
$twig = new Environment($twigLoader, $twigConfig);
Expand Down
12 changes: 6 additions & 6 deletions src/jblond/TwigTrans/TransNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
$lineno = 0,
$tag = null
) {
$nodes = array('body' => $body);
$nodes = ['body' => $body];
if (null !== $count) {
$nodes['count'] = $count;
}
Expand All @@ -45,7 +45,7 @@ public function __construct(
$nodes['notes'] = $notes;
}

parent::__construct($nodes, array(), $lineno, $tag);
parent::__construct($nodes, [], $lineno, $tag);
}

/**
Expand All @@ -70,7 +70,7 @@ public function compile(Compiler $compiler)
$message = trim($this->getNode('notes')->getAttribute('data'));

// line breaks are not allowed cause we want a single line comment
$message = str_replace(array("\n", "\r"), ' ', $message);
$message = str_replace(["\n", "\r"], ' ', $message);
$compiler->write("// notes: {$message}\n");
}

Expand Down Expand Up @@ -143,10 +143,10 @@ protected function compileString(Node $body)
$body instanceof ConstantExpression ||
$body instanceof TempNameExpression
) {
return array($body, array());
return [$body, []];
}

$vars = array();
$vars = [];
if (count($body)) {
$msg = '';

Expand All @@ -171,7 +171,7 @@ protected function compileString(Node $body)
$msg = $body->getAttribute('data');
}

return array(new Node(array(new ConstantExpression(trim($msg), $body->getTemplateLine()))), $vars);
return [new Node([new ConstantExpression(trim($msg), $body->getTemplateLine())]), $vars];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/jblond/TwigTrans/TransTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ public function parse(Token $token)
$body = $this->parser->getExpressionParser()->parseExpression();
} else {
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideForFork'));
$body = $this->parser->subparse([$this, 'decideForFork']);
$next = $stream->next()->getValue();

if ('plural' === $next) {
$count = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Token::BLOCK_END_TYPE);
$plural = $this->parser->subparse(array($this, 'decideForFork'));
$plural = $this->parser->subparse([$this, 'decideForFork']);

if ('notes' === $stream->next()->getValue()) {
$stream->expect(Token::BLOCK_END_TYPE);
$notes = $this->parser->subparse(array($this, 'decideForEnd'), true);
$notes = $this->parser->subparse([$this, 'decideForEnd'], true);
}
} elseif ('notes' === $next) {
$stream->expect(Token::BLOCK_END_TYPE);
$notes = $this->parser->subparse(array($this, 'decideForEnd'), true);
$notes = $this->parser->subparse([$this, 'decideForEnd'], true);
}
}

Expand All @@ -57,7 +57,7 @@ public function parse(Token $token)
*/
public function decideForFork(Token $token)
{
return $token->test(array('plural', 'notes', 'endtrans'));
return $token->test(['plural', 'notes', 'endtrans']);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/jblond/TwigTrans/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ public function getFunctions()
*/
public function getTests()
{
return array(
return [
new TwigTest('Translation', 'test')
);
];
}

/**
* @inheritDoc
*/
public function getTokenParsers()
{
return array(
return [
new TransTag()
);
];
}

/**
Expand Down

0 comments on commit 7a3b738

Please sign in to comment.