mirror of https://github.com/1099438829/apeblog
更新调整
This commit is contained in:
parent
042bd8eab4
commit
d8e693aa52
|
|
@ -116,7 +116,7 @@ class Index extends AuthController
|
||||||
foreach ($categoryInfo as $v) {
|
foreach ($categoryInfo as $v) {
|
||||||
$str .= '<url>';
|
$str .= '<url>';
|
||||||
$str .= '<loc>' . url('index/article/lists',["id"=>$v["alias"]?:$v['id']],".html",$domain) . '</loc>';
|
$str .= '<loc>' . url('index/article/lists',["id"=>$v["alias"]?:$v['id']],".html",$domain) . '</loc>';
|
||||||
$str .= '<lastmod>' . $v['create_time'] . '</lastmod>';
|
$str .= '<lastmod>' . date("Y-M-DTH:i:s+00:00",strtotime($v['create_time'])) . '</lastmod>';
|
||||||
$str .= '<changefreq>always</changefreq>';
|
$str .= '<changefreq>always</changefreq>';
|
||||||
$str .= '<priority>0.8</priority>';
|
$str .= '<priority>0.8</priority>';
|
||||||
$str .= '</url>';
|
$str .= '</url>';
|
||||||
|
|
@ -131,7 +131,7 @@ class Index extends AuthController
|
||||||
foreach ($documentInfo as $v) {
|
foreach ($documentInfo as $v) {
|
||||||
$str .= '<url>';
|
$str .= '<url>';
|
||||||
$str .= '<loc>' . url('/index/article/detail',["id"=>$v["alias"]?:$v['id']],".html",$domain) . '</loc>';
|
$str .= '<loc>' . url('/index/article/detail',["id"=>$v["alias"]?:$v['id']],".html",$domain) . '</loc>';
|
||||||
$str .= '<lastmod>' . $v['create_time'] . '</lastmod>';
|
$str .= '<lastmod>' . date("Y-M-DTH:i:s+00:00",strtotime($v['create_time'])) . '</lastmod>';
|
||||||
$str .= '<changefreq>monthly</changefreq>';
|
$str .= '<changefreq>monthly</changefreq>';
|
||||||
$str .= '<priority>0.6</priority>';
|
$str .= '<priority>0.6</priority>';
|
||||||
$str .= '</url>';
|
$str .= '</url>';
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,27 @@ function get_document_category_by_name($name, $field = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个文章分类
|
||||||
|
*/
|
||||||
|
function get_document_category_by($x, $field = false)
|
||||||
|
{
|
||||||
|
if (!$x) {
|
||||||
|
throw new Exception('请指定要获取的栏目分类id!');
|
||||||
|
}
|
||||||
|
//获取缓存的文章菜单
|
||||||
|
$documentCategoryList = get_document_category_list();
|
||||||
|
if (!isset($documentCategoryList[$x])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($field) {
|
||||||
|
return $documentCategoryList[$x][$field];
|
||||||
|
} else {
|
||||||
|
$documentCategoryList[$x]['child'] = implode(",",array_column(getSubs($documentCategoryList,$x),"id"));
|
||||||
|
return $documentCategoryList[$x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板-获取文章分类
|
* 模板-获取文章分类
|
||||||
* @param $type
|
* @param $type
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ return [
|
||||||
// 自动多应用模式
|
// 自动多应用模式
|
||||||
'auto_multi_app' => true,
|
'auto_multi_app' => true,
|
||||||
// 应用映射(自动多应用模式有效)
|
// 应用映射(自动多应用模式有效)
|
||||||
'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index'],
|
'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index','api'=>'api'],
|
||||||
// 域名绑定(自动多应用模式有效)
|
// 域名绑定(自动多应用模式有效)
|
||||||
'domain_bind' => [],
|
'domain_bind' => [],
|
||||||
// 禁止URL访问的应用列表(自动多应用模式有效)
|
// 禁止URL访问的应用列表(自动多应用模式有效)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||||
// 执行HTTP应用并响应
|
// 执行HTTP应用并响应
|
||||||
$http = (new App())->http;
|
$http = (new App())->http;
|
||||||
|
|
||||||
$response = $http->app()->run();
|
$response = $http->name('admin')->run();
|
||||||
|
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
||||||
$http->end($response);
|
$http->end($response);
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// [ 应用入口文件 ]
|
||||||
|
namespace think;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
// 执行HTTP应用并响应
|
||||||
|
$http = (new App())->http;
|
||||||
|
|
||||||
|
$response = $http->name('api')->run();
|
||||||
|
|
||||||
|
$response->send();
|
||||||
|
|
||||||
|
$http->end($response);
|
||||||
|
|
@ -26,7 +26,7 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||||
// 执行HTTP应用并响应
|
// 执行HTTP应用并响应
|
||||||
$http = (new App())->http;
|
$http = (new App())->http;
|
||||||
|
|
||||||
$response = $http->run();
|
$response = $http->name('index')->run();
|
||||||
|
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
location / {
|
location / {
|
||||||
if (!-e $request_filename) {
|
if (!-e $request_filename){
|
||||||
rewrite ^(.*)$ /index.php?s=/$1 last;
|
rewrite /api.php(.*)$ /api.php$1 last;
|
||||||
}
|
rewrite /admin.php(.*)$ /admin.php$1 last;
|
||||||
}
|
rewrite ^(.*)$ /index.php/$1 last;
|
||||||
|
break;
|
||||||
|
#rewrite ^(.*)$ /index.php?s=/$1 last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ return array(
|
||||||
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
|
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
|
||||||
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
|
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
|
||||||
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
|
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
|
||||||
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-template/src'),
|
'think\\' => array($vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/framework/src/think'),
|
||||||
'mailer\\' => array($vendorDir . '/yzh52521/think-mail/src/mailer'),
|
'mailer\\' => array($vendorDir . '/yzh52521/think-mail/src/mailer'),
|
||||||
'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'),
|
'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'),
|
||||||
'liliuwei\\sitemap\\' => array($vendorDir . '/liliuwei/php-sitemap/src'),
|
'liliuwei\\sitemap\\' => array($vendorDir . '/liliuwei/php-sitemap/src'),
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,11 @@ class ComposerStaticInit4b57298e8d0e895486f3307a354a7e1a
|
||||||
),
|
),
|
||||||
'think\\' =>
|
'think\\' =>
|
||||||
array (
|
array (
|
||||||
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
0 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
|
||||||
1 => __DIR__ . '/..' . '/topthink/think-orm/src',
|
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||||
2 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
|
||||||
3 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
|
3 => __DIR__ . '/..' . '/topthink/think-template/src',
|
||||||
4 => __DIR__ . '/..' . '/topthink/think-template/src',
|
4 => __DIR__ . '/..' . '/topthink/framework/src/think',
|
||||||
),
|
),
|
||||||
'mailer\\' =>
|
'mailer\\' =>
|
||||||
array (
|
array (
|
||||||
|
|
|
||||||
|
|
@ -87,17 +87,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/deprecations",
|
"name": "doctrine/deprecations",
|
||||||
"version": "v1.0.0",
|
"version": "v1.1.0",
|
||||||
"version_normalized": "1.0.0.0",
|
"version_normalized": "1.1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/doctrine/deprecations.git",
|
"url": "https://github.com/doctrine/deprecations.git",
|
||||||
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
|
"reference": "8cffffb2218e01f3b370bf763e00e81697725259"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
|
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/8cffffb2218e01f3b370bf763e00e81697725259",
|
||||||
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
|
"reference": "8cffffb2218e01f3b370bf763e00e81697725259",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +117,7 @@
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
|
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
|
||||||
},
|
},
|
||||||
"time": "2022-05-02T15:47:09+00:00",
|
"time": "2023-05-29T18:55:17+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
"homepage": "https://www.doctrine-project.org/",
|
"homepage": "https://www.doctrine-project.org/",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/doctrine/deprecations/issues",
|
"issues": "https://github.com/doctrine/deprecations/issues",
|
||||||
"source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
|
"source": "https://github.com/doctrine/deprecations/tree/v1.1.0"
|
||||||
},
|
},
|
||||||
"install-path": "../doctrine/deprecations"
|
"install-path": "../doctrine/deprecations"
|
||||||
},
|
},
|
||||||
|
|
@ -226,17 +226,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "egulias/email-validator",
|
"name": "egulias/email-validator",
|
||||||
"version": "3.2.5",
|
"version": "3.2.6",
|
||||||
"version_normalized": "3.2.5.0",
|
"version_normalized": "3.2.6.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/egulias/EmailValidator.git",
|
"url": "https://github.com/egulias/EmailValidator.git",
|
||||||
"reference": "b531a2311709443320c786feb4519cfaf94af796"
|
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b531a2311709443320c786feb4519cfaf94af796",
|
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
|
||||||
"reference": "b531a2311709443320c786feb4519cfaf94af796",
|
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +257,7 @@
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||||
},
|
},
|
||||||
"time": "2023-01-02T17:26:14+00:00",
|
"time": "2023-06-01T07:04:22+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
|
@ -290,7 +290,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/egulias/EmailValidator/issues",
|
"issues": "https://github.com/egulias/EmailValidator/issues",
|
||||||
"source": "https://github.com/egulias/EmailValidator/tree/3.2.5"
|
"source": "https://github.com/egulias/EmailValidator/tree/3.2.6"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
|
@ -1361,17 +1361,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/http-foundation",
|
"name": "symfony/http-foundation",
|
||||||
"version": "v5.4.23",
|
"version": "v5.4.25",
|
||||||
"version_normalized": "5.4.23.0",
|
"version_normalized": "5.4.25.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/http-foundation.git",
|
"url": "https://github.com/symfony/http-foundation.git",
|
||||||
"reference": "af9fbb378f5f956c8f29d4886644c84c193780ac"
|
"reference": "f66be2706075c5f6325d2fe2b743a57fb5d23f6b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/af9fbb378f5f956c8f29d4886644c84c193780ac",
|
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/f66be2706075c5f6325d2fe2b743a57fb5d23f6b",
|
||||||
"reference": "af9fbb378f5f956c8f29d4886644c84c193780ac",
|
"reference": "f66be2706075c5f6325d2fe2b743a57fb5d23f6b",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
|
|
@ -1398,7 +1398,7 @@
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/mime": "To use the file extension guesser"
|
"symfony/mime": "To use the file extension guesser"
|
||||||
},
|
},
|
||||||
"time": "2023-04-18T06:30:11+00:00",
|
"time": "2023-06-22T08:06:06+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
@ -1426,7 +1426,7 @@
|
||||||
"description": "Defines an object-oriented layer for the HTTP specification",
|
"description": "Defines an object-oriented layer for the HTTP specification",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/http-foundation/tree/v5.4.23"
|
"source": "https://github.com/symfony/http-foundation/tree/v5.4.25"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
|
@ -2272,17 +2272,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/framework",
|
"name": "topthink/framework",
|
||||||
"version": "v6.1.2",
|
"version": "v6.1.4",
|
||||||
"version_normalized": "6.1.2.0",
|
"version_normalized": "6.1.4.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/framework.git",
|
"url": "https://github.com/top-think/framework.git",
|
||||||
"reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3"
|
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/framework/zipball/67235be5b919aaaf1de5aed9839f65d8e766aca3",
|
"url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c",
|
||||||
"reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3",
|
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
|
|
@ -2308,7 +2308,7 @@
|
||||||
"mockery/mockery": "^1.2",
|
"mockery/mockery": "^1.2",
|
||||||
"phpunit/phpunit": "^7.0"
|
"phpunit/phpunit": "^7.0"
|
||||||
},
|
},
|
||||||
"time": "2023-02-08T02:24:01+00:00",
|
"time": "2023-07-11T15:16:03+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
@ -2340,7 +2340,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/top-think/framework/issues",
|
"issues": "https://github.com/top-think/framework/issues",
|
||||||
"source": "https://github.com/top-think/framework/tree/v6.1.2"
|
"source": "https://github.com/top-think/framework/tree/v6.1.4"
|
||||||
},
|
},
|
||||||
"install-path": "../topthink/framework"
|
"install-path": "../topthink/framework"
|
||||||
},
|
},
|
||||||
|
|
@ -2572,17 +2572,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "topthink/think-multi-app",
|
"name": "topthink/think-multi-app",
|
||||||
"version": "v1.0.16",
|
"version": "v1.0.17",
|
||||||
"version_normalized": "1.0.16.0",
|
"version_normalized": "1.0.17.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/top-think/think-multi-app.git",
|
"url": "https://github.com/top-think/think-multi-app.git",
|
||||||
"reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f"
|
"reference": "4055a6187296ac16c0bc7bbab4ed5d92f82f791c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/07b9183855150455e1f76f8cbe9d77d6d1bc399f",
|
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/4055a6187296ac16c0bc7bbab4ed5d92f82f791c",
|
||||||
"reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f",
|
"reference": "4055a6187296ac16c0bc7bbab4ed5d92f82f791c",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
|
|
@ -2595,7 +2595,7 @@
|
||||||
"php": ">=7.1.0",
|
"php": ">=7.1.0",
|
||||||
"topthink/framework": "^6.0|^8.0"
|
"topthink/framework": "^6.0|^8.0"
|
||||||
},
|
},
|
||||||
"time": "2023-02-07T08:40:09+00:00",
|
"time": "2023-03-29T02:04:29+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
|
@ -2620,10 +2620,10 @@
|
||||||
"email": "liu21st@gmail.com"
|
"email": "liu21st@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "thinkphp6 multi app support",
|
"description": "thinkphp multi app support",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/top-think/think-multi-app/issues",
|
"issues": "https://github.com/top-think/think-multi-app/issues",
|
||||||
"source": "https://github.com/top-think/think-multi-app/tree/v1.0.16"
|
"source": "https://github.com/top-think/think-multi-app/tree/v1.0.17"
|
||||||
},
|
},
|
||||||
"install-path": "../topthink/think-multi-app"
|
"install-path": "../topthink/think-multi-app"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
'name' => 'topthink/think',
|
'name' => 'topthink/think',
|
||||||
'pretty_version' => 'dev-master',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-master',
|
'version' => 'dev-master',
|
||||||
'reference' => 'c7deee9ae9a946ac4af3f530791f720402b7692d',
|
'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6',
|
||||||
'type' => 'project',
|
'type' => 'project',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -20,9 +20,9 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'doctrine/deprecations' => array(
|
'doctrine/deprecations' => array(
|
||||||
'pretty_version' => 'v1.0.0',
|
'pretty_version' => 'v1.1.0',
|
||||||
'version' => '1.0.0.0',
|
'version' => '1.1.0.0',
|
||||||
'reference' => '0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de',
|
'reference' => '8cffffb2218e01f3b370bf763e00e81697725259',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../doctrine/deprecations',
|
'install_path' => __DIR__ . '/../doctrine/deprecations',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -38,9 +38,9 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'egulias/email-validator' => array(
|
'egulias/email-validator' => array(
|
||||||
'pretty_version' => '3.2.5',
|
'pretty_version' => '3.2.6',
|
||||||
'version' => '3.2.5.0',
|
'version' => '3.2.6.0',
|
||||||
'reference' => 'b531a2311709443320c786feb4519cfaf94af796',
|
'reference' => 'e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../egulias/email-validator',
|
'install_path' => __DIR__ . '/../egulias/email-validator',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -194,9 +194,9 @@
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'symfony/http-foundation' => array(
|
'symfony/http-foundation' => array(
|
||||||
'pretty_version' => 'v5.4.23',
|
'pretty_version' => 'v5.4.25',
|
||||||
'version' => '5.4.23.0',
|
'version' => '5.4.25.0',
|
||||||
'reference' => 'af9fbb378f5f956c8f29d4886644c84c193780ac',
|
'reference' => 'f66be2706075c5f6325d2fe2b743a57fb5d23f6b',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../symfony/http-foundation',
|
'install_path' => __DIR__ . '/../symfony/http-foundation',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -284,9 +284,9 @@
|
||||||
'dev_requirement' => true,
|
'dev_requirement' => true,
|
||||||
),
|
),
|
||||||
'topthink/framework' => array(
|
'topthink/framework' => array(
|
||||||
'pretty_version' => 'v6.1.2',
|
'pretty_version' => 'v6.1.4',
|
||||||
'version' => '6.1.2.0',
|
'version' => '6.1.4.0',
|
||||||
'reference' => '67235be5b919aaaf1de5aed9839f65d8e766aca3',
|
'reference' => '66eb9cf4d627df12911344cd328faf9bb596bf2c',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../topthink/framework',
|
'install_path' => __DIR__ . '/../topthink/framework',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -295,7 +295,7 @@
|
||||||
'topthink/think' => array(
|
'topthink/think' => array(
|
||||||
'pretty_version' => 'dev-master',
|
'pretty_version' => 'dev-master',
|
||||||
'version' => 'dev-master',
|
'version' => 'dev-master',
|
||||||
'reference' => 'c7deee9ae9a946ac4af3f530791f720402b7692d',
|
'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6',
|
||||||
'type' => 'project',
|
'type' => 'project',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
@ -338,9 +338,9 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'topthink/think-multi-app' => array(
|
'topthink/think-multi-app' => array(
|
||||||
'pretty_version' => 'v1.0.16',
|
'pretty_version' => 'v1.0.17',
|
||||||
'version' => '1.0.16.0',
|
'version' => '1.0.17.0',
|
||||||
'reference' => '07b9183855150455e1f76f8cbe9d77d6d1bc399f',
|
'reference' => '4055a6187296ac16c0bc7bbab4ed5d92f82f791c',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../topthink/think-multi-app',
|
'install_path' => __DIR__ . '/../topthink/think-multi-app',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,16 @@ Enable Doctrine deprecations to be sent to a PSR3 logger:
|
||||||
```
|
```
|
||||||
|
|
||||||
Enable Doctrine deprecations to be sent as `@trigger_error($message, E_USER_DEPRECATED)`
|
Enable Doctrine deprecations to be sent as `@trigger_error($message, E_USER_DEPRECATED)`
|
||||||
messages.
|
messages by setting the `DOCTRINE_DEPRECATIONS` environment variable to `trigger`.
|
||||||
|
Alternatively, call:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
\Doctrine\Deprecations\Deprecation::enableWithTriggerError();
|
\Doctrine\Deprecations\Deprecation::enableWithTriggerError();
|
||||||
```
|
```
|
||||||
|
|
||||||
If you only want to enable deprecation tracking, without logging or calling `trigger_error` then call:
|
If you only want to enable deprecation tracking, without logging or calling `trigger_error`
|
||||||
|
then set the `DOCTRINE_DEPRECATIONS` environment variable to `track`.
|
||||||
|
Alternatively, call:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
\Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
|
\Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ class Deprecation
|
||||||
private const TYPE_TRIGGER_ERROR = 2;
|
private const TYPE_TRIGGER_ERROR = 2;
|
||||||
private const TYPE_PSR_LOGGER = 4;
|
private const TYPE_PSR_LOGGER = 4;
|
||||||
|
|
||||||
/** @var int */
|
/** @var self::TYPE_*|null */
|
||||||
private static $type = self::TYPE_NONE;
|
private static $type;
|
||||||
|
|
||||||
/** @var LoggerInterface|null */
|
/** @var LoggerInterface|null */
|
||||||
private static $logger;
|
private static $logger;
|
||||||
|
|
@ -72,7 +72,9 @@ class Deprecation
|
||||||
*/
|
*/
|
||||||
public static function trigger(string $package, string $link, string $message, ...$args): void
|
public static function trigger(string $package, string $link, string $message, ...$args): void
|
||||||
{
|
{
|
||||||
if (self::$type === self::TYPE_NONE) {
|
$type = self::$type ?? self::getTypeFromEnv();
|
||||||
|
|
||||||
|
if ($type === self::TYPE_NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +120,9 @@ class Deprecation
|
||||||
*/
|
*/
|
||||||
public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args): void
|
public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args): void
|
||||||
{
|
{
|
||||||
if (self::$type === self::TYPE_NONE) {
|
$type = self::$type ?? self::getTypeFromEnv();
|
||||||
|
|
||||||
|
if ($type === self::TYPE_NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +165,9 @@ class Deprecation
|
||||||
*/
|
*/
|
||||||
private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package): void
|
private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package): void
|
||||||
{
|
{
|
||||||
if ((self::$type & self::TYPE_PSR_LOGGER) > 0) {
|
$type = self::$type ?? self::getTypeFromEnv();
|
||||||
|
|
||||||
|
if (($type & self::TYPE_PSR_LOGGER) > 0) {
|
||||||
$context = [
|
$context = [
|
||||||
'file' => $backtrace[0]['file'],
|
'file' => $backtrace[0]['file'],
|
||||||
'line' => $backtrace[0]['line'],
|
'line' => $backtrace[0]['line'],
|
||||||
|
|
@ -172,7 +178,7 @@ class Deprecation
|
||||||
self::$logger->notice($message, $context);
|
self::$logger->notice($message, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ((self::$type & self::TYPE_TRIGGER_ERROR) > 0)) {
|
if (! (($type & self::TYPE_TRIGGER_ERROR) > 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -263,4 +269,26 @@ class Deprecation
|
||||||
{
|
{
|
||||||
return self::$ignoredLinks;
|
return self::$ignoredLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return self::TYPE_*
|
||||||
|
*/
|
||||||
|
private static function getTypeFromEnv(): int
|
||||||
|
{
|
||||||
|
switch ($_SERVER['DOCTRINE_DEPRECATIONS'] ?? $_ENV['DOCTRINE_DEPRECATIONS'] ?? null) {
|
||||||
|
case 'trigger':
|
||||||
|
self::$type = self::TYPE_TRIGGER_ERROR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'track':
|
||||||
|
self::$type = self::TYPE_TRACK_DEPRECATIONS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
self::$type = self::TYPE_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -213,13 +213,11 @@ class EmailLexer extends AbstractLexer
|
||||||
public function moveNext() : bool
|
public function moveNext() : bool
|
||||||
{
|
{
|
||||||
if ($this->hasToRecord && $this->previous === self::$nullToken) {
|
if ($this->hasToRecord && $this->previous === self::$nullToken) {
|
||||||
$this->accumulator .= $this->token['value'];
|
$this->accumulator .= ((array) $this->token)['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->previous = $this->token instanceof Token
|
$this->previous = (array) $this->token;
|
||||||
? ['value' => $this->token->value, 'type' => $this->token->type, 'position' => $this->token->position]
|
|
||||||
: $this->token;
|
|
||||||
|
|
||||||
if($this->lookahead === null) {
|
if($this->lookahead === null) {
|
||||||
$this->lookahead = self::$nullToken;
|
$this->lookahead = self::$nullToken;
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +225,7 @@ class EmailLexer extends AbstractLexer
|
||||||
$hasNext = parent::moveNext();
|
$hasNext = parent::moveNext();
|
||||||
|
|
||||||
if ($this->hasToRecord) {
|
if ($this->hasToRecord) {
|
||||||
$this->accumulator .= $this->token['value'];
|
$this->accumulator .= ((array) $this->token)['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hasNext;
|
return $hasNext;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ abstract class Parser
|
||||||
|
|
||||||
public function __construct(EmailLexer $lexer)
|
public function __construct(EmailLexer $lexer)
|
||||||
{
|
{
|
||||||
$this->lexer = $lexer;
|
$this->lexer = $lexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parse(string $str) : Result
|
public function parse(string $str) : Result
|
||||||
|
|
@ -51,7 +51,7 @@ abstract class Parser
|
||||||
return $localPartResult;
|
return $localPartResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domainPartResult = $this->parseRightFromAt();
|
$domainPartResult = $this->parseRightFromAt();
|
||||||
|
|
||||||
if ($domainPartResult->isInvalid()) {
|
if ($domainPartResult->isInvalid()) {
|
||||||
return $domainPartResult;
|
return $domainPartResult;
|
||||||
|
|
@ -73,6 +73,6 @@ abstract class Parser
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
return $this->lexer->token['type'] !== EmailLexer::S_AT;
|
return ((array) $this->lexer->token)['type'] !== EmailLexer::S_AT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,15 @@ class Comment extends PartParser
|
||||||
|
|
||||||
public function parse() : Result
|
public function parse() : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||||
$this->openedParenthesis++;
|
$this->openedParenthesis++;
|
||||||
if($this->noClosingParenthesis()) {
|
if($this->noClosingParenthesis()) {
|
||||||
return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']);
|
return new InvalidEmail(new UnclosedComment(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||||
return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']);
|
return new InvalidEmail(new UnOpenedComment(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warnings[WarningComment::CODE] = new WarningComment();
|
$this->warnings[WarningComment::CODE] = new WarningComment();
|
||||||
|
|
@ -58,10 +58,10 @@ class Comment extends PartParser
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->openedParenthesis >= 1) {
|
if($this->openedParenthesis >= 1) {
|
||||||
return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']);
|
return new InvalidEmail(new UnclosedComment(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
if ($this->openedParenthesis < 0) {
|
if ($this->openedParenthesis < 0) {
|
||||||
return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']);
|
return new InvalidEmail(new UnOpenedComment(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer);
|
$finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer);
|
||||||
|
|
@ -78,7 +78,7 @@ class Comment extends PartParser
|
||||||
private function warnEscaping() : bool
|
private function warnEscaping() : bool
|
||||||
{
|
{
|
||||||
//Backslash found
|
//Backslash found
|
||||||
if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
|
if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,12 +87,12 @@ class Comment extends PartParser
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warnings[QuotedPart::CODE] =
|
$this->warnings[QuotedPart::CODE] =
|
||||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
new QuotedPart($this->lexer->getPrevious()['type'], ((array) $this->lexer->token)['type']);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function noClosingParenthesis() : bool
|
private function noClosingParenthesis() : bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
|
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class DomainComment implements CommentStrategy
|
||||||
{
|
{
|
||||||
//test for end of string
|
//test for end of string
|
||||||
if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
|
if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), ((array) $lexer->token)['value']);
|
||||||
}
|
}
|
||||||
//add warning
|
//add warning
|
||||||
//Address is valid within the message but cannot be used unmodified for the envelope
|
//Address is valid within the message but cannot be used unmodified for the envelope
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class LocalComment implements CommentStrategy
|
||||||
public function endOfLoopValidations(EmailLexer $lexer) : Result
|
public function endOfLoopValidations(EmailLexer $lexer) : Result
|
||||||
{
|
{
|
||||||
if (!$lexer->isNextToken(EmailLexer::S_AT)) {
|
if (!$lexer->isNextToken(EmailLexer::S_AT)) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), ((array) $lexer->token)['value']);
|
||||||
}
|
}
|
||||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,14 @@ class DomainLiteral extends PartParser
|
||||||
$addressLiteral = '';
|
$addressLiteral = '';
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ($this->lexer->token['type'] === EmailLexer::C_NUL) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) {
|
||||||
return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingDTEXT(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addObsoleteWarnings();
|
$this->addObsoleteWarnings();
|
||||||
|
|
||||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENBRACKET, EmailLexer::S_OPENBRACKET))) {
|
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||||
return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingDTEXT(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->isNextTokenAny(
|
if ($this->lexer->isNextTokenAny(
|
||||||
|
|
@ -57,21 +57,21 @@ class DomainLiteral extends PartParser
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->isNextToken(EmailLexer::S_CR)) {
|
if ($this->lexer->isNextToken(EmailLexer::S_CR)) {
|
||||||
return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']);
|
return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH) {
|
||||||
return new InvalidEmail(new UnusualElements($this->lexer->token['value']), $this->lexer->token['value']);
|
return new InvalidEmail(new UnusualElements(((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_IPV6TAG) {
|
||||||
$IPv6TAG = true;
|
$IPv6TAG = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEBRACKET) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEBRACKET) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$addressLiteral .= $this->lexer->token['value'];
|
$addressLiteral .= ((array) $this->lexer->token)['value'];
|
||||||
|
|
||||||
} while ($this->lexer->moveNext());
|
} while ($this->lexer->moveNext());
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ class DomainLiteral extends PartParser
|
||||||
$this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();
|
$this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string
|
public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string
|
||||||
{
|
{
|
||||||
$matchesIP = [];
|
$matchesIP = [];
|
||||||
|
|
@ -189,7 +189,7 @@ class DomainLiteral extends PartParser
|
||||||
|
|
||||||
private function addObsoleteWarnings() : void
|
private function addObsoleteWarnings() : void
|
||||||
{
|
{
|
||||||
if(in_array($this->lexer->token['type'], self::OBSOLETE_WARNINGS)) {
|
if(in_array(((array) $this->lexer->token)['type'], self::OBSOLETE_WARNINGS)) {
|
||||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ class DomainPart extends PartParser
|
||||||
return $domainChecks;
|
return $domainChecks;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_AT) {
|
||||||
return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token['value']);
|
return new InvalidEmail(new ConsecutiveAt(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->doParseDomainPart();
|
$result = $this->doParseDomainPart();
|
||||||
|
|
@ -69,7 +69,7 @@ class DomainPart extends PartParser
|
||||||
|
|
||||||
$length = strlen($this->domainPart);
|
$length = strlen($this->domainPart);
|
||||||
if ($length > self::DOMAIN_MAX_LENGTH) {
|
if ($length > self::DOMAIN_MAX_LENGTH) {
|
||||||
return new InvalidEmail(new DomainTooLong(), $this->lexer->token['value']);
|
return new InvalidEmail(new DomainTooLong(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -79,13 +79,13 @@ class DomainPart extends PartParser
|
||||||
{
|
{
|
||||||
$prev = $this->lexer->getPrevious();
|
$prev = $this->lexer->getPrevious();
|
||||||
if ($prev['type'] === EmailLexer::S_DOT) {
|
if ($prev['type'] === EmailLexer::S_DOT) {
|
||||||
return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']);
|
return new InvalidEmail(new DotAtEnd(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
if ($prev['type'] === EmailLexer::S_HYPHEN) {
|
if ($prev['type'] === EmailLexer::S_HYPHEN) {
|
||||||
return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']);
|
return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_SP) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_SP) {
|
||||||
return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']);
|
return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']);
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -98,13 +98,13 @@ class DomainPart extends PartParser
|
||||||
if ($invalidTokens->isInvalid()) {
|
if ($invalidTokens->isInvalid()) {
|
||||||
return $invalidTokens;
|
return $invalidTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
$missingDomain = $this->checkEmptyDomain();
|
$missingDomain = $this->checkEmptyDomain();
|
||||||
if ($missingDomain->isInvalid()) {
|
if ($missingDomain->isInvalid()) {
|
||||||
return $missingDomain;
|
return $missingDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||||
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -112,12 +112,12 @@ class DomainPart extends PartParser
|
||||||
|
|
||||||
private function checkEmptyDomain() : Result
|
private function checkEmptyDomain() : Result
|
||||||
{
|
{
|
||||||
$thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY ||
|
$thereIsNoDomain = ((array) $this->lexer->token)['type'] === EmailLexer::S_EMPTY ||
|
||||||
($this->lexer->token['type'] === EmailLexer::S_SP &&
|
(((array) $this->lexer->token)['type'] === EmailLexer::S_SP &&
|
||||||
!$this->lexer->isNextToken(EmailLexer::GENERIC));
|
!$this->lexer->isNextToken(EmailLexer::GENERIC));
|
||||||
|
|
||||||
if ($thereIsNoDomain) {
|
if ($thereIsNoDomain) {
|
||||||
return new InvalidEmail(new NoDomainPart(), $this->lexer->token['value']);
|
return new InvalidEmail(new NoDomainPart(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -125,11 +125,11 @@ class DomainPart extends PartParser
|
||||||
|
|
||||||
private function checkInvalidTokensAfterAT() : Result
|
private function checkInvalidTokensAfterAT() : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT) {
|
||||||
return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']);
|
return new InvalidEmail(new DotAtStart(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN) {
|
||||||
return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token['value']);
|
return new InvalidEmail(new DomainHyphened('After AT'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
@ -156,8 +156,8 @@ class DomainPart extends PartParser
|
||||||
return $notAllowedChars;
|
return $notAllowedChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS ||
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS ||
|
||||||
$this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) {
|
((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) {
|
||||||
$hasComments = true;
|
$hasComments = true;
|
||||||
$commentsResult = $this->parseComments();
|
$commentsResult = $this->parseComments();
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ class DomainPart extends PartParser
|
||||||
return $dotsResult;
|
return $dotsResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET) {
|
||||||
$literalResult = $this->parseDomainLiteral();
|
$literalResult = $this->parseDomainLiteral();
|
||||||
|
|
||||||
$this->addTLDWarnings($tldMissing);
|
$this->addTLDWarnings($tldMissing);
|
||||||
|
|
@ -189,9 +189,9 @@ class DomainPart extends PartParser
|
||||||
return $FwsResult;
|
return $FwsResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain .= $this->lexer->token['value'];
|
$domain .= ((array) $this->lexer->token)['value'];
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||||
$tldMissing = false;
|
$tldMissing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ class DomainPart extends PartParser
|
||||||
}
|
}
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
} while (null !== $this->lexer->token['type']);
|
} while (null !== ((array) $this->lexer->token)['type']);
|
||||||
|
|
||||||
$labelCheck = $this->checkLabelLength(true);
|
$labelCheck = $this->checkLabelLength(true);
|
||||||
if ($labelCheck->isInvalid()) {
|
if ($labelCheck->isInvalid()) {
|
||||||
|
|
@ -219,8 +219,8 @@ class DomainPart extends PartParser
|
||||||
private function checkNotAllowedChars($token) : Result
|
private function checkNotAllowedChars($token) : Result
|
||||||
{
|
{
|
||||||
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
|
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
|
||||||
if (isset($notAllowed[$token['type']])) {
|
if (isset($notAllowed[((array) $token)['type']])) {
|
||||||
return new InvalidEmail(new CharNotAllowed(), $token['value']);
|
return new InvalidEmail(new CharNotAllowed(), ((array) $token)['value']);
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +233,7 @@ class DomainPart extends PartParser
|
||||||
try {
|
try {
|
||||||
$this->lexer->find(EmailLexer::S_CLOSEBRACKET);
|
$this->lexer->find(EmailLexer::S_CLOSEBRACKET);
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
return new InvalidEmail(new ExpectingDomainLiteralClose(), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingDomainLiteralClose(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$domainLiteralParser = new DomainLiteralParser($this->lexer);
|
$domainLiteralParser = new DomainLiteralParser($this->lexer);
|
||||||
|
|
@ -244,17 +244,17 @@ class DomainPart extends PartParser
|
||||||
|
|
||||||
protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result
|
protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||||
return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
|
return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH
|
||||||
&& $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
&& $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->validateTokens($hasComments);
|
return $this->validateTokens($hasComments);
|
||||||
|
|
@ -273,8 +273,8 @@ class DomainPart extends PartParser
|
||||||
$validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true;
|
$validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($validDomainTokens[$this->lexer->token['type']])) {
|
if (!isset($validDomainTokens[((array) $this->lexer->token)['type']])) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -282,13 +282,13 @@ class DomainPart extends PartParser
|
||||||
|
|
||||||
private function checkLabelLength(bool $isEndOfDomain = false) : Result
|
private function checkLabelLength(bool $isEndOfDomain = false) : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT || $isEndOfDomain) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT || $isEndOfDomain) {
|
||||||
if ($this->isLabelTooLong($this->label)) {
|
if ($this->isLabelTooLong($this->label)) {
|
||||||
return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']);
|
return new InvalidEmail(new LabelTooLong(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
$this->label = '';
|
$this->label = '';
|
||||||
}
|
}
|
||||||
$this->label .= $this->lexer->token['value'];
|
$this->label .= ((array) $this->lexer->token)['value'];
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,24 +30,24 @@ class DoubleQuote extends PartParser
|
||||||
EmailLexer::S_CR => true,
|
EmailLexer::S_CR => true,
|
||||||
EmailLexer::S_LF => true
|
EmailLexer::S_LF => true
|
||||||
];
|
];
|
||||||
|
|
||||||
$setSpecialsWarning = true;
|
$setSpecialsWarning = true;
|
||||||
|
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) {
|
while (((array) $this->lexer->token)['type'] !== EmailLexer::S_DQUOTE && null !== ((array) $this->lexer->token)['type']) {
|
||||||
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
if (isset($special[((array) $this->lexer->token)['type']]) && $setSpecialsWarning) {
|
||||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||||
$setSpecialsWarning = false;
|
$setSpecialsWarning = false;
|
||||||
}
|
}
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) {
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) {
|
if (!$this->escaped() && isset($invalid[((array) $this->lexer->token)['type']])) {
|
||||||
return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ class DoubleQuote extends PartParser
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
|
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
|
||||||
return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -71,15 +71,15 @@ class DoubleQuote extends PartParser
|
||||||
|
|
||||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||||
$description = 'https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit';
|
$description = 'https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit';
|
||||||
return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT($description), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->lexer->find(EmailLexer::S_DQUOTE);
|
$this->lexer->find(EmailLexer::S_DQUOTE);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return new InvalidEmail(new UnclosedQuotedString(), $this->lexer->token['value']);
|
return new InvalidEmail(new UnclosedQuotedString(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
$this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']);
|
$this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], ((array) $this->lexer->token)['value']);
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,16 +36,16 @@ class FoldingWhiteSpace extends PartParser
|
||||||
return $resultCRLF;
|
return $resultCRLF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_CR) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_CR) {
|
||||||
return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']);
|
return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) {
|
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) {
|
||||||
return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token['value']);
|
return new InvalidEmail(new AtextAfterCFWS(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_LF || ((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) {
|
||||||
return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingCTEXT(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
||||||
|
|
@ -59,28 +59,28 @@ class FoldingWhiteSpace extends PartParser
|
||||||
|
|
||||||
protected function checkCRLFInFWS() : Result
|
protected function checkCRLFInFWS() : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] !== EmailLexer::CRLF) {
|
if (((array) $this->lexer->token)['type'] !== EmailLexer::CRLF) {
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||||
return new InvalidEmail(new CRLFX2(), $this->lexer->token['value']);
|
return new InvalidEmail(new CRLFX2(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//this has no coverage. Condition is repeated from above one
|
//this has no coverage. Condition is repeated from above one
|
||||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||||
return new InvalidEmail(new CRLFAtTheEnd(), $this->lexer->token['value']);
|
return new InvalidEmail(new CRLFAtTheEnd(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isFWS() : bool
|
protected function isFWS() : bool
|
||||||
{
|
{
|
||||||
if ($this->escaped()) {
|
if ($this->escaped()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return in_array($this->lexer->token['type'], self::FWS_TYPES);
|
return in_array(((array) $this->lexer->token)['type'], self::FWS_TYPES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ class IDLeftPart extends LocalPart
|
||||||
{
|
{
|
||||||
protected function parseComments(): Result
|
protected function parseComments(): Result
|
||||||
{
|
{
|
||||||
return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']);
|
return new InvalidEmail(new CommentsInIDRight(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ class IDRightPart extends DomainPart
|
||||||
EmailLexer::S_GREATERTHAN => true,
|
EmailLexer::S_GREATERTHAN => true,
|
||||||
EmailLexer::S_LOWERTHAN => true,
|
EmailLexer::S_LOWERTHAN => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
|
if (isset($invalidDomainTokens[((array) $this->lexer->token)['type']])) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,12 @@ class LocalPart extends PartParser
|
||||||
{
|
{
|
||||||
$this->lexer->startRecording();
|
$this->lexer->startRecording();
|
||||||
|
|
||||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) {
|
while (((array) $this->lexer->token)['type'] !== EmailLexer::S_AT && null !== ((array) $this->lexer->token)['type']) {
|
||||||
if ($this->hasDotAtStart()) {
|
if ($this->hasDotAtStart()) {
|
||||||
return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']);
|
return new InvalidEmail(new DotAtStart(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DQUOTE) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DQUOTE) {
|
||||||
$dquoteParsingResult = $this->parseDoubleQuote();
|
$dquoteParsingResult = $this->parseDoubleQuote();
|
||||||
|
|
||||||
//Invalid double quote parsing
|
//Invalid double quote parsing
|
||||||
|
|
@ -50,8 +50,8 @@ class LocalPart extends PartParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS ||
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS ||
|
||||||
$this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) {
|
((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) {
|
||||||
$commentsResult = $this->parseComments();
|
$commentsResult = $this->parseComments();
|
||||||
|
|
||||||
//Invalid comment parsing
|
//Invalid comment parsing
|
||||||
|
|
@ -60,14 +60,14 @@ class LocalPart extends PartParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||||
return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
|
return new InvalidEmail(new ConsecutiveDot(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT &&
|
||||||
$this->lexer->isNextToken(EmailLexer::S_AT)
|
$this->lexer->isNextToken(EmailLexer::S_AT)
|
||||||
) {
|
) {
|
||||||
return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']);
|
return new InvalidEmail(new DotAtEnd(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resultEscaping = $this->validateEscaping();
|
$resultEscaping = $this->validateEscaping();
|
||||||
|
|
@ -99,8 +99,8 @@ class LocalPart extends PartParser
|
||||||
|
|
||||||
protected function validateTokens(bool $hasComments) : Result
|
protected function validateTokens(bool $hasComments) : Result
|
||||||
{
|
{
|
||||||
if (isset(self::INVALID_TOKENS[$this->lexer->token['type']])) {
|
if (isset(self::INVALID_TOKENS[((array) $this->lexer->token)['type']])) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('Invalid token found'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ class LocalPart extends PartParser
|
||||||
return $this->localPart;
|
return $this->localPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseLocalFWS() : Result
|
private function parseLocalFWS() : Result
|
||||||
{
|
{
|
||||||
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
||||||
$resultFWS = $foldingWS->parse();
|
$resultFWS = $foldingWS->parse();
|
||||||
|
|
@ -122,7 +122,7 @@ class LocalPart extends PartParser
|
||||||
|
|
||||||
private function hasDotAtStart() : bool
|
private function hasDotAtStart() : bool
|
||||||
{
|
{
|
||||||
return $this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type'];
|
return ((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseDoubleQuote() : Result
|
private function parseDoubleQuote() : Result
|
||||||
|
|
@ -148,12 +148,12 @@ class LocalPart extends PartParser
|
||||||
private function validateEscaping() : Result
|
private function validateEscaping() : Result
|
||||||
{
|
{
|
||||||
//Backslash found
|
//Backslash found
|
||||||
if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
|
if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) {
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||||
return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->token['value']);
|
return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ abstract class PartParser
|
||||||
|
|
||||||
protected function checkConsecutiveDots() : Result
|
protected function checkConsecutiveDots() : Result
|
||||||
{
|
{
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||||
return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
|
return new InvalidEmail(new ConsecutiveDot(), ((array) $this->lexer->token)['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|
@ -58,6 +58,6 @@ abstract class PartParser
|
||||||
|
|
||||||
return $previous && $previous['type'] === EmailLexer::S_BACKSLASH
|
return $previous && $previous['type'] === EmailLexer::S_BACKSLASH
|
||||||
&&
|
&&
|
||||||
$this->lexer->token['type'] !== EmailLexer::GENERIC;
|
((array) $this->lexer->token)['type'] !== EmailLexer::GENERIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2023-05-05 09:47:16
|
// This file is automatically generated at:2023-07-17 17:36:46
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\captcha\\CaptchaService',
|
0 => 'think\\captcha\\CaptchaService',
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ class BinaryFileResponse extends Response
|
||||||
while ('' !== $data) {
|
while ('' !== $data) {
|
||||||
$read = fwrite($out, $data);
|
$read = fwrite($out, $data);
|
||||||
if (false === $read || connection_aborted()) {
|
if (false === $read || connection_aborted()) {
|
||||||
break;
|
break 2;
|
||||||
}
|
}
|
||||||
if (0 < $length) {
|
if (0 < $length) {
|
||||||
$length -= $read;
|
$length -= $read;
|
||||||
|
|
|
||||||
|
|
@ -397,8 +397,8 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||||
$updateStmt = $this->pdo->prepare(
|
$updateStmt = $this->pdo->prepare(
|
||||||
"UPDATE $this->table SET $this->lifetimeCol = :expiry, $this->timeCol = :time WHERE $this->idCol = :id"
|
"UPDATE $this->table SET $this->lifetimeCol = :expiry, $this->timeCol = :time WHERE $this->idCol = :id"
|
||||||
);
|
);
|
||||||
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
$updateStmt->bindValue(':id', $sessionId, \PDO::PARAM_STR);
|
||||||
$updateStmt->bindParam(':expiry', $expiry, \PDO::PARAM_INT);
|
$updateStmt->bindValue(':expiry', $expiry, \PDO::PARAM_INT);
|
||||||
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||||
$updateStmt->execute();
|
$updateStmt->execute();
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Configuration;
|
||||||
use Doctrine\DBAL\DriverManager;
|
use Doctrine\DBAL\DriverManager;
|
||||||
|
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
|
||||||
|
use Doctrine\DBAL\Tools\DsnParser;
|
||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||||
|
|
@ -71,7 +74,15 @@ class SessionHandlerFactory
|
||||||
if (!class_exists(DriverManager::class)) {
|
if (!class_exists(DriverManager::class)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require doctrine/dbal".', $connection));
|
throw new \InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require doctrine/dbal".', $connection));
|
||||||
}
|
}
|
||||||
$connection = DriverManager::getConnection(['url' => $connection])->getWrappedConnection();
|
$connection[3] = '-';
|
||||||
|
$params = class_exists(DsnParser::class) ? (new DsnParser())->parse($connection) : ['url' => $connection];
|
||||||
|
$config = new Configuration();
|
||||||
|
if (class_exists(DefaultSchemaManagerFactory::class)) {
|
||||||
|
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
$connection = DriverManager::getConnection($params, $config);
|
||||||
|
$connection = method_exists($connection, 'getNativeConnection') ? $connection->getNativeConnection() : $connection->getWrappedConnection();
|
||||||
// no break;
|
// no break;
|
||||||
|
|
||||||
case str_starts_with($connection, 'mssql://'):
|
case str_starts_with($connection, 'mssql://'):
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
namespace Symfony\Component\HttpFoundation;
|
namespace Symfony\Component\HttpFoundation;
|
||||||
|
|
||||||
use Symfony\Component\Routing\RequestContext;
|
use Symfony\Component\Routing\RequestContext;
|
||||||
|
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper service for manipulating URLs within and outside the request scope.
|
* A helper service for manipulating URLs within and outside the request scope.
|
||||||
|
|
@ -23,8 +24,15 @@ final class UrlHelper
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
private $requestContext;
|
private $requestContext;
|
||||||
|
|
||||||
public function __construct(RequestStack $requestStack, RequestContext $requestContext = null)
|
/**
|
||||||
|
* @param RequestContextAwareInterface|RequestContext|null $requestContext
|
||||||
|
*/
|
||||||
|
public function __construct(RequestStack $requestStack, $requestContext = null)
|
||||||
{
|
{
|
||||||
|
if (null !== $requestContext && !$requestContext instanceof RequestContext && !$requestContext instanceof RequestContextAwareInterface) {
|
||||||
|
throw new \TypeError(__METHOD__.': Argument #2 ($requestContext) must of type Symfony\Component\Routing\RequestContextAwareInterface|Symfony\Component\Routing\RequestContext|null, '.get_debug_type($requestContext).' given.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
$this->requestContext = $requestContext;
|
$this->requestContext = $requestContext;
|
||||||
}
|
}
|
||||||
|
|
@ -73,28 +81,36 @@ final class UrlHelper
|
||||||
|
|
||||||
private function getAbsoluteUrlFromContext(string $path): string
|
private function getAbsoluteUrlFromContext(string $path): string
|
||||||
{
|
{
|
||||||
if (null === $this->requestContext || '' === $host = $this->requestContext->getHost()) {
|
if (null === $context = $this->requestContext) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scheme = $this->requestContext->getScheme();
|
if ($context instanceof RequestContextAwareInterface) {
|
||||||
|
$context = $context->getContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('' === $host = $context->getHost()) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scheme = $context->getScheme();
|
||||||
$port = '';
|
$port = '';
|
||||||
|
|
||||||
if ('http' === $scheme && 80 !== $this->requestContext->getHttpPort()) {
|
if ('http' === $scheme && 80 !== $context->getHttpPort()) {
|
||||||
$port = ':'.$this->requestContext->getHttpPort();
|
$port = ':'.$context->getHttpPort();
|
||||||
} elseif ('https' === $scheme && 443 !== $this->requestContext->getHttpsPort()) {
|
} elseif ('https' === $scheme && 443 !== $context->getHttpsPort()) {
|
||||||
$port = ':'.$this->requestContext->getHttpsPort();
|
$port = ':'.$context->getHttpsPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('#' === $path[0]) {
|
if ('#' === $path[0]) {
|
||||||
$queryString = $this->requestContext->getQueryString();
|
$queryString = $context->getQueryString();
|
||||||
$path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path;
|
$path = $context->getPathInfo().($queryString ? '?'.$queryString : '').$path;
|
||||||
} elseif ('?' === $path[0]) {
|
} elseif ('?' === $path[0]) {
|
||||||
$path = $this->requestContext->getPathInfo().$path;
|
$path = $context->getPathInfo().$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('/' !== $path[0]) {
|
if ('/' !== $path[0]) {
|
||||||
$path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path;
|
$path = rtrim($context->getBaseUrl(), '/').'/'.$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scheme.'://'.$host.$port.$path;
|
return $scheme.'://'.$host.$port.$path;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
|
||||||
|
|
||||||
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||||
|
|
||||||
版权所有Copyright © 2006-2021 by ThinkPHP (http://thinkphp.cn) All rights reserved。
|
版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。
|
||||||
|
|
||||||
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ use think\initializer\RegisterService;
|
||||||
*/
|
*/
|
||||||
class App extends Container
|
class App extends Container
|
||||||
{
|
{
|
||||||
const VERSION = '6.1.1';
|
const VERSION = '6.1.4';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用调试模式
|
* 应用调试模式
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ use think\route\dispatch\Callback;
|
||||||
use think\route\dispatch\Url as UrlDispatch;
|
use think\route\dispatch\Url as UrlDispatch;
|
||||||
use think\route\Domain;
|
use think\route\Domain;
|
||||||
use think\route\Resource;
|
use think\route\Resource;
|
||||||
|
use think\route\ResourceRegister;
|
||||||
use think\route\Rule;
|
use think\route\Rule;
|
||||||
use think\route\RuleGroup;
|
use think\route\RuleGroup;
|
||||||
use think\route\RuleItem;
|
use think\route\RuleItem;
|
||||||
|
|
@ -182,6 +183,11 @@ class Route
|
||||||
$this->removeSlash = $this->config['remove_slash'];
|
$this->removeSlash = $this->config['remove_slash'];
|
||||||
|
|
||||||
$this->group->removeSlash($this->removeSlash);
|
$this->group->removeSlash($this->removeSlash);
|
||||||
|
|
||||||
|
// 注册全局MISS路由
|
||||||
|
$this->miss(function () {
|
||||||
|
return Response::create('', 'html', 204)->header(['Allow' => 'GET, POST, PUT, DELETE']);
|
||||||
|
}, 'options')->allowCrossDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function config(string $name = null)
|
public function config(string $name = null)
|
||||||
|
|
@ -317,8 +323,7 @@ class Route
|
||||||
$domainName = is_array($name) ? array_shift($name) : $name;
|
$domainName = is_array($name) ? array_shift($name) : $name;
|
||||||
|
|
||||||
if (!isset($this->domains[$domainName])) {
|
if (!isset($this->domains[$domainName])) {
|
||||||
$domain = (new Domain($this, $domainName, $rule))
|
$domain = (new Domain($this, $domainName, $rule, $this->lazy))
|
||||||
->lazy($this->lazy)
|
|
||||||
->removeSlash($this->removeSlash)
|
->removeSlash($this->removeSlash)
|
||||||
->mergeRuleRegex($this->mergeRuleRegex);
|
->mergeRuleRegex($this->mergeRuleRegex);
|
||||||
|
|
||||||
|
|
@ -523,19 +528,18 @@ class Route
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置跨域有效路由规则
|
* 设置路由规则全局有效
|
||||||
* @access public
|
* @access public
|
||||||
* @param Rule $rule 路由规则
|
* @param Rule $rule 路由规则
|
||||||
* @param string $method 请求类型
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCrossDomainRule(Rule $rule, string $method = '*')
|
public function setCrossDomainRule(Rule $rule)
|
||||||
{
|
{
|
||||||
if (!isset($this->cross)) {
|
if (!isset($this->cross)) {
|
||||||
$this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex);
|
$this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cross->addRuleItem($rule, $method);
|
$this->cross->addRuleItem($rule);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -554,8 +558,7 @@ class Route
|
||||||
$name = '';
|
$name = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new RuleGroup($this, $this->group, $name, $route))
|
return (new RuleGroup($this, $this->group, $name, $route, $this->lazy))
|
||||||
->lazy($this->lazy)
|
|
||||||
->removeSlash($this->removeSlash)
|
->removeSlash($this->removeSlash)
|
||||||
->mergeRuleRegex($this->mergeRuleRegex);
|
->mergeRuleRegex($this->mergeRuleRegex);
|
||||||
}
|
}
|
||||||
|
|
@ -661,12 +664,17 @@ class Route
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $rule 路由规则
|
* @param string $rule 路由规则
|
||||||
* @param string $route 路由地址
|
* @param string $route 路由地址
|
||||||
* @return Resource
|
* @return Resource|ResourceRegister
|
||||||
*/
|
*/
|
||||||
public function resource(string $rule, string $route): Resource
|
public function resource(string $rule, string $route)
|
||||||
{
|
{
|
||||||
return (new Resource($this, $this->group, $rule, $route, $this->rest))
|
$resource = new Resource($this, $this->group, $rule, $route, $this->rest);
|
||||||
->lazy($this->lazy);
|
|
||||||
|
if (!$this->lazy) {
|
||||||
|
return new ResourceRegister($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,8 @@ class File extends Driver
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data;
|
$data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data;
|
||||||
$result = file_put_contents($filename, $data);
|
|
||||||
|
$result = file_put_contents($filename, $data, LOCK_EX);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ class RouteList extends Command
|
||||||
|
|
||||||
protected function getRouteList(string $dir = null): string
|
protected function getRouteList(string $dir = null): string
|
||||||
{
|
{
|
||||||
$this->app->route->setTestMode(true);
|
|
||||||
$this->app->route->clear();
|
$this->app->route->clear();
|
||||||
|
$this->app->route->lazy(false);
|
||||||
|
|
||||||
if ($dir) {
|
if ($dir) {
|
||||||
$path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
|
$path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,12 @@ class Schema extends Command
|
||||||
if (0 === strpos($file, '.')) {
|
if (0 === strpos($file, '.')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME);
|
$class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME);
|
||||||
|
if (!class_exists($class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$this->buildModelSchema($class);
|
$this->buildModelSchema($class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ declare (strict_types = 1);
|
||||||
namespace think\facade;
|
namespace think\facade;
|
||||||
|
|
||||||
use think\Facade;
|
use think\Facade;
|
||||||
|
use think\Response;
|
||||||
use think\route\Dispatch;
|
use think\route\Dispatch;
|
||||||
use think\route\Domain;
|
use think\route\Domain;
|
||||||
use think\route\Rule;
|
use think\route\Rule;
|
||||||
|
|
@ -20,6 +21,7 @@ use think\route\RuleGroup;
|
||||||
use think\route\RuleItem;
|
use think\route\RuleItem;
|
||||||
use think\route\RuleName;
|
use think\route\RuleName;
|
||||||
use think\route\Url as UrlBuild;
|
use think\route\Url as UrlBuild;
|
||||||
|
use think\route\ResourceRegister as Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see \think\Route
|
* @see \think\Route
|
||||||
|
|
@ -48,7 +50,7 @@ use think\route\Url as UrlBuild;
|
||||||
* @method static array getRuleList() 读取路由列表
|
* @method static array getRuleList() 读取路由列表
|
||||||
* @method static void clear() 清空路由规则
|
* @method static void clear() 清空路由规则
|
||||||
* @method static RuleItem rule(string $rule, mixed $route = null, string $method = '*') 注册路由规则
|
* @method static RuleItem rule(string $rule, mixed $route = null, string $method = '*') 注册路由规则
|
||||||
* @method static \think\Route setCrossDomainRule(Rule $rule, string $method = '*') 设置跨域有效路由规则
|
* @method static \think\Route setCrossDomainRule(Rule $rule) 设置跨域有效路由规则
|
||||||
* @method static RuleGroup group(string|\Closure $name, mixed $route = null) 注册路由分组
|
* @method static RuleGroup group(string|\Closure $name, mixed $route = null) 注册路由分组
|
||||||
* @method static RuleItem any(string $rule, mixed $route) 注册路由
|
* @method static RuleItem any(string $rule, mixed $route) 注册路由
|
||||||
* @method static RuleItem get(string $rule, mixed $route) 注册GET路由
|
* @method static RuleItem get(string $rule, mixed $route) 注册GET路由
|
||||||
|
|
@ -64,7 +66,7 @@ use think\route\Url as UrlBuild;
|
||||||
* @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改
|
* @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改
|
||||||
* @method static array|null getRest(string $name = null) 获取rest方法定义的参数
|
* @method static array|null getRest(string $name = null) 获取rest方法定义的参数
|
||||||
* @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理
|
* @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理
|
||||||
* @method static Response dispatch(\think\Request $request, Closure|bool $withRoute = true) 路由调度
|
* @method static Response dispatch(\think\Request $request, \Closure|bool $withRoute = true) 路由调度
|
||||||
* @method static Dispatch|false check() 检测URL路由
|
* @method static Dispatch|false check() 检测URL路由
|
||||||
* @method static Dispatch url(string $url) 默认URL解析
|
* @method static Dispatch url(string $url) 默认URL解析
|
||||||
* @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射
|
* @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,9 @@ class Error
|
||||||
if ($this->app->runningInConsole()) {
|
if ($this->app->runningInConsole()) {
|
||||||
$handler->renderForConsole(new ConsoleOutput, $e);
|
$handler->renderForConsole(new ConsoleOutput, $e);
|
||||||
} else {
|
} else {
|
||||||
$handler->render($this->app->request, $e)->send();
|
$response = $handler->render($this->app->request, $e);
|
||||||
|
$response->send();
|
||||||
|
$this->app->http->end($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class SessionInit
|
||||||
|
|
||||||
$response->setSession($this->session);
|
$response->setSession($this->session);
|
||||||
|
|
||||||
$this->app->cookie->set($cookieName, $this->session->getId());
|
$this->app->cookie->set($cookieName, $this->session->getId(), $this->session->getConfig('expire'));
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,24 +36,28 @@ class Redirect extends Response
|
||||||
$this->cacheControl('no-cache,must-revalidate');
|
$this->cacheControl('no-cache,must-revalidate');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function data($data)
|
||||||
|
{
|
||||||
|
$this->header['Location'] = $data;
|
||||||
|
return parent::data($data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理数据
|
* 处理数据
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param mixed $data 要处理的数据
|
* @param mixed $data 要处理的数据
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function output($data): string
|
protected function output($data): string
|
||||||
{
|
{
|
||||||
$this->header['Location'] = $data;
|
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重定向传值(通过Session)
|
* 重定向传值(通过Session)
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string|array $name 变量名或者数组
|
* @param string|array $name 变量名或者数组
|
||||||
* @param mixed $value 值
|
* @param mixed $value 值
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function with($name, $value = null)
|
public function with($name, $value = null)
|
||||||
|
|
|
||||||
|
|
@ -77,16 +77,6 @@ abstract class Dispatch
|
||||||
*/
|
*/
|
||||||
public function run(): Response
|
public function run(): Response
|
||||||
{
|
{
|
||||||
if ($this->rule instanceof RuleItem && $this->request->method() == 'OPTIONS' && $this->rule->isAutoOptions()) {
|
|
||||||
$rules = $this->rule->getRouter()->getRule($this->rule->getRule());
|
|
||||||
$allow = [];
|
|
||||||
foreach ($rules as $item) {
|
|
||||||
$allow[] = strtoupper($item->getMethod());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response::create('', 'html', 204)->header(['Allow' => implode(', ', $allow)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->exec();
|
$data = $this->exec();
|
||||||
return $this->autoResponse($data);
|
return $this->autoResponse($data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,17 @@ class Domain extends RuleGroup
|
||||||
* @param Route $router 路由对象
|
* @param Route $router 路由对象
|
||||||
* @param string $name 路由域名
|
* @param string $name 路由域名
|
||||||
* @param mixed $rule 域名路由
|
* @param mixed $rule 域名路由
|
||||||
|
* @param bool $lazy 延迟解析
|
||||||
*/
|
*/
|
||||||
public function __construct(Route $router, string $name = null, $rule = null)
|
public function __construct(Route $router, string $name = null, $rule = null, bool $lazy = false)
|
||||||
{
|
{
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
$this->domain = $name;
|
$this->domain = $name;
|
||||||
$this->rule = $rule;
|
$this->rule = $rule;
|
||||||
|
|
||||||
|
if (!$lazy) {
|
||||||
|
$this->parseGroupRule($rule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,6 @@ use think\Route;
|
||||||
*/
|
*/
|
||||||
class Resource extends RuleGroup
|
class Resource extends RuleGroup
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 资源路由名称
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 资源路由地址
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $route;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST方法定义
|
* REST方法定义
|
||||||
* @var array
|
* @var array
|
||||||
|
|
@ -58,18 +46,18 @@ class Resource extends RuleGroup
|
||||||
/**
|
/**
|
||||||
* 架构函数
|
* 架构函数
|
||||||
* @access public
|
* @access public
|
||||||
* @param Route $router 路由对象
|
* @param Route $router 路由对象
|
||||||
* @param RuleGroup $parent 上级对象
|
* @param RuleGroup|null $parent 上级对象
|
||||||
* @param string $name 资源名称
|
* @param string $name 资源名称
|
||||||
* @param string $route 路由地址
|
* @param string $route 路由地址
|
||||||
* @param array $rest 资源定义
|
* @param array $rest 资源定义
|
||||||
*/
|
*/
|
||||||
public function __construct(Route $router, RuleGroup $parent = null, string $name = '', string $route = '', array $rest = [])
|
public function __construct(Route $router, RuleGroup $parent = null, string $name = '', string $route = '', array $rest = [])
|
||||||
{
|
{
|
||||||
$name = ltrim($name, '/');
|
$name = ltrim($name, '/');
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
$this->resource = $name;
|
$this->rule = $name;
|
||||||
$this->route = $route;
|
$this->route = $route;
|
||||||
$this->name = strpos($name, '.') ? strstr($name, '.', true) : $name;
|
$this->name = strpos($name, '.') ? strstr($name, '.', true) : $name;
|
||||||
|
|
||||||
|
|
@ -84,20 +72,16 @@ class Resource extends RuleGroup
|
||||||
$this->domain = $this->parent->getDomain();
|
$this->domain = $this->parent->getDomain();
|
||||||
$this->parent->addRuleItem($this);
|
$this->parent->addRuleItem($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($router->isTest()) {
|
|
||||||
$this->buildResourceRule();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成资源路由规则
|
* 解析资源路由规则
|
||||||
* @access protected
|
* @access public
|
||||||
|
* @param mixed $rule 路由规则
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function buildResourceRule(): void
|
public function parseGroupRule($rule): void
|
||||||
{
|
{
|
||||||
$rule = $this->resource;
|
|
||||||
$option = $this->option;
|
$option = $this->option;
|
||||||
$origin = $this->router->getGroup();
|
$origin = $this->router->getGroup();
|
||||||
$this->router->setGroup($this);
|
$this->router->setGroup($this);
|
||||||
|
|
@ -141,6 +125,7 @@ class Resource extends RuleGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->router->setGroup($origin);
|
$this->router->setGroup($origin);
|
||||||
|
$this->hasParsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace think\route;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源路由注册类
|
||||||
|
*/
|
||||||
|
class ResourceRegister
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 资源路由
|
||||||
|
* @var Resource
|
||||||
|
*/
|
||||||
|
protected $resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否注册过
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $registered = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 架构函数
|
||||||
|
* @access public
|
||||||
|
* @param Resource $resource 资源路由
|
||||||
|
*/
|
||||||
|
public function __construct(Resource $resource)
|
||||||
|
{
|
||||||
|
$this->resource = $resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册资源路由
|
||||||
|
* @access protected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function register()
|
||||||
|
{
|
||||||
|
$this->registered = true;
|
||||||
|
|
||||||
|
$this->resource->parseGroupRule($this->resource->getRule());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态方法
|
||||||
|
* @access public
|
||||||
|
* @param string $method 方法名
|
||||||
|
* @param array $args 调用参数
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __call($method, $args)
|
||||||
|
{
|
||||||
|
return call_user_func_array([$this->resource, $method], $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
if (!$this->registered) {
|
||||||
|
$this->register();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ abstract class Rule
|
||||||
* 请求类型
|
* 请求类型
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $method;
|
protected $method = '*';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由变量
|
* 路由变量
|
||||||
|
|
@ -572,14 +572,7 @@ abstract class Rule
|
||||||
*/
|
*/
|
||||||
public function crossDomainRule()
|
public function crossDomainRule()
|
||||||
{
|
{
|
||||||
if ($this instanceof RuleGroup) {
|
$this->router->setCrossDomainRule($this);
|
||||||
$method = '*';
|
|
||||||
} else {
|
|
||||||
$method = $this->method;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->router->setCrossDomainRule($this, $method);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,15 @@ class RuleGroup extends Rule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 分组路由(包括子分组)
|
* 分组路由(包括子分组)
|
||||||
* @var array
|
* @var Rule[]
|
||||||
*/
|
*/
|
||||||
protected $rules = [];
|
protected $rules = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组路由规则
|
* 是否已经解析
|
||||||
* @var mixed
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $rule;
|
protected $hasParsed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MISS路由
|
* MISS路由
|
||||||
|
|
@ -56,12 +56,13 @@ class RuleGroup extends Rule
|
||||||
/**
|
/**
|
||||||
* 架构函数
|
* 架构函数
|
||||||
* @access public
|
* @access public
|
||||||
* @param Route $router 路由对象
|
* @param Route $router 路由对象
|
||||||
* @param RuleGroup $parent 上级对象
|
* @param RuleGroup|null $parent 上级对象
|
||||||
* @param string $name 分组名称
|
* @param string $name 分组名称
|
||||||
* @param mixed $rule 分组路由
|
* @param mixed $rule 分组路由
|
||||||
|
* @param bool $lazy 延迟解析
|
||||||
*/
|
*/
|
||||||
public function __construct(Route $router, RuleGroup $parent = null, string $name = '', $rule = null)
|
public function __construct(Route $router, RuleGroup $parent = null, string $name = '', $rule = null, bool $lazy = false)
|
||||||
{
|
{
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
|
|
@ -75,8 +76,8 @@ class RuleGroup extends Rule
|
||||||
$this->parent->addRuleItem($this);
|
$this->parent->addRuleItem($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($router->isTest()) {
|
if (!$lazy) {
|
||||||
$this->lazy(false);
|
$this->parseGroupRule($rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,9 +139,7 @@ class RuleGroup extends Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析分组路由
|
// 解析分组路由
|
||||||
if ($this instanceof Resource) {
|
if (!$this->hasParsed) {
|
||||||
$this->buildResourceRule();
|
|
||||||
} else {
|
|
||||||
$this->parseGroupRule($this->rule);
|
$this->parseGroupRule($this->rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,8 +162,8 @@ class RuleGroup extends Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查分组路由
|
// 检查分组路由
|
||||||
foreach ($rules as $key => $item) {
|
foreach ($rules as $item) {
|
||||||
$result = $item[1]->check($request, $url, $completeMatch);
|
$result = $item->check($request, $url, $completeMatch);
|
||||||
|
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
return $result;
|
return $result;
|
||||||
|
|
@ -173,9 +172,9 @@ class RuleGroup extends Rule
|
||||||
|
|
||||||
if (!empty($option['dispatcher'])) {
|
if (!empty($option['dispatcher'])) {
|
||||||
$result = $this->parseRule($request, '', $option['dispatcher'], $url, $option);
|
$result = $this->parseRule($request, '', $option['dispatcher'], $url, $option);
|
||||||
} elseif ($this->miss && in_array($this->miss->getMethod(), ['*', $method])) {
|
} elseif ($miss = $this->getMissRule($method)) {
|
||||||
// 未匹配所有路由的路由规则处理
|
// 未匹配所有路由的路由规则处理
|
||||||
$result = $this->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->getOption());
|
$result = $miss->parseRule($request, '', $miss->getRoute(), $url, $miss->getOption());
|
||||||
} else {
|
} else {
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
|
|
@ -222,22 +221,6 @@ class RuleGroup extends Rule
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 延迟解析分组的路由规则
|
|
||||||
* @access public
|
|
||||||
* @param bool $lazy 路由是否延迟解析
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function lazy(bool $lazy = true)
|
|
||||||
{
|
|
||||||
if (!$lazy) {
|
|
||||||
$this->parseGroupRule($this->rule);
|
|
||||||
$this->rule = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析分组和域名的路由规则及绑定
|
* 解析分组和域名的路由规则及绑定
|
||||||
* @access public
|
* @access public
|
||||||
|
|
@ -246,6 +229,10 @@ class RuleGroup extends Rule
|
||||||
*/
|
*/
|
||||||
public function parseGroupRule($rule): void
|
public function parseGroupRule($rule): void
|
||||||
{
|
{
|
||||||
|
if (is_null($rule)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_string($rule) && is_subclass_of($rule, Dispatch::class)) {
|
if (is_string($rule) && is_subclass_of($rule, Dispatch::class)) {
|
||||||
$this->dispatcher($rule);
|
$this->dispatcher($rule);
|
||||||
return;
|
return;
|
||||||
|
|
@ -254,13 +241,14 @@ class RuleGroup extends Rule
|
||||||
$origin = $this->router->getGroup();
|
$origin = $this->router->getGroup();
|
||||||
$this->router->setGroup($this);
|
$this->router->setGroup($this);
|
||||||
|
|
||||||
if ($rule instanceof \Closure) {
|
if ($rule instanceof Closure) {
|
||||||
Container::getInstance()->invokeFunction($rule);
|
Container::getInstance()->invokeFunction($rule);
|
||||||
} elseif (is_string($rule) && $rule) {
|
} elseif (is_string($rule) && $rule) {
|
||||||
$this->router->bind($rule, $this->domain);
|
$this->router->bind($rule, $this->domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->router->setGroup($origin);
|
$this->router->setGroup($origin);
|
||||||
|
$this->hasParsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -279,8 +267,7 @@ class RuleGroup extends Rule
|
||||||
$regex = [];
|
$regex = [];
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
foreach ($rules as $key => $val) {
|
foreach ($rules as $key => $item) {
|
||||||
$item = $val[1];
|
|
||||||
if ($item instanceof RuleItem) {
|
if ($item instanceof RuleItem) {
|
||||||
$rule = $depr . str_replace('/', $depr, $item->getRule());
|
$rule = $depr . str_replace('/', $depr, $item->getRule());
|
||||||
if ($depr == $rule && $depr != $url) {
|
if ($depr == $rule && $depr != $url) {
|
||||||
|
|
@ -368,11 +355,19 @@ class RuleGroup extends Rule
|
||||||
/**
|
/**
|
||||||
* 获取分组的MISS路由
|
* 获取分组的MISS路由
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param string $method 请求类型
|
||||||
* @return RuleItem|null
|
* @return RuleItem|null
|
||||||
*/
|
*/
|
||||||
public function getMissRule(): ? RuleItem
|
public function getMissRule(string $method = '*'): ?RuleItem
|
||||||
{
|
{
|
||||||
return $this->miss;
|
if (isset($this->miss[$method])) {
|
||||||
|
$miss = $this->miss[$method];
|
||||||
|
} elseif (isset($this->miss['*'])) {
|
||||||
|
$miss = $this->miss['*'];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -387,8 +382,7 @@ class RuleGroup extends Rule
|
||||||
// 创建路由规则实例
|
// 创建路由规则实例
|
||||||
$ruleItem = new RuleItem($this->router, $this, null, '', $route, strtolower($method));
|
$ruleItem = new RuleItem($this->router, $this, null, '', $route, strtolower($method));
|
||||||
|
|
||||||
$ruleItem->setMiss();
|
$this->miss[$method] = $ruleItem->setMiss();
|
||||||
$this->miss = $ruleItem;
|
|
||||||
|
|
||||||
return $ruleItem;
|
return $ruleItem;
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +413,7 @@ class RuleGroup extends Rule
|
||||||
// 创建路由规则实例
|
// 创建路由规则实例
|
||||||
$ruleItem = new RuleItem($this->router, $this, $name, $rule, $route, $method);
|
$ruleItem = new RuleItem($this->router, $this, $name, $rule, $route, $method);
|
||||||
|
|
||||||
$this->addRuleItem($ruleItem, $method);
|
$this->addRuleItem($ruleItem);
|
||||||
|
|
||||||
return $ruleItem;
|
return $ruleItem;
|
||||||
}
|
}
|
||||||
|
|
@ -428,21 +422,11 @@ class RuleGroup extends Rule
|
||||||
* 注册分组下的路由规则
|
* 注册分组下的路由规则
|
||||||
* @access public
|
* @access public
|
||||||
* @param Rule $rule 路由规则
|
* @param Rule $rule 路由规则
|
||||||
* @param string $method 请求类型
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function addRuleItem(Rule $rule, string $method = '*')
|
public function addRuleItem(Rule $rule)
|
||||||
{
|
{
|
||||||
if (strpos($method, '|')) {
|
$this->rules[] = $rule;
|
||||||
$rule->method($method);
|
|
||||||
$method = '*';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->rules[] = [$method, $rule];
|
|
||||||
|
|
||||||
if ($rule instanceof RuleItem && 'options' != $method) {
|
|
||||||
$this->rules[] = ['options', $rule->setAutoOptions()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +491,8 @@ class RuleGroup extends Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_filter($this->rules, function ($item) use ($method) {
|
return array_filter($this->rules, function ($item) use ($method) {
|
||||||
return $method == $item[0] || '*' == $item[0];
|
$ruleMethod = $item->getMethod();
|
||||||
|
return '*' == $ruleMethod || false !== strpos($ruleMethod, $method);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class RuleItem extends Rule
|
||||||
* @access public
|
* @access public
|
||||||
* @param Route $router 路由实例
|
* @param Route $router 路由实例
|
||||||
* @param RuleGroup $parent 上级对象
|
* @param RuleGroup $parent 上级对象
|
||||||
* @param string $name 路由标识
|
* @param string|null $name 路由标识
|
||||||
* @param string $rule 路由规则
|
* @param string $rule 路由规则
|
||||||
* @param string|\Closure $route 路由地址
|
* @param string|\Closure $route 路由地址
|
||||||
* @param string $method 请求类型
|
* @param string $method 请求类型
|
||||||
|
|
@ -77,27 +77,6 @@ class RuleItem extends Rule
|
||||||
return $this->miss;
|
return $this->miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置当前路由为自动注册OPTIONS
|
|
||||||
* @access public
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setAutoOptions()
|
|
||||||
{
|
|
||||||
$this->autoOption = true;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前路由规则是否为自动注册的OPTIONS路由
|
|
||||||
* @access public
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAutoOptions(): bool
|
|
||||||
{
|
|
||||||
return $this->autoOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前路由的URL后缀
|
* 获取当前路由的URL后缀
|
||||||
* @access public
|
* @access public
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,9 @@ class RuleName
|
||||||
*/
|
*/
|
||||||
public function clear(): void
|
public function clear(): void
|
||||||
{
|
{
|
||||||
$this->item = [];
|
$this->item = [];
|
||||||
$this->rule = [];
|
$this->rule = [];
|
||||||
|
$this->group = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ class Url
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function build()
|
public function build(): string
|
||||||
{
|
{
|
||||||
// 解析URL
|
// 解析URL
|
||||||
$url = $this->url;
|
$url = $this->url;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "topthink/think-multi-app",
|
"name": "topthink/think-multi-app",
|
||||||
"description": "thinkphp6 multi app support",
|
"description": "thinkphp multi app support",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,29 +27,9 @@ class MultiApp
|
||||||
/** @var App */
|
/** @var App */
|
||||||
protected $app;
|
protected $app;
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用名称
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用名称
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $appName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用路径
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $path;
|
|
||||||
|
|
||||||
public function __construct(App $app)
|
public function __construct(App $app)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->name = $this->app->http->getName();
|
|
||||||
$this->path = $this->app->http->getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -90,15 +70,15 @@ class MultiApp
|
||||||
{
|
{
|
||||||
$scriptName = $this->getScriptName();
|
$scriptName = $this->getScriptName();
|
||||||
$defaultApp = $this->app->config->get('app.default_app') ?: 'index';
|
$defaultApp = $this->app->config->get('app.default_app') ?: 'index';
|
||||||
|
$appName = $this->app->http->getName();
|
||||||
|
|
||||||
if ($this->name || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) {
|
if ($appName || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) {
|
||||||
$appName = $this->name ?: $scriptName;
|
$appName = $appName ?: $scriptName;
|
||||||
$this->app->http->setBind();
|
$this->app->http->setBind();
|
||||||
} else {
|
} else {
|
||||||
// 自动多应用识别
|
// 自动多应用识别
|
||||||
$this->app->http->setBind(false);
|
$this->app->http->setBind(false);
|
||||||
$appName = null;
|
$appName = null;
|
||||||
$this->appName = '';
|
|
||||||
|
|
||||||
$bind = $this->app->config->get('app.domain_bind', []);
|
$bind = $this->app->config->get('app.domain_bind', []);
|
||||||
|
|
||||||
|
|
@ -142,7 +122,7 @@ class MultiApp
|
||||||
$appName = $map['*'];
|
$appName = $map['*'];
|
||||||
} else {
|
} else {
|
||||||
$appName = $name ?: $defaultApp;
|
$appName = $name ?: $defaultApp;
|
||||||
$appPath = $this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
|
$appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
if (!is_dir($appPath)) {
|
if (!is_dir($appPath)) {
|
||||||
$express = $this->app->config->get('app.app_express', false);
|
$express = $this->app->config->get('app.app_express', false);
|
||||||
|
|
@ -189,10 +169,9 @@ class MultiApp
|
||||||
*/
|
*/
|
||||||
protected function setApp(string $appName): void
|
protected function setApp(string $appName): void
|
||||||
{
|
{
|
||||||
$this->appName = $appName;
|
|
||||||
$this->app->http->name($appName);
|
$this->app->http->name($appName);
|
||||||
|
|
||||||
$appPath = $this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
|
$appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
$this->app->setAppPath($appPath);
|
$this->app->setAppPath($appPath);
|
||||||
// 设置应用命名空间
|
// 设置应用命名空间
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class Url extends UrlBuild
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build()
|
public function build(): string
|
||||||
{
|
{
|
||||||
// 解析URL
|
// 解析URL
|
||||||
$url = $this->url;
|
$url = $this->url;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue