mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-05 17:08:56 +02:00
PHPStorm refactoring.
This commit is contained in:
+10
-10
@@ -30,21 +30,21 @@ class Dumper
|
||||
/**
|
||||
* Sets the indentation.
|
||||
*
|
||||
* @param int $num The amount of spaces to use for indentation of nested nodes.
|
||||
* @param int $num The amount of spaces to use for indentation of nested nodes.
|
||||
*/
|
||||
public function setIndentation($num)
|
||||
{
|
||||
$this->indentation = (int) $num;
|
||||
$this->indentation = (int)$num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a PHP value to YAML.
|
||||
*
|
||||
* @param mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The level of indentation (used internally)
|
||||
* @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 mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The level of indentation (used internally)
|
||||
* @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
|
||||
*
|
||||
* @return string The YAML representation of the PHP value
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ class Dumper
|
||||
$prefix = $indent ? str_repeat(' ', $indent) : '';
|
||||
|
||||
if ($inline <= 0 || !is_array($input) || empty($input)) {
|
||||
$output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
|
||||
$output .= $prefix . Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
|
||||
} else {
|
||||
$isAHash = array_keys($input) !== range(0, count($input) - 1);
|
||||
|
||||
@@ -63,10 +63,10 @@ class Dumper
|
||||
|
||||
$output .= sprintf('%s%s%s%s',
|
||||
$prefix,
|
||||
$isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-',
|
||||
$isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport) . ':' : '-',
|
||||
$willBeInlined ? ' ' : "\n",
|
||||
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $exceptionOnInvalidType, $objectSupport)
|
||||
).($willBeInlined ? "\n" : '');
|
||||
) . ($willBeInlined ? "\n" : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,16 @@ class Escaper
|
||||
// on the input arrays. This ordering of the characters avoids the use of strtr,
|
||||
// which performs more slowly.
|
||||
private static $escapees = array('\\\\', '\\"', '"',
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9");
|
||||
private static $escaped = array('\\"', '\\\\', '\\"',
|
||||
"\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
|
||||
"\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
|
||||
private static $escaped = array('\\"', '\\\\', '\\"',
|
||||
"\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
|
||||
"\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
|
||||
"\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
|
||||
"\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
|
||||
"\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
|
||||
"\\N", "\\_", "\\L", "\\P");
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class Escaper
|
||||
*/
|
||||
public static function requiresDoubleQuoting($value)
|
||||
{
|
||||
return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
|
||||
return preg_match('/' . self::REGEX_CHARACTER_TO_ESCAPE . '/u', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,11 +35,11 @@ class ParseException extends RuntimeException
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $message The error message
|
||||
* @param int $parsedLine The line where the error occurred
|
||||
* @param int $snippet The snippet of code near the problem
|
||||
* @param string $parsedFile The file name where the error occurred
|
||||
* @param \Exception $previous The previous exception
|
||||
* @param string $message The error message
|
||||
* @param int $parsedLine The line where the error occurred
|
||||
* @param int $snippet The snippet of code near the problem
|
||||
* @param string $parsedFile The file name where the error occurred
|
||||
* @param \Exception $previous The previous exception
|
||||
*/
|
||||
public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
|
||||
{
|
||||
@@ -112,7 +112,7 @@ class ParseException extends RuntimeException
|
||||
/**
|
||||
* Sets the line where the error occurred.
|
||||
*
|
||||
* @param int $parsedLine The file line
|
||||
* @param int $parsedLine The file line
|
||||
*/
|
||||
public function setParsedLine($parsedLine)
|
||||
{
|
||||
|
||||
+36
-34
@@ -34,10 +34,10 @@ class Inline
|
||||
/**
|
||||
* Converts a YAML string to a PHP 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()
|
||||
* @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 array A PHP array representing the YAML string
|
||||
*
|
||||
@@ -55,7 +55,7 @@ class Inline
|
||||
return '';
|
||||
}
|
||||
|
||||
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('ASCII');
|
||||
}
|
||||
@@ -89,9 +89,9 @@ class Inline
|
||||
/**
|
||||
* Dumps a given PHP variable to a YAML string.
|
||||
*
|
||||
* @param mixed $value The PHP variable to convert
|
||||
* @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 mixed $value The PHP variable to convert
|
||||
* @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
|
||||
*
|
||||
* @return string The YAML string representing the PHP array
|
||||
*
|
||||
@@ -108,7 +108,7 @@ class Inline
|
||||
return 'null';
|
||||
case is_object($value):
|
||||
if ($objectSupport) {
|
||||
return '!!php/object:'.serialize($value);
|
||||
return '!!php/object:' . serialize($value);
|
||||
}
|
||||
|
||||
if ($exceptionOnInvalidType) {
|
||||
@@ -125,7 +125,7 @@ class Inline
|
||||
case false === $value:
|
||||
return 'false';
|
||||
case ctype_digit($value):
|
||||
return is_string($value) ? "'$value'" : (int) $value;
|
||||
return is_string($value) ? "'$value'" : (int)$value;
|
||||
case is_numeric($value):
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false !== $locale) {
|
||||
@@ -155,9 +155,9 @@ class Inline
|
||||
/**
|
||||
* Dumps a PHP array to a YAML string.
|
||||
*
|
||||
* @param array $value The PHP array to dump
|
||||
* @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 array $value The PHP array to dump
|
||||
* @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
|
||||
*
|
||||
* @return string The YAML string representing the PHP array
|
||||
*/
|
||||
@@ -166,7 +166,9 @@ class Inline
|
||||
// array
|
||||
$keys = array_keys($value);
|
||||
if ((1 == count($keys) && '0' == $keys[0])
|
||||
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
|
||||
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) {
|
||||
return (int)$v + $w;
|
||||
}, 0) == count($keys) * (count($keys) - 1) / 2)
|
||||
) {
|
||||
$output = array();
|
||||
foreach ($value as $val) {
|
||||
@@ -188,11 +190,11 @@ class Inline
|
||||
/**
|
||||
* Parses a scalar to a YAML string.
|
||||
*
|
||||
* @param scalar $scalar
|
||||
* @param string $delimiters
|
||||
* @param array $stringDelimiters
|
||||
* @param int &$i
|
||||
* @param bool $evaluate
|
||||
* @param scalar $scalar
|
||||
* @param string $delimiters
|
||||
* @param array $stringDelimiters
|
||||
* @param int &$i
|
||||
* @param bool $evaluate
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
@@ -220,7 +222,7 @@ class Inline
|
||||
if (false !== $strpos = strpos($output, ' #')) {
|
||||
$output = rtrim(substr($output, 0, $strpos));
|
||||
}
|
||||
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
|
||||
} elseif (preg_match('/^(.+?)(' . implode('|', $delimiters) . ')/', substr($scalar, $i), $match)) {
|
||||
$output = $match[1];
|
||||
$i += strlen($output);
|
||||
} else {
|
||||
@@ -239,7 +241,7 @@ class Inline
|
||||
* Parses a quoted scalar to YAML.
|
||||
*
|
||||
* @param string $scalar
|
||||
* @param int &$i
|
||||
* @param int &$i
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
@@ -247,7 +249,7 @@ class Inline
|
||||
*/
|
||||
private static function parseQuotedScalar($scalar, &$i)
|
||||
{
|
||||
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
|
||||
if (!preg_match('/' . self::REGEX_QUOTED_STRING . '/Au', substr($scalar, $i), $match)) {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
|
||||
}
|
||||
|
||||
@@ -268,8 +270,8 @@ class Inline
|
||||
/**
|
||||
* Parses a sequence to a YAML string.
|
||||
*
|
||||
* @param string $sequence
|
||||
* @param int &$i
|
||||
* @param string $sequence
|
||||
* @param int &$i
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
@@ -304,7 +306,7 @@ class Inline
|
||||
if (!$isQuoted && false !== strpos($value, ': ')) {
|
||||
// embedded mapping?
|
||||
try {
|
||||
$value = self::parseMapping('{'.$value.'}');
|
||||
$value = self::parseMapping('{' . $value . '}');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// no, it's not
|
||||
}
|
||||
@@ -324,8 +326,8 @@ class Inline
|
||||
/**
|
||||
* Parses a mapping to a YAML string.
|
||||
*
|
||||
* @param string $mapping
|
||||
* @param int &$i
|
||||
* @param string $mapping
|
||||
* @param int &$i
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
@@ -346,7 +348,7 @@ class Inline
|
||||
continue 2;
|
||||
case '}':
|
||||
if (self::$objectForMap) {
|
||||
return (object) $output;
|
||||
return (object)$output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -425,7 +427,7 @@ class Inline
|
||||
case '' === $scalar:
|
||||
case '~' === $scalar:
|
||||
/** @noinspection PhpInconsistentReturnPointsInspection */
|
||||
return;
|
||||
return;
|
||||
case 'true' === $scalarLower:
|
||||
return true;
|
||||
case 'false' === $scalarLower:
|
||||
@@ -435,7 +437,7 @@ class Inline
|
||||
case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || $scalar[0] === '!' || is_numeric($scalar[0]):
|
||||
switch (true) {
|
||||
case 0 === strpos($scalar, '!str'):
|
||||
return (string) substr($scalar, 5);
|
||||
return (string)substr($scalar, 5);
|
||||
case 0 === strpos($scalar, '! '):
|
||||
return intval(self::parseScalar(substr($scalar, 2)));
|
||||
case 0 === strpos($scalar, '!!php/object:'):
|
||||
@@ -453,14 +455,14 @@ class Inline
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
|
||||
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return '0' == $scalar[0] ? octdec($scalar) : (((string)$raw == (string)$cast) ? $cast : $raw);
|
||||
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string)$raw == (string)$cast) ? $cast : $raw);
|
||||
case is_numeric($scalar):
|
||||
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
||||
return '0x' == $scalar[0] . $scalar[1] ? hexdec($scalar) : floatval($scalar);
|
||||
case '.inf' === $scalarLower:
|
||||
case '.nan' === $scalarLower:
|
||||
return -log(0);
|
||||
@@ -472,7 +474,7 @@ class Inline
|
||||
return strtotime($scalar);
|
||||
}
|
||||
default:
|
||||
return (string) $scalar;
|
||||
return (string)$scalar;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+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
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ class Unescaper
|
||||
};
|
||||
|
||||
// evaluate the string
|
||||
return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
|
||||
return preg_replace_callback('/' . self::REGEX_ESCAPED_CHARACTER . '/u', $callback, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,12 +131,12 @@ class Unescaper
|
||||
return chr($c);
|
||||
}
|
||||
if (0x800 > $c) {
|
||||
return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F);
|
||||
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
if (0x10000 > $c) {
|
||||
return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
|
||||
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
|
||||
return chr(0xF0 | $c>>18).chr(0x80 | $c>>12 & 0x3F).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
|
||||
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -40,9 +40,9 @@ class Yaml
|
||||
* you must validate the input before calling this method. Passing a file
|
||||
* as an input is a deprecated feature and will be removed in 3.0.
|
||||
*
|
||||
* @param string $input Path to a YAML file or a string containing YAML
|
||||
* @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 string $input Path to a YAML file or a string containing YAML
|
||||
* @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
|
||||
*
|
||||
* @return array The YAML converted to a PHP array
|
||||
*
|
||||
@@ -82,11 +82,11 @@ class Yaml
|
||||
* The dump method, when supplied with an array, will do its best
|
||||
* to convert the array into friendly YAML.
|
||||
*
|
||||
* @param array $array PHP array
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The amount of spaces to use for indentation of nested nodes.
|
||||
* @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 array $array PHP array
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The amount of spaces to use for indentation of nested nodes.
|
||||
* @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
|
||||
*
|
||||
* @return string A YAML string representing the original PHP array
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user