From d8e693aa52e5a4108bf7a54a2f32494c0571fbce Mon Sep 17 00:00:00 2001 From: yumo Date: Mon, 17 Jul 2023 17:37:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Index.php | 4 +- app/index/common.php | 21 ++++ config/app.php | 2 +- public/admin.php | 4 +- public/api.php | 24 +++++ public/index.php | 2 +- public/nginx.htaccess | 12 ++- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_static.php | 10 +- vendor/composer/installed.json | 72 +++++++------- vendor/composer/installed.php | 34 +++---- vendor/doctrine/deprecations/README.md | 7 +- .../lib/Doctrine/Deprecations/Deprecation.php | 40 ++++++-- .../email-validator/src/EmailLexer.php | 10 +- vendor/egulias/email-validator/src/Parser.php | 6 +- .../email-validator/src/Parser/Comment.php | 18 ++-- .../Parser/CommentStrategy/DomainComment.php | 2 +- .../Parser/CommentStrategy/LocalComment.php | 2 +- .../src/Parser/DomainLiteral.php | 22 ++--- .../email-validator/src/Parser/DomainPart.php | 68 ++++++------- .../src/Parser/DoubleQuote.php | 20 ++-- .../src/Parser/FoldingWhiteSpace.php | 20 ++-- .../email-validator/src/Parser/IDLeftPart.php | 2 +- .../src/Parser/IDRightPart.php | 6 +- .../email-validator/src/Parser/LocalPart.php | 30 +++--- .../email-validator/src/Parser/PartParser.php | 6 +- vendor/services.php | 2 +- .../http-foundation/BinaryFileResponse.php | 2 +- .../Storage/Handler/PdoSessionHandler.php | 4 +- .../Storage/Handler/SessionHandlerFactory.php | 13 ++- vendor/symfony/http-foundation/UrlHelper.php | 38 +++++--- vendor/topthink/framework/README.md | 2 +- vendor/topthink/framework/src/think/App.php | 2 +- vendor/topthink/framework/src/think/Route.php | 32 ++++--- .../framework/src/think/cache/driver/File.php | 3 +- .../src/think/console/command/RouteList.php | 2 +- .../think/console/command/optimize/Schema.php | 5 + .../framework/src/think/facade/Route.php | 6 +- .../framework/src/think/initializer/Error.php | 4 +- .../src/think/middleware/SessionInit.php | 2 +- .../framework/src/think/response/Redirect.php | 14 ++- .../framework/src/think/route/Dispatch.php | 10 -- .../framework/src/think/route/Domain.php | 7 +- .../framework/src/think/route/Resource.php | 37 +++----- .../src/think/route/ResourceRegister.php | 72 ++++++++++++++ .../framework/src/think/route/Rule.php | 11 +-- .../framework/src/think/route/RuleGroup.php | 95 ++++++++----------- .../framework/src/think/route/RuleItem.php | 23 +---- .../framework/src/think/route/RuleName.php | 5 +- .../framework/src/think/route/Url.php | 2 +- vendor/topthink/think-multi-app/composer.json | 2 +- .../topthink/think-multi-app/src/MultiApp.php | 33 ++----- vendor/topthink/think-multi-app/src/Url.php | 2 +- 53 files changed, 496 insertions(+), 380 deletions(-) create mode 100644 public/api.php create mode 100644 vendor/topthink/framework/src/think/route/ResourceRegister.php diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 9e18b43..e21fda4 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -116,7 +116,7 @@ class Index extends AuthController foreach ($categoryInfo as $v) { $str .= ''; $str .= '' . url('index/article/lists',["id"=>$v["alias"]?:$v['id']],".html",$domain) . ''; - $str .= '' . $v['create_time'] . ''; + $str .= '' . date("Y-M-DTH:i:s+00:00",strtotime($v['create_time'])) . ''; $str .= 'always'; $str .= '0.8'; $str .= ''; @@ -131,7 +131,7 @@ class Index extends AuthController foreach ($documentInfo as $v) { $str .= ''; $str .= '' . url('/index/article/detail',["id"=>$v["alias"]?:$v['id']],".html",$domain) . ''; - $str .= '' . $v['create_time'] . ''; + $str .= '' . date("Y-M-DTH:i:s+00:00",strtotime($v['create_time'])) . ''; $str .= 'monthly'; $str .= '0.6'; $str .= ''; diff --git a/app/index/common.php b/app/index/common.php index 62b2338..c4a8ab7 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -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 diff --git a/config/app.php b/config/app.php index 5c908f4..49f13c0 100644 --- a/config/app.php +++ b/config/app.php @@ -25,7 +25,7 @@ return [ // 自动多应用模式 'auto_multi_app' => true, // 应用映射(自动多应用模式有效) - 'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index'], + 'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index','api'=>'api'], // 域名绑定(自动多应用模式有效) 'domain_bind' => [], // 禁止URL访问的应用列表(自动多应用模式有效) diff --git a/public/admin.php b/public/admin.php index c029f12..83d1c9b 100644 --- a/public/admin.php +++ b/public/admin.php @@ -17,8 +17,8 @@ require __DIR__ . '/../vendor/autoload.php'; // 执行HTTP应用并响应 $http = (new App())->http; -$response = $http->app()->run(); +$response = $http->name('admin')->run(); $response->send(); -$http->end($response); +$http->end($response); \ No newline at end of file diff --git a/public/api.php b/public/api.php new file mode 100644 index 0000000..7dabcc0 --- /dev/null +++ b/public/api.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +// [ 应用入口文件 ] +namespace think; + +require __DIR__ . '/../vendor/autoload.php'; + +// 执行HTTP应用并响应 +$http = (new App())->http; + +$response = $http->name('api')->run(); + +$response->send(); + +$http->end($response); \ No newline at end of file diff --git a/public/index.php b/public/index.php index b981a31..e1ba8de 100644 --- a/public/index.php +++ b/public/index.php @@ -26,7 +26,7 @@ require __DIR__ . '/../vendor/autoload.php'; // 执行HTTP应用并响应 $http = (new App())->http; -$response = $http->run(); +$response = $http->name('index')->run(); $response->send(); diff --git a/public/nginx.htaccess b/public/nginx.htaccess index dc5e230..6a3d140 100644 --- a/public/nginx.htaccess +++ b/public/nginx.htaccess @@ -1,5 +1,9 @@ location / { - if (!-e $request_filename) { - rewrite ^(.*)$ /index.php?s=/$1 last; - } -} \ No newline at end of file + if (!-e $request_filename){ + 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; + } +} diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 2d097a5..456f7e9 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -10,7 +10,7 @@ return array( 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/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'), 'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'), 'liliuwei\\sitemap\\' => array($vendorDir . '/liliuwei/php-sitemap/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3eef2c9..4e5fb22 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -107,11 +107,11 @@ class ComposerStaticInit4b57298e8d0e895486f3307a354a7e1a ), 'think\\' => array ( - 0 => __DIR__ . '/..' . '/topthink/think-helper/src', - 1 => __DIR__ . '/..' . '/topthink/think-orm/src', - 2 => __DIR__ . '/..' . '/topthink/framework/src/think', - 3 => __DIR__ . '/..' . '/topthink/think-filesystem/src', - 4 => __DIR__ . '/..' . '/topthink/think-template/src', + 0 => __DIR__ . '/..' . '/topthink/think-filesystem/src', + 1 => __DIR__ . '/..' . '/topthink/think-helper/src', + 2 => __DIR__ . '/..' . '/topthink/think-orm/src', + 3 => __DIR__ . '/..' . '/topthink/think-template/src', + 4 => __DIR__ . '/..' . '/topthink/framework/src/think', ), 'mailer\\' => array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 55ac9ad..8d0a4e1 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -87,17 +87,17 @@ }, { "name": "doctrine/deprecations", - "version": "v1.0.0", - "version_normalized": "1.0.0.0", + "version": "v1.1.0", + "version_normalized": "1.1.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + "reference": "8cffffb2218e01f3b370bf763e00e81697725259" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/8cffffb2218e01f3b370bf763e00e81697725259", + "reference": "8cffffb2218e01f3b370bf763e00e81697725259", "shasum": "", "mirrors": [ { @@ -117,7 +117,7 @@ "suggest": { "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", "installation-source": "dist", "autoload": { @@ -133,7 +133,7 @@ "homepage": "https://www.doctrine-project.org/", "support": { "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" }, @@ -226,17 +226,17 @@ }, { "name": "egulias/email-validator", - "version": "3.2.5", - "version_normalized": "3.2.5.0", + "version": "3.2.6", + "version_normalized": "3.2.6.0", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "b531a2311709443320c786feb4519cfaf94af796" + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b531a2311709443320c786feb4519cfaf94af796", - "reference": "b531a2311709443320c786feb4519cfaf94af796", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", "shasum": "", "mirrors": [ { @@ -257,7 +257,7 @@ "suggest": { "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", "extra": { "branch-alias": { @@ -290,7 +290,7 @@ ], "support": { "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": [ { @@ -1361,17 +1361,17 @@ }, { "name": "symfony/http-foundation", - "version": "v5.4.23", - "version_normalized": "5.4.23.0", + "version": "v5.4.25", + "version_normalized": "5.4.25.0", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "af9fbb378f5f956c8f29d4886644c84c193780ac" + "reference": "f66be2706075c5f6325d2fe2b743a57fb5d23f6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/af9fbb378f5f956c8f29d4886644c84c193780ac", - "reference": "af9fbb378f5f956c8f29d4886644c84c193780ac", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/f66be2706075c5f6325d2fe2b743a57fb5d23f6b", + "reference": "f66be2706075c5f6325d2fe2b743a57fb5d23f6b", "shasum": "", "mirrors": [ { @@ -1398,7 +1398,7 @@ "suggest": { "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", "installation-source": "dist", "autoload": { @@ -1426,7 +1426,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.4.23" + "source": "https://github.com/symfony/http-foundation/tree/v5.4.25" }, "funding": [ { @@ -2272,17 +2272,17 @@ }, { "name": "topthink/framework", - "version": "v6.1.2", - "version_normalized": "6.1.2.0", + "version": "v6.1.4", + "version_normalized": "6.1.4.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3" + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/67235be5b919aaaf1de5aed9839f65d8e766aca3", - "reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3", + "url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c", + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c", "shasum": "", "mirrors": [ { @@ -2308,7 +2308,7 @@ "mockery/mockery": "^1.2", "phpunit/phpunit": "^7.0" }, - "time": "2023-02-08T02:24:01+00:00", + "time": "2023-07-11T15:16:03+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2340,7 +2340,7 @@ ], "support": { "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" }, @@ -2572,17 +2572,17 @@ }, { "name": "topthink/think-multi-app", - "version": "v1.0.16", - "version_normalized": "1.0.16.0", + "version": "v1.0.17", + "version_normalized": "1.0.17.0", "source": { "type": "git", "url": "https://github.com/top-think/think-multi-app.git", - "reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f" + "reference": "4055a6187296ac16c0bc7bbab4ed5d92f82f791c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/07b9183855150455e1f76f8cbe9d77d6d1bc399f", - "reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f", + "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/4055a6187296ac16c0bc7bbab4ed5d92f82f791c", + "reference": "4055a6187296ac16c0bc7bbab4ed5d92f82f791c", "shasum": "", "mirrors": [ { @@ -2595,7 +2595,7 @@ "php": ">=7.1.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", "extra": { "think": { @@ -2620,10 +2620,10 @@ "email": "liu21st@gmail.com" } ], - "description": "thinkphp6 multi app support", + "description": "thinkphp multi app support", "support": { "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" }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 45dc978..7ec3f94 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'topthink/think', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'c7deee9ae9a946ac4af3f530791f720402b7692d', + 'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -20,9 +20,9 @@ 'dev_requirement' => false, ), 'doctrine/deprecations' => array( - 'pretty_version' => 'v1.0.0', - 'version' => '1.0.0.0', - 'reference' => '0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de', + 'pretty_version' => 'v1.1.0', + 'version' => '1.1.0.0', + 'reference' => '8cffffb2218e01f3b370bf763e00e81697725259', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/deprecations', 'aliases' => array(), @@ -38,9 +38,9 @@ 'dev_requirement' => false, ), 'egulias/email-validator' => array( - 'pretty_version' => '3.2.5', - 'version' => '3.2.5.0', - 'reference' => 'b531a2311709443320c786feb4519cfaf94af796', + 'pretty_version' => '3.2.6', + 'version' => '3.2.6.0', + 'reference' => 'e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7', 'type' => 'library', 'install_path' => __DIR__ . '/../egulias/email-validator', 'aliases' => array(), @@ -194,9 +194,9 @@ ), ), 'symfony/http-foundation' => array( - 'pretty_version' => 'v5.4.23', - 'version' => '5.4.23.0', - 'reference' => 'af9fbb378f5f956c8f29d4886644c84c193780ac', + 'pretty_version' => 'v5.4.25', + 'version' => '5.4.25.0', + 'reference' => 'f66be2706075c5f6325d2fe2b743a57fb5d23f6b', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/http-foundation', 'aliases' => array(), @@ -284,9 +284,9 @@ 'dev_requirement' => true, ), 'topthink/framework' => array( - 'pretty_version' => 'v6.1.2', - 'version' => '6.1.2.0', - 'reference' => '67235be5b919aaaf1de5aed9839f65d8e766aca3', + 'pretty_version' => 'v6.1.4', + 'version' => '6.1.4.0', + 'reference' => '66eb9cf4d627df12911344cd328faf9bb596bf2c', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/framework', 'aliases' => array(), @@ -295,7 +295,7 @@ 'topthink/think' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'c7deee9ae9a946ac4af3f530791f720402b7692d', + 'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -338,9 +338,9 @@ 'dev_requirement' => false, ), 'topthink/think-multi-app' => array( - 'pretty_version' => 'v1.0.16', - 'version' => '1.0.16.0', - 'reference' => '07b9183855150455e1f76f8cbe9d77d6d1bc399f', + 'pretty_version' => 'v1.0.17', + 'version' => '1.0.17.0', + 'reference' => '4055a6187296ac16c0bc7bbab4ed5d92f82f791c', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-multi-app', 'aliases' => array(), diff --git a/vendor/doctrine/deprecations/README.md b/vendor/doctrine/deprecations/README.md index 22f0cce..93caf83 100644 --- a/vendor/doctrine/deprecations/README.md +++ b/vendor/doctrine/deprecations/README.md @@ -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)` -messages. +messages by setting the `DOCTRINE_DEPRECATIONS` environment variable to `trigger`. +Alternatively, call: ```php \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 \Doctrine\Deprecations\Deprecation::enableTrackingDeprecations(); diff --git a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php index 1029372..6c76d98 100644 --- a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php +++ b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php @@ -46,8 +46,8 @@ class Deprecation private const TYPE_TRIGGER_ERROR = 2; private const TYPE_PSR_LOGGER = 4; - /** @var int */ - private static $type = self::TYPE_NONE; + /** @var self::TYPE_*|null */ + private static $type; /** @var LoggerInterface|null */ private static $logger; @@ -72,7 +72,9 @@ class Deprecation */ 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; } @@ -118,7 +120,9 @@ class Deprecation */ 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; } @@ -161,7 +165,9 @@ class Deprecation */ 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 = [ 'file' => $backtrace[0]['file'], 'line' => $backtrace[0]['line'], @@ -172,7 +178,7 @@ class Deprecation self::$logger->notice($message, $context); } - if (! ((self::$type & self::TYPE_TRIGGER_ERROR) > 0)) { + if (! (($type & self::TYPE_TRIGGER_ERROR) > 0)) { return; } @@ -263,4 +269,26 @@ class Deprecation { 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; + } } diff --git a/vendor/egulias/email-validator/src/EmailLexer.php b/vendor/egulias/email-validator/src/EmailLexer.php index 6add6bd..4099758 100644 --- a/vendor/egulias/email-validator/src/EmailLexer.php +++ b/vendor/egulias/email-validator/src/EmailLexer.php @@ -213,13 +213,11 @@ class EmailLexer extends AbstractLexer public function moveNext() : bool { if ($this->hasToRecord && $this->previous === self::$nullToken) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= ((array) $this->token)['value']; } - $this->previous = $this->token instanceof Token - ? ['value' => $this->token->value, 'type' => $this->token->type, 'position' => $this->token->position] - : $this->token; - + $this->previous = (array) $this->token; + if($this->lookahead === null) { $this->lookahead = self::$nullToken; } @@ -227,7 +225,7 @@ class EmailLexer extends AbstractLexer $hasNext = parent::moveNext(); if ($this->hasToRecord) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= ((array) $this->token)['value']; } return $hasNext; diff --git a/vendor/egulias/email-validator/src/Parser.php b/vendor/egulias/email-validator/src/Parser.php index b1905f9..4e5ac7d 100644 --- a/vendor/egulias/email-validator/src/Parser.php +++ b/vendor/egulias/email-validator/src/Parser.php @@ -29,7 +29,7 @@ abstract class Parser public function __construct(EmailLexer $lexer) { - $this->lexer = $lexer; + $this->lexer = $lexer; } public function parse(string $str) : Result @@ -51,7 +51,7 @@ abstract class Parser return $localPartResult; } - $domainPartResult = $this->parseRightFromAt(); + $domainPartResult = $this->parseRightFromAt(); if ($domainPartResult->isInvalid()) { return $domainPartResult; @@ -73,6 +73,6 @@ abstract class Parser $this->lexer->moveNext(); $this->lexer->moveNext(); - return $this->lexer->token['type'] !== EmailLexer::S_AT; + return ((array) $this->lexer->token)['type'] !== EmailLexer::S_AT; } } diff --git a/vendor/egulias/email-validator/src/Parser/Comment.php b/vendor/egulias/email-validator/src/Parser/Comment.php index d6f3032..34ef972 100644 --- a/vendor/egulias/email-validator/src/Parser/Comment.php +++ b/vendor/egulias/email-validator/src/Parser/Comment.php @@ -31,15 +31,15 @@ class Comment extends PartParser public function parse() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS) { $this->openedParenthesis++; 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) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + return new InvalidEmail(new UnOpenedComment(), ((array) $this->lexer->token)['value']); } $this->warnings[WarningComment::CODE] = new WarningComment(); @@ -58,10 +58,10 @@ class Comment extends PartParser } 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) { - 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); @@ -78,7 +78,7 @@ class Comment extends PartParser private function warnEscaping() : bool { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) { return false; } @@ -87,12 +87,12 @@ class Comment extends PartParser } $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; } - private function noClosingParenthesis() : bool + private function noClosingParenthesis() : bool { try { $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); diff --git a/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php b/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php index cbbe3f2..17b686b 100644 --- a/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php +++ b/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php @@ -23,7 +23,7 @@ class DomainComment implements CommentStrategy { //test for end of string 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 //Address is valid within the message but cannot be used unmodified for the envelope diff --git a/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php b/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php index e72319a..179802b 100644 --- a/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php +++ b/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php @@ -24,7 +24,7 @@ class LocalComment implements CommentStrategy public function endOfLoopValidations(EmailLexer $lexer) : Result { 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(); return new ValidEmail(); diff --git a/vendor/egulias/email-validator/src/Parser/DomainLiteral.php b/vendor/egulias/email-validator/src/Parser/DomainLiteral.php index e6d66d0..1048634 100644 --- a/vendor/egulias/email-validator/src/Parser/DomainLiteral.php +++ b/vendor/egulias/email-validator/src/Parser/DomainLiteral.php @@ -39,14 +39,14 @@ class DomainLiteral extends PartParser $addressLiteral = ''; do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) { + return new InvalidEmail(new ExpectingDTEXT(), ((array) $this->lexer->token)['value']); } $this->addObsoleteWarnings(); 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( @@ -57,21 +57,21 @@ class DomainLiteral extends PartParser } 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) { - return new InvalidEmail(new UnusualElements($this->lexer->token['value']), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH) { + 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; } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEBRACKET) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEBRACKET) { break; } - $addressLiteral .= $this->lexer->token['value']; + $addressLiteral .= ((array) $this->lexer->token)['value']; } while ($this->lexer->moveNext()); @@ -144,7 +144,7 @@ class DomainLiteral extends PartParser $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); } } - + public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string { $matchesIP = []; @@ -189,7 +189,7 @@ class DomainLiteral extends PartParser 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(); } } diff --git a/vendor/egulias/email-validator/src/Parser/DomainPart.php b/vendor/egulias/email-validator/src/Parser/DomainPart.php index e1f5b3b..84a4180 100644 --- a/vendor/egulias/email-validator/src/Parser/DomainPart.php +++ b/vendor/egulias/email-validator/src/Parser/DomainPart.php @@ -50,8 +50,8 @@ class DomainPart extends PartParser return $domainChecks; } - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_AT) { + return new InvalidEmail(new ConsecutiveAt(), ((array) $this->lexer->token)['value']); } $result = $this->doParseDomainPart(); @@ -69,7 +69,7 @@ class DomainPart extends PartParser $length = strlen($this->domainPart); 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(); @@ -79,13 +79,13 @@ class DomainPart extends PartParser { $prev = $this->lexer->getPrevious(); 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) { 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 ValidEmail(); @@ -98,13 +98,13 @@ class DomainPart extends PartParser if ($invalidTokens->isInvalid()) { return $invalidTokens; } - + $missingDomain = $this->checkEmptyDomain(); if ($missingDomain->isInvalid()) { 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(); } return new ValidEmail(); @@ -112,12 +112,12 @@ class DomainPart extends PartParser private function checkEmptyDomain() : Result { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && + $thereIsNoDomain = ((array) $this->lexer->token)['type'] === EmailLexer::S_EMPTY || + (((array) $this->lexer->token)['type'] === EmailLexer::S_SP && !$this->lexer->isNextToken(EmailLexer::GENERIC)); if ($thereIsNoDomain) { - return new InvalidEmail(new NoDomainPart(), $this->lexer->token['value']); + return new InvalidEmail(new NoDomainPart(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -125,11 +125,11 @@ class DomainPart extends PartParser private function checkInvalidTokensAfterAT() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT) { + return new InvalidEmail(new DotAtStart(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN) { + return new InvalidEmail(new DomainHyphened('After AT'), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } @@ -156,8 +156,8 @@ class DomainPart extends PartParser return $notAllowedChars; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS || + ((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { $hasComments = true; $commentsResult = $this->parseComments(); @@ -172,7 +172,7 @@ class DomainPart extends PartParser return $dotsResult; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET) { $literalResult = $this->parseDomainLiteral(); $this->addTLDWarnings($tldMissing); @@ -189,9 +189,9 @@ class DomainPart extends PartParser 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; } @@ -201,7 +201,7 @@ class DomainPart extends PartParser } $this->lexer->moveNext(); - } while (null !== $this->lexer->token['type']); + } while (null !== ((array) $this->lexer->token)['type']); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -219,8 +219,8 @@ class DomainPart extends PartParser private function checkNotAllowedChars($token) : Result { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - return new InvalidEmail(new CharNotAllowed(), $token['value']); + if (isset($notAllowed[((array) $token)['type']])) { + return new InvalidEmail(new CharNotAllowed(), ((array) $token)['value']); } return new ValidEmail(); } @@ -233,7 +233,7 @@ class DomainPart extends PartParser try { $this->lexer->find(EmailLexer::S_CLOSEBRACKET); } 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); @@ -244,17 +244,17 @@ class DomainPart extends PartParser protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result { - if ($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']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) { + 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)) { - return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + 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)) { - 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); @@ -273,8 +273,8 @@ class DomainPart extends PartParser $validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true; } - if (!isset($validDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + if (!isset($validDomainTokens[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -282,13 +282,13 @@ class DomainPart extends PartParser 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)) { - return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']); + return new InvalidEmail(new LabelTooLong(), ((array) $this->lexer->token)['value']); } $this->label = ''; } - $this->label .= $this->lexer->token['value']; + $this->label .= ((array) $this->lexer->token)['value']; return new ValidEmail(); } diff --git a/vendor/egulias/email-validator/src/Parser/DoubleQuote.php b/vendor/egulias/email-validator/src/Parser/DoubleQuote.php index b32e2b6..d722292 100644 --- a/vendor/egulias/email-validator/src/Parser/DoubleQuote.php +++ b/vendor/egulias/email-validator/src/Parser/DoubleQuote.php @@ -30,24 +30,24 @@ class DoubleQuote extends PartParser EmailLexer::S_CR => true, EmailLexer::S_LF => true ]; - + $setSpecialsWarning = true; $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + while (((array) $this->lexer->token)['type'] !== EmailLexer::S_DQUOTE && null !== ((array) $this->lexer->token)['type']) { + if (isset($special[((array) $this->lexer->token)['type']]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); $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(); - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']); + if (!$this->escaped() && isset($invalid[((array) $this->lexer->token)['type']])) { + 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) { - 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(); @@ -71,15 +71,15 @@ class DoubleQuote extends PartParser 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'; - return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT($description), ((array) $this->lexer->token)['value']); } try { $this->lexer->find(EmailLexer::S_DQUOTE); } 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(); } diff --git a/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php b/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php index fff6ec3..be4b05b 100644 --- a/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php +++ b/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php @@ -36,16 +36,16 @@ class FoldingWhiteSpace extends PartParser return $resultCRLF; } - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CR) { + return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']); } 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) { - return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_LF || ((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) { + return new InvalidEmail(new ExpectingCTEXT(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { @@ -59,28 +59,28 @@ class FoldingWhiteSpace extends PartParser protected function checkCRLFInFWS() : Result { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::CRLF) { return new ValidEmail(); } 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 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(); } - + protected function isFWS() : bool { if ($this->escaped()) { return false; } - return in_array($this->lexer->token['type'], self::FWS_TYPES); + return in_array(((array) $this->lexer->token)['type'], self::FWS_TYPES); } } diff --git a/vendor/egulias/email-validator/src/Parser/IDLeftPart.php b/vendor/egulias/email-validator/src/Parser/IDLeftPart.php index 5fd9cdf..3b01ae2 100644 --- a/vendor/egulias/email-validator/src/Parser/IDLeftPart.php +++ b/vendor/egulias/email-validator/src/Parser/IDLeftPart.php @@ -10,6 +10,6 @@ class IDLeftPart extends LocalPart { protected function parseComments(): Result { - return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']); + return new InvalidEmail(new CommentsInIDRight(), ((array) $this->lexer->token)['value']); } } diff --git a/vendor/egulias/email-validator/src/Parser/IDRightPart.php b/vendor/egulias/email-validator/src/Parser/IDRightPart.php index 1a1268f..d19e05a 100644 --- a/vendor/egulias/email-validator/src/Parser/IDRightPart.php +++ b/vendor/egulias/email-validator/src/Parser/IDRightPart.php @@ -20,9 +20,9 @@ class IDRightPart extends DomainPart EmailLexer::S_GREATERTHAN => true, EmailLexer::S_LOWERTHAN => true, ]; - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + + if (isset($invalidDomainTokens[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } diff --git a/vendor/egulias/email-validator/src/Parser/LocalPart.php b/vendor/egulias/email-validator/src/Parser/LocalPart.php index 154521b..3f2ef7d 100644 --- a/vendor/egulias/email-validator/src/Parser/LocalPart.php +++ b/vendor/egulias/email-validator/src/Parser/LocalPart.php @@ -36,12 +36,12 @@ class LocalPart extends PartParser { $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()) { - 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(); //Invalid double quote parsing @@ -50,8 +50,8 @@ class LocalPart extends PartParser } } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS || + ((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { $commentsResult = $this->parseComments(); //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)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + 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) ) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtEnd(), ((array) $this->lexer->token)['value']); } $resultEscaping = $this->validateEscaping(); @@ -99,8 +99,8 @@ class LocalPart extends PartParser protected function validateTokens(bool $hasComments) : Result { - if (isset(self::INVALID_TOKENS[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token['value']); + if (isset(self::INVALID_TOKENS[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token found'), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } @@ -110,7 +110,7 @@ class LocalPart extends PartParser return $this->localPart; } - private function parseLocalFWS() : Result + private function parseLocalFWS() : Result { $foldingWS = new FoldingWhiteSpace($this->lexer); $resultFWS = $foldingWS->parse(); @@ -122,7 +122,7 @@ class LocalPart extends PartParser 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 @@ -148,12 +148,12 @@ class LocalPart extends PartParser private function validateEscaping() : Result { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) { return new ValidEmail(); } 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))) { diff --git a/vendor/egulias/email-validator/src/Parser/PartParser.php b/vendor/egulias/email-validator/src/Parser/PartParser.php index a75a172..7fc6d7b 100644 --- a/vendor/egulias/email-validator/src/Parser/PartParser.php +++ b/vendor/egulias/email-validator/src/Parser/PartParser.php @@ -45,8 +45,8 @@ abstract class PartParser protected function checkConsecutiveDots() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -58,6 +58,6 @@ abstract class PartParser return $previous && $previous['type'] === EmailLexer::S_BACKSLASH && - $this->lexer->token['type'] !== EmailLexer::GENERIC; + ((array) $this->lexer->token)['type'] !== EmailLexer::GENERIC; } } diff --git a/vendor/services.php b/vendor/services.php index c1e83d7..55738f1 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\captcha\\CaptchaService', diff --git a/vendor/symfony/http-foundation/BinaryFileResponse.php b/vendor/symfony/http-foundation/BinaryFileResponse.php index 03cf1a2..d3caa36 100644 --- a/vendor/symfony/http-foundation/BinaryFileResponse.php +++ b/vendor/symfony/http-foundation/BinaryFileResponse.php @@ -349,7 +349,7 @@ class BinaryFileResponse extends Response while ('' !== $data) { $read = fwrite($out, $data); if (false === $read || connection_aborted()) { - break; + break 2; } if (0 < $length) { $length -= $read; diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php index 2d83020..cad7e0a 100644 --- a/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php @@ -397,8 +397,8 @@ class PdoSessionHandler extends AbstractSessionHandler $updateStmt = $this->pdo->prepare( "UPDATE $this->table SET $this->lifetimeCol = :expiry, $this->timeCol = :time WHERE $this->idCol = :id" ); - $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $updateStmt->bindParam(':expiry', $expiry, \PDO::PARAM_INT); + $updateStmt->bindValue(':id', $sessionId, \PDO::PARAM_STR); + $updateStmt->bindValue(':expiry', $expiry, \PDO::PARAM_INT); $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); $updateStmt->execute(); } catch (\PDOException $e) { diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/SessionHandlerFactory.php b/vendor/symfony/http-foundation/Session/Storage/Handler/SessionHandlerFactory.php index f3f7b20..39dc30c 100644 --- a/vendor/symfony/http-foundation/Session/Storage/Handler/SessionHandlerFactory.php +++ b/vendor/symfony/http-foundation/Session/Storage/Handler/SessionHandlerFactory.php @@ -11,7 +11,10 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; +use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; +use Doctrine\DBAL\Tools\DsnParser; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Traits\RedisClusterProxy; use Symfony\Component\Cache\Traits\RedisProxy; @@ -71,7 +74,15 @@ class SessionHandlerFactory if (!class_exists(DriverManager::class)) { 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; case str_starts_with($connection, 'mssql://'): diff --git a/vendor/symfony/http-foundation/UrlHelper.php b/vendor/symfony/http-foundation/UrlHelper.php index c15f101..9065994 100644 --- a/vendor/symfony/http-foundation/UrlHelper.php +++ b/vendor/symfony/http-foundation/UrlHelper.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpFoundation; use Symfony\Component\Routing\RequestContext; +use Symfony\Component\Routing\RequestContextAwareInterface; /** * A helper service for manipulating URLs within and outside the request scope. @@ -23,8 +24,15 @@ final class UrlHelper private $requestStack; 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->requestContext = $requestContext; } @@ -73,28 +81,36 @@ final class UrlHelper private function getAbsoluteUrlFromContext(string $path): string { - if (null === $this->requestContext || '' === $host = $this->requestContext->getHost()) { + if (null === $context = $this->requestContext) { return $path; } - $scheme = $this->requestContext->getScheme(); + if ($context instanceof RequestContextAwareInterface) { + $context = $context->getContext(); + } + + if ('' === $host = $context->getHost()) { + return $path; + } + + $scheme = $context->getScheme(); $port = ''; - if ('http' === $scheme && 80 !== $this->requestContext->getHttpPort()) { - $port = ':'.$this->requestContext->getHttpPort(); - } elseif ('https' === $scheme && 443 !== $this->requestContext->getHttpsPort()) { - $port = ':'.$this->requestContext->getHttpsPort(); + if ('http' === $scheme && 80 !== $context->getHttpPort()) { + $port = ':'.$context->getHttpPort(); + } elseif ('https' === $scheme && 443 !== $context->getHttpsPort()) { + $port = ':'.$context->getHttpsPort(); } if ('#' === $path[0]) { - $queryString = $this->requestContext->getQueryString(); - $path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path; + $queryString = $context->getQueryString(); + $path = $context->getPathInfo().($queryString ? '?'.$queryString : '').$path; } elseif ('?' === $path[0]) { - $path = $this->requestContext->getPathInfo().$path; + $path = $context->getPathInfo().$path; } if ('/' !== $path[0]) { - $path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path; + $path = rtrim($context->getBaseUrl(), '/').'/'.$path; } return $scheme.'://'.$host.$port.$path; diff --git a/vendor/topthink/framework/README.md b/vendor/topthink/framework/README.md index dd38e34..8781de0 100644 --- a/vendor/topthink/framework/README.md +++ b/vendor/topthink/framework/README.md @@ -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® 商标和著作权所有者为上海顶想信息科技有限公司。 diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php index 9f309c0..597cf87 100644 --- a/vendor/topthink/framework/src/think/App.php +++ b/vendor/topthink/framework/src/think/App.php @@ -38,7 +38,7 @@ use think\initializer\RegisterService; */ class App extends Container { - const VERSION = '6.1.1'; + const VERSION = '6.1.4'; /** * 应用调试模式 diff --git a/vendor/topthink/framework/src/think/Route.php b/vendor/topthink/framework/src/think/Route.php index e45cb33..60eba4a 100644 --- a/vendor/topthink/framework/src/think/Route.php +++ b/vendor/topthink/framework/src/think/Route.php @@ -19,6 +19,7 @@ use think\route\dispatch\Callback; use think\route\dispatch\Url as UrlDispatch; use think\route\Domain; use think\route\Resource; +use think\route\ResourceRegister; use think\route\Rule; use think\route\RuleGroup; use think\route\RuleItem; @@ -182,6 +183,11 @@ class Route $this->removeSlash = $this->config['remove_slash']; $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) @@ -317,8 +323,7 @@ class Route $domainName = is_array($name) ? array_shift($name) : $name; if (!isset($this->domains[$domainName])) { - $domain = (new Domain($this, $domainName, $rule)) - ->lazy($this->lazy) + $domain = (new Domain($this, $domainName, $rule, $this->lazy)) ->removeSlash($this->removeSlash) ->mergeRuleRegex($this->mergeRuleRegex); @@ -523,19 +528,18 @@ class Route } /** - * 设置跨域有效路由规则 + * 设置路由规则全局有效 * @access public * @param Rule $rule 路由规则 - * @param string $method 请求类型 * @return $this */ - public function setCrossDomainRule(Rule $rule, string $method = '*') + public function setCrossDomainRule(Rule $rule) { if (!isset($this->cross)) { $this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex); } - $this->cross->addRuleItem($rule, $method); + $this->cross->addRuleItem($rule); return $this; } @@ -554,8 +558,7 @@ class Route $name = ''; } - return (new RuleGroup($this, $this->group, $name, $route)) - ->lazy($this->lazy) + return (new RuleGroup($this, $this->group, $name, $route, $this->lazy)) ->removeSlash($this->removeSlash) ->mergeRuleRegex($this->mergeRuleRegex); } @@ -661,12 +664,17 @@ class Route * @access public * @param string $rule 路由规则 * @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)) - ->lazy($this->lazy); + $resource = new Resource($this, $this->group, $rule, $route, $this->rest); + + if (!$this->lazy) { + return new ResourceRegister($resource); + } + + return $resource; } /** diff --git a/vendor/topthink/framework/src/think/cache/driver/File.php b/vendor/topthink/framework/src/think/cache/driver/File.php index b36b069..70a4757 100644 --- a/vendor/topthink/framework/src/think/cache/driver/File.php +++ b/vendor/topthink/framework/src/think/cache/driver/File.php @@ -176,7 +176,8 @@ class File extends Driver } $data = "\n" . $data; - $result = file_put_contents($filename, $data); + + $result = file_put_contents($filename, $data, LOCK_EX); if ($result) { clearstatcache(); diff --git a/vendor/topthink/framework/src/think/console/command/RouteList.php b/vendor/topthink/framework/src/think/console/command/RouteList.php index e9d4c5d..cfc7293 100644 --- a/vendor/topthink/framework/src/think/console/command/RouteList.php +++ b/vendor/topthink/framework/src/think/console/command/RouteList.php @@ -56,8 +56,8 @@ class RouteList extends Command protected function getRouteList(string $dir = null): string { - $this->app->route->setTestMode(true); $this->app->route->clear(); + $this->app->route->lazy(false); if ($dir) { $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php index 6ce3e64..424daaf 100644 --- a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php +++ b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php @@ -67,7 +67,12 @@ class Schema extends Command if (0 === strpos($file, '.')) { continue; } + $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + if (!class_exists($class)) { + continue; + } + $this->buildModelSchema($class); } } diff --git a/vendor/topthink/framework/src/think/facade/Route.php b/vendor/topthink/framework/src/think/facade/Route.php index 37504ce..1b9a872 100644 --- a/vendor/topthink/framework/src/think/facade/Route.php +++ b/vendor/topthink/framework/src/think/facade/Route.php @@ -13,6 +13,7 @@ declare (strict_types = 1); namespace think\facade; use think\Facade; +use think\Response; use think\route\Dispatch; use think\route\Domain; use think\route\Rule; @@ -20,6 +21,7 @@ use think\route\RuleGroup; use think\route\RuleItem; use think\route\RuleName; use think\route\Url as UrlBuild; +use think\route\ResourceRegister as Resource; /** * @see \think\Route @@ -48,7 +50,7 @@ use think\route\Url as UrlBuild; * @method static array getRuleList() 读取路由列表 * @method static void clear() 清空路由规则 * @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 RuleItem any(string $rule, mixed $route) 注册路由 * @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 array|null getRest(string $name = null) 获取rest方法定义的参数 * @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 url(string $url) 默认URL解析 * @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射 diff --git a/vendor/topthink/framework/src/think/initializer/Error.php b/vendor/topthink/framework/src/think/initializer/Error.php index 201d947..5018b1e 100644 --- a/vendor/topthink/framework/src/think/initializer/Error.php +++ b/vendor/topthink/framework/src/think/initializer/Error.php @@ -55,7 +55,9 @@ class Error if ($this->app->runningInConsole()) { $handler->renderForConsole(new ConsoleOutput, $e); } else { - $handler->render($this->app->request, $e)->send(); + $response = $handler->render($this->app->request, $e); + $response->send(); + $this->app->http->end($response); } } diff --git a/vendor/topthink/framework/src/think/middleware/SessionInit.php b/vendor/topthink/framework/src/think/middleware/SessionInit.php index 3cb2fad..55cea3b 100644 --- a/vendor/topthink/framework/src/think/middleware/SessionInit.php +++ b/vendor/topthink/framework/src/think/middleware/SessionInit.php @@ -68,7 +68,7 @@ class SessionInit $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; } diff --git a/vendor/topthink/framework/src/think/response/Redirect.php b/vendor/topthink/framework/src/think/response/Redirect.php index ee067be..c6d71ae 100644 --- a/vendor/topthink/framework/src/think/response/Redirect.php +++ b/vendor/topthink/framework/src/think/response/Redirect.php @@ -36,24 +36,28 @@ class Redirect extends Response $this->cacheControl('no-cache,must-revalidate'); } + public function data($data) + { + $this->header['Location'] = $data; + return parent::data($data); + } + /** * 处理数据 * @access protected - * @param mixed $data 要处理的数据 + * @param mixed $data 要处理的数据 * @return string */ protected function output($data): string { - $this->header['Location'] = $data; - return ''; } /** * 重定向传值(通过Session) * @access protected - * @param string|array $name 变量名或者数组 - * @param mixed $value 值 + * @param string|array $name 变量名或者数组 + * @param mixed $value 值 * @return $this */ public function with($name, $value = null) diff --git a/vendor/topthink/framework/src/think/route/Dispatch.php b/vendor/topthink/framework/src/think/route/Dispatch.php index 58666b5..e0baad9 100644 --- a/vendor/topthink/framework/src/think/route/Dispatch.php +++ b/vendor/topthink/framework/src/think/route/Dispatch.php @@ -77,16 +77,6 @@ abstract class Dispatch */ 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(); return $this->autoResponse($data); } diff --git a/vendor/topthink/framework/src/think/route/Domain.php b/vendor/topthink/framework/src/think/route/Domain.php index 84f1d46..4cf03cf 100644 --- a/vendor/topthink/framework/src/think/route/Domain.php +++ b/vendor/topthink/framework/src/think/route/Domain.php @@ -29,12 +29,17 @@ class Domain extends RuleGroup * @param Route $router 路由对象 * @param string $name 路由域名 * @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->domain = $name; $this->rule = $rule; + + if (!$lazy) { + $this->parseGroupRule($rule); + } } /** diff --git a/vendor/topthink/framework/src/think/route/Resource.php b/vendor/topthink/framework/src/think/route/Resource.php index 5185cdc..33cd824 100644 --- a/vendor/topthink/framework/src/think/route/Resource.php +++ b/vendor/topthink/framework/src/think/route/Resource.php @@ -19,18 +19,6 @@ use think\Route; */ class Resource extends RuleGroup { - /** - * 资源路由名称 - * @var string - */ - protected $resource; - - /** - * 资源路由地址 - * @var string - */ - protected $route; - /** * REST方法定义 * @var array @@ -58,18 +46,18 @@ class Resource extends RuleGroup /** * 架构函数 * @access public - * @param Route $router 路由对象 - * @param RuleGroup $parent 上级对象 - * @param string $name 资源名称 - * @param string $route 路由地址 - * @param array $rest 资源定义 + * @param Route $router 路由对象 + * @param RuleGroup|null $parent 上级对象 + * @param string $name 资源名称 + * @param string $route 路由地址 + * @param array $rest 资源定义 */ public function __construct(Route $router, RuleGroup $parent = null, string $name = '', string $route = '', array $rest = []) { $name = ltrim($name, '/'); $this->router = $router; $this->parent = $parent; - $this->resource = $name; + $this->rule = $name; $this->route = $route; $this->name = strpos($name, '.') ? strstr($name, '.', true) : $name; @@ -84,20 +72,16 @@ class Resource extends RuleGroup $this->domain = $this->parent->getDomain(); $this->parent->addRuleItem($this); } - - if ($router->isTest()) { - $this->buildResourceRule(); - } } /** - * 生成资源路由规则 - * @access protected + * 解析资源路由规则 + * @access public + * @param mixed $rule 路由规则 * @return void */ - protected function buildResourceRule(): void + public function parseGroupRule($rule): void { - $rule = $this->resource; $option = $this->option; $origin = $this->router->getGroup(); $this->router->setGroup($this); @@ -141,6 +125,7 @@ class Resource extends RuleGroup } $this->router->setGroup($origin); + $this->hasParsed = true; } /** diff --git a/vendor/topthink/framework/src/think/route/ResourceRegister.php b/vendor/topthink/framework/src/think/route/ResourceRegister.php new file mode 100644 index 0000000..6a34787 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/ResourceRegister.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- +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(); + } + } +} diff --git a/vendor/topthink/framework/src/think/route/Rule.php b/vendor/topthink/framework/src/think/route/Rule.php index 2d864cd..e909e78 100644 --- a/vendor/topthink/framework/src/think/route/Rule.php +++ b/vendor/topthink/framework/src/think/route/Rule.php @@ -67,7 +67,7 @@ abstract class Rule * 请求类型 * @var string */ - protected $method; + protected $method = '*'; /** * 路由变量 @@ -572,14 +572,7 @@ abstract class Rule */ public function crossDomainRule() { - if ($this instanceof RuleGroup) { - $method = '*'; - } else { - $method = $this->method; - } - - $this->router->setCrossDomainRule($this, $method); - + $this->router->setCrossDomainRule($this); return $this; } diff --git a/vendor/topthink/framework/src/think/route/RuleGroup.php b/vendor/topthink/framework/src/think/route/RuleGroup.php index cd9ddbd..f8fbc1e 100644 --- a/vendor/topthink/framework/src/think/route/RuleGroup.php +++ b/vendor/topthink/framework/src/think/route/RuleGroup.php @@ -25,15 +25,15 @@ class RuleGroup extends Rule { /** * 分组路由(包括子分组) - * @var array + * @var Rule[] */ protected $rules = []; /** - * 分组路由规则 - * @var mixed + * 是否已经解析 + * @var bool */ - protected $rule; + protected $hasParsed; /** * MISS路由 @@ -56,12 +56,13 @@ class RuleGroup extends Rule /** * 架构函数 * @access public - * @param Route $router 路由对象 - * @param RuleGroup $parent 上级对象 - * @param string $name 分组名称 - * @param mixed $rule 分组路由 + * @param Route $router 路由对象 + * @param RuleGroup|null $parent 上级对象 + * @param string $name 分组名称 + * @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->parent = $parent; @@ -75,8 +76,8 @@ class RuleGroup extends Rule $this->parent->addRuleItem($this); } - if ($router->isTest()) { - $this->lazy(false); + if (!$lazy) { + $this->parseGroupRule($rule); } } @@ -138,9 +139,7 @@ class RuleGroup extends Rule } // 解析分组路由 - if ($this instanceof Resource) { - $this->buildResourceRule(); - } else { + if (!$this->hasParsed) { $this->parseGroupRule($this->rule); } @@ -163,8 +162,8 @@ class RuleGroup extends Rule } // 检查分组路由 - foreach ($rules as $key => $item) { - $result = $item[1]->check($request, $url, $completeMatch); + foreach ($rules as $item) { + $result = $item->check($request, $url, $completeMatch); if (false !== $result) { return $result; @@ -173,9 +172,9 @@ class RuleGroup extends Rule if (!empty($option['dispatcher'])) { $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 { $result = false; } @@ -222,22 +221,6 @@ class RuleGroup extends Rule 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 @@ -246,6 +229,10 @@ class RuleGroup extends Rule */ public function parseGroupRule($rule): void { + if (is_null($rule)) { + return; + } + if (is_string($rule) && is_subclass_of($rule, Dispatch::class)) { $this->dispatcher($rule); return; @@ -254,13 +241,14 @@ class RuleGroup extends Rule $origin = $this->router->getGroup(); $this->router->setGroup($this); - if ($rule instanceof \Closure) { + if ($rule instanceof Closure) { Container::getInstance()->invokeFunction($rule); } elseif (is_string($rule) && $rule) { $this->router->bind($rule, $this->domain); } $this->router->setGroup($origin); + $this->hasParsed = true; } /** @@ -279,8 +267,7 @@ class RuleGroup extends Rule $regex = []; $items = []; - foreach ($rules as $key => $val) { - $item = $val[1]; + foreach ($rules as $key => $item) { if ($item instanceof RuleItem) { $rule = $depr . str_replace('/', $depr, $item->getRule()); if ($depr == $rule && $depr != $url) { @@ -368,11 +355,19 @@ class RuleGroup extends Rule /** * 获取分组的MISS路由 * @access public + * @param string $method 请求类型 * @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->setMiss(); - $this->miss = $ruleItem; + $this->miss[$method] = $ruleItem->setMiss(); return $ruleItem; } @@ -419,7 +413,7 @@ class RuleGroup extends Rule // 创建路由规则实例 $ruleItem = new RuleItem($this->router, $this, $name, $rule, $route, $method); - $this->addRuleItem($ruleItem, $method); + $this->addRuleItem($ruleItem); return $ruleItem; } @@ -428,21 +422,11 @@ class RuleGroup extends Rule * 注册分组下的路由规则 * @access public * @param Rule $rule 路由规则 - * @param string $method 请求类型 * @return $this */ - public function addRuleItem(Rule $rule, string $method = '*') + public function addRuleItem(Rule $rule) { - if (strpos($method, '|')) { - $rule->method($method); - $method = '*'; - } - - $this->rules[] = [$method, $rule]; - - if ($rule instanceof RuleItem && 'options' != $method) { - $this->rules[] = ['options', $rule->setAutoOptions()]; - } + $this->rules[] = $rule; return $this; } @@ -507,7 +491,8 @@ class RuleGroup extends Rule } return array_filter($this->rules, function ($item) use ($method) { - return $method == $item[0] || '*' == $item[0]; + $ruleMethod = $item->getMethod(); + return '*' == $ruleMethod || false !== strpos($ruleMethod, $method); }); } diff --git a/vendor/topthink/framework/src/think/route/RuleItem.php b/vendor/topthink/framework/src/think/route/RuleItem.php index e4e3246..cdde273 100644 --- a/vendor/topthink/framework/src/think/route/RuleItem.php +++ b/vendor/topthink/framework/src/think/route/RuleItem.php @@ -38,7 +38,7 @@ class RuleItem extends Rule * @access public * @param Route $router 路由实例 * @param RuleGroup $parent 上级对象 - * @param string $name 路由标识 + * @param string|null $name 路由标识 * @param string $rule 路由规则 * @param string|\Closure $route 路由地址 * @param string $method 请求类型 @@ -77,27 +77,6 @@ class RuleItem extends Rule 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后缀 * @access public diff --git a/vendor/topthink/framework/src/think/route/RuleName.php b/vendor/topthink/framework/src/think/route/RuleName.php index 0684367..dd93a0d 100644 --- a/vendor/topthink/framework/src/think/route/RuleName.php +++ b/vendor/topthink/framework/src/think/route/RuleName.php @@ -113,8 +113,9 @@ class RuleName */ public function clear(): void { - $this->item = []; - $this->rule = []; + $this->item = []; + $this->rule = []; + $this->group = []; } /** diff --git a/vendor/topthink/framework/src/think/route/Url.php b/vendor/topthink/framework/src/think/route/Url.php index b3f8b9f..9e60fca 100644 --- a/vendor/topthink/framework/src/think/route/Url.php +++ b/vendor/topthink/framework/src/think/route/Url.php @@ -358,7 +358,7 @@ class Url * @access public * @return string */ - public function build() + public function build(): string { // 解析URL $url = $this->url; diff --git a/vendor/topthink/think-multi-app/composer.json b/vendor/topthink/think-multi-app/composer.json index 333d9e3..df25420 100644 --- a/vendor/topthink/think-multi-app/composer.json +++ b/vendor/topthink/think-multi-app/composer.json @@ -1,6 +1,6 @@ { "name": "topthink/think-multi-app", - "description": "thinkphp6 multi app support", + "description": "thinkphp multi app support", "license": "Apache-2.0", "authors": [ { diff --git a/vendor/topthink/think-multi-app/src/MultiApp.php b/vendor/topthink/think-multi-app/src/MultiApp.php index b0ac260..130d25c 100644 --- a/vendor/topthink/think-multi-app/src/MultiApp.php +++ b/vendor/topthink/think-multi-app/src/MultiApp.php @@ -27,29 +27,9 @@ class MultiApp /** @var App */ protected $app; - /** - * 应用名称 - * @var string - */ - protected $name; - - /** - * 应用名称 - * @var string - */ - protected $appName; - - /** - * 应用路径 - * @var string - */ - protected $path; - public function __construct(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(); $defaultApp = $this->app->config->get('app.default_app') ?: 'index'; + $appName = $this->app->http->getName(); - if ($this->name || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) { - $appName = $this->name ?: $scriptName; + if ($appName || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) { + $appName = $appName ?: $scriptName; $this->app->http->setBind(); } else { // 自动多应用识别 $this->app->http->setBind(false); - $appName = null; - $this->appName = ''; + $appName = null; $bind = $this->app->config->get('app.domain_bind', []); @@ -142,7 +122,7 @@ class MultiApp $appName = $map['*']; } else { $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)) { $express = $this->app->config->get('app.app_express', false); @@ -189,10 +169,9 @@ class MultiApp */ protected function setApp(string $appName): void { - $this->appName = $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); // 设置应用命名空间 diff --git a/vendor/topthink/think-multi-app/src/Url.php b/vendor/topthink/think-multi-app/src/Url.php index df415ad..34bf8da 100644 --- a/vendor/topthink/think-multi-app/src/Url.php +++ b/vendor/topthink/think-multi-app/src/Url.php @@ -68,7 +68,7 @@ class Url extends UrlBuild return $url; } - public function build() + public function build(): string { // 解析URL $url = $this->url;