diff --git a/.gitignore b/.gitignore index f4c782b..006ab6d 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /vendor/ composer.lock .php-cs-fixer.cache -.idea \ No newline at end of file +.ideacghooks.lock + +cghooks.lock diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php deleted file mode 100755 index e900659..0000000 --- a/.php-cs-fixer.php +++ /dev/null @@ -1,12 +0,0 @@ -setRules([ - '@PSR12' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('vendor') - ->in([__DIR__.'/src/']) - ) -; diff --git a/composer.json b/composer.json index 5a38295..f476728 100644 --- a/composer.json +++ b/composer.json @@ -1,63 +1,67 @@ { - "name": "overtrue/laravel-wechat", - "description": "微信 SDK for Laravel", - "keywords": ["wechat", "weixin","laravel", "sdk"], - "license": "MIT", - "authors": [ - { - "name": "overtrue", - "email": "anzhengchao@gmail.com" - } - ], - "require": { - "illuminate/container": "^9.0|^10.0", - "w7corp/easywechat": "^6.0.0" - }, - "require-dev": { - "laravel/framework": "^9.0|^10.0", - "friendsofphp/php-cs-fixer": "^3.1", - "jetbrains/phpstorm-attributes": "^1.0" - }, - "autoload": { - "psr-4": { - "Overtrue\\LaravelWeChat\\": "src/" - } - }, - "extra": { - "laravel": { - "providers": [ - "Overtrue\\LaravelWeChat\\ServiceProvider" - ] - }, - "hooks": { - "pre-commit": [ - "composer check-style", - "composer test" - ], - "pre-push": [ - "composer check-style" - ] - } - }, - "scripts": { - "post-update-cmd": [ - "cghooks remove", - "cghooks add --ignore-lock", - "cghooks update" - ], - "post-merge": "composer install", - "post-install-cmd": [ - "cghooks remove", - "cghooks add --ignore-lock", - "cghooks update" - ], - "check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --allow-risky=yes --ansi", - "fix-style": "php-cs-fixer fix --using-cache=no --allow-risky=yes --ansi", - "test": "phpunit --colors" + "name": "overtrue/laravel-wechat", + "description": "微信 SDK for Laravel", + "keywords": [ + "wechat", + "weixin", + "laravel", + "sdk" + ], + "license": "MIT", + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "require": { + "illuminate/container": "^9.0|^10.0", + "w7corp/easywechat": "^6.0.0" + }, + "require-dev": { + "laravel/framework": "^10.0", + "jetbrains/phpstorm-attributes": "^1.0", + "brainmaestro/composer-git-hooks": "dev-master", + "laravel/pint": "^1.5" + }, + "autoload": { + "psr-4": { + "Overtrue\\LaravelWeChat\\": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "Overtrue\\LaravelWeChat\\ServiceProvider" + ] }, - "config": { - "allow-plugins": { - "easywechat-composer/easywechat-composer": true - } + "hooks": { + "pre-commit": [ + "composer check-style" + ], + "pre-push": [ + "composer check-style" + ] + } + }, + "scripts": { + "post-update-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" + ], + "post-merge": "composer install", + "post-install-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" + ], + "check-style": "vendor/bin/pint --test", + "fix-style": "vendor/bin/pint" + }, + "config": { + "allow-plugins": { + "easywechat-composer/easywechat-composer": true } + } } diff --git a/config/easywechat.php b/config/easywechat.php index 239952e..721c102 100755 --- a/config/easywechat.php +++ b/config/easywechat.php @@ -4,7 +4,7 @@ /* * 默认配置,将会合并到各模块中 */ - 'defaults' => [ + 'defaults' => [ 'http' => [ 'timeout' => 5.0, ], @@ -15,9 +15,9 @@ */ 'official_account' => [ 'default' => [ - 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', ''), // AppID - 'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', ''), // AppSecret - 'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', ''), // Token + 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', ''), // AppID + 'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', ''), // AppSecret + 'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', ''), // Token 'aes_key' => env('WECHAT_OFFICIAL_ACCOUNT_AES_KEY', ''), // EncodingAESKey /* @@ -33,10 +33,10 @@ // 'enforce_https' => true, // ], - /** - * 接口请求相关配置,超时时间等,具体可用参数请参考: - * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 - */ + /** + * 接口请求相关配置,超时时间等,具体可用参数请参考: + * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 + */ //'http' => [ // 'timeout' => 5.0, // // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri @@ -55,10 +55,10 @@ // 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''), // 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''), - /** - * 接口请求相关配置,超时时间等,具体可用参数请参考: - * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 - */ +/** + * 接口请求相关配置,超时时间等,具体可用参数请参考: + * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 + */ // 'http' => [ // 'timeout' => 5.0, // // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri @@ -77,10 +77,10 @@ // 'token' => env('WECHAT_MINI_APP_TOKEN', ''), // 'aes_key' => env('WECHAT_MINI_APP_AES_KEY', ''), - /** - * 接口请求相关配置,超时时间等,具体可用参数请参考: - * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 - */ +/** + * 接口请求相关配置,超时时间等,具体可用参数请参考: + * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 + */ // 'http' => [ // 'timeout' => 5.0, // // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri @@ -114,7 +114,7 @@ // // // v3 API 秘钥 // //'secret_key' => '43A03299A3C3FED3D8CE7B820Fxxxxx', - // + // // // 注意 此处为微信支付平台证书 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml // 'platform_certs' => [ // '/data/private/certs/platform_key.pem', @@ -132,10 +132,10 @@ // 'token' => env('WECHAT_WORK_TOKEN', ''), // 'aes_key' => env('WECHAT_WORK_AES_KEY', ''), - /** - * 接口请求相关配置,超时时间等,具体可用参数请参考: - * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 - */ +/** + * 接口请求相关配置,超时时间等,具体可用参数请参考: + * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 + */ // 'http' => [ // 'timeout' => 5.0, // // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri @@ -154,10 +154,10 @@ // 'token' => env('WECHAT_OPEN_WORK_TOKEN', ''), // 'aes_key' => env('WECHAT_OPEN_WORK_AES_KEY', ''), - /** - * 接口请求相关配置,超时时间等,具体可用参数请参考: - * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 - */ +/** + * 接口请求相关配置,超时时间等,具体可用参数请参考: + * https://github.com/symfony/symfony/blob/6.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php#L26 + */ // 'http' => [ // 'timeout' => 5.0, // // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri diff --git a/src/Middleware/OAuthAuthenticate.php b/src/Middleware/OAuthAuthenticate.php index a248f0b..2eb94f9 100644 --- a/src/Middleware/OAuthAuthenticate.php +++ b/src/Middleware/OAuthAuthenticate.php @@ -24,16 +24,8 @@ */ class OAuthAuthenticate { - /** - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string $account - * @param string|null $scope - * - * @return mixed - */ public function handle( - \Illuminate\Http\Request $request, + Request $request, Closure $next, string $account = 'default', string $scope = null, @@ -92,7 +84,7 @@ protected function getIntendUrl(Request $request, bool $https = false): string protected function getRedirectUrl(Request $request, bool $https = false): string { - if (!$https) { + if (! $https) { return $request->fullUrl(); } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 9cc2e0f..4a6caa1 100755 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -17,7 +17,6 @@ use EasyWeChat\OpenWork\Application as OpenWork; use EasyWeChat\Pay\Application as Payment; use EasyWeChat\Work\Application as Work; -use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider as LaravelServiceProvider; class ServiceProvider extends LaravelServiceProvider @@ -51,7 +50,7 @@ public function register() continue; } - if (!empty(config('easywechat.'.$name.'.app_id')) || !empty(config('easywechat.'.$name.'.corp_id'))) { + if (! empty(config('easywechat.'.$name.'.app_id')) || ! empty(config('easywechat.'.$name.'.corp_id'))) { $accounts = [ 'default' => config('easywechat.'.$name), ]; @@ -61,7 +60,7 @@ public function register() } foreach ($accounts as $account => $config) { - $this->app->bind("easywechat.{$name}.{$account}", function ($laravelApp) use ($name, $account, $config, $class) { + $this->app->bind("easywechat.{$name}.{$account}", function ($laravelApp) use ($config, $class) { $app = new $class(array_merge(config('easywechat.defaults', []), $config)); if (\is_callable([$app, 'setCache'])) { diff --git a/src/Traits/HandleOpenPlatformServerEvents.php b/src/Traits/HandleOpenPlatformServerEvents.php index 043dc13..494c6d8 100644 --- a/src/Traits/HandleOpenPlatformServerEvents.php +++ b/src/Traits/HandleOpenPlatformServerEvents.php @@ -4,8 +4,8 @@ use EasyWeChat\OpenPlatform\Application; use Overtrue\LaravelWeChat\Events\OpenPlatform\Authorized; -use Overtrue\LaravelWeChat\Events\OpenPlatform\Unauthorized; use Overtrue\LaravelWeChat\Events\OpenPlatform\AuthorizeUpdated; +use Overtrue\LaravelWeChat\Events\OpenPlatform\Unauthorized; use Overtrue\LaravelWeChat\Events\OpenPlatform\VerifyTicketRefreshed; trait HandleOpenPlatformServerEvents