From 973285c462a27b98d097bfbfbf1db4b539655da4 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Mon, 26 Jun 2023 16:03:36 +0800 Subject: [PATCH 1/9] =?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(); From 4a004b0b85e78d3da0d4c096b4b202d11cc5e562 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Thu, 6 Jul 2023 17:26:26 +0800 Subject: [PATCH 2/9] =?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); } From 8a25441bed39118786a0dac7fb9234ba76d54bf7 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Sun, 30 Jul 2023 23:11:57 +0800 Subject: [PATCH 3/9] =?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(); } From e0cb3388ec62951a2c95b5afb4fd41f0e52e7528 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Mon, 12 Feb 2024 22:51:17 +0800 Subject: [PATCH 4/9] =?UTF-8?q?fix(Template):=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=20php8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Template.php b/library/think/Template.php index 9ba0ff35..75034fa1 100644 --- a/library/think/Template.php +++ b/library/think/Template.php @@ -925,11 +925,11 @@ class Template $args[1] = str_replace('###', $name, $args[1]); $name = "$fun($args[1])"; } else { - $name = "$fun($name,$args[1])"; + $name = "$fun($name ?? '',$args[1])"; } } else { if (!empty($args[0])) { - $name = "$fun($name)"; + $name = "$fun($name ?? '')"; } } } From 4938e2d87157daa8c911bcb4b88895c4bac2908e Mon Sep 17 00:00:00 2001 From: F4nniu Date: Mon, 12 Feb 2024 23:13:12 +0800 Subject: [PATCH 5/9] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E5=B9=B4?= =?UTF-8?q?=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ba439cb..3200d316 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 本项目包含的第三方源码和二进制文件之版权信息另行标注。 -版权所有Copyright © 2006-2022 by ThinkPHP (http://thinkphp.cn) +版权所有Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) All rights reserved。 From d0f6422a5785f5a030fb06d5641d67b0f320cf49 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Tue, 13 Feb 2024 10:20:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B0=20v5.0.26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base.php b/base.php index 2a217085..6510aa48 100644 --- a/base.php +++ b/base.php @@ -9,7 +9,7 @@ // | Author: liu21st // +---------------------------------------------------------------------- -define('THINK_VERSION', '5.0.25'); +define('THINK_VERSION', '5.0.26'); define('THINK_START_TIME', microtime(true)); define('THINK_START_MEM', memory_get_usage()); define('EXT', '.php'); From c769166eacd98afb5732b57332e6e5976e7e063b Mon Sep 17 00:00:00 2001 From: F4nniu Date: Sun, 18 Feb 2024 22:09:20 +0800 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20php8=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/console/output/Ask.php | 2 +- library/think/console/output/Descriptor.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/console/output/Ask.php b/library/think/console/output/Ask.php index 3933eb29..7304af90 100644 --- a/library/think/console/output/Ask.php +++ b/library/think/console/output/Ask.php @@ -299,7 +299,7 @@ class Ask $width = max(array_map('strlen', array_keys($this->question->getChoices()))); foreach ($this->question->getChoices() as $key => $value) { - $this->output->writeln(sprintf(" [%-${width}s] %s", $key, $value)); + $this->output->writeln(sprintf(" [%-{$width}s] %s", $key, $value)); } } diff --git a/library/think/console/output/Descriptor.php b/library/think/console/output/Descriptor.php index 23dc6481..b4d1bc2a 100644 --- a/library/think/console/output/Descriptor.php +++ b/library/think/console/output/Descriptor.php @@ -219,7 +219,7 @@ class Descriptor $width = $this->getColumnWidth($description->getCommands()); foreach ($description->getCommands() as $command) { - $this->writeText(sprintf("%-${width}s %s", $command->getName(), $command->getDescription()), $options); + $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options); $this->writeText("\n"); } } else { From 8fa1957eb15aab3c08efdebed28c5e7fe25706b8 Mon Sep 17 00:00:00 2001 From: F4nniu Date: Sun, 18 Feb 2024 22:12:58 +0800 Subject: [PATCH 8/9] =?UTF-8?q?chore:=20=E5=BF=BD=E7=95=A5=20.vscode=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7e31ef51..7884c741 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /vendor .idea .DS_Store +/.vscode From dcc1ac2bb42e05f8bc9784d0b82ca7fbc46468e5 Mon Sep 17 00:00:00 2001 From: bazhe <1031601644@qq.com> Date: Wed, 6 Mar 2024 18:25:47 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=AF=B9?= =?UTF-8?q?=E5=A4=9A=E5=85=B3=E8=81=94=E7=9A=84withCount=E8=87=AA=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=97=AE=E9=A2=98=20=E5=8F=82=E7=85=A7https://github.?= =?UTF-8?q?com/top-think/framework/commit/98af9cd4f6da08168fd83045f52111f1?= =?UTF-8?q?5ef85b20=E4=BF=AE=E6=94=B9=E7=9A=84=EF=BC=8C=E6=B2=BB=E6=A0=87?= =?UTF-8?q?=E4=B8=8D=E6=B2=BB=E6=9C=AC=EF=BC=8C=E4=BD=86=E6=98=AF=E8=83=BD?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/HasMany.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/model/relation/HasMany.php b/library/think/model/relation/HasMany.php index ebab051a..240d2ca4 100644 --- a/library/think/model/relation/HasMany.php +++ b/library/think/model/relation/HasMany.php @@ -164,7 +164,7 @@ class HasMany extends Relation } } $localKey = $this->localKey ?: $this->parent->getPk(); - return $this->query->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count(); + return $this->query->alias( 'count_table')->whereExp( 'count_table.' . $this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count(); } /**