Skip to content

Commit

Permalink
🫑 Support PHP 8.1 (#14)
Browse files Browse the repository at this point in the history
* Support PHP 8.1

close #13
  • Loading branch information
godruoyi authored Jul 8, 2023
1 parent 7803e73 commit 8e2352e
Show file tree
Hide file tree
Showing 44 changed files with 487 additions and 727 deletions.
5 changes: 0 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@
/.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpunit.php export-ignore
phpunit.xml.dist export-ignore
phpunit.xml export-ignore
.php_cs export-ignore
36 changes: 10 additions & 26 deletions .github/workflows/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['8.1', '8.2']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -23,14 +23,10 @@ jobs:
coverage: none

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: PHPUnit Test
run: vendor/bin/phpunit --verbose
- name: PHP Unit Test
run: vendor/bin/phpunit
env:
BAIDU_ACCESS_KEY: ${{ secrets.BAIDU_ACCESS_KEY }}
BAIDU_SECRET_KEY: ${{ secrets.BAIDU_SECRET_KEY }}
Expand All @@ -46,7 +42,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- 8.0
- 8.2
dependencies:
- highest
steps:
Expand All @@ -59,18 +55,13 @@ jobs:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: gd
tools: composer:v2, php-cs-fixer

- name: Coding Guidelines
run: php-cs-fixer fix --config=.php-cs-fixer.php
tools: composer:v2

- name: Install lowest dependencies with composer
if: matrix.dependencies == 'lowest'
run: composer update --no-ansi --no-interaction --no-progress --prefer-lowest
- name: Install dependencies
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Install highest dependencies with composer
if: matrix.dependencies == 'highest'
run: composer update --no-ansi --no-interaction --no-progress
- name: Coding Guidelines
run: vendor/bin/pint --test --config ./pint.json

- name: Collect code coverage with phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml
Expand All @@ -86,10 +77,3 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
version: "v0.1.15"
env:
BAIDU_ACCESS_KEY: ${{ secrets.BAIDU_ACCESS_KEY }}
BAIDU_SECRET_KEY: ${{ secrets.BAIDU_SECRET_KEY }}
ALIYUN_APPCODE: ${{ secrets.ALIYUN_APPCODE }}
TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ composer.lock
*.log
/.php-cs-fixer.cache
/.phpunit.result.cache
.phpunit.cache
30 changes: 0 additions & 30 deletions .php-cs-fixer.php

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@

## Requirement

- PHP >= 7.1
- PHP >= 8.1
- composer

## Installation

> 注意此版本**不兼容** 1.x 版本,若你在寻在 1.x 版本,请查看 [这里](https://github.com/godruoyi/ocr/tree/1.1.4)
```
composer require "godruoyi/ocr:^2.1"
```
| SDK Version | PHP Version | Composer Command |
| ----------- | ----------- |----------------------------------------|
| 3.x | >= 8.1 | `composer require "godruoyi/ocr:^3.0"` |
| 2.x | >= 7.2 | `composer require "godruoyi/ocr:^2.1"` |

## Document

Expand Down
22 changes: 12 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
"email": "godruoyi@gmail.com"
}],
"require": {
"php": ">=7.1.3",
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"monolog/monolog": "^1.22 || ^2.0",
"psr/log": "^1.0",
"godruoyi/easy-container": "^1.1",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": "^4.4 || ^5.0 || ^6.0",
"php": ">=8.1",
"guzzlehttp/guzzle": "^7.2",
"monolog/monolog": "^3.0",
"psr/log": "^2.0 || ^3.0",
"godruoyi/easy-container": "^2.0",
"psr/simple-cache": "^2.0 || ^3.0",
"symfony/cache": "^6.1",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": ">=6.0",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^10.1",
"mockery/mockery": "^1.6",
"laravel/pint": "^1.10",
"ext-gd": "*"
},
"autoload": {
Expand All @@ -35,6 +36,7 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "vendor/bin/phpunit",
"pint": "vendor/bin/pint"
}
}
42 changes: 20 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>

<php>
<env name="ENVIRONMENT" value="" />
<env name="BAIDU_ACCESS_KEY" value="" />
<env name="BAIDU_SECRET_KEY" value="" />
<env name="ALIYUN_APPCODE" value="" />
<env name="TENCENT_SECRET_ID" value="" />
<env name="TENCENT_SECRET_KEY" value="" />
</php>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<coverage/>
<php>
<env name="ENVIRONMENT" value=""/>
<env name="BAIDU_ACCESS_KEY" value=""/>
<env name="BAIDU_SECRET_KEY" value=""/>
<env name="ALIYUN_APPCODE" value=""/>
<env name="TENCENT_SECRET_ID" value=""/>
<env name="TENCENT_SECRET_KEY" value=""/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
14 changes: 14 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"rules": {
"header_comment": {
"header": "This file is part of the godruoyi/ocr.\n \n(c) Godruoyi <gmail@godruoyi.com> \n \nThis source file is subject to the MIT license that is bundled."
},
"no_superfluous_phpdoc_tags": false,
"array_syntax" : {
"syntax" : "short"
},
"ordered_imports" : true,
"no_useless_else" : true,
"no_useless_return" : true
}
}
11 changes: 5 additions & 6 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Application extends Manager

/**
* Create application instance.
*
* @throws Exception
*/
public function __construct(array $config = [])
Expand All @@ -69,6 +70,7 @@ public function getContainer(): Container

/**
* Boot application for ocr.
*
* @throws Exception
*/
protected function boot()
Expand All @@ -81,6 +83,7 @@ protected function boot()
* Registe core alias and service.
*
* @return void
*
* @throws Exception
*/
protected function registerCore()
Expand Down Expand Up @@ -114,7 +117,7 @@ protected function registerDefaultProvider()
/**
* Register a service to container.
*
* @param mixed $service
* @param mixed $service
*/
public function register($service)
{
Expand All @@ -138,8 +141,7 @@ public function register($service)
/**
* Recover __get method.
*
* @param mixed $key
*
* @param mixed $key
* @return mixed
*/
public function __get($key)
Expand All @@ -149,9 +151,6 @@ public function __get($key)

/**
* RebindCache cache support.
*
* @param CacheInterface $cache
* @return Application
*/
public function rebindCache(CacheInterface $cache): self
{
Expand Down
Loading

0 comments on commit 8e2352e

Please sign in to comment.