Skip to content

Commit 4a85e75

Browse files
committed
Merge pull request #30 from Elsensee/fix-shortarraysyntax
Allow short array syntax
2 parents 59df1be + 31af053 commit 4a85e75

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateNoPhpClosingTagTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public function validateNoPhpClosingTagData()
2828
Output::FATAL . '-File must not contain a PHP closing tag, but end with one new line-nophpclosingtag/withtag.php-',
2929
)),
3030
array('3.1', 'nophpclosingtag/withcrlf.php', array()),
31+
array('3.1', 'nophpclosingtag/shortarraysyntax.php', array(
32+
Output::FATAL . '-File must not contain short array syntax for any version prior to 3.2-nophpclosingtag/shortarraysyntax.php-',
33+
)),
34+
35+
array('3.2', 'nophpclosingtag/shortarraysyntax.php', array()),
3136
);
3237
}
3338

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$synonyms = [
4+
'Cacao' => 'Kakao',
5+
];

src/Phpbb/TranslationValidator/Validator/FileValidator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,14 @@ public function validateNoPhpClosingTag($originFile)
594594
// Does the file contain anything after the last ");"
595595
if (substr($fileContents, -3) !== ");\n")
596596
{
597-
$this->output->addMessage(Output::FATAL, 'File must not contain a PHP closing tag, but end with one new line', $originFile);
597+
if (substr($fileContents, -3) !== "];\n")
598+
{
599+
$this->output->addMessage(Output::FATAL, 'File must not contain a PHP closing tag, but end with one new line', $originFile);
600+
}
601+
else if ($this->phpbbVersion === '3.1')
602+
{
603+
$this->output->addMessage(OUTPUT::FATAL, 'File must not contain short array syntax for any version prior to 3.2', $originFile);
604+
}
598605
}
599606
}
600607

0 commit comments

Comments
 (0)