mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-06 09:28:57 +02:00
PHPStorm refactoring.
This commit is contained in:
+24
-24
@@ -23,16 +23,16 @@ class Parser
|
||||
{
|
||||
const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
|
||||
|
||||
private $offset = 0;
|
||||
private $lines = array();
|
||||
private $currentLineNb = -1;
|
||||
private $currentLine = '';
|
||||
private $refs = array();
|
||||
private $offset = 0;
|
||||
private $lines = array();
|
||||
private $currentLineNb = -1;
|
||||
private $currentLine = '';
|
||||
private $refs = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $offset The offset of YAML document (used for line numbers in error messages)
|
||||
* @param int $offset The offset of YAML document (used for line numbers in error messages)
|
||||
*/
|
||||
public function __construct($offset = 0)
|
||||
{
|
||||
@@ -42,10 +42,10 @@ class Parser
|
||||
/**
|
||||
* Parses a YAML string to a PHP value.
|
||||
*
|
||||
* @param string $value A YAML string
|
||||
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param bool $objectSupport true if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||
* @param string $value A YAML string
|
||||
* @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
|
||||
* @param bool $objectSupport true if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
*
|
||||
@@ -61,7 +61,7 @@ class Parser
|
||||
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
|
||||
}
|
||||
|
||||
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
||||
if (function_exists('mb_internal_encoding') && ((int)ini_get('mbstring.func_overload')) & 2) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('UTF-8');
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class Parser
|
||||
} else {
|
||||
if (isset($values['leadspaces'])
|
||||
&& ' ' == $values['leadspaces']
|
||||
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
|
||||
&& preg_match('#^(?P<key>' . Inline::REGEX_QUOTED_STRING . '|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
|
||||
) {
|
||||
// this is a compact notation element, add to next block and parse
|
||||
$c = $this->getRealCurrentLineNb();
|
||||
@@ -108,7 +108,7 @@ class Parser
|
||||
|
||||
$block = $values['value'];
|
||||
if ($this->isNextLineIndented()) {
|
||||
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
||||
$block .= "\n" . $this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
|
||||
}
|
||||
|
||||
$data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
@@ -116,7 +116,7 @@ class Parser
|
||||
$data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) {
|
||||
} elseif (preg_match('#^(?P<key>' . Inline::REGEX_QUOTED_STRING . '|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'], ' #')) {
|
||||
if ($context && 'sequence' == $context) {
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence');
|
||||
}
|
||||
@@ -300,7 +300,7 @@ class Parser
|
||||
/**
|
||||
* Returns the next embed block of YAML.
|
||||
*
|
||||
* @param int $indentation The indent level at which the block is to be read, or null for default
|
||||
* @param int $indentation The indent level at which the block is to be read, or null for default
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
@@ -327,7 +327,7 @@ class Parser
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
||||
|
||||
// Comments must not be removed inside a string block (ie. after a line ending with "|")
|
||||
$removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~';
|
||||
$removeCommentsPattern = '~' . self::FOLDED_SCALAR_PATTERN . '$~';
|
||||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
@@ -392,10 +392,10 @@ class Parser
|
||||
/**
|
||||
* Parses a YAML value.
|
||||
*
|
||||
* @param string $value A YAML value
|
||||
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
|
||||
* @param bool $objectSupport True if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||
* @param string $value A YAML value
|
||||
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
|
||||
* @param bool $objectSupport True if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
*
|
||||
@@ -417,7 +417,7 @@ class Parser
|
||||
return $this->refs[$value];
|
||||
}
|
||||
|
||||
if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
|
||||
if (preg_match('/^' . self::FOLDED_SCALAR_PATTERN . '$/', $value, $matches)) {
|
||||
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
|
||||
|
||||
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
|
||||
@@ -436,9 +436,9 @@ class Parser
|
||||
/**
|
||||
* Parses a folded scalar.
|
||||
*
|
||||
* @param string $separator The separator that was used to begin this folded scalar (| or >)
|
||||
* @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
|
||||
* @param int $indentation The indentation that was used to begin this folded scalar
|
||||
* @param string $separator The separator that was used to begin this folded scalar (| or >)
|
||||
* @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
|
||||
* @param int $indentation The indentation that was used to begin this folded scalar
|
||||
*
|
||||
* @return string The text value
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user