From d9c2abcc3cf1b49caaa1050de5ced37bc748d1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?= <1518079521@qq.com> Date: Wed, 31 May 2023 11:25:43 +0800 Subject: [PATCH] vendor --- niucloud/.env | 2 +- niucloud/vendor/composer/autoload_files.php | 4 +- niucloud/vendor/composer/autoload_psr4.php | 2 +- niucloud/vendor/composer/autoload_static.php | 20 +- niucloud/vendor/composer/installed.json | 78 ++-- niucloud/vendor/composer/installed.php | 20 +- .../vendor/guzzlehttp/promises/CHANGELOG.md | 6 + .../vendor/guzzlehttp/promises/composer.json | 5 - .../vendor/guzzlehttp/promises/src/Each.php | 2 +- .../vendor/guzzlehttp/promises/src/Utils.php | 2 +- niucloud/vendor/services.php | 3 +- .../topthink/think-captcha/src/Captcha.php | 45 +- .../vendor/yunwuxin/think-cron/.gitignore | 3 - niucloud/vendor/yunwuxin/think-cron/README.md | 66 --- .../vendor/yunwuxin/think-cron/composer.json | 42 -- .../vendor/yunwuxin/think-cron/src/config.php | 5 - .../think-cron/src/cron/Scheduler.php | 94 ----- .../yunwuxin/think-cron/src/cron/Service.php | 30 -- .../yunwuxin/think-cron/src/cron/Task.php | 171 -------- .../think-cron/src/cron/command/Run.php | 56 --- .../think-cron/src/cron/command/Schedule.php | 34 -- .../think-cron/src/cron/event/TaskEvent.php | 20 - .../think-cron/src/cron/event/TaskFailed.php | 14 - .../src/cron/event/TaskProcessed.php | 8 - .../think-cron/src/cron/event/TaskSkipped.php | 7 - niucloud/vendor/yzh52521/schedule/.gitignore | 1 + niucloud/vendor/yzh52521/schedule/README.md | 130 ++++++ .../vendor/yzh52521/schedule/composer.json | 24 ++ niucloud/vendor/yzh52521/schedule/src/Run.php | 26 ++ .../schedule/src/console/AbstractField.php | 148 +++++++ .../schedule/src/console/CallbackEvent.php | 104 +++++ .../yzh52521/schedule/src/console/Command.php | 84 ++++ .../schedule/src/console/CronExpression.php | 390 ++++++++++++++++++ .../schedule/src/console/DayOfMonthField.php | 173 ++++++++ .../schedule/src/console/DayOfWeekField.php | 141 +++++++ .../yzh52521/schedule/src/console/Event.php | 123 ++++++ .../schedule/src/console/FieldFactory.php | 58 +++ .../schedule/src/console/FieldInterface.php | 41 ++ .../schedule/src/console/HoursField.php | 71 ++++ .../src/console}/ManagesFrequencies.php | 230 ++++++----- .../schedule/src/console/MinutesField.php | 62 +++ .../schedule/src/console/MonthField.php | 44 ++ .../schedule/src/console/YearField.php | 37 ++ .../schedule/src/exceptions/Exception.php | 8 + .../exceptions/InvalidArgumentException.php | 10 + 45 files changed, 1891 insertions(+), 753 deletions(-) delete mode 100644 niucloud/vendor/yunwuxin/think-cron/.gitignore delete mode 100644 niucloud/vendor/yunwuxin/think-cron/README.md delete mode 100644 niucloud/vendor/yunwuxin/think-cron/composer.json delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/config.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/Service.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/command/Run.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskEvent.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskFailed.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskProcessed.php delete mode 100644 niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskSkipped.php create mode 100644 niucloud/vendor/yzh52521/schedule/.gitignore create mode 100644 niucloud/vendor/yzh52521/schedule/README.md create mode 100644 niucloud/vendor/yzh52521/schedule/composer.json create mode 100644 niucloud/vendor/yzh52521/schedule/src/Run.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/AbstractField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/CallbackEvent.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/Command.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/CronExpression.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/DayOfMonthField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/DayOfWeekField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/Event.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/FieldFactory.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/FieldInterface.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/HoursField.php rename niucloud/vendor/{yunwuxin/think-cron/src/cron => yzh52521/schedule/src/console}/ManagesFrequencies.php (59%) create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/MinutesField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/MonthField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/console/YearField.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/exceptions/Exception.php create mode 100644 niucloud/vendor/yzh52521/schedule/src/exceptions/InvalidArgumentException.php diff --git a/niucloud/.env b/niucloud/.env index 399f7e5f6..2bd64549a 100644 --- a/niucloud/.env +++ b/niucloud/.env @@ -1 +1 @@ -APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/Shanghai AUTH_KEY = [REDIS] REDIS_HOSTNAME = 127.0.0.1 PORT = 6379 REDIS_PASSWORD = SELECT = 0 [LANG] default_lang = zh-cn [SYSTEM] ADMIN_TOKEN_NAME = token API_TOKEN_NAME = token ADMIN_SITE_ID_NAME = site-id API_SITE_ID_NAME = site-id ADMIN_TOKEN_EXPIRE_TIME = 604800 API_TOKEN_EXPIRE_TIME = 86400 LANG_NAME = lang CHANNEL_NAME = channel WAP_DOMAIN = WEB_DOMAIN = \ No newline at end of file +APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/Shanghai AUTH_KEY = [REDIS] REDIS_HOSTNAME = 127.0.0.1 PORT = 6379 REDIS_PASSWORD = SELECT = 0 [LANG] default_lang = zh-cn [SYSTEM] ADMIN_TOKEN_NAME = token API_TOKEN_NAME = token ADMIN_SITE_ID_NAME = site-id API_SITE_ID_NAME = site-id ADMIN_TOKEN_EXPIRE_TIME = 604800 API_TOKEN_EXPIRE_TIME = 86400 LANG_NAME = lang CHANNEL_NAME = channel ADMIN_DOMAIN = WAP_DOMAIN = WEB_DOMAIN = \ No newline at end of file diff --git a/niucloud/vendor/composer/autoload_files.php b/niucloud/vendor/composer/autoload_files.php index cc8b6f2c4..d56d9f7a7 100644 --- a/niucloud/vendor/composer/autoload_files.php +++ b/niucloud/vendor/composer/autoload_files.php @@ -10,9 +10,9 @@ return array( '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', - '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', - 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', + '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', '35fab96057f1bf5e7aba31a8a6d5fdde' => $vendorDir . '/topthink/think-orm/stubs/load_stubs.php', 'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php', '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php', diff --git a/niucloud/vendor/composer/autoload_psr4.php b/niucloud/vendor/composer/autoload_psr4.php index b7663ed79..2ed5d0428 100644 --- a/niucloud/vendor/composer/autoload_psr4.php +++ b/niucloud/vendor/composer/autoload_psr4.php @@ -6,12 +6,12 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( - 'yunwuxin\\cron\\' => array($vendorDir . '/yunwuxin/think-cron/src/cron'), 'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'), 'think\\trace\\' => array($vendorDir . '/topthink/think-trace/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-image/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-queue/src', $vendorDir . '/topthink/think-template/src'), + 'schedule\\' => array($vendorDir . '/yzh52521/schedule/src'), 'dh2y\\qrcode\\' => array($vendorDir . '/dh2y/think-qrcode/src'), 'core\\' => array($baseDir . '/core'), 'clagiordano\\weblibs\\configmanager\\' => array($vendorDir . '/clagiordano/weblibs-configmanager/src'), diff --git a/niucloud/vendor/composer/autoload_static.php b/niucloud/vendor/composer/autoload_static.php index b6eaa7f9f..a7281c5ae 100644 --- a/niucloud/vendor/composer/autoload_static.php +++ b/niucloud/vendor/composer/autoload_static.php @@ -11,9 +11,9 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', - '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', - 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', '35fab96057f1bf5e7aba31a8a6d5fdde' => __DIR__ . '/..' . '/topthink/think-orm/stubs/load_stubs.php', 'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php', '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php', @@ -39,10 +39,6 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e ); public static $prefixLengthsPsr4 = array ( - 'y' => - array ( - 'yunwuxin\\cron\\' => 14, - ), 't' => array ( 'think\\view\\driver\\' => 18, @@ -51,6 +47,10 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e 'think\\app\\' => 10, 'think\\' => 6, ), + 's' => + array ( + 'schedule\\' => 9, + ), 'd' => array ( 'dh2y\\qrcode\\' => 12, @@ -180,10 +180,6 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e ); public static $prefixDirsPsr4 = array ( - 'yunwuxin\\cron\\' => - array ( - 0 => __DIR__ . '/..' . '/yunwuxin/think-cron/src/cron', - ), 'think\\view\\driver\\' => array ( 0 => __DIR__ . '/..' . '/topthink/think-view/src', @@ -209,6 +205,10 @@ class ComposerStaticInitf082efa3600aae2b847c3e8b4e641a4e 4 => __DIR__ . '/..' . '/topthink/think-queue/src', 5 => __DIR__ . '/..' . '/topthink/think-template/src', ), + 'schedule\\' => + array ( + 0 => __DIR__ . '/..' . '/yzh52521/schedule/src', + ), 'dh2y\\qrcode\\' => array ( 0 => __DIR__ . '/..' . '/dh2y/think-qrcode/src', diff --git a/niucloud/vendor/composer/installed.json b/niucloud/vendor/composer/installed.json index b2349d363..749b7202e 100644 --- a/niucloud/vendor/composer/installed.json +++ b/niucloud/vendor/composer/installed.json @@ -944,17 +944,17 @@ }, { "name": "guzzlehttp/promises", - "version": "1.5.2", - "version_normalized": "1.5.2.0", + "version": "1.5.3", + "version_normalized": "1.5.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b94b2807d85443f9719887892882d0329d1e2598" + "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", - "reference": "b94b2807d85443f9719887892882d0329d1e2598", + "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", + "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", "shasum": "", "mirrors": [ { @@ -969,13 +969,8 @@ "require-dev": { "symfony/phpunit-bridge": "^4.4 || ^5.1" }, - "time": "2022-08-28T14:55:35+00:00", + "time": "2023-05-21T12:31:43+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, "installation-source": "dist", "autoload": { "files": [ @@ -1017,7 +1012,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.2" + "source": "https://github.com/guzzle/promises/tree/1.5.3" }, "funding": [ { @@ -5716,18 +5711,18 @@ "install-path": "../yansongda/supports" }, { - "name": "yunwuxin/think-cron", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", + "name": "yzh52521/schedule", + "version": "v1.0.0", + "version_normalized": "1.0.0.0", "source": { "type": "git", - "url": "https://github.com/yunwuxin/think-cron.git", - "reference": "a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca" + "url": "https://github.com/yzh52521/schedule.git", + "reference": "4c8f537f0c08417e785f84b8b91bf16b083cb163" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/yunwuxin/think-cron/zipball/a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca", - "reference": "a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca", + "url": "https://api.github.com/repos/yzh52521/schedule/zipball/4c8f537f0c08417e785f84b8b91bf16b083cb163", + "reference": "4c8f537f0c08417e785f84b8b91bf16b083cb163", "shasum": "", "mirrors": [ { @@ -5737,48 +5732,35 @@ ] }, "require": { - "dragonmantank/cron-expression": "^3.0", - "nesbot/carbon": "^2.28", - "symfony/process": "^4.4|^5.0", - "topthink/framework": "^6.0" + "nesbot/carbon": "^2.0", + "php": ">=7.1" }, - "require-dev": { - "topthink/think-swoole": "^4.0" - }, - "time": "2021-12-22T09:25:54+00:00", + "time": "2020-07-02T01:34:32+00:00", "type": "library", - "extra": { - "think": { - "config": { - "cron": "src/config.php" - }, - "services": [ - "yunwuxin\\cron\\Service" - ] - } - }, "installation-source": "dist", "autoload": { "psr-4": { - "yunwuxin\\cron\\": "src/cron" + "schedule\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "Apache-2.0" + "MIT" ], - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } + "description": "task schedule,schedule,thinkphp schedule,任务调度", + "keywords": [ + "schedule", + "task schedule", + "think-schedule", + "thinkphp", + "thinkphp5.1", + "thinkphp6" ], - "description": "计划任务", "support": { - "issues": "https://github.com/yunwuxin/think-cron/issues", - "source": "https://github.com/yunwuxin/think-cron/tree/v3.0.5" + "issues": "https://github.com/yzh52521/schedule/issues", + "source": "https://github.com/yzh52521/schedule/tree/v1.0.0" }, - "install-path": "../yunwuxin/think-cron" + "install-path": "../yzh52521/schedule" } ], "dev": true, diff --git a/niucloud/vendor/composer/installed.php b/niucloud/vendor/composer/installed.php index 51bd46cee..6afaec7bb 100644 --- a/niucloud/vendor/composer/installed.php +++ b/niucloud/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'topthink/think', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '7939a59b413ebc73af2f7f44540d15df3ad38d1a', + 'reference' => 'dc3bba8859823f8836483423b8b7bfdda3a18e7d', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -128,9 +128,9 @@ 'dev_requirement' => false, ), 'guzzlehttp/promises' => array( - 'pretty_version' => '1.5.2', - 'version' => '1.5.2.0', - 'reference' => 'b94b2807d85443f9719887892882d0329d1e2598', + 'pretty_version' => '1.5.3', + 'version' => '1.5.3.0', + 'reference' => '67ab6e18aaa14d753cc148911d273f6e6cb6721e', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), @@ -652,7 +652,7 @@ 'topthink/think' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '7939a59b413ebc73af2f7f44540d15df3ad38d1a', + 'reference' => 'dc3bba8859823f8836483423b8b7bfdda3a18e7d', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -766,12 +766,12 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'yunwuxin/think-cron' => array( - 'pretty_version' => 'v3.0.5', - 'version' => '3.0.5.0', - 'reference' => 'a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca', + 'yzh52521/schedule' => array( + 'pretty_version' => 'v1.0.0', + 'version' => '1.0.0.0', + 'reference' => '4c8f537f0c08417e785f84b8b91bf16b083cb163', 'type' => 'library', - 'install_path' => __DIR__ . '/../yunwuxin/think-cron', + 'install_path' => __DIR__ . '/../yzh52521/schedule', 'aliases' => array(), 'dev_requirement' => false, ), diff --git a/niucloud/vendor/guzzlehttp/promises/CHANGELOG.md b/niucloud/vendor/guzzlehttp/promises/CHANGELOG.md index 253282eb1..2e1a2f384 100644 --- a/niucloud/vendor/guzzlehttp/promises/CHANGELOG.md +++ b/niucloud/vendor/guzzlehttp/promises/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.5.3 - 2023-05-21 + +### Changed + +- Removed remaining usage of deprecated functions + ## 1.5.2 - 2022-08-07 ### Changed diff --git a/niucloud/vendor/guzzlehttp/promises/composer.json b/niucloud/vendor/guzzlehttp/promises/composer.json index c959fb32b..966e3e3a8 100644 --- a/niucloud/vendor/guzzlehttp/promises/composer.json +++ b/niucloud/vendor/guzzlehttp/promises/composer.json @@ -46,11 +46,6 @@ "test": "vendor/bin/simple-phpunit", "test-ci": "vendor/bin/simple-phpunit --coverage-text" }, - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, "config": { "preferred-install": "dist", "sort-packages": true diff --git a/niucloud/vendor/guzzlehttp/promises/src/Each.php b/niucloud/vendor/guzzlehttp/promises/src/Each.php index 1dda35499..ff8efd734 100644 --- a/niucloud/vendor/guzzlehttp/promises/src/Each.php +++ b/niucloud/vendor/guzzlehttp/promises/src/Each.php @@ -78,7 +78,7 @@ final class Each $concurrency, callable $onFulfilled = null ) { - return each_limit( + return self::ofLimit( $iterable, $concurrency, $onFulfilled, diff --git a/niucloud/vendor/guzzlehttp/promises/src/Utils.php b/niucloud/vendor/guzzlehttp/promises/src/Utils.php index 8647126d8..e37618833 100644 --- a/niucloud/vendor/guzzlehttp/promises/src/Utils.php +++ b/niucloud/vendor/guzzlehttp/promises/src/Utils.php @@ -107,7 +107,7 @@ final class Utils { $results = []; foreach ($promises as $key => $promise) { - $results[$key] = inspect($promise); + $results[$key] = self::inspect($promise); } return $results; diff --git a/niucloud/vendor/services.php b/niucloud/vendor/services.php index 71a4cdecb..5fbbd6aa4 100644 --- a/niucloud/vendor/services.php +++ b/niucloud/vendor/services.php @@ -1,10 +1,9 @@ 'think\\captcha\\CaptchaService', 1 => 'think\\app\\Service', 2 => 'think\\queue\\Service', 3 => 'think\\trace\\Service', - 4 => 'yunwuxin\\cron\\Service', ); \ No newline at end of file diff --git a/niucloud/vendor/topthink/think-captcha/src/Captcha.php b/niucloud/vendor/topthink/think-captcha/src/Captcha.php index 80844dbd5..3de732548 100644 --- a/niucloud/vendor/topthink/think-captcha/src/Captcha.php +++ b/niucloud/vendor/topthink/think-captcha/src/Captcha.php @@ -117,7 +117,7 @@ class Captcha } for ($i = 0; $i < $this->length; $i++) { - $bag .= $characters[random_int(0, count($characters) - 1)]; + $bag .= $characters[rand(0, count($characters) - 1)]; } $key = mb_strtolower($bag, 'UTF-8'); @@ -167,7 +167,7 @@ class Captcha * @param bool $api * @return Response */ - public function create(string $config = null, bool $api = false): Response + public function create(string $config = null, bool $api = false) { $this->configure($config); @@ -178,11 +178,11 @@ class Captcha // 图片高(px) $this->imageH || $this->imageH = $this->fontSize * 2.5; - $this->imageW = (int)$this->imageW; - $this->imageH = (int)$this->imageH; + $this->imageW = intval($this->imageW); + $this->imageH = intval($this->imageH); // 建立一幅 $this->imageW x $this->imageH 的图像 - $this->im = imagecreate($this->imageW, $this->imageH); + $this->im = imagecreate((int) $this->imageW, (int) $this->imageH); // 设置背景 imagecolorallocate($this->im, $this->bg[0], $this->bg[1], $this->bg[2]); @@ -196,7 +196,7 @@ class Captcha $dir = dir($ttfPath); $ttfs = []; while (false !== ($file = $dir->read())) { - if (substr($file, -4) === '.ttf' || substr($file, -4) === '.otf') { + if (substr($file, -4) == '.ttf' || substr($file, -4) == '.otf') { $ttfs[] = $file; } } @@ -228,7 +228,7 @@ class Captcha $y = $this->fontSize + mt_rand(10, 20); $angle = $this->math ? 0 : mt_rand(-40, 40); - imagettftext($this->im, (int)$this->fontSize, $angle, (int)$x, (int)$y, $this->color, $fontttf, $char); + imagettftext($this->im, intval($this->fontSize), intval($this->fontSize), intval($x), intval($y), $this->color, $fontttf, $char); } ob_start(); @@ -237,6 +237,13 @@ class Captcha $content = ob_get_clean(); imagedestroy($this->im); + // api调用 + if ($api) { + return [ + 'code' => implode('', $text), + 'img' => 'data:image/png;base64,' . chunk_split(base64_encode($content)) + ]; + } return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/png'); } @@ -257,30 +264,30 @@ class Captcha $px = $py = 0; // 曲线前部分 - $A = mt_rand(1, (int)($this->imageH / 2)); // 振幅 - $b = mt_rand((int)(-$this->imageH / 4), (int)($this->imageH / 4)); // Y轴方向偏移量 - $f = mt_rand((int)(-$this->imageH / 4), (int)($this->imageH / 4)); // X轴方向偏移量 - $T = mt_rand((int)$this->imageH, (int)$this->imageW * 2); // 周期 + $A = mt_rand(1, $this->imageH / 2); // 振幅 + $b = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // Y轴方向偏移量 + $f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量 + $T = mt_rand($this->imageH, $this->imageW * 2); // 周期 $w = (2 * M_PI) / $T; $px1 = 0; // 曲线横坐标起始位置 - $px2 = mt_rand((int)($this->imageW / 2), (int)($this->imageW * 0.8)); // 曲线横坐标结束位置 + $px2 = mt_rand($this->imageW / 2, $this->imageW * 0.8); // 曲线横坐标结束位置 for ($px = $px1; $px <= $px2; $px = $px + 1) { if (0 != $w) { $py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b $i = (int) ($this->fontSize / 5); while ($i > 0) { - imagesetpixel($this->im, (int)($px + $i), (int)($py + $i), $this->color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出(不用这while循环)性能要好很多 + imagesetpixel($this->im, intval($px + $i), intval($py + $i), $this->color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出(不用这while循环)性能要好很多 $i--; } } } // 曲线后部分 - $A = mt_rand(1, (int)($this->imageH / 2)); // 振幅 - $f = mt_rand((int)(-$this->imageH / 4), (int)($this->imageH / 4)); // X轴方向偏移量 - $T = mt_rand((int)$this->imageH, (int)$this->imageW * 2); // 周期 + $A = mt_rand(1, $this->imageH / 2); // 振幅 + $f = mt_rand(intval(-$this->imageH / 4), intval($this->imageH / 4)); // X轴方向偏移量 + $T = mt_rand($this->imageH, $this->imageW * 2); // 周期 $w = (2 * M_PI) / $T; $b = $py - $A * sin($w * $px + $f) - $this->imageH / 2; $px1 = $px2; @@ -291,7 +298,7 @@ class Captcha $py = $A * sin($w * $px + $f) + $b + $this->imageH / 2; // y = Asin(ωx+φ) + b $i = (int) ($this->fontSize / 5); while ($i > 0) { - imagesetpixel($this->im, (int)($px + $i), (int)($py + $i), $this->color); + imagesetpixel($this->im, intval($px + $i), intval($py + $i), $this->color); $i--; } } @@ -310,7 +317,7 @@ class Captcha $noiseColor = imagecolorallocate($this->im, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225)); for ($j = 0; $j < 5; $j++) { // 绘杂点 - imagestring($this->im, 5, mt_rand(-10, (int)$this->imageW), mt_rand(-10, (int)$this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor); + imagestring($this->im, 5, mt_rand(-10, $this->imageW), mt_rand(-10, $this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor); } } } @@ -337,7 +344,7 @@ class Captcha list($width, $height) = @getimagesize($gb); // Resample $bgImage = @imagecreatefromjpeg($gb); - @imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, (int)$this->imageW, (int)$this->imageH, $width, $height); + @imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height); @imagedestroy($bgImage); } } diff --git a/niucloud/vendor/yunwuxin/think-cron/.gitignore b/niucloud/vendor/yunwuxin/think-cron/.gitignore deleted file mode 100644 index 35ec8a0f0..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea/ -composer.lock -vendor/ \ No newline at end of file diff --git a/niucloud/vendor/yunwuxin/think-cron/README.md b/niucloud/vendor/yunwuxin/think-cron/README.md deleted file mode 100644 index 2da9a1855..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# think-cron 计划任务 - -## 安装方法 -``` -composer require yunwuxin/think-cron -``` - -## 使用方法 - -### 创建任务类 - -``` -daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释 - } - - /** - * 执行任务 - * @return mixed - */ - protected function execute() - { - //...具体的任务执行 - } -} - -``` - -### 配置 -> 配置文件位于 application/extra/cron.php - -``` -return [ - 'tasks' => [ - \app\task\DemoTask::class, //任务的完整类名 - ] -]; -``` - -### 任务监听 - -#### 两种方法: - -> 方法一 (推荐) - -起一个常驻进程,可以配合supervisor使用 -~~~ -php think cron:schedule -~~~ - -> 方法二 - -在系统的计划任务里添加 -~~~ -* * * * * php /path/to/think cron:run >> /dev/null 2>&1 -~~~ diff --git a/niucloud/vendor/yunwuxin/think-cron/composer.json b/niucloud/vendor/yunwuxin/think-cron/composer.json deleted file mode 100644 index 044d966c6..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/composer.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "yunwuxin/think-cron", - "description": "计划任务", - "license": "Apache-2.0", - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "require": { - "topthink/framework": "^6.0", - "symfony/process": "^4.4|^5.0", - "nesbot/carbon": "^2.28", - "dragonmantank/cron-expression": "^3.0" - }, - "autoload": { - "psr-4": { - "yunwuxin\\cron\\": "src/cron" - } - }, - "extra": { - "think": { - "config": { - "cron": "src/config.php" - }, - "services": [ - "yunwuxin\\cron\\Service" - ] - } - }, - "require-dev": { - "topthink/think-swoole": "^4.0" - }, - "config": { - "preferred-install": "dist", - "platform-check": false, - "platform": { - "ext-swoole": "4.6.0" - } - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/config.php b/niucloud/vendor/yunwuxin/think-cron/src/config.php deleted file mode 100644 index e5a24290a..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/config.php +++ /dev/null @@ -1,5 +0,0 @@ - [] -]; \ No newline at end of file diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php deleted file mode 100644 index 9cf74aeec..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php +++ /dev/null @@ -1,94 +0,0 @@ -app = $app; - $this->tasks = $app->config->get('cron.tasks', []); - $this->cache = $app->cache->store($app->config->get('cron.store', null)); - } - - public function run() - { - $this->startedAt = Carbon::now(); - foreach ($this->tasks as $taskClass) { - - if (is_subclass_of($taskClass, Task::class)) { - - /** @var Task $task */ - $task = $this->app->invokeClass($taskClass, [$this->cache]); - if ($task->isDue()) { - - if (!$task->filtersPass()) { - continue; - } - - if ($task->onOneServer) { - $this->runSingleServerTask($task); - } else { - $this->runTask($task); - } - - $this->app->event->trigger(new TaskProcessed($task)); - } - } - } - } - - /** - * @param $task Task - * @return bool - */ - protected function serverShouldRun($task) - { - $key = $task->mutexName() . $this->startedAt->format('Hi'); - if ($this->cache->has($key)) { - return false; - } - $this->cache->set($key, true, 60); - return true; - } - - protected function runSingleServerTask($task) - { - if ($this->serverShouldRun($task)) { - $this->runTask($task); - } else { - $this->app->event->trigger(new TaskSkipped($task)); - } - } - - /** - * @param $task Task - */ - protected function runTask($task) - { - try { - $task->run(); - } catch (Exception $e) { - $this->app->event->trigger(new TaskFailed($task, $e)); - } - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/Service.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/Service.php deleted file mode 100644 index 33e383383..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/Service.php +++ /dev/null @@ -1,30 +0,0 @@ -commands([ - Run::class, - Schedule::class, - ]); - - $this->app->event->listen('swoole.init', function (Manager $manager) { - $manager->addWorker(function () use ($manager) { - Timer::tick(60 * 1000, function () use ($manager) { - $manager->runWithBarrier([$manager, 'runInSandbox'], function (Scheduler $scheduler) { - $scheduler->run(); - }); - }); - }, "cron"); - }); - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php deleted file mode 100644 index 5f491e826..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php +++ /dev/null @@ -1,171 +0,0 @@ -app = $app; - $this->cache = $cache; - $this->configure(); - } - - /** - * 是否到期执行 - * @return bool - */ - public function isDue() - { - $cronExpression = new CronExpression($this->expression); - - return $cronExpression->isDue('now', $this->timezone); - } - - /** - * 配置任务 - */ - protected function configure() - { - } - - /** - * 执行任务 - */ - protected function execute() - { - $this->app->invoke([$this, 'handle'], [], true); - } - - final public function run() - { - if ($this->withoutOverlapping && - !$this->createMutex()) { - return; - } - - register_shutdown_function(function () { - $this->removeMutex(); - }); - - try { - $this->execute(); - } finally { - $this->removeMutex(); - } - } - - /** - * 过滤 - * @return bool - */ - public function filtersPass() - { - foreach ($this->filters as $callback) { - if (!call_user_func($callback)) { - return false; - } - } - - foreach ($this->rejects as $callback) { - if (call_user_func($callback)) { - return false; - } - } - - return true; - } - - /** - * 任务标识 - */ - public function mutexName() - { - return 'task-' . sha1(static::class); - } - - protected function removeMutex() - { - return $this->cache->delete($this->mutexName()); - } - - protected function createMutex() - { - $name = $this->mutexName(); - - return $this->cache->set($name, time(), $this->expiresAt); - } - - protected function existsMutex() - { - if ($this->cache->has($this->mutexName())) { - $mutex = $this->cache->get($this->mutexName()); - return $mutex + $this->expiresAt > time(); - } - return false; - } - - public function when(Closure $callback) - { - $this->filters[] = $callback; - - return $this; - } - - public function skip(Closure $callback) - { - $this->rejects[] = $callback; - - return $this; - } - - public function withoutOverlapping($expiresAt = 1440) - { - $this->withoutOverlapping = true; - - $this->expiresAt = $expiresAt; - - return $this->skip(function () { - return $this->existsMutex(); - }); - } - - public function onOneServer() - { - $this->onOneServer = true; - - return $this; - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Run.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Run.php deleted file mode 100644 index 7b3718b6c..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Run.php +++ /dev/null @@ -1,56 +0,0 @@ -startedAt = Carbon::now(); - $this->setName('cron:run'); - } - - public function handle(Scheduler $scheduler) - { - $this->listenForEvents(); - - $scheduler->run(); - } - - /** - * 注册事件 - */ - protected function listenForEvents() - { - $this->app->event->listen(TaskProcessed::class, function (TaskProcessed $event) { - $this->output->writeln("Task {$event->getName()} run at " . Carbon::now()); - }); - - $this->app->event->listen(TaskSkipped::class, function (TaskSkipped $event) { - $this->output->writeln('Skipping task (has already run on another server): ' . $event->getName()); - }); - - $this->app->event->listen(TaskFailed::class, function (TaskFailed $event) { - $this->output->writeln("Task {$event->getName()} failed at " . Carbon::now()); - - /** @var Handle $handle */ - $handle = $this->app->make(Handle::class); - - $handle->renderForConsole($this->output, $event->exception); - - $handle->report($event->exception); - }); - } - -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php deleted file mode 100644 index edeea6041..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php +++ /dev/null @@ -1,34 +0,0 @@ -setName('cron:schedule'); - } - - protected function execute(Input $input, Output $output) - { - - if ('\\' == DIRECTORY_SEPARATOR) { - $command = 'start /B "' . PHP_BINARY . '" think cron:run'; - } else { - $command = 'nohup "' . PHP_BINARY . '" think cron:run >> /dev/null 2>&1 &'; - } - - $process = Process::fromShellCommandline($command); - - while (true) { - $process->run(); - sleep(60); - } - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskEvent.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskEvent.php deleted file mode 100644 index 33acb322b..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskEvent.php +++ /dev/null @@ -1,20 +0,0 @@ -task = $task; - } - - public function getName() - { - return get_class($this->task); - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskFailed.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskFailed.php deleted file mode 100644 index a56756111..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskFailed.php +++ /dev/null @@ -1,14 +0,0 @@ -exception = $exception; - } -} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskProcessed.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskProcessed.php deleted file mode 100644 index 44b74eac9..000000000 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/event/TaskProcessed.php +++ /dev/null @@ -1,8 +0,0 @@ -setName('schedule:run'); + } + + protected function execute(Input $input, Output $output) + { + //每天的上午十点和晚上八点执行这个命令 + $this->command('test')->twiceDaily(10, 20); + parent::execute($input, $output); + } +} +``` + +继续运行指令 +``` +php think make:command Test test +``` + +第二步,配置config/console.php文件 + +``` + [ + 'schedule:run'=>\app\command\Schedule::class, + 'test' => 'app\command\Test', + ] +]; +``` + +第三步,您应该在crontab中添加以下命令: + +``` +* * * * * php /path/to/think schedule:run >> /dev/null 2>&1 +``` + +时间表范例 +此扩展支持Laravel Schedule的所有功能,环境和维护模式除外。 +Scheduling Closures +``` +$this->call(function() +{ + // Do some task... + +})->hourly(); +``` +Running command of your application +``` +$this->command('migrate')->cron('* * * * *'); +``` +Frequent Jobs +``` +$this->command('foo')->everyFiveMinutes(); + +$this->command('foo')->everyTenMinutes(); + +$this->command('foo')->everyThirtyMinutes(); +``` +Daily Jobs +``` +$this->command('foo')->daily(); +``` +Daily Jobs At A Specific Time (24 Hour Time) + +``` +$this->command('foo')->dailyAt('15:00'); +``` +Twice Daily Jobs +``` +$this->command('foo')->twiceDaily(); +``` +Job That Runs Every Weekday +``` +$this->command('foo')->weekdays(); +``` +Weekly Jobs +``` +$this->command('foo')->weekly(); + +// Schedule weekly job for specific day (0-6) and time... +$this->command('foo')->weeklyOn(1, '8:00'); +``` + +Monthly Jobs +``` +$this->command('foo')->monthly(); +``` +Job That Runs On Specific Days +``` +$this->command('foo')->mondays(); +$this->command('foo')->tuesdays(); +$this->command('foo')->wednesdays(); +$this->command('foo')->thursdays(); +$this->command('foo')->fridays(); +$this->command('foo')->saturdays(); +$this->command('foo')->sundays(); +``` + +Only Allow Job To Run When Callback Is True +``` +$this->command('foo')->monthly()->when(function() +{ + return true; +}); +``` + diff --git a/niucloud/vendor/yzh52521/schedule/composer.json b/niucloud/vendor/yzh52521/schedule/composer.json new file mode 100644 index 000000000..179a3746f --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/composer.json @@ -0,0 +1,24 @@ +{ + "name": "yzh52521/schedule", + "description": "task schedule,schedule,thinkphp schedule,任务调度", + "keywords": [ + "schedule", + "task schedule", + "thinkphp", + "thinkphp6", + "thinkphp5.1", + "think-schedule" + ], + "type": "library", + "license": "MIT", + "minimum-stability": "dev", + "require": { + "php": ">=7.1", + "nesbot/carbon": "^2.0" + }, + "autoload": { + "psr-4": { + "schedule\\": "src/" + } + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/Run.php b/niucloud/vendor/yzh52521/schedule/src/Run.php new file mode 100644 index 000000000..94314b18c --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/Run.php @@ -0,0 +1,26 @@ +setName('schedule:run'); + } + + protected function execute(Input $input, Output $output) + { + //每天的上午十点和晚上八点执行这个命令 + $this->command('test')->twiceDaily(10, 20); + + parent::execute($input, $output); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/AbstractField.php b/niucloud/vendor/yzh52521/schedule/src/console/AbstractField.php new file mode 100644 index 000000000..90faa46b8 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/AbstractField.php @@ -0,0 +1,148 @@ +isIncrementsOfRanges($value)) { + return $this->isInIncrementsOfRanges($dateValue, $value); + } elseif ($this->isRange($value)) { + return $this->isInRange($dateValue, $value); + } + + return $value == '*' || $dateValue == $value; + } + + /** + * Check if a value is a range + * + * @param string $value Value to test + * + * @return bool + */ + public function isRange($value) + { + return strpos($value, '-') !== false; + } + + /** + * Check if a value is an increments of ranges + * + * @param string $value Value to test + * + * @return bool + */ + public function isIncrementsOfRanges($value) + { + return strpos($value, '/') !== false; + } + + /** + * Test if a value is within a range + * + * @param string $dateValue Set date value + * @param string $value Value to test + * + * @return bool + */ + public function isInRange($dateValue, $value) + { + $parts = array_map('trim', explode('-', $value, 2)); + + return $dateValue >= $parts[0] && $dateValue <= $parts[1]; + } + + /** + * Test if a value is within an increments of ranges (offset[-to]/step size) + * + * @param string $dateValue Set date value + * @param string $value Value to test + * + * @return bool + */ + public function isInIncrementsOfRanges($dateValue, $value) + { + $parts = array_map('trim', explode('/', $value, 2)); + $stepSize = isset($parts[1]) ? (int) $parts[1] : 0; + + if ($stepSize === 0) { + return false; + } + + if (($parts[0] == '*' || $parts[0] === '0')) { + return (int) $dateValue % $stepSize == 0; + } + + $range = explode('-', $parts[0], 2); + $offset = $range[0]; + $to = isset($range[1]) ? $range[1] : $dateValue; + // Ensure that the date value is within the range + if ($dateValue < $offset || $dateValue > $to) { + return false; + } + + if ($dateValue > $offset && 0 === $stepSize) { + return false; + } + + for ($i = $offset; $i <= $to; $i+= $stepSize) { + if ($i == $dateValue) { + return true; + } + } + + return false; + } + + /** + * Returns a range of values for the given cron expression + * + * @param string $expression The expression to evaluate + * @param int $max Maximum offset for range + * + * @return array + */ + public function getRangeForExpression($expression, $max) + { + $values = array(); + + if ($this->isRange($expression) || $this->isIncrementsOfRanges($expression)) { + if (!$this->isIncrementsOfRanges($expression)) { + list ($offset, $to) = explode('-', $expression); + $stepSize = 1; + } + else { + $range = array_map('trim', explode('/', $expression, 2)); + $stepSize = isset($range[1]) ? $range[1] : 0; + $range = $range[0]; + $range = explode('-', $range, 2); + $offset = $range[0]; + $to = isset($range[1]) ? $range[1] : $max; + } + $offset = $offset == '*' ? 0 : $offset; + for ($i = $offset; $i <= $to; $i += $stepSize) { + $values[] = $i; + } + sort($values); + } + else { + $values = array($expression); + } + + return $values; + } + +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/CallbackEvent.php b/niucloud/vendor/yzh52521/schedule/src/console/CallbackEvent.php new file mode 100644 index 000000000..ee89c6a0c --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/CallbackEvent.php @@ -0,0 +1,104 @@ +callback = $callback; + + $this->parameters = $parameters; + } + + /** + * Run the given event. + * + * @param \think\Container $container + * @return mixed + * + * @throws \Exception + */ + public function run(Container $container) + { + $this->callBeforeCallbacks($container); + + try { + if(is_object($this->callback)){ + $response = $container->invokeFunction($this->callback, $this->parameters); +// $response = $container->invoke([$this->callback, 'doJob'], $this->parameters); + }else if(is_array($this->callback)){ + $response = $container->invoke([$this->callback[0], $this->callback[1] ?? 'doJob'], $this->parameters); + }else{ + $response = $container->invokeFunction($this->callback, $this->parameters); + } +// $response = is_object($this->callback) +// ? $container->invoke([$this->callback, 'doJob'], $this->parameters) +// : $container->invokeFunction($this->callback, $this->parameters); + + +// $container->make($this->callback)->invokeFunction('doJob', $this->parameters); +// $response = $container->invokeFunction($this->callback, $this->parameters); + } finally { + parent::callAfterCallbacks($container); + } + + return $response; + } + public function isCallable($var, $syntaxOnly = false) + { + if(is_array($var)){ + return true; + } + if (! is_array($var)) { + return is_callable($var, $syntaxOnly); + } + + if ((! isset($var[0]) || ! isset($var[1])) || + ! is_string($var[1] ?? null)) { + return false; + } + + if ($syntaxOnly && + (is_string($var[0]) || is_object($var[0])) && + is_string($var[1])) { + return true; + } + + $class = is_object($var[0]) ? get_class($var[0]) : $var[0]; + + $method = $var[1]; + + if (! class_exists($class)) { + return false; + } + + if (method_exists($class, $method)) { + return (new \ReflectionMethod($class, $method))->isPublic(); + } + + if (is_object($var[0]) && method_exists($class, '__call')) { + return (new \ReflectionMethod($class, '__call'))->isPublic(); + } + + if (! is_object($var[0]) && method_exists($class, '__callStatic')) { + return (new \ReflectionMethod($class, '__callStatic'))->isPublic(); + } + + return false; + } + +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/Command.php b/niucloud/vendor/yzh52521/schedule/src/console/Command.php new file mode 100644 index 000000000..7160932ed --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/Command.php @@ -0,0 +1,84 @@ +app = Container::getInstance(); + } + + public function call($callback, array $parameters = []) + { + $this->events[] = $event = new CallbackEvent( + $callback, $parameters + ); + + return $event; + } + + public function command($command, array $parameters = []) + { + $this->events[] = $event = new Event( + $command, $parameters + ); + + return $event; + } + + public function job($job, $data, $queue = null) + { + return $this->call(function ($data) use ($job, $queue) { + Queue::push($job, $data, $queue); + }, [ $data ]); + } + + /* + $this->command('article:pushed')->dailyAt("21:00"); + + /*$this->call(function () use ($input, $output){ + echo '-------------'; + echo 11; + })->twiceDaily(9, 20); + */ + protected function execute(Input $input, Output $output) + { + $eventsRan = false; + + foreach ($this->dueEvents($this->events) as $event) { + //foreach ($this->events as $event) { + if (! $event->filtersPass($this->app)) { + continue; + } + $event->run($this->app); + + $eventsRan = true; + } + + if (! $eventsRan) { + $output->writeln('No scheduled commands are ready to run.'); + } + } + + public function dueEvents($app) + { + return collect($this->events)->filter(function($event) use ($app){ + return $event->isDue($app); + }); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/CronExpression.php b/niucloud/vendor/yzh52521/schedule/src/console/CronExpression.php new file mode 100644 index 000000000..c80657812 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/CronExpression.php @@ -0,0 +1,390 @@ + '0 0 1 1 *', + '@annually' => '0 0 1 1 *', + '@monthly' => '0 0 1 * *', + '@weekly' => '0 0 * * 0', + '@daily' => '0 0 * * *', + '@hourly' => '0 * * * *' + ); + + if (isset($mappings[$expression])) { + $expression = $mappings[$expression]; + } + + return new static($expression, $fieldFactory ?: new FieldFactory()); + } + + /** + * Validate a CronExpression. + * + * @param string $expression The CRON expression to validate. + * + * @return bool True if a valid CRON expression was passed. False if not. + * @see \Cron\CronExpression::factory + */ + public static function isValidExpression($expression) + { + try { + self::factory($expression); + } catch (InvalidArgumentException $e) { + return false; + } + + return true; + } + + /** + * Parse a CRON expression + * + * @param string $expression CRON expression (e.g. '8 * * * *') + * @param FieldFactory $fieldFactory Factory to create cron fields + */ + public function __construct($expression, FieldFactory $fieldFactory) + { + $this->fieldFactory = $fieldFactory; + $this->setExpression($expression); + } + + /** + * Set or change the CRON expression + * + * @param string $value CRON expression (e.g. 8 * * * *) + * + * @return CronExpression + * @throws \InvalidArgumentException if not a valid CRON expression + */ + public function setExpression($value) + { + $this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY); + if (count($this->cronParts) < 5) { + throw new InvalidArgumentException( + $value . ' is not a valid CRON expression' + ); + } + + foreach ($this->cronParts as $position => $part) { + $this->setPart($position, $part); + } + + return $this; + } + + /** + * Set part of the CRON expression + * + * @param int $position The position of the CRON expression to set + * @param string $value The value to set + * + * @return CronExpression + * @throws \InvalidArgumentException if the value is not valid for the part + */ + public function setPart($position, $value) + { + if (!$this->fieldFactory->getField($position)->validate($value)) { + throw new InvalidArgumentException( + 'Invalid CRON field value ' . $value . ' at position ' . $position + ); + } + + $this->cronParts[$position] = $value; + + return $this; + } + + /** + * Set max iteration count for searching next run dates + * + * @param int $maxIterationCount Max iteration count when searching for next run date + * + * @return CronExpression + */ + public function setMaxIterationCount($maxIterationCount) + { + $this->maxIterationCount = $maxIterationCount; + + return $this; + } + + /** + * Get a next run date relative to the current date or a specific date + * + * @param string|\DateTime $currentTime Relative calculation date + * @param int $nth Number of matches to skip before returning a + * matching next run date. 0, the default, will return the current + * date and time if the next run date falls on the current date and + * time. Setting this value to 1 will skip the first match and go to + * the second match. Setting this value to 2 will skip the first 2 + * matches and so on. + * @param bool $allowCurrentDate Set to TRUE to return the current date if + * it matches the cron expression. + * + * @return \DateTime + * @throws \RuntimeException on too many iterations + */ + public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) + { + return $this->getRunDate($currentTime, $nth, false, $allowCurrentDate); + } + + /** + * Get a previous run date relative to the current date or a specific date + * + * @param string|\DateTime $currentTime Relative calculation date + * @param int $nth Number of matches to skip before returning + * @param bool $allowCurrentDate Set to TRUE to return the + * current date if it matches the cron expression + * + * @return \DateTime + * @throws \RuntimeException on too many iterations + * @see \Cron\CronExpression::getNextRunDate + */ + public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) + { + return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); + } + + /** + * Get multiple run dates starting at the current date or a specific date + * + * @param int $total Set the total number of dates to calculate + * @param string|\DateTime $currentTime Relative calculation date + * @param bool $invert Set to TRUE to retrieve previous dates + * @param bool $allowCurrentDate Set to TRUE to return the + * current date if it matches the cron expression + * + * @return array Returns an array of run dates + */ + public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false) + { + $matches = array(); + for ($i = 0; $i < max(0, $total); $i++) { + try { + $matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate); + } catch (RuntimeException $e) { + break; + } + } + + return $matches; + } + + /** + * Get all or part of the CRON expression + * + * @param string $part Specify the part to retrieve or NULL to get the full + * cron schedule string. + * + * @return string|null Returns the CRON expression, a part of the + * CRON expression, or NULL if the part was specified but not found + */ + public function getExpression($part = null) + { + if (null === $part) { + return implode(' ', $this->cronParts); + } elseif (array_key_exists($part, $this->cronParts)) { + return $this->cronParts[$part]; + } + + return null; + } + + /** + * Helper method to output the full expression. + * + * @return string Full CRON expression + */ + public function __toString() + { + return $this->getExpression(); + } + + /** + * Determine if the cron is due to run based on the current date or a + * specific date. This method assumes that the current number of + * seconds are irrelevant, and should be called once per minute. + * + * @param string|\DateTime $currentTime Relative calculation date + * + * @return bool Returns TRUE if the cron is due to run or FALSE if not + */ + public function isDue($currentTime = 'now') + { + if ('now' === $currentTime) { + $currentDate = date('Y-m-d H:i'); + $currentTime = strtotime($currentDate); + } elseif ($currentTime instanceof DateTime) { + $currentDate = clone $currentTime; + // Ensure time in 'current' timezone is used + $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); + $currentDate = $currentDate->format('Y-m-d H:i'); + $currentTime = strtotime($currentDate); + } elseif ($currentTime instanceof DateTimeImmutable) { + $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); + $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); + $currentDate = $currentDate->format('Y-m-d H:i'); + $currentTime = strtotime($currentDate); + } else { + $currentTime = new DateTime($currentTime); + $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0); + $currentDate = $currentTime->format('Y-m-d H:i'); + $currentTime = $currentTime->getTimeStamp(); + } + + try { + return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime; + } catch (Exception $e) { + return false; + } + } + + /** + * Get the next or previous run date of the expression relative to a date + * + * @param string|\DateTime $currentTime Relative calculation date + * @param int $nth Number of matches to skip before returning + * @param bool $invert Set to TRUE to go backwards in time + * @param bool $allowCurrentDate Set to TRUE to return the + * current date if it matches the cron expression + * + * @return \DateTime + * @throws \RuntimeException on too many iterations + */ + protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) + { + if ($currentTime instanceof DateTime) { + $currentDate = clone $currentTime; + } elseif ($currentTime instanceof DateTimeImmutable) { + $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); + $currentDate->setTimezone($currentTime->getTimezone()); + } else { + $currentDate = new DateTime($currentTime ?: 'now'); + $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); + } + + $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); + $nextRun = clone $currentDate; + $nth = (int) $nth; + + // We don't have to satisfy * or null fields + $parts = array(); + $fields = array(); + foreach (self::$order as $position) { + $part = $this->getExpression($position); + if (null === $part || '*' === $part) { + continue; + } + $parts[$position] = $part; + $fields[$position] = $this->fieldFactory->getField($position); + } + + // Set a hard limit to bail on an impossible date + for ($i = 0; $i < $this->maxIterationCount; $i++) { + + foreach ($parts as $position => $part) { + $satisfied = false; + // Get the field object used to validate this part + $field = $fields[$position]; + // Check if this is singular or a list + if (strpos($part, ',') === false) { + $satisfied = $field->isSatisfiedBy($nextRun, $part); + } else { + foreach (array_map('trim', explode(',', $part)) as $listPart) { + if ($field->isSatisfiedBy($nextRun, $listPart)) { + $satisfied = true; + break; + } + } + } + + // If the field is not satisfied, then start over + if (!$satisfied) { + $field->increment($nextRun, $invert, $part); + continue 2; + } + } + + // Skip this match if needed + if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { + $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null); + continue; + } + + return $nextRun; + } + + // @codeCoverageIgnoreStart + throw new RuntimeException('Impossible CRON expression'); + // @codeCoverageIgnoreEnd + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/DayOfMonthField.php b/niucloud/vendor/yzh52521/schedule/src/console/DayOfMonthField.php new file mode 100644 index 000000000..6d17c97af --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/DayOfMonthField.php @@ -0,0 +1,173 @@ + + */ +class DayOfMonthField extends AbstractField +{ + /** + * Get the nearest day of the week for a given day in a month + * + * @param int $currentYear Current year + * @param int $currentMonth Current month + * @param int $targetDay Target day of the month + * + * @return \DateTime Returns the nearest date + */ + private static function getNearestWeekday($currentYear, $currentMonth, $targetDay) + { + $tday = str_pad($targetDay, 2, '0', STR_PAD_LEFT); + $target = DateTime::createFromFormat('Y-m-d', "$currentYear-$currentMonth-$tday"); + $currentWeekday = (int) $target->format('N'); + + if ($currentWeekday < 6) { + return $target; + } + + $lastDayOfMonth = $target->format('t'); + + foreach (array(-1, 1, -2, 2) as $i) { + $adjusted = $targetDay + $i; + if ($adjusted > 0 && $adjusted <= $lastDayOfMonth) { + $target->setDate($currentYear, $currentMonth, $adjusted); + if ($target->format('N') < 6 && $target->format('m') == $currentMonth) { + return $target; + } + } + } + } + + public function isSatisfiedBy(DateTime $date, $value) + { + // ? states that the field value is to be skipped + if ($value == '?') { + return true; + } + + $fieldValue = $date->format('d'); + + // Check to see if this is the last day of the month + if ($value == 'L') { + return $fieldValue == $date->format('t'); + } + + // Check to see if this is the nearest weekday to a particular value + if (strpos($value, 'W')) { + // Parse the target day + $targetDay = substr($value, 0, strpos($value, 'W')); + // Find out if the current day is the nearest day of the week + return $date->format('j') == self::getNearestWeekday( + $date->format('Y'), + $date->format('m'), + $targetDay + )->format('j'); + } + + return $this->isSatisfied($date->format('d'), $value); + } + + public function increment(DateTime $date, $invert = false) + { + if ($invert) { + $date->modify('previous day'); + $date->setTime(23, 59); + } else { + $date->modify('next day'); + $date->setTime(0, 0); + } + + return $this; + } + + /** + * Validates that the value is valid for the Day of the Month field + * Days of the month can contain values of 1-31, *, L, or ? by default. This can be augmented with lists via a ',', + * ranges via a '-', or with a '[0-9]W' to specify the closest weekday. + * + * @param string $value + * @return bool + */ + public function validate($value) + { + // Allow wildcards and a single L + if ($value === '?' || $value === '*' || $value === 'L') { + return true; + } + + // If you only contain numbers and are within 1-31 + if ((bool) preg_match('/^\d{1,2}$/', $value) && ($value >= 1 && $value <= 31)) { + return true; + } + + // If you have a -, we will deal with each of your chunks + if ((bool) preg_match('/-/', $value)) { + // We cannot have a range within a list or vice versa + if ((bool) preg_match('/,/', $value)) { + return false; + } + + $chunks = explode('-', $value); + foreach ($chunks as $chunk) { + if (!$this->validate($chunk)) { + return false; + } + } + + return true; + } + + // If you have a comma, we will deal with each value + if ((bool) preg_match('/,/', $value)) { + // We cannot have a range within a list or vice versa + if ((bool) preg_match('/-/', $value)) { + return false; + } + + $chunks = explode(',', $value); + foreach ($chunks as $chunk) { + if (!$this->validate($chunk)) { + return false; + } + } + + return true; + } + + // If you contain a /, we'll deal with it + if ((bool) preg_match('/\//', $value)) { + $chunks = explode('/', $value); + foreach ($chunks as $chunk) { + if (!$this->validate($chunk)) { + return false; + } + } + return true; + } + + // If you end in W, make sure that it has a numeric in front of it + if ((bool) preg_match('/^\d{1,2}W$/', $value)) { + return true; + } + + return false; + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/DayOfWeekField.php b/niucloud/vendor/yzh52521/schedule/src/console/DayOfWeekField.php new file mode 100644 index 000000000..721243d4d --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/DayOfWeekField.php @@ -0,0 +1,141 @@ +convertLiterals($value); + + $currentYear = $date->format('Y'); + $currentMonth = $date->format('m'); + $lastDayOfMonth = $date->format('t'); + + // Find out if this is the last specific weekday of the month + if (strpos($value, 'L')) { + $weekday = str_replace('7', '0', substr($value, 0, strpos($value, 'L'))); + $tdate = clone $date; + $tdate->setDate($currentYear, $currentMonth, $lastDayOfMonth); + while ($tdate->format('w') != $weekday) { + $tdateClone = new DateTime(); + $tdate = $tdateClone + ->setTimezone($tdate->getTimezone()) + ->setDate($currentYear, $currentMonth, --$lastDayOfMonth); + } + + return $date->format('j') == $lastDayOfMonth; + } + + // Handle # hash tokens + if (strpos($value, '#')) { + list($weekday, $nth) = explode('#', $value); + + // 0 and 7 are both Sunday, however 7 matches date('N') format ISO-8601 + if ($weekday === '0') { + $weekday = 7; + } + + // Validate the hash fields + if ($weekday < 0 || $weekday > 7) { + throw new InvalidArgumentException("Weekday must be a value between 0 and 7. {$weekday} given"); + } + if ($nth > 5) { + throw new InvalidArgumentException('There are never more than 5 of a given weekday in a month'); + } + // The current weekday must match the targeted weekday to proceed + if ($date->format('N') != $weekday) { + return false; + } + + $tdate = clone $date; + $tdate->setDate($currentYear, $currentMonth, 1); + $dayCount = 0; + $currentDay = 1; + while ($currentDay < $lastDayOfMonth + 1) { + if ($tdate->format('N') == $weekday) { + if (++$dayCount >= $nth) { + break; + } + } + $tdate->setDate($currentYear, $currentMonth, ++$currentDay); + } + + return $date->format('j') == $currentDay; + } + + // Handle day of the week values + if (strpos($value, '-')) { + $parts = explode('-', $value); + if ($parts[0] == '7') { + $parts[0] = '0'; + } elseif ($parts[1] == '0') { + $parts[1] = '7'; + } + $value = implode('-', $parts); + } + + // Test to see which Sunday to use -- 0 == 7 == Sunday + $format = in_array(7, str_split($value)) ? 'N' : 'w'; + $fieldValue = $date->format($format); + + return $this->isSatisfied($fieldValue, $value); + } + + public function increment(DateTime $date, $invert = false) + { + if ($invert) { + $date->modify('-1 day'); + $date->setTime(23, 59, 0); + } else { + $date->modify('+1 day'); + $date->setTime(0, 0, 0); + } + + return $this; + } + + public function validate($value) + { + $value = $this->convertLiterals($value); + + foreach (explode(',', $value) as $expr) { + if (!preg_match('/^(\*|[0-7](L?|#[1-5]))([\/\,\-][0-7]+)*$/', $expr)) { + return false; + } + } + + return true; + } + + private function convertLiterals($string) + { + return str_ireplace( + array('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'), + range(0, 6), + $string + ); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/Event.php b/niucloud/vendor/yzh52521/schedule/src/console/Event.php new file mode 100644 index 000000000..5471e1176 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/Event.php @@ -0,0 +1,123 @@ +command = $command; + + $this->parameters = $parameters; + } + + public function run(Container $container) + { + $this->callBeforeCallbacks($container); + + if (strpos(\think\App::VERSION, '6.0') !== false) { + \think\facade\Console::call($this->command, $this->parameters, 'console'); + }else{ + \think\Console::call($this->command, $this->parameters, 'console'); + } + + + $this->callAfterCallbacks($container); + } + + public function filtersPass($app) + { + foreach ($this->filters as $callback) { + if (! $app->call($callback)) { + return false; + } + } + + return true; + } + + public function isDue($app) + { + return $this->expressionPasses(); + } + + public function expressionPasses() + { + $date = Carbon::now(); + + if ($this->timezone) { + $date->setTimezone($this->timezone); + } + + return CronExpression::factory($this->expression)->isDue($date->toDateTimeString()); + } + + public function when($callback) + { + $this->filters[] = is_callable($callback) ? $callback : function () use ($callback) { + return $callback; + }; + + return $this; + } + + public function before(Closure $callback) + { + $this->beforeCallbacks[] = $callback; + + return $this; + } + + + public function after(Closure $callback) + { + return $this->then($callback); + } + + public function then(Closure $callback) + { + $this->afterCallbacks[] = $callback; + + return $this; + } + + public function callBeforeCallbacks(Container $container) + { + foreach ($this->beforeCallbacks as $callback) { + $container->invokeFunction($callback); + } + } + + public function callAfterCallbacks(Container $container) + { + foreach ($this->afterCallbacks as $callback) { + $container->invokeFunction($callback); + } + } + + public function timezone($timezone) + { + $this->timezone = $timezone; + + return $this; + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/FieldFactory.php b/niucloud/vendor/yzh52521/schedule/src/console/FieldFactory.php new file mode 100644 index 000000000..7fd855be9 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/FieldFactory.php @@ -0,0 +1,58 @@ +fields[$position])) { + switch ($position) { + case 0: + $this->fields[$position] = new MinutesField(); + break; + case 1: + $this->fields[$position] = new HoursField(); + break; + case 2: + $this->fields[$position] = new DayOfMonthField(); + break; + case 3: + $this->fields[$position] = new MonthField(); + break; + case 4: + $this->fields[$position] = new DayOfWeekField(); + break; + case 5: + $this->fields[$position] = new YearField(); + break; + default: + throw new InvalidArgumentException( + $position . ' is not a valid position' + ); + } + } + + return $this->fields[$position]; + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/FieldInterface.php b/niucloud/vendor/yzh52521/schedule/src/console/FieldInterface.php new file mode 100644 index 000000000..942fc501b --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/FieldInterface.php @@ -0,0 +1,41 @@ +isSatisfied($date->format('H'), $value); + } + + public function increment(DateTime $date, $invert = false, $parts = null) + { + // Change timezone to UTC temporarily. This will + // allow us to go back or forwards and hour even + // if DST will be changed between the hours. + if (is_null($parts) || $parts == '*') { + $timezone = $date->getTimezone(); + $date->setTimezone(new DateTimeZone('UTC')); + if ($invert) { + $date->modify('-1 hour'); + } else { + $date->modify('+1 hour'); + } + $date->setTimezone($timezone); + + $date->setTime($date->format('H'), $invert ? 59 : 0); + return $this; + } + + $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts); + $hours = array(); + foreach ($parts as $part) { + $hours = array_merge($hours, $this->getRangeForExpression($part, 23)); + } + + $current_hour = $date->format('H'); + $position = $invert ? count($hours) - 1 : 0; + if (count($hours) > 1) { + for ($i = 0; $i < count($hours) - 1; $i++) { + if ((!$invert && $current_hour >= $hours[$i] && $current_hour < $hours[$i + 1]) || + ($invert && $current_hour > $hours[$i] && $current_hour <= $hours[$i + 1])) { + $position = $invert ? $i : $i + 1; + break; + } + } + } + + $hour = $hours[$position]; + if ((!$invert && $date->format('H') >= $hour) || ($invert && $date->format('H') <= $hour)) { + $date->modify(($invert ? '-' : '+') . '1 day'); + $date->setTime($invert ? 23 : 0, $invert ? 59 : 0); + } + else { + $date->setTime($hour, $invert ? 59 : 0); + } + + return $this; + } + + public function validate($value) + { + return (bool) preg_match('/^[\*,\/\-0-9]+$/', $value); + } +} diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/ManagesFrequencies.php b/niucloud/vendor/yzh52521/schedule/src/console/ManagesFrequencies.php similarity index 59% rename from niucloud/vendor/yunwuxin/think-cron/src/cron/ManagesFrequencies.php rename to niucloud/vendor/yzh52521/schedule/src/console/ManagesFrequencies.php index 1b78ebae9..4af43a2a3 100644 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/ManagesFrequencies.php +++ b/niucloud/vendor/yzh52521/schedule/src/console/ManagesFrequencies.php @@ -1,18 +1,18 @@ expression = $expression; @@ -20,10 +20,10 @@ trait ManagesFrequencies } /** - * 设置区间时间 + * Schedule the event to run between start and end time. * - * @param string $startTime - * @param string $endTime + * @param string $startTime + * @param string $endTime * @return $this */ public function between($startTime, $endTime) @@ -32,10 +32,10 @@ trait ManagesFrequencies } /** - * 排除区间时间 + * Schedule the event to not run between start and end time. * - * @param string $startTime - * @param string $endTime + * @param string $startTime + * @param string $endTime * @return $this */ public function unlessBetween($startTime, $endTime) @@ -43,6 +43,13 @@ trait ManagesFrequencies return $this->skip($this->inTimeInterval($startTime, $endTime)); } + /** + * Schedule the event to run between start and end time. + * + * @param string $startTime + * @param string $endTime + * @return \Closure + */ private function inTimeInterval($startTime, $endTime) { return function () use ($startTime, $endTime) { @@ -55,7 +62,57 @@ trait ManagesFrequencies } /** - * 按小时执行 + * Schedule the event to run every minute. + * + * @return $this + */ + public function everyMinute() + { + return $this->spliceIntoPosition(1, '*'); + } + + /** + * Schedule the event to run every five minutes. + * + * @return $this + */ + public function everyFiveMinutes() + { + return $this->spliceIntoPosition(1, '*/5'); + } + + /** + * Schedule the event to run every ten minutes. + * + * @return $this + */ + public function everyTenMinutes() + { + return $this->spliceIntoPosition(1, '*/10'); + } + + /** + * Schedule the event to run every fifteen minutes. + * + * @return $this + */ + public function everyFifteenMinutes() + { + return $this->spliceIntoPosition(1, '*/15'); + } + + /** + * Schedule the event to run every thirty minutes. + * + * @return $this + */ + public function everyThirtyMinutes() + { + return $this->spliceIntoPosition(1, '0,30'); + } + + /** + * Schedule the event to run hourly. * * @return $this */ @@ -65,9 +122,9 @@ trait ManagesFrequencies } /** - * 按小时延期执行 + * Schedule the event to run hourly at a given offset in the hour. * - * @param int $offset + * @param int $offset * @return $this */ public function hourlyAt($offset) @@ -76,20 +133,20 @@ trait ManagesFrequencies } /** - * 按天执行 + * Schedule the event to run daily. * * @return $this */ public function daily() { return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, 0); + ->spliceIntoPosition(2, 0); } /** - * 指定时间执行 + * Schedule the command at a given time. * - * @param string $time + * @param string $time * @return $this */ public function at($time) @@ -98,9 +155,9 @@ trait ManagesFrequencies } /** - * 指定时间执行 + * Schedule the event to run daily at a given time (10:00, 19:30, etc). * - * @param string $time + * @param string $time * @return $this */ public function dailyAt($time) @@ -108,26 +165,26 @@ trait ManagesFrequencies $segments = explode(':', $time); return $this->spliceIntoPosition(2, (int) $segments[0]) - ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0'); + ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0'); } /** - * 每天执行两次 + * Schedule the event to run twice daily. * - * @param int $first - * @param int $second + * @param int $first + * @param int $second * @return $this */ public function twiceDaily($first = 1, $second = 13) { - $hours = $first . ',' . $second; + $hours = $first.','.$second; return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, $hours); + ->spliceIntoPosition(2, $hours); } /** - * 工作日执行 + * Schedule the event to run only on weekdays. * * @return $this */ @@ -137,7 +194,7 @@ trait ManagesFrequencies } /** - * 周末执行 + * Schedule the event to run only on weekends. * * @return $this */ @@ -147,7 +204,7 @@ trait ManagesFrequencies } /** - * 星期一执行 + * Schedule the event to run only on Mondays. * * @return $this */ @@ -157,7 +214,7 @@ trait ManagesFrequencies } /** - * 星期二执行 + * Schedule the event to run only on Tuesdays. * * @return $this */ @@ -167,7 +224,7 @@ trait ManagesFrequencies } /** - * 星期三执行 + * Schedule the event to run only on Wednesdays. * * @return $this */ @@ -177,7 +234,7 @@ trait ManagesFrequencies } /** - * 星期四执行 + * Schedule the event to run only on Thursdays. * * @return $this */ @@ -187,7 +244,7 @@ trait ManagesFrequencies } /** - * 星期五执行 + * Schedule the event to run only on Fridays. * * @return $this */ @@ -197,7 +254,7 @@ trait ManagesFrequencies } /** - * 星期六执行 + * Schedule the event to run only on Saturdays. * * @return $this */ @@ -207,7 +264,7 @@ trait ManagesFrequencies } /** - * 星期天执行 + * Schedule the event to run only on Sundays. * * @return $this */ @@ -217,22 +274,22 @@ trait ManagesFrequencies } /** - * 按周执行 + * Schedule the event to run weekly. * * @return $this */ public function weekly() { return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, 0) - ->spliceIntoPosition(5, 0); + ->spliceIntoPosition(2, 0) + ->spliceIntoPosition(5, 0); } /** - * 指定每周的时间执行 + * Schedule the event to run weekly on a given day and time. * - * @param int $day - * @param string $time + * @param int $day + * @param string $time * @return $this */ public function weeklyOn($day, $time = '0:0') @@ -243,22 +300,22 @@ trait ManagesFrequencies } /** - * 按月执行 + * Schedule the event to run monthly. * * @return $this */ public function monthly() { return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, 0) - ->spliceIntoPosition(3, 1); + ->spliceIntoPosition(2, 0) + ->spliceIntoPosition(3, 1); } /** - * 指定每月的执行时间 + * Schedule the event to run monthly on a given day and time. * - * @param int $day - * @param string $time + * @param int $day + * @param string $time * @return $this */ public function monthlyOn($day = 1, $time = '0:0') @@ -269,15 +326,15 @@ trait ManagesFrequencies } /** - * 每月执行两次 + * Schedule the event to run twice monthly. * - * @param int $first - * @param int $second + * @param int $first + * @param int $second * @return $this */ public function twiceMonthly($first = 1, $second = 16) { - $days = $first . ',' . $second; + $days = $first.','.$second; return $this->spliceIntoPosition(1, 0) ->spliceIntoPosition(2, 0) @@ -285,75 +342,35 @@ trait ManagesFrequencies } /** - * 按季度执行 + * Schedule the event to run quarterly. * * @return $this */ public function quarterly() { return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, 0) - ->spliceIntoPosition(3, 1) - ->spliceIntoPosition(4, '*/3'); + ->spliceIntoPosition(2, 0) + ->spliceIntoPosition(3, 1) + ->spliceIntoPosition(4, '1-12/3'); } /** - * 按年执行 + * Schedule the event to run yearly. * * @return $this */ public function yearly() { return $this->spliceIntoPosition(1, 0) - ->spliceIntoPosition(2, 0) - ->spliceIntoPosition(3, 1) - ->spliceIntoPosition(4, 1); + ->spliceIntoPosition(2, 0) + ->spliceIntoPosition(3, 1) + ->spliceIntoPosition(4, 1); } /** - * 每分钟执行 + * Set the days of the week the command should run on. * - * @return $this - */ - public function everyMinute() - { - return $this->spliceIntoPosition(1, '*'); - } - - /** - * 每5分钟执行 - * - * @return $this - */ - public function everyFiveMinutes() - { - return $this->spliceIntoPosition(1, '*/5'); - } - - /** - * 每10分钟执行 - * - * @return $this - */ - public function everyTenMinutes() - { - return $this->spliceIntoPosition(1, '*/10'); - } - - /** - * 每30分钟执行 - * - * @return $this - */ - public function everyThirtyMinutes() - { - return $this->spliceIntoPosition(1, '0,30'); - } - - /** - * 按周设置天执行 - * - * @param array|mixed $days + * @param array|mixed $days * @return $this */ public function days($days) @@ -364,9 +381,9 @@ trait ManagesFrequencies } /** - * 设置时区 + * Set the timezone the date should be evaluated on. * - * @param string $timezone + * @param \DateTimeZone|string $timezone * @return $this */ public function timezone($timezone) @@ -376,12 +393,19 @@ trait ManagesFrequencies return $this; } + /** + * Splice the given value into the given position of the expression. + * + * @param int $position + * @param string $value + * @return $this + */ protected function spliceIntoPosition($position, $value) { $segments = explode(' ', $this->expression); $segments[$position - 1] = $value; - return $this->expression(implode(' ', $segments)); + return $this->cron(implode(' ', $segments)); } } diff --git a/niucloud/vendor/yzh52521/schedule/src/console/MinutesField.php b/niucloud/vendor/yzh52521/schedule/src/console/MinutesField.php new file mode 100644 index 000000000..0827bc996 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/MinutesField.php @@ -0,0 +1,62 @@ +isSatisfied($date->format('i'), $value); + } + + public function increment(DateTime $date, $invert = false, $parts = null) + { + if (is_null($parts)) { + if ($invert) { + $date->modify('-1 minute'); + } else { + $date->modify('+1 minute'); + } + return $this; + } + + $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts); + $minutes = array(); + foreach ($parts as $part) { + $minutes = array_merge($minutes, $this->getRangeForExpression($part, 59)); + } + + $current_minute = $date->format('i'); + $position = $invert ? count($minutes) - 1 : 0; + if (count($minutes) > 1) { + for ($i = 0; $i < count($minutes) - 1; $i++) { + if ((!$invert && $current_minute >= $minutes[$i] && $current_minute < $minutes[$i + 1]) || + ($invert && $current_minute > $minutes[$i] && $current_minute <= $minutes[$i + 1])) { + $position = $invert ? $i : $i + 1; + break; + } + } + } + + if ((!$invert && $current_minute >= $minutes[$position]) || ($invert && $current_minute <= $minutes[$position])) { + $date->modify(($invert ? '-' : '+') . '1 hour'); + $date->setTime($date->format('H'), $invert ? 59 : 0); + } + else { + $date->setTime($date->format('H'), $minutes[$position]); + } + + return $this; + } + + public function validate($value) + { + return (bool) preg_match('/^[\*,\/\-0-9]+$/', $value); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/MonthField.php b/niucloud/vendor/yzh52521/schedule/src/console/MonthField.php new file mode 100644 index 000000000..33b18deb4 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/MonthField.php @@ -0,0 +1,44 @@ +isSatisfied($date->format('m'), $value); + } + + public function increment(DateTime $date, $invert = false) + { + if ($invert) { + $date->modify('last day of previous month'); + $date->setTime(23, 59); + } else { + $date->modify('first day of next month'); + $date->setTime(0, 0); + } + + return $this; + } + + public function validate($value) + { + return (bool) preg_match('/^[\*,\/\-0-9A-Z]+$/', $value); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/console/YearField.php b/niucloud/vendor/yzh52521/schedule/src/console/YearField.php new file mode 100644 index 000000000..2d3ece687 --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/console/YearField.php @@ -0,0 +1,37 @@ +isSatisfied($date->format('Y'), $value); + } + + public function increment(DateTime $date, $invert = false) + { + if ($invert) { + $date->modify('-1 year'); + $date->setDate($date->format('Y'), 12, 31); + $date->setTime(23, 59, 0); + } else { + $date->modify('+1 year'); + $date->setDate($date->format('Y'), 1, 1); + $date->setTime(0, 0, 0); + } + + return $this; + } + + public function validate($value) + { + return (bool) preg_match('/^[\*,\/\-0-9]+$/', $value); + } +} diff --git a/niucloud/vendor/yzh52521/schedule/src/exceptions/Exception.php b/niucloud/vendor/yzh52521/schedule/src/exceptions/Exception.php new file mode 100644 index 000000000..f4543a40a --- /dev/null +++ b/niucloud/vendor/yzh52521/schedule/src/exceptions/Exception.php @@ -0,0 +1,8 @@ +