Skip to content

Commit

Permalink
Drop old PHP versions (#26)
Browse files Browse the repository at this point in the history
* Drop old PHP versions

* Add changelog

* Apply CS fixes

* Minors
  • Loading branch information
Nyholm authored Mar 26, 2021
1 parent 6194c93 commit a3bbb60
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 177 deletions.
21 changes: 9 additions & 12 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/behat.yml.dist export-ignore
/features/ export-ignore
/phpunit.xml.dist export-ignore
/Tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
33 changes: 33 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Static code analysis

on: [pull_request]

jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run PHPStan
uses: docker://jakzal/phpqa:php7.3-alpine
with:
args: phpstan analyze

php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run PHP-CS-Fixer
uses: docker://jakzal/phpqa:php7.3-alpine
with:
args: php-cs-fixer fix --dry-run --diff-format udiff -vvv

roave-bc-check:
name: Roave BC Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
pull_request:

jobs:
build:
name: Test
runs-on: Ubuntu-20.04
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0' ]
strategy: [ 'highest' ]
include:
- php: 7.4
strategy: 'lowest'

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Download dependencies
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.strategy }}
composer-options: --no-interaction --prefer-dist --optimize-autoloader

- name: Run tests
run: ./vendor/bin/phpunit

69 changes: 0 additions & 69 deletions .github/workflows/continuous-integration.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/behat.yml
/build/
/.php_cs.cache
/composer.lock
/phpspec.yml
/phpunit.xml
/vendor/
24 changes: 14 additions & 10 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

/*
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally
* with composer.
*
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(__DIR__.'/vendor')
->name('*.php')
)
;

use SLLH\StyleCIBridge\ConfigBridge;

return ConfigBridge::create();
return $config;
8 changes: 0 additions & 8 deletions .scrutinizer.yml

This file was deleted.

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

This file was deleted.

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

This file was deleted.

14 changes: 12 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Change Log

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## 1.2.0

### Added

- Support for PHP 8

### Removed

- Support for PHP < 7.2

## 1.1.0

### Added
### Added

- Bing Translator
- Support for HTTPlug 2.0
Expand Down
3 changes: 0 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

[![Latest Version](https://img.shields.io/github/release/php-translation/translator.svg?style=flat-square)](https://github.com/php-translation/translator/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://img.shields.io/travis/php-translation/translator.svg?style=flat-square)](https://travis-ci.org/php-translation/translator)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-translation/translator.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/translator)
[![Quality Score](https://img.shields.io/scrutinizer/g/php-translation/translator.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-translation/translator)
[![Total Downloads](https://img.shields.io/packagist/dt/php-translation/translator.svg?style=flat-square)](https://packagist.org/packages/php-translation/translator)

**Services that can be used to translate strings**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
}
],
"require": {
"php": "^5.6 || ^7.0 || ^8.0",
"php": "^7.2 || ^8.0",
"php-http/httplug": "^1.0 || ^2.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.7",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^5.5 || ^6.2 || ^7.5 || ^8.4 || ^9.5",
"phpunit/phpunit": "^8.4",
"nyholm/nsa": "^1.1",
"php-http/curl-client": "^1.0 || ^2.0",
"php-http/message": "^1.8",
Expand Down
32 changes: 32 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
parameters:
ignoreErrors:
-
message: "#^Method Translation\\\\Translator\\\\Service\\\\BingTranslator\\:\\:getUrl\\(\\) invoked with 4 parameters, 2 required\\.$#"
count: 1
path: src/Service/BingTranslator.php

-
message: "#^Method Translation\\\\Translator\\\\Service\\\\BingTranslator\\:\\:translate\\(\\) should return string but return statement is missing\\.$#"
count: 1
path: src/Service/BingTranslator.php

-
message: "#^Method Translation\\\\Translator\\\\Service\\\\GoogleTranslator\\:\\:translate\\(\\) should return string but return statement is missing\\.$#"
count: 1
path: src/Service/GoogleTranslator.php

-
message: "#^Method Translation\\\\Translator\\\\Service\\\\YandexTranslator\\:\\:translate\\(\\) should return string but return statement is missing\\.$#"
count: 1
path: src/Service/YandexTranslator.php

-
message: "#^Method Translation\\\\Translator\\\\Translator\\:\\:translate\\(\\) should return string\\|null but empty return statement found\\.$#"
count: 1
path: src/Translator.php

-
message: "#^PHPDoc tag @throws with type Translation\\\\Translator\\\\Exception is not subtype of Throwable$#"
count: 1
path: src/TranslatorService.php

9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- phpstan-baseline.neon

parameters:
level: 3
paths:
- src
excludes_analyse:
- vendor
8 changes: 3 additions & 5 deletions src/Service/BingTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class BingTranslator extends HttpTranslator implements TranslatorService
private $key;

/**
* @param string $key Google API key
* @param HttpClient|null $httpClient
* @param RequestFactory|null $requestFactory
* @param string $key Google API key
*/
public function __construct($key, HttpClient $httpClient = null, RequestFactory $requestFactory = null)
{
Expand All @@ -56,7 +54,7 @@ public function translate($string, $from, $to)
->withHeader('Ocp-Apim-Subscription-Key', $this->key)
->withHeader('Content-Type', 'application/json')
->withHeader('X-ClientTraceId', $this->createGuid())
->withHeader('Content-length', strlen($body));
->withHeader('Content-length', \strlen($body));

/** @var ResponseInterface $response */
$response = $this->getHttpClient()->sendRequest($request);
Expand All @@ -68,7 +66,7 @@ public function translate($string, $from, $to)
$responseBody = $response->getBody()->__toString();
$data = json_decode($responseBody, true);

if (!is_array($data)) {
if (!\is_array($data)) {
throw ResponseException::createUnexpectedResponse($url, $responseBody);
}

Expand Down
Loading

0 comments on commit a3bbb60

Please sign in to comment.