Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -85,7 +85,7 @@ class PoHeader {
* Plural form component from the header, for example:
* 'nplurals=2; plural=(n > 1);'.
*/
function getPluralForms() {
public function getPluralForms() {
return $this->_pluralForms;
}
@ -95,7 +95,7 @@ class PoHeader {
* @param string $languageName
* Human readable language name.
*/
function setLanguageName($languageName) {
public function setLanguageName($languageName) {
$this->_languageName = $languageName;
}
@ -105,7 +105,7 @@ class PoHeader {
* @return string
* The human readable language name.
*/
function getLanguageName() {
public function getLanguageName() {
return $this->_languageName;
}
@ -115,7 +115,7 @@ class PoHeader {
* @param string $projectName
* Human readable project name.
*/
function setProjectName($projectName) {
public function setProjectName($projectName) {
$this->_projectName = $projectName;
}
@ -125,7 +125,7 @@ class PoHeader {
* @return string
* The human readable project name.
*/
function getProjectName() {
public function getProjectName() {
return $this->_projectName;
}
@ -190,10 +190,10 @@ class PoHeader {
*
* @throws Exception
*/
function parsePluralForms($pluralforms) {
$plurals = array();
public function parsePluralForms($pluralforms) {
$plurals = [];
// First, delete all whitespace.
$pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
$pluralforms = strtr($pluralforms, [" " => "", "\t" => ""]);
// Select the parts that define nplurals and plural.
$nplurals = strstr($pluralforms, "nplurals=");
@ -215,7 +215,7 @@ class PoHeader {
// If the number of plurals is zero, we return a default result.
if ($nplurals == 0) {
return array($nplurals, array('default' => 0));
return [$nplurals, ['default' => 0]];
}
// Calculate possible plural positions of different plural values. All known
@ -233,7 +233,7 @@ class PoHeader {
});
$plurals['default'] = $default;
return array($nplurals, $plurals);
return [$nplurals, $plurals];
}
else {
throw new \Exception('The plural formula could not be parsed.');
@ -250,7 +250,7 @@ class PoHeader {
* An associative array of key-value pairs.
*/
private function parseHeader($header) {
$header_parsed = array();
$header_parsed = [];
$lines = array_map('trim', explode("\n", $header));
foreach ($lines as $line) {
if ($line) {
@ -275,17 +275,17 @@ class PoHeader {
*/
private function parseArithmetic($string) {
// Operator precedence table.
$precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
$precedence = ["(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8];
// Right associativity.
$right_associativity = array("?" => 1, ":" => 1);
$right_associativity = ["?" => 1, ":" => 1];
$tokens = $this->tokenizeFormula($string);
// Parse by converting into infix notation then back into postfix
// Operator stack - holds math operators and symbols.
$operator_stack = array();
$operator_stack = [];
// Element Stack - holds data to be operated on.
$element_stack = array();
$element_stack = [];
foreach ($tokens as $token) {
$current_token = $token;
@ -373,7 +373,7 @@ class PoHeader {
*/
private function tokenizeFormula($formula) {
$formula = str_replace(" ", "", $formula);
$tokens = array();
$tokens = [];
for ($i = 0; $i < strlen($formula); $i++) {
if (is_numeric($formula[$i])) {
$num = $formula[$i];

View file

@ -59,7 +59,7 @@ class PoItem {
*
* @return string with langcode
*/
function getLangcode() {
public function getLangcode() {
return $this->_langcode;
}
@ -68,7 +68,7 @@ class PoItem {
*
* @param string $langcode
*/
function setLangcode($langcode) {
public function setLangcode($langcode) {
$this->_langcode = $langcode;
}
@ -77,7 +77,7 @@ class PoItem {
*
* @return string $context
*/
function getContext() {
public function getContext() {
return $this->_context;
}
@ -86,7 +86,7 @@ class PoItem {
*
* @param string $context
*/
function setContext($context) {
public function setContext($context) {
$this->_context = $context;
}
@ -96,7 +96,7 @@ class PoItem {
*
* @return string or array $translation
*/
function getSource() {
public function getSource() {
return $this->_source;
}
@ -106,7 +106,7 @@ class PoItem {
*
* @param string or array $source
*/
function setSource($source) {
public function setSource($source) {
$this->_source = $source;
}
@ -116,7 +116,7 @@ class PoItem {
*
* @return string or array $translation
*/
function getTranslation() {
public function getTranslation() {
return $this->_translation;
}
@ -126,7 +126,7 @@ class PoItem {
*
* @param string or array $translation
*/
function setTranslation($translation) {
public function setTranslation($translation) {
$this->_translation = $translation;
}
@ -135,7 +135,7 @@ class PoItem {
*
* @param bool $plural
*/
function setPlural($plural) {
public function setPlural($plural) {
$this->_plural = $plural;
}
@ -144,7 +144,7 @@ class PoItem {
*
* @return bool
*/
function isPlural() {
public function isPlural() {
return $this->_plural;
}
@ -153,7 +153,7 @@ class PoItem {
*
* @return String $comment
*/
function getComment() {
public function getComment() {
return $this->_comment;
}
@ -162,7 +162,7 @@ class PoItem {
*
* @param string $comment
*/
function setComment($comment) {
public function setComment($comment) {
$this->_comment = $comment;
}
@ -171,7 +171,7 @@ class PoItem {
*
* @param array $values
*/
public function setFromArray(array $values = array()) {
public function setFromArray(array $values = []) {
if (isset($values['context'])) {
$this->setContext($values['context']);
}

View file

@ -17,8 +17,8 @@ class PoMemoryWriter implements PoWriterInterface {
/**
* Constructor, initialize empty items.
*/
function __construct() {
$this->_items = array();
public function __construct() {
$this->_items = [];
}
/**
@ -57,7 +57,7 @@ class PoMemoryWriter implements PoWriterInterface {
*
* Not implemented. Not relevant for the MemoryWriter.
*/
function setLangcode($langcode) {
public function setLangcode($langcode) {
}
/**
@ -65,7 +65,7 @@ class PoMemoryWriter implements PoWriterInterface {
*
* Not implemented. Not relevant for the MemoryWriter.
*/
function getLangcode() {
public function getLangcode() {
}
/**
@ -73,7 +73,7 @@ class PoMemoryWriter implements PoWriterInterface {
*
* Not implemented. Not relevant for the MemoryWriter.
*/
function getHeader() {
public function getHeader() {
}
/**
@ -81,7 +81,7 @@ class PoMemoryWriter implements PoWriterInterface {
*
* Not implemented. Not relevant for the MemoryWriter.
*/
function setHeader(PoHeader $header) {
public function setHeader(PoHeader $header) {
}
}

View file

@ -37,7 +37,7 @@ interface PoMetadataInterface {
/**
* Get header metadata.
*
* @return \Drupal\Component\Gettext\PoHeader $header
* @return \Drupal\Component\Gettext\PoHeader
* Header instance representing metadata in a PO header.
*/
public function getHeader();

View file

@ -39,7 +39,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
*
* @var array
*/
private $_current_item = array();
private $_current_item = [];
/**
* Current plural index for plural translations.
@ -261,14 +261,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->_line_number++;
// Initialize common values for error logging.
$log_vars = array(
$log_vars = [
'%uri' => $this->getURI(),
'%line' => $this->_line_number,
);
];
// Trim away the linefeed. \\n might appear at the end of the string if
// another line continuing the same string follows. We can remove that.
$line = trim(strtr($line, array("\\\n" => "")));
$line = trim(strtr($line, ["\\\n" => ""]));
if (!strncmp('#', $line, 1)) {
// Lines starting with '#' are comments.
@ -282,7 +282,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->setItemFromArray($this->_current_item);
// Start a new entry for the comment.
$this->_current_item = array();
$this->_current_item = [];
$this->_current_item['#'][] = substr($line, 1);
$this->_context = 'COMMENT';
@ -319,7 +319,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (is_string($this->_current_item['msgid'])) {
// The first value was stored as string. Now we know the context is
// plural, it is converted to array.
$this->_current_item['msgid'] = array($this->_current_item['msgid']);
$this->_current_item['msgid'] = [$this->_current_item['msgid']];
}
$this->_current_item['msgid'][] = $quoted;
@ -334,7 +334,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
$this->setItemFromArray($this->_current_item);
// Start a new context for the msgid.
$this->_current_item = array();
$this->_current_item = [];
}
elseif ($this->_context == 'MSGID') {
// We are currently already in the context, meaning we passed an id with no data.
@ -363,7 +363,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
// We are currently in string context, save current item.
$this->setItemFromArray($this->_current_item);
$this->_current_item = array();
$this->_current_item = [];
}
elseif (!empty($this->_current_item['msgctxt'])) {
// A context cannot apply to another context.
@ -421,7 +421,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
return FALSE;
}
if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
$this->_current_item['msgstr'] = array();
$this->_current_item['msgstr'] = [];
}
$this->_current_item['msgstr'][$this->_current_plural_index] = $quoted;
@ -500,7 +500,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
// Empty line read or EOF of PO stream, close out the last entry.
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
$this->setItemFromArray($this->_current_item);
$this->_current_item = array();
$this->_current_item = [];
}
elseif ($this->_context != 'COMMENT') {
$this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
@ -547,7 +547,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
* @return
* The string parsed from inside the quotes.
*/
function parseQuoted($string) {
public function parseQuoted($string) {
if (substr($string, 0, 1) != substr($string, -1, 1)) {
// Start and end quotes must be the same.
return FALSE;