diff --git a/library/think/Collection.php b/library/think/Collection.php index f872476f9ae26681ad23deb66ca9250bb282cf06..0ff1dfc0c4448dab91ded0664fd76167af532159 100644 --- a/library/think/Collection.php +++ b/library/think/Collection.php @@ -360,6 +360,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param mixed $offset 键名 * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return array_key_exists($offset, $this->items); @@ -371,6 +372,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param mixed $offset 键名 * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->items[$offset]; @@ -383,6 +385,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param mixed $value 值 * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -398,6 +401,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @param mixed $offset 键名 * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->items[$offset]); @@ -408,6 +412,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->items); @@ -418,6 +423,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @return ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->items); @@ -428,6 +434,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria * @access public * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/library/think/Loader.php b/library/think/Loader.php index d813a5d7bd1519eadf54de4150aa3030da4c9328..283a2807b31b149a2dee550170070b236dd8476c 100644 --- a/library/think/Loader.php +++ b/library/think/Loader.php @@ -613,7 +613,7 @@ class Loader if ($type) { $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { return strtoupper($match[1]); - }, $name); + }, $name ?? ''); return $ucfirst ? ucfirst($name) : lcfirst($name); } diff --git a/library/think/Model.php b/library/think/Model.php index 2dc27b48ab0d42a4755d3473ab2a696f641c2efc..068032d8ccf0f3a8444519234f6fd19e4d3644f9 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -2268,27 +2268,32 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // JsonSerializable + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); } // ArrayAccess + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { $this->setAttr($name, $value); } + #[\ReturnTypeWillChange] public function offsetExists($name) { return $this->__isset($name); } + #[\ReturnTypeWillChange] public function offsetUnset($name) { $this->__unset($name); } + #[\ReturnTypeWillChange] public function offsetGet($name) { return $this->getAttr($name); diff --git a/library/think/Paginator.php b/library/think/Paginator.php index 365556784a850d3074f1b07aab8fecb984939570..d19472eef975c6238b651c86e1ad083b87accf30 100644 --- a/library/think/Paginator.php +++ b/library/think/Paginator.php @@ -128,7 +128,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } $url = $path; if (!empty($parameters)) { - $url .= '?' . http_build_query($parameters, null, '&'); + $url .= '?' . http_build_query($parameters, '', '&'); } return $url . $this->buildFragment(); } @@ -304,6 +304,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J * @return Traversable An instance of an object implementing Iterator or * Traversable */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->items->all()); @@ -314,6 +315,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J * @param mixed $offset * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return $this->items->offsetExists($offset); @@ -324,6 +326,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->items->offsetGet($offset); @@ -334,6 +337,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J * @param mixed $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->items->offsetSet($offset, $value); @@ -345,6 +349,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J * @return void * @since 5.0.0 */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $this->items->offsetUnset($offset); @@ -353,6 +358,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * Count elements of an object */ + #[\ReturnTypeWillChange] public function count() { return $this->items->count(); @@ -388,6 +394,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * Specify data which should be serialized to JSON */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/library/think/Request.php b/library/think/Request.php index 5997a763a1d72b39c613943e7fdecd00d60c761c..4baf026a4bdc1d7b0d66f6839ee8dec542c05ae1 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -1091,7 +1091,7 @@ class Request foreach ($filters as $filter) { if (is_callable($filter)) { // 调用函数或者方法过滤 - $value = call_user_func($filter, $value); + $value = call_user_func($filter, $value ?? ''); } elseif (is_scalar($value)) { if (false !== strpos($filter, '/')) { // 正则过滤 diff --git a/library/think/Validate.php b/library/think/Validate.php index 608e1e4a52aad92e1fa460756aa7fd5951dfc71b..11a1de9f714aae4101c39ae3b2e5e1757e8739cd 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -931,10 +931,10 @@ class Validate if (is_string($rule) && strpos($rule, ',')) { list($rule, $param) = explode(',', $rule); } elseif (is_array($rule)) { - $param = isset($rule[1]) ? $rule[1] : null; + $param = $rule[1] ?? 0; $rule = $rule[0]; } else { - $param = null; + $param = 0; } return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param); } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 37310f5c32bc5d555c66194524a22ed3807d4c5a..4aa74eba21162e5c28dbc88e46823cf6f7217624 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -480,6 +480,7 @@ class Query $result = Cache::get($guid); } if (false === $result) { + $result = []; if (isset($this->options['field'])) { unset($this->options['field']); } diff --git a/library/traits/controller/Jump.php b/library/traits/controller/Jump.php index 6a572246aafc2e81f9838a5241b27e91723a8762..019b520ad5440c4e571d01bec384b56e469ba879 100644 --- a/library/traits/controller/Jump.php +++ b/library/traits/controller/Jump.php @@ -38,8 +38,8 @@ trait Jump { if (is_null($url) && !is_null(Request::instance()->server('HTTP_REFERER'))) { $url = Request::instance()->server('HTTP_REFERER'); - } elseif ('' !== $url && !strpos($url, '://') && 0 !== strpos($url, '/')) { - $url = Url::build($url); + } elseif ('' !== $url && !strpos($url ?? '', '://') && 0 !== strpos($url ?? '', '/')) { + $url = Url::build($url ?? ''); } $type = $this->getResponseType();