Laravel version update
Laravel version update
This commit is contained in:
63
vendor/sebastian/exporter/src/Exporter.php
vendored
63
vendor/sebastian/exporter/src/Exporter.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Exporter package.
|
||||
* This file is part of the exporter package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -38,8 +38,9 @@ class Exporter
|
||||
* - Carriage returns and newlines are normalized to \n
|
||||
* - Recursion and repeated rendering is treated properly
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param int $indentation The indentation level of the 2nd+ line
|
||||
* @param mixed $value
|
||||
* @param int $indentation The indentation level of the 2nd+ line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function export($value, $indentation = 0)
|
||||
@@ -48,36 +49,34 @@ class Exporter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @param Context $context
|
||||
* @param mixed $data
|
||||
* @param Context $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function shortenedRecursiveExport(&$data, Context $context = null)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
$exporter = new self();
|
||||
|
||||
if (!$context) {
|
||||
$context = new Context;
|
||||
}
|
||||
|
||||
$array = $data;
|
||||
$context->add($data);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if ($context->contains($data[$key]) !== false) {
|
||||
$result[] = '*RECURSION*';
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$result[] = sprintf(
|
||||
'array(%s)',
|
||||
$this->shortenedRecursiveExport($data[$key], $context)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$result[] = $exporter->shortenedExport($value);
|
||||
}
|
||||
}
|
||||
@@ -94,14 +93,16 @@ class Exporter
|
||||
* Newlines are replaced by the visible string '\n'.
|
||||
* Contents of arrays and objects (if any) are replaced by '...'.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see SebastianBergmann\Exporter\Exporter::export
|
||||
*/
|
||||
public function shortenedExport($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$string = $this->export($value);
|
||||
$string = str_replace("\n", '', $this->export($value));
|
||||
|
||||
if (function_exists('mb_strlen')) {
|
||||
if (mb_strlen($string) > 40) {
|
||||
@@ -113,7 +114,7 @@ class Exporter
|
||||
}
|
||||
}
|
||||
|
||||
return str_replace("\n", '\n', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
if (is_object($value)) {
|
||||
@@ -138,7 +139,8 @@ class Exporter
|
||||
* Converts an object to an array containing all of its private, protected
|
||||
* and public properties.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($value)
|
||||
@@ -147,7 +149,7 @@ class Exporter
|
||||
return (array) $value;
|
||||
}
|
||||
|
||||
$array = array();
|
||||
$array = [];
|
||||
|
||||
foreach ((array) $value as $key => $val) {
|
||||
// properties are transformed to keys in the following way:
|
||||
@@ -183,10 +185,10 @@ class Exporter
|
||||
}
|
||||
|
||||
foreach ($value as $key => $val) {
|
||||
$array[spl_object_hash($val)] = array(
|
||||
$array[spl_object_hash($val)] = [
|
||||
'obj' => $val,
|
||||
'inf' => $value->getInfo(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +198,12 @@ class Exporter
|
||||
/**
|
||||
* Recursive implementation of export
|
||||
*
|
||||
* @param mixed $value The value to export
|
||||
* @param int $indentation The indentation level of the 2nd+ line
|
||||
* @param \SebastianBergmann\RecursionContext\Context $processed Previously processed objects
|
||||
* @param mixed $value The value to export
|
||||
* @param int $indentation The indentation level of the 2nd+ line
|
||||
* @param \SebastianBergmann\RecursionContext\Context $processed Previously processed objects
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see SebastianBergmann\Exporter\Exporter::export
|
||||
*/
|
||||
protected function recursiveExport(&$value, $indentation, $processed = null)
|
||||
@@ -235,7 +239,13 @@ class Exporter
|
||||
}
|
||||
|
||||
return "'" .
|
||||
str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) .
|
||||
str_replace('<lf>', "\n",
|
||||
str_replace(
|
||||
["\r\n", "\n\r", "\r", "\n"],
|
||||
['\r\n<lf>', '\n\r<lf>', '\r<lf>', '\n<lf>'],
|
||||
$value
|
||||
)
|
||||
) .
|
||||
"'";
|
||||
}
|
||||
|
||||
@@ -250,11 +260,12 @@ class Exporter
|
||||
return 'Array &' . $key;
|
||||
}
|
||||
|
||||
$array = $value;
|
||||
$key = $processed->add($value);
|
||||
$values = '';
|
||||
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
if (count($array) > 0) {
|
||||
foreach ($array as $k => $v) {
|
||||
$values .= sprintf(
|
||||
'%s %s => %s' . "\n",
|
||||
$whitespace,
|
||||
|
||||
Reference in New Issue
Block a user