From 973285c462a27b98d097bfbfbf1db4b539655da4 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Mon, 26 Jun 2023 16:03:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?php8=20=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Collection.php | 7 +++++++ library/think/Model.php | 5 +++++ library/think/Paginator.php | 7 +++++++ library/think/Request.php | 2 +- library/think/db/Query.php | 1 + library/traits/controller/Jump.php | 4 ++-- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/library/think/Collection.php b/library/think/Collection.php index f872476f..0ff1dfc0 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/Model.php b/library/think/Model.php index 2dc27b48..068032d8 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 36555678..be774924 100644 --- a/library/think/Paginator.php +++ b/library/think/Paginator.php @@ -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 5997a763..4baf026a 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/db/Query.php b/library/think/db/Query.php index 37310f5c..4aa74eba 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 6a572246..019b520a 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(); -- Gitee From 4a004b0b85e78d3da0d4c096b4b202d11cc5e562 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Thu, 6 Jul 2023 17:26:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=82=E9=85=8D=20php8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Loader.php | 2 +- library/think/Validate.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/think/Loader.php b/library/think/Loader.php index d813a5d7..283a2807 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/Validate.php b/library/think/Validate.php index 608e1e4a..11a1de9f 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); } -- Gitee From 8a25441bed39118786a0dac7fb9234ba76d54bf7 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Sun, 30 Jul 2023 23:11:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=20http=5Fbuild=5Fquery?= =?UTF-8?q?=20=E5=9C=A8=20php8=20=E7=8E=AF=E5=A2=83=E7=9A=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Paginator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Paginator.php b/library/think/Paginator.php index be774924..d19472ee 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(); } -- Gitee