Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/overtrue/wechat into over…
Browse files Browse the repository at this point in the history
…true-master
  • Loading branch information
wscrlhs committed Dec 14, 2019
2 parents 4af38a9 + 633bfb2 commit 04089de
Show file tree
Hide file tree
Showing 360 changed files with 13,288 additions and 909 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
phpunit.php export-ignore
phpunit.xml export-ignore
phpunit.xml.dist export-ignore
Expand Down
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github: [overtrue]
patreon: overtrue
custom: https://www.easywechat.com/img/pay/wechat.jpg
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
## 我用的环境

PHP 版本:
overtrue/wechat 版本:
是否使用了框架?框架名称:
* PHP 版本:
* overtrue/wechat 版本:
* 是否使用了框架?框架名称:

## 问题及现象

描述你的问题现象,报错**贴截图**粘贴或者贴具体信息,提供**必要的代码段**
<!-- 描述你的问题现象,报错**贴截图**粘贴或者贴具体信息,提供**必要的代码段**
如果你不提供相关的代码,我不会做任何应答,直接 close,感谢!
如果你不提供相关的代码,我不会做任何应答,直接 close,感谢!-->


<!-- Love wechat? Please consider supporting our collective:
👉 https://opencollective.com/wechat/donate -->
👉 https://opencollective.com/wechat/donate -->
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint
on: [push, pull_request]

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Dependencies
run: composer install --no-progress
- name: Run PHPStan
run: ./vendor/bin/phpstan analyse --no-progress

php_cs_fixer:
name: PHP-CS-Fxier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Dependencies
run: composer install --no-progress
- name: Run PHP-CS-Fxier
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff 1>&2
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on: [push, pull_request]

jobs:
phpunit:
name: PHP-${{ matrix.php_version }}-${{ matrix.perfer }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php_version:
- 7.2
- 7.3
- 7.4
perfer:
- stable
- lowest
container:
image: nauxliu/php-ci-image:${{ matrix.php_version }}
steps:
- uses: actions/checkout@master
- name: Install Dependencies
run: composer update --prefer-dist --no-interaction --no-suggest --prefer-${{ matrix.perfer }}
- name: Run PHPUnit
run: ./vendor/bin/phpunit
6 changes: 0 additions & 6 deletions .phplint.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .styleci.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

49 changes: 20 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
<p align="center">
<a href="https://easywechat.org/">
<img src="http://7u2jwa.com1.z0.glb.clouddn.com/logo-20171121.png" height="300" alt="EasyWeChat Logo"/>
</a>
<img align="right" width="100" src="https://user-images.githubusercontent.com/1472352/49656357-1e874080-fa78-11e8-80ea-69e2103345cf.png" alt="EasyWeChat Logo"/>

<p align="center">📦 It is probably the best SDK in the world for developing Wechat App.</p>
<h1 align="left"><a href="https://www.easywechat.com">EasyWeChat</a></h1>

<p align="center">
<a href="https://travis-ci.org/overtrue/wechat"><img src="https://travis-ci.org/overtrue/wechat.svg?branch=master" alt="Build Status"></a>
<a href="https://packagist.org/packages/overtrue/wechat"><img src="https://poser.pugx.org/overtrue/wechat/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/overtrue/wechat"><img src="https://poser.pugx.org/overtrue/wechat/v/unstable.svg" alt="Latest Unstable Version"></a>
<a href="https://scrutinizer-ci.com/g/overtrue/wechat/build-status/master"><img src="https://scrutinizer-ci.com/g/overtrue/wechat/badges/build.png?b=master" alt="Build Status"></a>
<a href="https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master"><img src="https://scrutinizer-ci.com/g/overtrue/wechat/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality"></a>
<a href="https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master"><img src="https://scrutinizer-ci.com/g/overtrue/wechat/badges/coverage.png?b=master" alt="Code Coverage"></a>
<a href="https://packagist.org/packages/overtrue/wechat"><img src="https://poser.pugx.org/overtrue/wechat/downloads" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/overtrue/wechat"><img src="https://poser.pugx.org/overtrue/wechat/license" alt="License"></a>
<a href="#backers"><img src="https://opencollective.com/wechat/backers/badge.svg" alt="Backers on Open Collective"></a>
<a href="#sponsors"><img src="https://opencollective.com/wechat/sponsors/badge.svg" alt="Sponsors on Open Collective"></a>
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fovertrue%2Fwechat?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fovertrue%2Fwechat.svg?type=shield"/></a>
</p>
📦 It is probably the best SDK in the world for developing Wechat App.

</div>
[![Test Status](https://github.com/overtrue/wechat/workflows/Test/badge.svg)](https://github.com/overtrue/wechat/actions)
[![Lint Status](https://github.com/overtrue/wechat/workflows/Lint/badge.svg)](https://github.com/overtrue/wechat/actions)
[![Latest Stable Version](https://poser.pugx.org/overtrue/wechat/v/stable.svg)](https://packagist.org/packages/overtrue/wechat)
[![Latest Unstable Version](https://poser.pugx.org/overtrue/wechat/v/unstable.svg)](https://packagist.org/packages/overtrue/wechat)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/overtrue/wechat/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/overtrue/wechat/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
[![Total Downloads](https://poser.pugx.org/overtrue/wechat/downloads)](https://packagist.org/packages/overtrue/wechat)
[![License](https://poser.pugx.org/overtrue/wechat/license)](https://packagist.org/packages/overtrue/wechat)

<p align="center">
<img width="200" src="http://wx1.sinaimg.cn/mw690/82b94fb4gy1fgwafq32r0j20nw0nwter.jpg">
</p>

<p align="center">关注公众号我们一起聊聊代码怎么样?</p>

<p><img src="http://7u2jwa.com1.z0.glb.clouddn.com/QQ20171121-130611.jpg" alt="Features" /></p>

## Requirement

1. PHP >= 7.0
1. PHP >= 7.2
2. **[Composer](https://getcomposer.org/)**
3. openssl 拓展
4. fileinfo 拓展(素材管理模块需要用到)

## Installation

```shell
$ composer require "overtrue/wechat:~4.0" -vvv
$ composer require "overtrue/wechat:^4.2" -vvv
```

## Usage
Expand Down Expand Up @@ -80,7 +65,7 @@ $server->serve()->send();

## Documentation

[官网](https://www.easywechat.com) · [教程](https://www.easywechat.com/tutorials) · [讨论](https://www.easywechat.com/discussions) · [微信公众平台](https://mp.weixin.qq.com/wiki) · [WeChat Official](http://admin.wechat.com/wiki)
[官网](https://www.easywechat.com) · [教程](https://www.easywechat.com/tutorials) · [讨论](https://yike.io/) · [微信公众平台](https://mp.weixin.qq.com/wiki) · [WeChat Official](http://admin.wechat.com/wiki)

## Integration

Expand All @@ -92,6 +77,12 @@ This project exists thanks to all the people who contribute. [[Contribute](CONTR
<a href="https://github.com/overtrue/wechat/graphs/contributors"><img src="https://opencollective.com/wechat/contributors.svg?width=890" /></a>


## PHP 扩展包开发

> 想知道如何从零开始构建 PHP 扩展包?
>
> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)

## License

Expand Down
27 changes: 18 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "muxing0608/wechat",
"description": "微信SDK",
"keywords": [
"easywechat",
"wechat",
"weixin",
"weixin-sdk",
Expand All @@ -15,24 +16,27 @@
}
],
"require": {
"php": ">=7.0",
"php": ">=7.2",
"ext-fileinfo": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"easywechat-composer/easywechat-composer": "1.1.3",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"monolog/monolog": "^1.22 || ^2.0",
"overtrue/socialite": "~2.0",
"pimple/pimple": "^3.0",
"symfony/cache": "^3.3|^4.0",
"symfony/http-foundation": "^2.7|^3.0|^4.0",
"symfony/psr-http-message-bridge": "^0.3|^1.0"
"psr/simple-cache": "^1.0",
"symfony/cache": "^3.3 || ^4.3 || ^5.0",
"symfony/event-dispatcher": "^4.3 || ^5.0",
"symfony/http-foundation": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"symfony/psr-http-message-bridge": "^0.3 || ^1.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
"overtrue/phplint": "dev-master",
"mockery/mockery": "^1.0",
"mikey179/vfsStream": "^1.6"
"friendsofphp/php-cs-fixer": "^2.15",
"mikey179/vfsstream": "^1.6",
"mockery/mockery": "^1.2.3",
"phpstan/phpstan": "^0.12.0",
"phpunit/phpunit": "^7.5"
},
"autoload": {
"psr-4": {
Expand All @@ -47,5 +51,10 @@
"psr-4": {
"EasyWeChat\\Tests\\": "tests/"
}
},
"scripts": {
"phpcs": "vendor/bin/php-cs-fixer fix",
"phpstan": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit"
}
}
17 changes: 17 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
parameters:
level: 3
paths:
- src
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- '#EasyWeChat\\MicroMerchant\\Kernel\\BaseClient::__construct\(\) does not call parent constructor from EasyWeChat\\Payment\\Kernel\\BaseClient#'
- '#Psr.*Exception is not subtype of Throwable#'
- '#Call to an undefined method Overtrue\\Socialite\\ProviderInterface#'
- '#Access to an undefined property .*\$base#'
- '#Call to an undefined method EasyWeChat\\Payment\\Application::verifySignature\(\)#'
- '#Access to an undefined property EasyWeChat\\Kernel\\Messages\\Raw::\$content#'
- '#Default value of the parameter \#2 \$depth \(INF.0\) of method EasyWeChat\\Kernel\\Support\\Arr::flatten\(\) is incompatible with type int#'
- '#Access to an undefined property EasyWeChat\\Kernel\\ServiceContainer::\$extension#'
- '#Method EasyWeChat\\Kernel\\Contracts\\MessageInterface::transformToXml\(\) invoked with 1 parameter, 0 required#'
- '#Method EasyWeChat\\Kernel\\Support\\Collection::__set_state\(\) should return object but returns array#'
- '#Property EasyWeChat\\Payment\\Kernel\\BaseClient::\$app \(EasyWeChat\\Payment\\Application\) does not accept EasyWeChat\\MicroMerchant\\Application#'
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
Expand Down
64 changes: 64 additions & 0 deletions src/BasicService/ContentSecurity/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace EasyWeChat\BasicService\ContentSecurity;

use EasyWeChat\Kernel\BaseClient;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

/**
* Class Client.
Expand All @@ -33,6 +34,7 @@ class Client extends BaseClient
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkText(string $text)
{
Expand All @@ -51,9 +53,71 @@ public function checkText(string $text)
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkImage(string $path)
{
return $this->httpUpload('img_sec_check', ['media' => $path]);
}

/**
* Media security check.
*
* @param string $mediaUrl
* @param int $mediaType
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
*/
public function checkMediaAsync(string $mediaUrl, int $mediaType)
{
/*
* 1:音频;2:图片
*/
$mediaTypes = [1, 2];

if (!in_array($mediaType, $mediaTypes, true)) {
throw new InvalidArgumentException('media type must be 1 or 2');
}

$params = [
'media_url' => $mediaUrl,
'media_type' => $mediaType,
];

return $this->httpPostJson('media_check_async', $params);
}

/**
* Image security check async.
*
* @param string $mediaUrl
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkImageAsync(string $mediaUrl)
{
return $this->checkMediaAsync($mediaUrl, 2);
}

/**
* Audio security check async.
*
* @param string $mediaUrl
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkAudioAsync(string $mediaUrl)
{
return $this->checkMediaAsync($mediaUrl, 1);
}
}
Loading

0 comments on commit 04089de

Please sign in to comment.