处理 vendor 依赖错误问题

This commit is contained in:
柳清爽
2025-03-25 18:31:48 +08:00
parent f7f48a03fe
commit 4af129acf8
416 changed files with 26268 additions and 28381 deletions

View File

@@ -29,25 +29,14 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*/
protected $items = [];
/**
* The delimiter (alternative to a '.') to be used.
*
* @var string
*/
protected $delimiter = '.';
/**
* Create a new Dot instance
*
* @param mixed $items
* @param string $delimiter
*/
public function __construct($items = [], $delimiter = '.')
public function __construct($items = [])
{
$this->items = $this->getArrayItems($items);
$this->delimiter = strlen($delimiter) ? $delimiter : '.';
}
/**
@@ -115,7 +104,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
}
$items = &$this->items;
$segments = explode($this->delimiter, $key);
$segments = explode('.', $key);
$lastSegment = array_pop($segments);
foreach ($segments as $segment) {
@@ -159,10 +148,6 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
$items = $this->items;
}
if (!func_num_args()) {
$delimiter = $this->delimiter;
}
foreach ($items as $key => $value) {
if (is_array($value) && !empty($value)) {
$flatten = array_merge(
@@ -194,13 +179,13 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
return $this->items[$key];
}
if (strpos($key, $this->delimiter) === false) {
if (strpos($key, '.') === false) {
return $default;
}
$items = $this->items;
foreach (explode($this->delimiter, $key) as $segment) {
foreach (explode('.', $key) as $segment) {
if (!is_array($items) || !$this->exists($items, $segment)) {
return $default;
}
@@ -249,7 +234,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
continue;
}
foreach (explode($this->delimiter, $key) as $segment) {
foreach (explode('.', $key) as $segment) {
if (!is_array($items) || !$this->exists($items, $segment)) {
return false;
}
@@ -461,7 +446,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
$items = &$this->items;
foreach (explode($this->delimiter, $keys) as $key) {
foreach (explode('.', $keys) as $key) {
if (!isset($items[$key]) || !is_array($items[$key])) {
$items[$key] = [];
}
@@ -615,7 +600,6 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->items;

View File

@@ -11,14 +11,13 @@ use Adbar\Dot;
if (! function_exists('dot')) {
/**
* Create a new Dot object with the given items and optional delimiter
* Create a new Dot object with the given items
*
* @param mixed $items
* @param string $delimiter
* @param mixed $items
* @return \Adbar\Dot
*/
function dot($items, $delimiter = '.')
function dot($items)
{
return new Dot($items, $delimiter);
return new Dot($items);
}
}