From e7967d906a1615d496c56c0794b2011f1b4ddc31 Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Fri, 28 Apr 2023 11:53:05 +0800 Subject: [PATCH] Adapt to the latest version of Hyperf (#87) --- .gitignore | 1 + .php-cs-fixer.php | 22 +++++++++++++++---- app/Listener/DbQueryExecutedListener.php | 2 +- config/autoload/cache.php | 2 +- config/autoload/databases.php | 2 ++ config/config.php | 2 ++ config/container.php | 2 +- installer/OptionalPackages.php | 3 ++- .../resources/config_center/config_etcd.php | 2 +- 9 files changed, 29 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4ac68301..6bd35f01 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ vendor/ .phpunit* *.cache composer.lock +.vscode/ \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index dd164b5d..213c558a 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,5 +1,14 @@ 'after_declare_strict', ], 'array_syntax' => [ - 'syntax' => 'short' + 'syntax' => 'short', ], 'list_syntax' => [ - 'syntax' => 'short' + 'syntax' => 'short', ], 'concat_space' => [ - 'spacing' => 'one' + 'spacing' => 'one', + ], + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => null, ], 'blank_line_before_statement' => [ 'statements' => [ @@ -38,7 +52,7 @@ ], 'general_phpdoc_annotation_remove' => [ 'annotations' => [ - 'author' + 'author', ], ], 'ordered_imports' => [ diff --git a/app/Listener/DbQueryExecutedListener.php b/app/Listener/DbQueryExecutedListener.php index dd028f49..dbd49923 100644 --- a/app/Listener/DbQueryExecutedListener.php +++ b/app/Listener/DbQueryExecutedListener.php @@ -11,11 +11,11 @@ */ namespace App\Listener; +use Hyperf\Collection\Arr; use Hyperf\Database\Events\QueryExecuted; use Hyperf\Event\Annotation\Listener; use Hyperf\Event\Contract\ListenerInterface; use Hyperf\Logger\LoggerFactory; -use Hyperf\Utils\Arr; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; diff --git a/config/autoload/cache.php b/config/autoload/cache.php index def82eb0..471228c8 100644 --- a/config/autoload/cache.php +++ b/config/autoload/cache.php @@ -12,7 +12,7 @@ return [ 'default' => [ 'driver' => Hyperf\Cache\Driver\RedisDriver::class, - 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, + 'packer' => Hyperf\Codec\Packer\PhpSerializerPacker::class, 'prefix' => 'c:', ], ]; diff --git a/config/autoload/databases.php b/config/autoload/databases.php index b3cfbe79..79c013e9 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -9,6 +9,8 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use function Hyperf\Support\env; + return [ 'default' => [ 'driver' => env('DB_DRIVER', 'mysql'), diff --git a/config/config.php b/config/config.php index 38823e01..418135e3 100644 --- a/config/config.php +++ b/config/config.php @@ -12,6 +12,8 @@ use Hyperf\Contract\StdoutLoggerInterface; use Psr\Log\LogLevel; +use function Hyperf\Support\env; + return [ 'app_name' => env('APP_NAME', 'skeleton'), 'app_env' => env('APP_ENV', 'dev'), diff --git a/config/container.php b/config/container.php index beb33689..c82a0e80 100644 --- a/config/container.php +++ b/config/container.php @@ -12,9 +12,9 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Context\ApplicationContext; use Hyperf\Di\Container; use Hyperf\Di\Definition\DefinitionSourceFactory; -use Hyperf\Utils\ApplicationContext; $container = new Container((new DefinitionSourceFactory())()); diff --git a/installer/OptionalPackages.php b/installer/OptionalPackages.php index 641b5f90..1931f263 100644 --- a/installer/OptionalPackages.php +++ b/installer/OptionalPackages.php @@ -20,6 +20,7 @@ use Composer\Package\RootPackageInterface; use Composer\Package\Version\VersionParser; use FilesystemIterator; +use InvalidArgumentException; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -128,7 +129,7 @@ public function installHyperfScript() implode('', $ask), function ($value) { if ($value === 'y' || $value === 'yes') { - throw new \InvalidArgumentException('You should type a time zone name, like Asia/Shanghai. Or type n to skip.'); + throw new InvalidArgumentException('You should type a time zone name, like Asia/Shanghai. Or type n to skip.'); } return trim($value); diff --git a/installer/resources/config_center/config_etcd.php b/installer/resources/config_center/config_etcd.php index b35139f7..426ce672 100644 --- a/installer/resources/config_center/config_etcd.php +++ b/installer/resources/config_center/config_etcd.php @@ -18,7 +18,7 @@ 'drivers' => [ 'etcd' => [ 'driver' => Hyperf\ConfigEtcd\EtcdDriver::class, - 'packer' => Hyperf\Utils\Packer\JsonPacker::class, + 'packer' => Hyperf\Codec\Packer\JsonPacker::class, 'namespaces' => [ '/application', ],