Merge branch 'master' of gitee.com:fastadminnet/framework

This commit is contained in:
Karson
2024-03-26 17:19:29 +08:00
15 changed files with 35 additions and 14 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
/vendor /vendor
.idea .idea
.DS_Store .DS_Store
/.vscode

View File

@@ -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。 All rights reserved。

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
define('THINK_VERSION', '5.0.25'); define('THINK_VERSION', '5.0.26');
define('THINK_START_TIME', microtime(true)); define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage()); define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php'); define('EXT', '.php');

View File

@@ -360,6 +360,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param mixed $offset 键名 * @param mixed $offset 键名
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange]
public function offsetExists($offset) public function offsetExists($offset)
{ {
return array_key_exists($offset, $this->items); return array_key_exists($offset, $this->items);
@@ -371,6 +372,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param mixed $offset 键名 * @param mixed $offset 键名
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->items[$offset]; return $this->items[$offset];
@@ -383,6 +385,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param mixed $value 值 * @param mixed $value 值
* @return void * @return void
*/ */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
if (is_null($offset)) { if (is_null($offset)) {
@@ -398,6 +401,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @param mixed $offset 键名 * @param mixed $offset 键名
* @return void * @return void
*/ */
#[\ReturnTypeWillChange]
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
unset($this->items[$offset]); unset($this->items[$offset]);
@@ -408,6 +412,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @access public * @access public
* @return int * @return int
*/ */
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
return count($this->items); return count($this->items);
@@ -418,6 +423,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @access public * @access public
* @return ArrayIterator * @return ArrayIterator
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return new ArrayIterator($this->items); return new ArrayIterator($this->items);
@@ -428,6 +434,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
* @access public * @access public
* @return array * @return array
*/ */
#[\ReturnTypeWillChange]
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@@ -613,7 +613,7 @@ class Loader
if ($type) { if ($type) {
$name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) {
return strtoupper($match[1]); return strtoupper($match[1]);
}, $name); }, $name ?? '');
return $ucfirst ? ucfirst($name) : lcfirst($name); return $ucfirst ? ucfirst($name) : lcfirst($name);
} }

View File

@@ -2276,27 +2276,32 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
} }
// JsonSerializable // JsonSerializable
#[\ReturnTypeWillChange]
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();
} }
// ArrayAccess // ArrayAccess
#[\ReturnTypeWillChange]
public function offsetSet($name, $value) public function offsetSet($name, $value)
{ {
$this->setAttr($name, $value); $this->setAttr($name, $value);
} }
#[\ReturnTypeWillChange]
public function offsetExists($name) public function offsetExists($name)
{ {
return $this->__isset($name); return $this->__isset($name);
} }
#[\ReturnTypeWillChange]
public function offsetUnset($name) public function offsetUnset($name)
{ {
$this->__unset($name); $this->__unset($name);
} }
#[\ReturnTypeWillChange]
public function offsetGet($name) public function offsetGet($name)
{ {
return $this->getAttr($name); return $this->getAttr($name);

View File

@@ -128,7 +128,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
} }
$url = $path; $url = $path;
if (!empty($parameters)) { if (!empty($parameters)) {
$url .= '?' . http_build_query($parameters, null, '&'); $url .= '?' . http_build_query($parameters, '', '&');
} }
return $url . $this->buildFragment(); return $url . $this->buildFragment();
} }
@@ -304,6 +304,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
* @return Traversable An instance of an object implementing <b>Iterator</b> or * @return Traversable An instance of an object implementing <b>Iterator</b> or
* <b>Traversable</b> * <b>Traversable</b>
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return new ArrayIterator($this->items->all()); return new ArrayIterator($this->items->all());
@@ -314,6 +315,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
* @param mixed $offset * @param mixed $offset
* @return bool * @return bool
*/ */
#[\ReturnTypeWillChange]
public function offsetExists($offset) public function offsetExists($offset)
{ {
return $this->items->offsetExists($offset); return $this->items->offsetExists($offset);
@@ -324,6 +326,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
* @param mixed $offset * @param mixed $offset
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->items->offsetGet($offset); return $this->items->offsetGet($offset);
@@ -334,6 +337,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
* @param mixed $offset * @param mixed $offset
* @param mixed $value * @param mixed $value
*/ */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
$this->items->offsetSet($offset, $value); $this->items->offsetSet($offset, $value);
@@ -345,6 +349,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
* @return void * @return void
* @since 5.0.0 * @since 5.0.0
*/ */
#[\ReturnTypeWillChange]
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
$this->items->offsetUnset($offset); $this->items->offsetUnset($offset);
@@ -353,6 +358,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
/** /**
* Count elements of an object * Count elements of an object
*/ */
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
return $this->items->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 * Specify data which should be serialized to JSON
*/ */
#[\ReturnTypeWillChange]
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@@ -1091,7 +1091,7 @@ class Request
foreach ($filters as $filter) { foreach ($filters as $filter) {
if (is_callable($filter)) { if (is_callable($filter)) {
// 调用函数或者方法过滤 // 调用函数或者方法过滤
$value = call_user_func($filter, $value); $value = call_user_func($filter, $value ?? '');
} elseif (is_scalar($value)) { } elseif (is_scalar($value)) {
if (false !== strpos($filter, '/')) { if (false !== strpos($filter, '/')) {
// 正则过滤 // 正则过滤

View File

@@ -925,11 +925,11 @@ class Template
$args[1] = str_replace('###', $name, $args[1]); $args[1] = str_replace('###', $name, $args[1]);
$name = "$fun($args[1])"; $name = "$fun($args[1])";
} else { } else {
$name = "$fun($name,$args[1])"; $name = "$fun($name ?? '',$args[1])";
} }
} else { } else {
if (!empty($args[0])) { if (!empty($args[0])) {
$name = "$fun($name)"; $name = "$fun($name ?? '')";
} }
} }
} }

View File

@@ -931,10 +931,10 @@ class Validate
if (is_string($rule) && strpos($rule, ',')) { if (is_string($rule) && strpos($rule, ',')) {
list($rule, $param) = explode(',', $rule); list($rule, $param) = explode(',', $rule);
} elseif (is_array($rule)) { } elseif (is_array($rule)) {
$param = isset($rule[1]) ? $rule[1] : null; $param = $rule[1] ?? 0;
$rule = $rule[0]; $rule = $rule[0];
} else { } else {
$param = null; $param = 0;
} }
return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param); return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param);
} }

View File

@@ -299,7 +299,7 @@ class Ask
$width = max(array_map('strlen', array_keys($this->question->getChoices()))); $width = max(array_map('strlen', array_keys($this->question->getChoices())));
foreach ($this->question->getChoices() as $key => $value) { foreach ($this->question->getChoices() as $key => $value) {
$this->output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value)); $this->output->writeln(sprintf(" [<comment>%-{$width}s</comment>] %s", $key, $value));
} }
} }

View File

@@ -219,7 +219,7 @@ class Descriptor
$width = $this->getColumnWidth($description->getCommands()); $width = $this->getColumnWidth($description->getCommands());
foreach ($description->getCommands() as $command) { 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"); $this->writeText("\n");
} }
} else { } else {

View File

@@ -480,6 +480,7 @@ class Query
$result = Cache::get($guid); $result = Cache::get($guid);
} }
if (false === $result) { if (false === $result) {
$result = [];
if (isset($this->options['field'])) { if (isset($this->options['field'])) {
unset($this->options['field']); unset($this->options['field']);
} }

View File

@@ -164,7 +164,7 @@ class HasMany extends Relation
} }
} }
$localKey = $this->localKey ?: $this->parent->getPk(); $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();
} }
/** /**

View File

@@ -38,8 +38,8 @@ trait Jump
{ {
if (is_null($url) && !is_null(Request::instance()->server('HTTP_REFERER'))) { if (is_null($url) && !is_null(Request::instance()->server('HTTP_REFERER'))) {
$url = Request::instance()->server('HTTP_REFERER'); $url = Request::instance()->server('HTTP_REFERER');
} elseif ('' !== $url && !strpos($url, '://') && 0 !== strpos($url, '/')) { } elseif ('' !== $url && !strpos($url ?? '', '://') && 0 !== strpos($url ?? '', '/')) {
$url = Url::build($url); $url = Url::build($url ?? '');
} }
$type = $this->getResponseType(); $type = $this->getResponseType();