Release v3.1.16 (#6649)

Co-authored-by: gaichao168 <1432681790@qq.com>
Co-authored-by: 10966 <gaichaowang@addcn.com>
Co-authored-by: kingIZZZY <logic.cpp@gmail.com>
Co-authored-by: guandeng <guandeng@Hotmail.com>
This commit is contained in:
李铭昕 2024-04-02 10:40:09 +08:00 committed by GitHub
parent 80de19e00a
commit a42618efea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 176 additions and 111 deletions

View File

@ -7,8 +7,8 @@ assignees: ''
---
## Before you submit this issue, you has been search all existed issues and search the [documentation](https://hyperf.wiki)
- [] I've been search all existed issues
- [] I've been read all documentation
## Before you submit an issue, please be sure to search through existing issues as well as search through the [documentation](https://hyperf.wiki)
- [] I've searched all existing issues
- [] I've read all relevant documentation I could find
### Describe your question

View File

@ -1,5 +1,6 @@
# v3.1.16 - TBD
# v3.1.17 - TBD
# v3.1.16 - 2024-04-02
## Added

View File

@ -49,7 +49,7 @@ We have provided you with a [Hyperf component development guide](en/component-gu
## Database
- [hyperf/database](https://github.com/hyperf/database) Based on the Eloquent database ORM forked by Hyperf, this component can be reused in other frameworks
- [hyperf/model-cache](https://github.com/hyperf/model-cache) [Hyperf/database](https://github.com/hyperf/database) component-based automatic model caching component provided by Hyperf officially
- [hyperf/model-cache](https://github.com/hyperf/model-cache) [hyperf/database](https://github.com/hyperf/database) component-based automatic model caching component provided by Hyperf officially
## Dependency injection container

View File

@ -1,5 +1,21 @@
# Changelogs
# v3.1.16 - 2024-04-02
## Added
- [#6632](https://github.com/hyperf/hyperf/pull/6632) Support to set headers for `websocket-client`.
- [#6648](https://github.com/hyperf/hyperf/pull/6648) Return result about websocket sender`push``disconnect`.
## Fixed
- [#6633](https://github.com/hyperf/hyperf/pull/6633) Fixed bug that crontab will be skipped sometimes.
- [#6635](https://github.com/hyperf/hyperf/pull/6635) Fixed AMQP `ConsumerMessage::getQueue` return type.
## Optimized
- [#6640](https://github.com/hyperf/hyperf/pull/6640) Support PHP8 Attribute for `hyperf/constants`.
# v3.1.15 - 2024-03-28
## Added

View File

@ -97,7 +97,7 @@ The configuration of `ConfigProvider` is not necessarily divided in this way. Th
Since the `extra` attribute in `composer.json` has no other effect and influence when the data is not used, the definitions in these components will not cause any interference and influence when used by other frameworks, so `ConfigProvider` is A mechanism that only works on the Hyperf framework, and will not have any impact on other frameworks that do not use this mechanism, which lays the foundation for component reuse, but it also requires that the following must be followed when designing components specification:
- All classes must be designed to allow standard `OOP` usage, and all Hyperf-specific features must be provided as enhancements and in separate classes, which means they can still be used in non-Hyperf frameworks through standard means to realize the use of components;
- If the dependency design of the component can meet the [PSR standard](https://www.php-fig.org/psr), it will be satisfied first and depend on the corresponding interface instead of the implementation class; such as [PSR standard](https:// www.php-fig.org/psr) does not contain functions, then it can satisfy the interface in the contract library [Hyperf/contract](https://github.com/hyperf/contract) defined by Hyperf, which is satisfied first and depends on The corresponding interface rather than the implementation class;
- If the dependency design of the component can meet the [PSR standard](https://www.php-fig.org/psr), it will be satisfied first and depend on the corresponding interface instead of the implementation class; such as [PSR standard](https:// www.php-fig.org/psr) does not contain functions, then it can satisfy the interface in the contract library [hyperf/contract](https://github.com/hyperf/contract) defined by Hyperf, which is satisfied first and depends on The corresponding interface rather than the implementation class;
- For the enhanced function classes added to implement Hyperf's proprietary functions, generally speaking, they also have dependencies on some components of Hyperf, so the dependencies of these components should not be written in the `require` item of `composer.json`, but write exists as a suggestion in the `suggest` item;
- Component design should not perform any dependency injection through annotations, and the injection method should only use `constructor injection`, which can also meet the use under `OOP`;
- Component design should not define any functions through annotations, and function definitions should only be defined through `ConfigProvider`;

View File

@ -201,7 +201,7 @@ class IndexController
If you want to access files uploaded locally via http, please add the following configuration to the `config/autoload/server.php` configuration.
```
```php
return [
'settings' => [
...

View File

@ -4,7 +4,7 @@
Hyperf can only run on the Linux and MacOS system environments. However, due to the development of Docker virtualization technology, it is possible to use Windows as the system environment using Docker for Windows. If you use MacOS we recommend a local deployment to avoid the Docker shared disk causing slow startup times for Hyperf.
Various Dockerfiles have been prepared for in the [hyperf/hyperf-docker](https://github.com/hyperf/hyperf-docker) project, or you can use a prebuilt image based on [hyperf\Hyperf](https://hub.docker.com/r/hyperf/hyperf).
Various Dockerfiles have been prepared for in the [hyperf/hyperf-docker](https://github.com/hyperf/hyperf-docker) project, or you can use a prebuilt image based on [hyperf/hyperf](https://hub.docker.com/r/hyperf/hyperf).
If you don't use Docker as the basis for your system environment, you can also consider using [Box](en/eco/box.md) as the basic environment for running. If you wish to set up the environment yourself, you need to make sure that your native environment meets the following requirements:

View File

@ -94,8 +94,8 @@ Next we add some validation rules to the `rules` method of this class:
public function rules(): array
{
return [
'foo' =>'required|max:255',
'bar' =>'required',
'foo' => 'required|max:255',
'bar' => 'required',
];
}
```
@ -133,8 +133,8 @@ You can customize the error messages used by the form request by overriding the
public function messages(): array
{
return [
'foo.required' =>'foo is required',
'bar.required' =>'bar is required',
'foo.required' => 'foo is required',
'bar.required' => 'bar is required',
];
}
```
@ -150,7 +150,7 @@ If you want to replace the `:attribute` part of the authentication message with
public function attributes(): array
{
return [
'foo' =>'foo of request',
'foo' => 'foo of request',
];
}
```
@ -178,12 +178,12 @@ class IndexController
$validator = $this->validationFactory->make(
$request->all(),
[
'foo' =>'required',
'bar' =>'required',
'foo' => 'required',
'bar' => 'required',
],
[
'foo.required' =>'foo is required',
'bar.required' =>'bar is required',
'foo.required' => 'foo is required',
'bar.required' => 'bar is required',
]
);
@ -205,7 +205,7 @@ If necessary, you can also use custom error messages instead of default values
```php
<?php
$messages = [
'required' =>'The :attribute field is required.',
'required' => 'The :attribute field is required.',
];
$validator = $this->validationFactory->make($request->all(), $rules, $messages);
@ -215,10 +215,10 @@ In this example, the `:attribute` placeholder will be replaced by the actual nam
```php
$messages = [
'same' =>'The :attribute and :other must match.',
'size' =>'The :attribute must be exactly :size.',
'between' =>'The :attribute value :input is not between :min-:max.',
'in' =>'The :attribute must be one of the following types: :values',
'same' => 'The :attribute and :other must match.',
'size' => 'The :attribute must be exactly :size.',
'between' => 'The :attribute value :input is not between :min-:max.',
'in' => 'The :attribute must be one of the following types: :values',
];
```
@ -228,7 +228,7 @@ Sometimes you may only want to customize error messages for specific fields. Jus
```php
$messages = [
'email.required' =>'We need to know your e-mail address!',
'email.required' => 'We need to know your e-mail address!',
];
```
@ -242,7 +242,7 @@ If you want to replace the `:attribute` part of the validation information with
```php
'attributes' => [
'email' =>'email address',
'email' => 'email address',
],
```
@ -269,12 +269,12 @@ class IndexController
$validator = $this->validationFactory->make(
$request->all(),
[
'foo' =>'required',
'bar' =>'required',
'foo' => 'required',
'bar' => 'required',
],
[
'foo.required' =>'foo is required',
'bar.required' =>'bar is required',
'foo.required' => 'foo is required',
'bar.required' => 'bar is required',
]
);
@ -466,13 +466,13 @@ The validation field must be based on the `PHP` function `dns_get_record`, with
The field under validation must be a value after the given date, and the date will be passed through the PHP function `strtotime`:
```php
'start_date' =>'required|date|after:tomorrow'
'start_date' => 'required|date|after:tomorrow'
```
Instead of passing a date string to `strtotime`, you can specify another field to compare with the date:
```php
'finish_date' =>'required|date|after:start_date'
'finish_date' => 'required|date|after:start_date'
```
##### after_or_equal:date
@ -525,77 +525,77 @@ The validation field must have a matching field foo_confirmation. For example, i
The field under validation must be a valid date based on the PHP `strtotime` function
##### date_equals:date
##### date_equals:date
The field under validation must be equal to the given date, and the date will be passed to the PHP `strtotime` function.
The field under validation must be equal to the given date, and the date will be passed to the PHP `strtotime` function.
##### date_format:format
##### date_format:format
The field under validation must match the specified format. You can use the PHP function `date` or `date_format` to validate the field.
The field under validation must match the specified format. You can use the PHP function `date` or `date_format` to validate the field.
##### different:field
##### different:field
The field under validation must be a different value from the specified field.
The field under validation must be a different value from the specified field.
##### digits:value
##### digits:value
The field under validation must be numeric and the length must be the value specified by value.
The field under validation must be numeric and the length must be the value specified by value.
##### digits_between:min,max
##### digits_between:min,max
The length of the field under validation must be between the minimum and maximum values.
The length of the field under validation must be between the minimum and maximum values.
##### dimensions
##### dimensions
The size of the verified image must meet the constraints specified by the specified parameters:
The size of the verified image must meet the constraints specified by the specified parameters:
```php
'avatar' =>'dimensions:min_width=100,min_height=200'
```
```php
'avatar' => 'dimensions:min_width=100,min_height=200'
```
Valid constraints include: `min_width`, `max_width`, `min_height`, `max_height`, `width`, `height`, `ratio`.
Valid constraints include: `min_width`, `max_width`, `min_height`, `max_height`, `width`, `height`, `ratio`.
`ratio` constrains the width/height ratio, which can be expressed by the expression `3/2` or the floating point number `1.5`:
`ratio` constrains the width/height ratio, which can be expressed by the expression `3/2` or the floating point number `1.5`:
```php
'avatar' =>'dimensions:ratio=3/2'
```
```php
'avatar' => 'dimensions:ratio=3/2'
```
Since this rule requires multiple parameters, you can use the `Rule::dimensions` method to construct the rule:
Since this rule requires multiple parameters, you can use the `Rule::dimensions` method to construct the rule:
```
use Hyperf\Validation\Rule;
```php
use Hyperf\Validation\Rule;
public function rules(): array
{
return [
'avatar' => [
'required',
Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2),
],
];
}
```
##### distinct
public function rules(): array
{
return [
'avatar' => [
'required',
Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2),
],
];
}
```
##### distinct
When processing arrays, the validation field cannot contain duplicate values:
When processing arrays, the validation field cannot contain duplicate values:
```php
'foo.*.id' =>'distinct'
```
```php
'foo.*.id' => 'distinct'
```
##### email
##### email
The validation field must be a properly formatted email address.
The validation field must be a properly formatted email address.
##### exists:table,column
##### exists:table,column
The validation field must exist in the specified data table.
The validation field must exist in the specified data table.
Basic use:
Basic use:
```
'state' =>'exists:states'
```php
'state' => 'exists:states'
```
If the `column` option is not specified, the field name will be used.
@ -603,13 +603,13 @@ If the `column` option is not specified, the field name will be used.
Specify a custom column name:
```php
'state' =>'exists:states,abbreviation'
'state' => 'exists:states,abbreviation'
```
Sometimes, you may need to specify the database connection to be used for the `exists` query. This can be achieved by using the `.` pre-database connection before the table name:
```php
'email' =>'exists:connection.staff,email'
'email' => 'exists:connection.staff,email'
```
If you want to customize the query executed by the validation rules, you can use the `Rule` class to define the rules. In this example, we also specify the validation rules in the form of an array, instead of using `|` characters to qualify them:
@ -703,7 +703,7 @@ The field under validation must be less than or equal to the maximum value, whic
The validation file must match one of the given `MIME` file types:
```php
'video' =>'mimetypes:video/avi,video/mpeg,video/quicktime'
'video' => 'mimetypes:video/avi,video/mpeg,video/quicktime'
```
In order to determine the `MIME` type of the uploaded file, the component will read the file content to guess the `MIME` type, which may be different from the client's `MIME` type.
@ -714,7 +714,7 @@ The `MIME` type of the validation file must be one of the extension types listed
Basic usage of `MIME` rules:
```php
'photo' =>'mimes:jpeg,bmp,png'
'photo' => 'mimes:jpeg,bmp,png'
```
Although you only specify the extension, this rule actually verifies the file `MIME` type obtained by reading the file content.
@ -763,7 +763,7 @@ The field under validation must match the given regular expression.
The bottom layer of this rule is the `preg_match` function of `PHP`. Therefore, the specified pattern needs to follow the format required by the `preg_match` function and contain a valid separator. E.g:
```php
'email' =>'regex:/^.+@.+$/i'
'email' => 'regex:/^.+@.+$/i'
```
Note: When using the `regex/not_regex` mode, the rules must be placed in an array instead of pipe separators, especially when the regular expression contains pipe symbols.
@ -842,14 +842,14 @@ The field under validation must be unique on a given data table. If the `column`
1. Specify the custom column name:
```php
'email' =>'unique:users,email_address'
'email' => 'unique:users,email_address'
```
2. Custom database connection:
Sometimes, you may need to customize the database connection generated by the validator. As you can see above, setting `unique:users` as the authentication rule will use the default database connection to query the database. To override the default connection, use "." after the data table name to specify the connection:
```php
'email' =>'unique:connection.users,email_address'
'email' => 'unique:connection.users,email_address'
```
3. Force a unique rule that ignores a given `ID`:
@ -913,7 +913,7 @@ In some scenarios, you may want to perform validation checks when only a certain
```php
$validator = $this->validationFactory->make($data, [
'email' =>'sometimes|required|email',
'email' => 'sometimes|required|email',
]);
```
@ -927,8 +927,8 @@ Sometimes you may want to add validation rules based on more complex conditional
```php
$validator = $this->validationFactory->make($data, [
'email' =>'required|email',
'games' =>'required|numeric',
'email' => 'required|email',
'games' => 'required|numeric',
]);
```
@ -956,7 +956,7 @@ It is no longer a pain to verify the input fields of the form array. For example
```php
$validator = $this->validationFactory->make($request->all(), [
'photos.profile' =>'required|image',
'photos.profile' => 'required|image',
]);
```
@ -964,8 +964,8 @@ We can also verify each element of the array. For example, to verify that each e
```php
$validator = $this->validationFactory->make($request->all(), [
'person.*.email' =>'email|unique:users',
'person.*.first_name' =>'required_with:person.*.last_name',
'person.*.email' => 'email|unique:users',
'person.*.first_name' => 'required_with:person.*.last_name',
]);
```
@ -974,7 +974,7 @@ Similarly, in the language file, you can also use the `*` character to specify t
```php
'custom' => [
'person.*.email' => [
'unique' =>'E-mail address of each person must be unique',
'unique' => 'E-mail address of each person must be unique',
]
],
```
@ -1028,7 +1028,7 @@ You also need to define error messages for custom rules. You can use inline cust
`storage/languages/en/validation.php` add the following content to the file array
```php
'foo' =>'The :attribute must be foo',
'foo' => 'The :attribute must be foo',
```
`storage/languages/zh_CN/validation.php` add the following content to the file array
@ -1039,7 +1039,7 @@ You also need to define error messages for custom rules. You can use inline cust
#### Custom validator usage
```
```php
<?php
declare(strict_types=1);
@ -1065,7 +1065,7 @@ class DemoRequest extends FormRequest
{
return [
// use foo validator
'name' =>'foo'
'name' => 'foo'
];
}
}

View File

@ -872,11 +872,11 @@ After installing the extension package, you can override the view in the extensi
## Optional middleware
-Hyperf\ViewEngine\Http\Middleware\ShareErrorsFromSession::class
- Hyperf\ViewEngine\Http\Middleware\ShareErrorsFromSession::class
Automatically share the `errors` in the `session` to the view, relying on the `hyperf/session` component
-Hyperf\ViewEngine\Http\Middleware\ValidationExceptionHandle::class
- Hyperf\ViewEngine\Http\Middleware\ValidationExceptionHandle::class
Automatically catch exceptions in `validation` and add them to `session`, relying on `hyperf/session` and `hyperf/validation` components

View File

@ -1,5 +1,21 @@
# 版本更新记录
# v3.1.16 - 2024-04-02
## 新增
- [#6632](https://github.com/hyperf/hyperf/pull/6632) 为 `websocket-client` 增加设置 `headers` 的能力。
- [#6648](https://github.com/hyperf/hyperf/pull/6648) 使用 `WebSocket` 组件的 `Sender::push()``Sender::disconnect` 时,增加 `bool` 类型的返回值。
## 修复
- [#6633](https://github.com/hyperf/hyperf/pull/6633) 修复定时任务会偶发跳过某些任务,不执行的问题。
- [#6635](https://github.com/hyperf/hyperf/pull/6635) 修复 `ConsumerMessage::getQueue` 的返回类型。
## 优化
- [#6640](https://github.com/hyperf/hyperf/pull/6640) 为 `hyperf/constants` 增加 PHP8 注解的支持。
# v3.1.15 - 2024-03-28
## 新增

View File

@ -97,7 +97,7 @@ php bin/hyperf.php vendor:publish hyperf/amqp
由于 `composer.json` 内的 `extra` 属性在数据不被利用时无其它作用和影响,故这些组件内的定义在其它框架使用时,不会造成任何的干扰和影响,故`ConfigProvider` 是一种仅作用于 Hyperf 框架的机制,对其它没有利用此机制的框架不会造成任何的影响,这也就为组件的复用打下了基础,但这也要求在进行组件设计时,必须遵循以下规范:
- 所有类的设计都必须允许通过标准 `OOP` 的使用方式来使用,所有 Hyperf 专有的功能必须作为增强功能并以单独的类来提供,也就意味着在非 Hyperf 框架下仍能通过标准的手段来实现组件的使用;
- 组件的依赖设计如果可满足 [PSR 标准](https://www.php-fig.org/psr) 则优先满足且依赖对应的接口而不是实现类;如 [PSR 标准](https://www.php-fig.org/psr) 没有包含的功能,则可满足由 Hyperf 定义的契约库 [Hyperf/contract](https://github.com/hyperf/contract) 内的接口时优先满足且依赖对应的接口而不是实现类;
- 组件的依赖设计如果可满足 [PSR 标准](https://www.php-fig.org/psr) 则优先满足且依赖对应的接口而不是实现类;如 [PSR 标准](https://www.php-fig.org/psr) 没有包含的功能,则可满足由 Hyperf 定义的契约库 [hyperf/contract](https://github.com/hyperf/contract) 内的接口时优先满足且依赖对应的接口而不是实现类;
- 对于实现 Hyperf 专有功能所增加的增强功能类,通常来说也会对 Hyperf 的一些组件有依赖,那么这些组件的依赖不应该写在 `composer.json``require` 项,而是写在 `suggest` 项作为建议项存在;
- 组件设计时不应该通过注解进行任何的依赖注入,注入方式应只使用 `构造函数注入` 的方式,这样同时也能满足在 `OOP` 下的使用;
- 组件设计时不应该通过注解进行任何的功能定义,功能定义应只通过 `ConfigProvider` 来定义;

View File

@ -194,7 +194,7 @@ class IndexController
如果您希望通过 http 访问上传到本地的文件,请在 `config/autoload/server.php` 配置中增加以下配置。
```
```php
return [
'settings' => [
...

View File

@ -725,7 +725,7 @@ $this->validationFactory->make($request->all(), [
由于该规则要求多个参数,可以使用 `Rule::dimensions` 方法来构造该规则:
```
```php
use Hyperf\Validation\Rule;
public function rules(): array
@ -756,7 +756,7 @@ return [
基本使用:
```
```php
'state' => 'exists:states'
```
@ -1205,7 +1205,7 @@ class ValidatorFactoryResolvedListener implements ListenerInterface
#### 自定义验证器使用
```
```php
<?php
declare(strict_types=1);

View File

@ -1,5 +1,21 @@
# 版本更新記錄
# v3.1.16 - 2024-04-02
## 新增
- [#6632](https://github.com/hyperf/hyperf/pull/6632) 為 `websocket-client` 增加設置 `headers` 的能力。
- [#6648](https://github.com/hyperf/hyperf/pull/6648) 使用 `WebSocket` 組件的 `Sender::push()``Sender::disconnect` 時,增加 `bool` 類型的返回值。
## 修復
- [#6633](https://github.com/hyperf/hyperf/pull/6633) 修復定時任務會偶發跳過某些任務,不執行的問題。
- [#6635](https://github.com/hyperf/hyperf/pull/6635) 修復 `ConsumerMessage::getQueue` 的返回類型。
## 優化
- [#6640](https://github.com/hyperf/hyperf/pull/6640) 為 `hyperf/constants` 增加 PHP8 註解的支持。
# v3.1.15 - 2024-03-28
## 新增

View File

@ -97,7 +97,7 @@ php bin/hyperf.php vendor:publish hyperf/amqp
由於 `composer.json` 內的 `extra` 屬性在數據不被利用時無其它作用和影響,故這些組件內的定義在其它框架使用時,不會造成任何的干擾和影響,故`ConfigProvider` 是一種僅作用於 Hyperf 框架的機制,對其它沒有利用此機制的框架不會造成任何的影響,這也就為組件的複用打下了基礎,但這也要求在進行組件設計時,必須遵循以下規範:
- 所有類的設計都必須允許通過標準 `OOP` 的使用方式來使用,所有 Hyperf 專有的功能必須作為增強功能並以單獨的類來提供,也就意味着在非 Hyperf 框架下仍能通過標準的手段來實現組件的使用;
- 組件的依賴設計如果可滿足 [PSR 標準](https://www.php-fig.org/psr) 則優先滿足且依賴對應的接口而不是實現類;如 [PSR 標準](https://www.php-fig.org/psr) 沒有包含的功能,則可滿足由 Hyperf 定義的契約庫 [Hyperf/contract](https://github.com/hyperf/contract) 內的接口時優先滿足且依賴對應的接口而不是實現類;
- 組件的依賴設計如果可滿足 [PSR 標準](https://www.php-fig.org/psr) 則優先滿足且依賴對應的接口而不是實現類;如 [PSR 標準](https://www.php-fig.org/psr) 沒有包含的功能,則可滿足由 Hyperf 定義的契約庫 [hyperf/contract](https://github.com/hyperf/contract) 內的接口時優先滿足且依賴對應的接口而不是實現類;
- 對於實現 Hyperf 專有功能所增加的增強功能類,通常來説也會對 Hyperf 的一些組件有依賴,那麼這些組件的依賴不應該寫在 `composer.json``require` 項,而是寫在 `suggest` 項作為建議項存在;
- 組件設計時不應該通過註解進行任何的依賴注入,注入方式應只使用 `構造函數注入` 的方式,這樣同時也能滿足在 `OOP` 下的使用;
- 組件設計時不應該通過註解進行任何的功能定義,功能定義應只通過 `ConfigProvider` 來定義;

View File

@ -194,7 +194,7 @@ class IndexController
如果您希望通過 http 訪問上傳到本地的文件,請在 `config/autoload/server.php` 配置中增加以下配置。
```
```php
return [
'settings' => [
...

View File

@ -725,7 +725,7 @@ $this->validationFactory->make($request->all(), [
由於該規則要求多個參數,可以使用 `Rule::dimensions` 方法來構造該規則:
```
```php
use Hyperf\Validation\Rule;
public function rules(): array
@ -756,7 +756,7 @@ return [
基本使用:
```
```php
'state' => 'exists:states'
```
@ -1205,7 +1205,7 @@ class ValidatorFactoryResolvedListener implements ListenerInterface
#### 自定義驗證器使用
```
```php
<?php
declare(strict_types=1);

View File

@ -1,5 +1,21 @@
# 版本更新記錄
# v3.1.16 - 2024-04-02
## 新增
- [#6632](https://github.com/hyperf/hyperf/pull/6632) 為 `websocket-client` 增加設定 `headers` 的能力。
- [#6648](https://github.com/hyperf/hyperf/pull/6648) 使用 `WebSocket` 元件的 `Sender::push()``Sender::disconnect` 時,增加 `bool` 型別的返回值。
## 修復
- [#6633](https://github.com/hyperf/hyperf/pull/6633) 修復定時任務會偶發跳過某些任務,不執行的問題。
- [#6635](https://github.com/hyperf/hyperf/pull/6635) 修復 `ConsumerMessage::getQueue` 的返回型別。
## 最佳化
- [#6640](https://github.com/hyperf/hyperf/pull/6640) 為 `hyperf/constants` 增加 PHP8 註解的支援。
# v3.1.15 - 2024-03-28
## 新增

View File

@ -97,7 +97,7 @@ php bin/hyperf.php vendor:publish hyperf/amqp
由於 `composer.json` 內的 `extra` 屬性在資料不被利用時無其它作用和影響,故這些元件內的定義在其它框架使用時,不會造成任何的干擾和影響,故`ConfigProvider` 是一種僅作用於 Hyperf 框架的機制,對其它沒有利用此機制的框架不會造成任何的影響,這也就為元件的複用打下了基礎,但這也要求在進行元件設計時,必須遵循以下規範:
- 所有類的設計都必須允許透過標準 `OOP` 的使用方式來使用,所有 Hyperf 專有的功能必須作為增強功能並以單獨的類來提供,也就意味著在非 Hyperf 框架下仍能透過標準的手段來實現元件的使用;
- 元件的依賴設計如果可滿足 [PSR 標準](https://www.php-fig.org/psr) 則優先滿足且依賴對應的介面而不是實現類;如 [PSR 標準](https://www.php-fig.org/psr) 沒有包含的功能,則可滿足由 Hyperf 定義的契約庫 [Hyperf/contract](https://github.com/hyperf/contract) 內的介面時優先滿足且依賴對應的介面而不是實現類;
- 元件的依賴設計如果可滿足 [PSR 標準](https://www.php-fig.org/psr) 則優先滿足且依賴對應的介面而不是實現類;如 [PSR 標準](https://www.php-fig.org/psr) 沒有包含的功能,則可滿足由 Hyperf 定義的契約庫 [hyperf/contract](https://github.com/hyperf/contract) 內的介面時優先滿足且依賴對應的介面而不是實現類;
- 對於實現 Hyperf 專有功能所增加的增強功能類,通常來說也會對 Hyperf 的一些元件有依賴,那麼這些元件的依賴不應該寫在 `composer.json``require` 項,而是寫在 `suggest` 項作為建議項存在;
- 元件設計時不應該透過註解進行任何的依賴注入,注入方式應只使用 `建構函式注入` 的方式,這樣同時也能滿足在 `OOP` 下的使用;
- 元件設計時不應該透過註解進行任何的功能定義,功能定義應只通過 `ConfigProvider` 來定義;

View File

@ -194,7 +194,7 @@ class IndexController
如果您希望透過 http 訪問上傳到本地的檔案,請在 `config/autoload/server.php` 配置中增加以下配置。
```
```php
return [
'settings' => [
...

View File

@ -725,7 +725,7 @@ $this->validationFactory->make($request->all(), [
由於該規則要求多個引數,可以使用 `Rule::dimensions` 方法來構造該規則:
```
```php
use Hyperf\Validation\Rule;
public function rules(): array
@ -756,7 +756,7 @@ return [
基本使用:
```
```php
'state' => 'exists:states'
```
@ -1205,7 +1205,7 @@ class ValidatorFactoryResolvedListener implements ListenerInterface
#### 自定義驗證器使用
```
```php
<?php
declare(strict_types=1);

View File

@ -120,7 +120,7 @@ class CrontabDispatcherProcess extends AbstractProcess
{
$minuteTimestamp = (int) (time() / 60);
if ($this->minuteTimestamp !== 0 && $minuteTimestamp === $this->minuteTimestamp) {
$this->logger?->error('Crontab tasks will be executed at the same minute, but the framework found it, so you don\'t care it. If you received the error message, you can open a issue in `hyperf/hyperf`.');
$this->logger?->debug('Crontab tasks will be executed at the same minute, but the framework found it, so you don\'t care it. If you received the error message, you can open a issue in `hyperf/hyperf`.');
if (CoordinatorManager::until(Constants::WORKER_EXIT)->yield(0.1)) {
return true;
}

View File

@ -62,7 +62,7 @@ class SenderTest extends TestCase
],
]);
$sender = new Sender($container);
$sender->setResponse(1, new class (){
$sender->setResponse(1, new class() {
public function push($data)
{
return true;