This commit is contained in:
taoser 2023-08-02 19:41:11 +08:00
parent 0c2f0154a8
commit 78a9655d10
30 changed files with 1321 additions and 657 deletions

58
composer.lock generated
View File

@ -796,16 +796,16 @@
},
{
"name": "laravel/serializable-closure",
"version": "v1.3.0",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37"
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
"reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902",
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902",
"shasum": ""
},
"require": {
@ -852,7 +852,7 @@
"issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure"
},
"time": "2023-01-30T18:31:20+00:00"
"time": "2023-07-14T13:56:28+00:00"
},
{
"name": "league/flysystem",
@ -2106,16 +2106,16 @@
},
{
"name": "symfony/var-exporter",
"version": "v5.4.21",
"version": "v5.4.26",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-exporter.git",
"reference": "be74908a6942fdd331554b3cec27ff41b45ccad4"
"reference": "11401fe94f960249b3c63a488c63ba73091c1e4a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4",
"reference": "be74908a6942fdd331554b3cec27ff41b45ccad4",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/11401fe94f960249b3c63a488c63ba73091c1e4a",
"reference": "11401fe94f960249b3c63a488c63ba73091c1e4a",
"shasum": ""
},
"require": {
@ -2159,7 +2159,7 @@
"serialize"
],
"support": {
"source": "https://github.com/symfony/var-exporter/tree/v5.4.21"
"source": "https://github.com/symfony/var-exporter/tree/v5.4.26"
},
"funding": [
{
@ -2175,7 +2175,7 @@
"type": "tidelift"
}
],
"time": "2023-02-21T19:46:44+00:00"
"time": "2023-07-20T07:21:16+00:00"
},
{
"name": "taoser/think-addons",
@ -2383,16 +2383,16 @@
},
{
"name": "topthink/framework",
"version": "v6.1.3",
"version": "v6.1.4",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "7c324e7011246f0064b055b62ab9c3921cf0a041"
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041",
"reference": "7c324e7011246f0064b055b62ab9c3921cf0a041",
"url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c",
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c",
"shasum": ""
},
"require": {
@ -2442,9 +2442,9 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.1.3"
"source": "https://github.com/top-think/framework/tree/v6.1.4"
},
"time": "2023-05-22T03:02:08+00:00"
"time": "2023-07-11T15:16:03+00:00"
},
{
"name": "topthink/think-captcha",
@ -2592,20 +2592,20 @@
},
{
"name": "topthink/think-migration",
"version": "v3.0.5",
"version": "v3.0.6",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-migration.git",
"reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca"
"reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca",
"reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/82c4226cb14f973b9377c7fc6e89c525cbb8b030",
"reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0",
"topthink/framework": "^6.0 || ^8.0",
"topthink/think-helper": "^3.0.3"
},
"require-dev": {
@ -2640,9 +2640,9 @@
],
"support": {
"issues": "https://github.com/top-think/think-migration/issues",
"source": "https://github.com/top-think/think-migration/tree/v3.0.5"
"source": "https://github.com/top-think/think-migration/tree/v3.0.6"
},
"time": "2023-02-26T13:16:22+00:00"
"time": "2023-07-01T11:01:52+00:00"
},
{
"name": "topthink/think-multi-app",
@ -2958,16 +2958,16 @@
},
{
"name": "workerman/workerman",
"version": "v4.1.10",
"version": "v4.1.13",
"source": {
"type": "git",
"url": "https://github.com/walkor/workerman.git",
"reference": "e967b79f95b9251a72acb971be05623ec1a51e83"
"reference": "807780ff672775fcd08f89e573a2824e939021ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83",
"reference": "e967b79f95b9251a72acb971be05623ec1a51e83",
"url": "https://api.github.com/repos/walkor/workerman/zipball/807780ff672775fcd08f89e573a2824e939021ce",
"reference": "807780ff672775fcd08f89e573a2824e939021ce",
"shasum": ""
},
"require": {
@ -3017,7 +3017,7 @@
"type": "patreon"
}
],
"time": "2023-05-01T02:12:20+00:00"
"time": "2023-07-31T05:57:25+00:00"
},
{
"name": "yansongda/pay",

View File

@ -14,7 +14,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/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/framework/src/think'),
'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'),
'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'),
'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'),

View File

@ -176,10 +176,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2
),
'think\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src',
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
1 => __DIR__ . '/..' . '/topthink/think-orm/src',
2 => __DIR__ . '/..' . '/topthink/think-template/src',
3 => __DIR__ . '/..' . '/topthink/framework/src/think',
),
'taoser\\think\\' =>
array (

View File

@ -850,17 +850,17 @@
},
{
"name": "laravel/serializable-closure",
"version": "v1.3.0",
"version_normalized": "1.3.0.0",
"version": "v1.3.1",
"version_normalized": "1.3.1.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37"
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
"reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902",
"reference": "e5a3057a5591e1cfe8183034b0203921abe2c902",
"shasum": ""
},
"require": {
@ -872,7 +872,7 @@
"phpstan/phpstan": "^1.8.2",
"symfony/var-dumper": "^5.4.11"
},
"time": "2023-01-30T18:31:20+00:00",
"time": "2023-07-14T13:56:28+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2289,24 +2289,18 @@
},
{
"name": "symfony/var-exporter",
"version": "v5.4.21",
"version_normalized": "5.4.21.0",
"version": "v5.4.26",
"version_normalized": "5.4.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-exporter.git",
"reference": "be74908a6942fdd331554b3cec27ff41b45ccad4"
"reference": "11401fe94f960249b3c63a488c63ba73091c1e4a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4",
"reference": "be74908a6942fdd331554b3cec27ff41b45ccad4",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/11401fe94f960249b3c63a488c63ba73091c1e4a",
"reference": "11401fe94f960249b3c63a488c63ba73091c1e4a",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
@ -2315,7 +2309,7 @@
"require-dev": {
"symfony/var-dumper": "^4.4.9|^5.0.9|^6.0"
},
"time": "2023-02-21T19:46:44+00:00",
"time": "2023-07-20T07:21:16+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2351,7 +2345,7 @@
"serialize"
],
"support": {
"source": "https://github.com/symfony/var-exporter/tree/v5.4.21"
"source": "https://github.com/symfony/var-exporter/tree/v5.4.26"
},
"funding": [
{
@ -2599,24 +2593,18 @@
},
{
"name": "topthink/framework",
"version": "v6.1.3",
"version_normalized": "6.1.3.0",
"version": "v6.1.4",
"version_normalized": "6.1.4.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "7c324e7011246f0064b055b62ab9c3921cf0a041"
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041",
"reference": "7c324e7011246f0064b055b62ab9c3921cf0a041",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c",
"reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c",
"shasum": ""
},
"require": {
"ext-json": "*",
@ -2635,7 +2623,7 @@
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.0"
},
"time": "2023-05-22T03:02:08+00:00",
"time": "2023-07-11T15:16:03+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2667,7 +2655,7 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.1.3"
"source": "https://github.com/top-think/framework/tree/v6.1.4"
},
"install-path": "../topthink/framework"
},
@ -2844,21 +2832,21 @@
},
{
"name": "topthink/think-migration",
"version": "v3.0.5",
"version_normalized": "3.0.5.0",
"version": "v3.0.6",
"version_normalized": "3.0.6.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-migration.git",
"reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca"
"reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca",
"reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca",
"url": "https://api.github.com/repos/top-think/think-migration/zipball/82c4226cb14f973b9377c7fc6e89c525cbb8b030",
"reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030",
"shasum": ""
},
"require": {
"topthink/framework": "^6.0",
"topthink/framework": "^6.0 || ^8.0",
"topthink/think-helper": "^3.0.3"
},
"require-dev": {
@ -2867,7 +2855,7 @@
"suggest": {
"fzaninotto/faker": "Required to use the factory builder (^1.8)."
},
"time": "2023-02-26T13:16:22+00:00",
"time": "2023-07-01T11:01:52+00:00",
"type": "library",
"extra": {
"think": {
@ -2895,7 +2883,7 @@
],
"support": {
"issues": "https://github.com/top-think/think-migration/issues",
"source": "https://github.com/top-think/think-migration/tree/v3.0.5"
"source": "https://github.com/top-think/think-migration/tree/v3.0.6"
},
"install-path": "../topthink/think-migration"
},
@ -3326,24 +3314,18 @@
},
{
"name": "workerman/workerman",
"version": "v4.1.10",
"version_normalized": "4.1.10.0",
"version": "v4.1.13",
"version_normalized": "4.1.13.0",
"source": {
"type": "git",
"url": "https://github.com/walkor/workerman.git",
"reference": "e967b79f95b9251a72acb971be05623ec1a51e83"
"reference": "807780ff672775fcd08f89e573a2824e939021ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83",
"reference": "e967b79f95b9251a72acb971be05623ec1a51e83",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/walkor/workerman/zipball/807780ff672775fcd08f89e573a2824e939021ce",
"reference": "807780ff672775fcd08f89e573a2824e939021ce",
"shasum": ""
},
"require": {
"php": ">=7.0"
@ -3351,7 +3333,7 @@
"suggest": {
"ext-event": "For better performance. "
},
"time": "2023-05-01T02:12:20+00:00",
"time": "2023-07-31T05:57:25+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'taoser/taoler',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6',
'pretty_version' => '2.3.10.x-dev',
'version' => '2.3.10.9999999-dev',
'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -119,9 +119,9 @@
'dev_requirement' => false,
),
'laravel/serializable-closure' => array(
'pretty_version' => 'v1.3.0',
'version' => '1.3.0.0',
'reference' => 'f23fe9d4e95255dacee1bf3525e0810d1a1b0f37',
'pretty_version' => 'v1.3.1',
'version' => '1.3.1.0',
'reference' => 'e5a3057a5591e1cfe8183034b0203921abe2c902',
'type' => 'library',
'install_path' => __DIR__ . '/../laravel/serializable-closure',
'aliases' => array(),
@ -338,18 +338,18 @@
'dev_requirement' => false,
),
'symfony/var-exporter' => array(
'pretty_version' => 'v5.4.21',
'version' => '5.4.21.0',
'reference' => 'be74908a6942fdd331554b3cec27ff41b45ccad4',
'pretty_version' => 'v5.4.26',
'version' => '5.4.26.0',
'reference' => '11401fe94f960249b3c63a488c63ba73091c1e4a',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/var-exporter',
'aliases' => array(),
'dev_requirement' => false,
),
'taoser/taoler' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6',
'pretty_version' => '2.3.10.x-dev',
'version' => '2.3.10.9999999-dev',
'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -392,9 +392,9 @@
'dev_requirement' => false,
),
'topthink/framework' => array(
'pretty_version' => 'v6.1.3',
'version' => '6.1.3.0',
'reference' => '7c324e7011246f0064b055b62ab9c3921cf0a041',
'pretty_version' => 'v6.1.4',
'version' => '6.1.4.0',
'reference' => '66eb9cf4d627df12911344cd328faf9bb596bf2c',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/framework',
'aliases' => array(),
@ -428,9 +428,9 @@
'dev_requirement' => false,
),
'topthink/think-migration' => array(
'pretty_version' => 'v3.0.5',
'version' => '3.0.5.0',
'reference' => '7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca',
'pretty_version' => 'v3.0.6',
'version' => '3.0.6.0',
'reference' => '82c4226cb14f973b9377c7fc6e89c525cbb8b030',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-migration',
'aliases' => array(),
@ -509,9 +509,9 @@
'dev_requirement' => false,
),
'workerman/workerman' => array(
'pretty_version' => 'v4.1.10',
'version' => '4.1.10.0',
'reference' => 'e967b79f95b9251a72acb971be05623ec1a51e83',
'pretty_version' => 'v4.1.13',
'version' => '4.1.13.0',
'reference' => '807780ff672775fcd08f89e573a2824e939021ce',
'type' => 'library',
'install_path' => __DIR__ . '/../workerman/workerman',
'aliases' => array(),

View File

@ -51,9 +51,10 @@ echo $closure(); // james;
### Caveats
1. Creating **anonymous classes** within closures is not supported.
2. Using attributes within closures is not supported.
3. Serializing closures on REPL environments such as Laravel Tinker is not supported.
* Anonymous classes cannot be created within closures.
* Attributes cannot be used within closures.
* Serializing closures on REPL environments like Laravel Tinker is not supported.
* Serializing closures that reference objects with readonly properties is not supported.
## Contributing

View File

@ -511,8 +511,7 @@ class ReflectionClosure extends ReflectionFunction
// named arguments...
case ':':
if ($lastState === 'closure' && $context === 'root') {
$state = 'ignore_next';
$lastState = 'closure';
$state = 'closure';
$code .= $id_start.$token;
}

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2023-06-29 09:57:38
// This file is automatically generated at:2023-08-02 19:40:44
declare (strict_types = 1);
return array (
0 => 'taoser\\addons\\Service',

View File

@ -73,20 +73,29 @@ class Exporter
$class = \get_class($value);
$reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
$properties = [];
if ($reflector->hasMethod('__serialize')) {
if (!$reflector->getMethod('__serialize')->isPublic()) {
throw new \Error(sprintf('Call to %s method "%s::__serialize()".', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class));
}
if (!\is_array($properties = $value->__serialize())) {
if (!\is_array($serializeProperties = $value->__serialize())) {
throw new \TypeError($class.'::__serialize() must return an array');
}
if ($reflector->hasMethod('__unserialize')) {
$properties = $serializeProperties;
} else {
foreach ($serializeProperties as $n => $v) {
$c = \PHP_VERSION_ID >= 80100 && $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass';
$properties[$c][$n] = $v;
}
}
goto prepare_value;
}
$properties = [];
$sleep = null;
$proto = Registry::$prototypes[$class];

View File

@ -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® 商标和著作权所有者为上海顶想信息科技有限公司。

View File

@ -38,7 +38,7 @@ use think\initializer\RegisterService;
*/
class App extends Container
{
const VERSION = '6.1.3';
const VERSION = '6.1.4';
/**
* 应用调试模式

View File

@ -1,89 +0,0 @@
<?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: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think;
use InvalidArgumentException;
use think\filesystem\Driver;
use think\filesystem\driver\Local;
use think\helper\Arr;
/**
* Class Filesystem
* @package think
* @mixin Driver
* @mixin Local
*/
class Filesystem extends Manager
{
protected $namespace = '\\think\\filesystem\\driver\\';
/**
* @param null|string $name
* @return Driver
*/
public function disk(string $name = null): Driver
{
return $this->driver($name);
}
protected function resolveType(string $name)
{
return $this->getDiskConfig($name, 'type', 'local');
}
protected function resolveConfig(string $name)
{
return $this->getDiskConfig($name);
}
/**
* 获取缓存配置
* @access public
* @param null|string $name 名称
* @param mixed $default 默认值
* @return mixed
*/
public function getConfig(string $name = null, $default = null)
{
if (!is_null($name)) {
return $this->app->config->get('filesystem.' . $name, $default);
}
return $this->app->config->get('filesystem');
}
/**
* 获取磁盘配置
* @param string $disk
* @param null $name
* @param null $default
* @return array
*/
public function getDiskConfig($disk, $name = null, $default = null)
{
if ($config = $this->getConfig("disks.{$disk}")) {
return Arr::get($config, $name, $default);
}
throw new InvalidArgumentException("Disk [$disk] not found.");
}
/**
* 默认驱动
* @return string|null
*/
public function getDefaultDriver()
{
return $this->getConfig('default');
}
}

View File

@ -176,7 +176,8 @@ class File extends Driver
}
$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) {
clearstatcache();

View File

@ -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);
}
}

View File

@ -1,33 +0,0 @@
<?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: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think\facade;
use think\Facade;
use think\filesystem\Driver;
/**
* Class Filesystem
* @package think\facade
* @mixin \think\Filesystem
* @method static Driver disk(string $name = null) ,null|string
* @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置
* @method static array getDiskConfig(string $disk, null $name = null, null $default = null) 获取磁盘配置
* @method static string|null getDefaultDriver() 默认驱动
*/
class Filesystem extends Facade
{
protected static function getFacadeClass()
{
return 'filesystem';
}
}

View File

@ -1,54 +0,0 @@
<?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: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think\filesystem;
use League\Flysystem\Cached\Storage\AbstractCache;
use Psr\SimpleCache\CacheInterface;
class CacheStore extends AbstractCache
{
protected $store;
protected $key;
protected $expire;
public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null)
{
$this->key = $key;
$this->store = $store;
$this->expire = $expire;
}
/**
* Store the cache.
*/
public function save()
{
$contents = $this->getForStorage();
$this->store->set($this->key, $contents, $this->expire);
}
/**
* Load the cache.
*/
public function load()
{
$contents = $this->store->get($this->key);
if (!is_null($contents)) {
$this->setFromStorage($contents);
}
}
}

View File

@ -1,144 +0,0 @@
<?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: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think\filesystem;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Adapter\AbstractAdapter;
use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Cached\Storage\Memory as MemoryStore;
use League\Flysystem\Filesystem;
use RuntimeException;
use think\Cache;
use think\File;
/**
* Class Driver
* @package think\filesystem
* @mixin Filesystem
*/
abstract class Driver
{
/** @var Cache */
protected $cache;
/** @var Filesystem */
protected $filesystem;
/**
* 配置参数
* @var array
*/
protected $config = [];
public function __construct(Cache $cache, array $config)
{
$this->cache = $cache;
$this->config = array_merge($this->config, $config);
$adapter = $this->createAdapter();
$this->filesystem = $this->createFilesystem($adapter);
}
protected function createCacheStore($config)
{
if (true === $config) {
return new MemoryStore;
}
return new CacheStore(
$this->cache->store($config['store']),
$config['prefix'] ?? 'flysystem',
$config['expire'] ?? null
);
}
abstract protected function createAdapter(): AdapterInterface;
protected function createFilesystem(AdapterInterface $adapter): Filesystem
{
if (!empty($this->config['cache'])) {
$adapter = new CachedAdapter($adapter, $this->createCacheStore($this->config['cache']));
}
$config = array_intersect_key($this->config, array_flip(['visibility', 'disable_asserts', 'url']));
return new Filesystem($adapter, count($config) > 0 ? $config : null);
}
/**
* 获取文件完整路径
* @param string $path
* @return string
*/
public function path(string $path): string
{
$adapter = $this->filesystem->getAdapter();
if ($adapter instanceof AbstractAdapter) {
return $adapter->applyPathPrefix($path);
}
return $path;
}
protected function concatPathToUrl($url, $path)
{
return rtrim($url, '/') . '/' . ltrim($path, '/');
}
public function url(string $path): string
{
throw new RuntimeException('This driver does not support retrieving URLs.');
}
/**
* 保存文件
* @param string $path 路径
* @param File $file 文件
* @param null|string|\Closure $rule 文件名规则
* @param array $options 参数
* @return bool|string
*/
public function putFile(string $path, File $file, $rule = null, array $options = [])
{
return $this->putFileAs($path, $file, $file->hashName($rule), $options);
}
/**
* 指定文件名保存文件
* @param string $path 路径
* @param File $file 文件
* @param string $name 文件名
* @param array $options 参数
* @return bool|string
*/
public function putFileAs(string $path, File $file, string $name, array $options = [])
{
$stream = fopen($file->getRealPath(), 'r');
$path = trim($path . '/' . $name, '/');
$result = $this->putStream($path, $stream, $options);
if (is_resource($stream)) {
fclose($stream);
}
return $result ? $path : false;
}
public function __call($method, $parameters)
{
return $this->filesystem->$method(...$parameters);
}
}

View File

@ -1,59 +0,0 @@
<?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: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think\filesystem\driver;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Adapter\Local as LocalAdapter;
use think\filesystem\Driver;
class Local extends Driver
{
/**
* 配置参数
* @var array
*/
protected $config = [
'root' => '',
];
protected function createAdapter(): AdapterInterface
{
$permissions = $this->config['permissions'] ?? [];
$links = ($this->config['links'] ?? null) === 'skip'
? LocalAdapter::SKIP_LINKS
: LocalAdapter::DISALLOW_LINKS;
return new LocalAdapter(
$this->config['root'],
LOCK_EX,
$links,
$permissions
);
}
/**
* 获取文件访问地址
* @param string $path 文件路径
* @return string
*/
public function url(string $path): string
{
$path = str_replace('\\', '/', $path);
if (isset($this->config['url'])) {
return $this->concatPathToUrl($this->config['url'], $path);
}
return parent::url($path);
}
}

View File

@ -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);
}
}

View File

@ -267,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) {

View File

@ -1,131 +0,0 @@
<?php
namespace think\tests;
use League\Flysystem\Adapter\NullAdapter;
use League\Flysystem\AdapterInterface;
use Mockery as m;
use Mockery\MockInterface;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use PHPUnit\Framework\TestCase;
use think\App;
use think\Cache;
use think\cache\driver\File;
use think\Config;
use think\Container;
use think\Filesystem;
use think\filesystem\Driver;
use think\filesystem\driver\Local;
class FilesystemTest extends TestCase
{
/** @var App|MockInterface */
protected $app;
/** @var Filesystem */
protected $filesystem;
/** @var Config|MockInterface */
protected $config;
/** @var vfsStreamDirectory */
protected $root;
protected function setUp()
{
$this->app = m::mock(App::class)->makePartial();
Container::setInstance($this->app);
$this->app->shouldReceive('make')->with(App::class)->andReturn($this->app);
$this->config = m::mock(Config::class);
$this->config->shouldReceive('get')->with('filesystem.default', null)->andReturn('local');
$this->app->shouldReceive('get')->with('config')->andReturn($this->config);
$this->filesystem = new Filesystem($this->app);
$this->root = vfsStream::setup('rootDir');
}
protected function tearDown(): void
{
m::close();
}
public function testDisk()
{
$this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([
'type' => 'local',
'root' => $this->root->url(),
]);
$this->config->shouldReceive('get')->with('filesystem.disks.foo', null)->andReturn([
'type' => 'local',
'root' => $this->root->url(),
]);
$this->assertInstanceOf(Local::class, $this->filesystem->disk());
$this->assertInstanceOf(Local::class, $this->filesystem->disk('foo'));
}
public function testCache()
{
$this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([
'type' => 'local',
'root' => $this->root->url(),
'cache' => true,
]);
$this->assertInstanceOf(Local::class, $this->filesystem->disk());
$this->config->shouldReceive('get')->with('filesystem.disks.cache', null)->andReturn([
'type' => NullDriver::class,
'root' => $this->root->url(),
'cache' => [
'store' => 'flysystem',
],
]);
$cache = m::mock(Cache::class);
$cacheDriver = m::mock(File::class);
$cache->shouldReceive('store')->once()->with('flysystem')->andReturn($cacheDriver);
$this->app->shouldReceive('make')->with(Cache::class)->andReturn($cache);
$cacheDriver->shouldReceive('get')->with('flysystem')->once()->andReturn(null);
$cacheDriver->shouldReceive('set')->withAnyArgs();
$this->filesystem->disk('cache')->put('test.txt', 'aa');
}
public function testPutFile()
{
$root = vfsStream::setup('rootDir', null, [
'foo.jpg' => 'hello',
]);
$this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([
'type' => NullDriver::class,
'root' => $root->url(),
'cache' => true,
]);
$file = m::mock(\think\File::class);
$file->shouldReceive('hashName')->with(null)->once()->andReturn('foo.jpg');
$file->shouldReceive('getRealPath')->once()->andReturn($root->getChild('foo.jpg')->url());
$this->filesystem->putFile('test', $file);
}
}
class NullDriver extends Driver
{
protected function createAdapter(): AdapterInterface
{
return new NullAdapter();
}
}

View File

@ -21,7 +21,7 @@
}
},
"require": {
"topthink/framework": "^6.0",
"topthink/framework": "^6.0 || ^8.0",
"topthink/think-helper": "^3.0.3"
},
"minimum-stability": "dev",

View File

@ -65,6 +65,7 @@ class AdapterFactory
'pgsql' => 'Phinx\Db\Adapter\PostgresAdapter',
'sqlite' => 'Phinx\Db\Adapter\SQLiteAdapter',
'sqlsrv' => 'Phinx\Db\Adapter\SqlServerAdapter',
'dm' => 'Phinx\Db\Adapter\DmAdapter',
);
/**

File diff suppressed because it is too large Load Diff

View File

@ -174,9 +174,7 @@ class Ev implements EventInterface
*/
public function destroy()
{
foreach ($this->_allEvents as $event) {
$event->stop();
}
\Ev::stop(\Ev::BREAK_ALL);
}
/**

View File

@ -109,7 +109,7 @@ class Uv implements EventInterface
$repeat = $flag === self::EV_TIMER_ONCE ? 0 : (int)($fd * 1000);
$param = array($func, (array)$args, $flag, $fd, self::$_timerId);
$timerWatcher = \uv_timer_init();
\uv_timer_start($timerWatcher, 1, $repeat, function($watcher)use($param){
\uv_timer_start($timerWatcher, ($flag === self::EV_TIMER_ONCE ? (int)($fd * 1000) :1), $repeat, function($watcher)use($param){
call_user_func_array([$this, 'timerCallback'], [$param]);
});
$this->_eventTimer[self::$_timerId] = $timerWatcher;

View File

@ -71,6 +71,13 @@ class Request
*/
protected static $_enableCache = true;
/**
* Is safe.
*
* @var bool
*/
protected $_isSafe = true;
/**
* Request constructor.
@ -208,8 +215,8 @@ class Request
public function host($without_port = false)
{
$host = $this->header('host');
if ($host && $without_port && $pos = \strpos($host, ':')) {
return \substr($host, 0, $pos);
if ($host && $without_port) {
return preg_replace('/:\d{1,5}$/', '', $host);
}
return $host;
}
@ -656,6 +663,16 @@ class Request
return $this->_buffer;
}
/**
* __wakeup.
*
* @return void
*/
public function __wakeup()
{
$this->_isSafe = false;
}
/**
* __destruct.
*
@ -663,7 +680,7 @@ class Request
*/
public function __destruct()
{
if (isset($this->_data['files'])) {
if (isset($this->_data['files']) && $this->_isSafe) {
\clearstatcache();
\array_walk_recursive($this->_data['files'], function($value, $key){
if ($key === 'tmp_name') {

View File

@ -427,7 +427,7 @@ class Response
if (!isset($headers['Transfer-Encoding'])) {
$head .= "Content-Length: $body_len\r\n\r\n";
} else {
return "$head\r\n".dechex($body_len)."\r\n{$this->_body}\r\n";
return $body_len ? "$head\r\n" . dechex($body_len) . "\r\n{$this->_body}\r\n" : "$head\r\n";
}
// The whole http package

View File

@ -134,6 +134,13 @@ class Session
*/
protected $_sessionId = null;
/**
* Is safe.
*
* @var bool
*/
protected $_isSafe = true;
/**
* Session constructor.
*
@ -402,6 +409,16 @@ class Session
static::$_handler->gc(static::$lifetime);
}
/**
* __wakeup.
*
* @return void
*/
public function __wakeup()
{
$this->_isSafe = false;
}
/**
* __destruct.
*
@ -409,6 +426,9 @@ class Session
*/
public function __destruct()
{
if (!$this->_isSafe) {
return;
}
$this->save();
if (\random_int(1, static::$gcProbability[1]) <= static::$gcProbability[0]) {
$this->gc();
@ -422,7 +442,7 @@ class Session
*/
protected static function checkSessionId($session_id)
{
if (!\preg_match('/^[a-zA-Z0-9]+$/', $session_id)) {
if (!\preg_match('/^[a-zA-Z0-9"]+$/', $session_id)) {
throw new SessionException("session_id $session_id is invalid");
}
}

View File

@ -34,7 +34,7 @@ class Worker
*
* @var string
*/
const VERSION = '4.1.10';
const VERSION = '4.1.13';
/**
* Status starting.
@ -782,9 +782,9 @@ class Worker
return;
}
if (static::$_OS !== \OS_TYPE_LINUX) {
static::safeEcho("----------------------- WORKERMAN -----------------------------\r\n");
static::safeEcho("---------------------------------------------- WORKERMAN -----------------------------------------------\r\n");
static::safeEcho('Workerman version:'. static::VERSION. ' PHP version:'. \PHP_VERSION. "\r\n");
static::safeEcho("------------------------ WORKERS -------------------------------\r\n");
static::safeEcho("----------------------------------------------- WORKERS ------------------------------------------------\r\n");
static::safeEcho("worker listen processes status\r\n");
return;
}
@ -1060,8 +1060,11 @@ class Worker
}
$status_str = '';
$current_total_request = array();
$worker_info = \unserialize($info[0]);
\ksort($worker_info, SORT_NUMERIC);
$workerInfo = [];
try {
$workerInfo = unserialize($info[0], ['allowed_classes' => false]);
} catch (Throwable $exception) {}
\ksort($workerInfo, SORT_NUMERIC);
unset($info[0]);
$data_waiting_sort = array();
$read_process_status = false;
@ -1096,7 +1099,7 @@ class Worker
}
}
}
foreach($worker_info as $pid => $info) {
foreach($workerInfo as $pid => $info) {
if (!isset($data_waiting_sort[$pid])) {
$status_str .= "$pid\t" . \str_pad('N/A', 7) . " "
. \str_pad($info['listen'], static::$_maxSocketNameLength) . " "
@ -1472,8 +1475,11 @@ class Worker
\restore_error_handler();
// Add an empty timer to prevent the event-loop from exiting.
Timer::add(1000000, function (){});
// Display UI.
static::safeEcho(\str_pad($worker->name, 21) . \str_pad($worker->getSocketName(), 36) . \str_pad('1', 10) . "[ok]\n");
static::safeEcho(\str_pad($worker->name, 48) . \str_pad($worker->getSocketName(), 36) . \str_pad('1', 10) . " [ok]\n");
$worker->listen();
$worker->run();
static::$globalEvent->loop();