Skip to content

Commit

Permalink
fix(deps): Change compatibility to SF ^6.0 and php ^8.0
Browse files Browse the repository at this point in the history
* fix(deps): Add compat for PHP ^8.0 and SF ^6.0
[add-sf-6-support]

BREAKING CHANGE: no more support for php < 8 or SF < 6

* test(ci): Migrate from travis to github action

* test(ci): Trigger build only on pull requests

* test(ci): Run only in 7.4

* test(ci): Run phpstan on root folder

* test(ci): Reduce number of dependencies and fixe php version for all tools

* test(ci): Remove > from run in ci.yaml

* test(ci): try lower version of php tools

* test(ci): try revert composer install with shivammathur/setup-php

* test(ci): try revert phpstan install with shivammathur/setup-php

* test(ci): Fix coverall path

* doc(ci): Remove travis build badge

* doc(ci): Update reco

* test(ci): Remove unrecognized src_dir config from .coveralls.yml

* test(ci): Switch to official php-coveralls/php-coveralls package and follow GA doc

* test(ci): Run on prefer lowest and "normal"

* test(ci): Run composer update instead of install

* test(ci): change target php versions

* fix(ci): Normalizer signature

* chore(ci): Prevent symfony/serializer:6.0.0

See: symfony/symfony#44331

* chore(ci): Bump phpunit to >=9

Phpunit < 9 is bubby on php 8.1: "PHP Fatal error:  Cannot acquire reference to $GLOBALS"

* chore(ci): Bump phpunit to >=9

Phpunit < 9 is bubby on php 8.1: "PHP Fatal error:  Cannot acquire reference to $GLOBALS"

* test(ci): Remove coverage publish

* test(ci): Remove coverage publish

* chore(ci): Remove php-coveralls/php-coveralls since the support of PHP 8.1 is not ready

Co-authored-by: Cyril Labbe <4123392+ryden54@users.noreply.github.com>
Co-authored-by: Arnaud LAHAXE <arnaud.lahaxe@boursorama.fr>
  • Loading branch information
3 people committed Jan 5, 2022
1 parent 648bb44 commit 34145b1
Show file tree
Hide file tree
Showing 22 changed files with 3,349 additions and 1,914 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on: [ "pull_request" ]

jobs:
tests:
strategy:
matrix:
php-versions: [ '8.0', '8.1' ]
composer-options: [ '--prefer-lowest', '']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: pcov
env:
fail-fast: true
- name: "Remove composer.lock file"
run: rm composer.lock || true
- uses: php-actions/composer@v6
with:
command: update # use update to use --prefer-lowest parameter
php_version: ${{ matrix.php-versions }}
version: 2
dev: yes
args: --no-interaction --no-progress --prefer-dist ${{ matrix.composer-options }}
- name: "Run php -l on all bundle files"
run: find . -not -path "./vendor/*" -type f -name '*.php' -exec php -l {} \;
- uses: php-actions/phpstan@v3
with:
path: .
memory_limit: 1G
level: 0
php_version: ${{ matrix.php-versions }}
- name: "Run phpunit"
run: "XDEBUG_MODE=coverage php ./vendor/bin/phpunit --coverage-text"
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion Curl/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function __destruct() {
*/
public function execute() {
$value = curl_exec($this->handle);

$error_no = curl_errno($this->handle);

if (0 !== $error_no) {
Expand Down
32 changes: 17 additions & 15 deletions DataCollector/LazyJsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Date: 29/11/2016
* Time: 15:05
*/

namespace evaisse\SimpleHttpBundle\DataCollector;

use Symfony\Component\Serializer\Encoder\JsonEncoder;
Expand All @@ -14,11 +15,10 @@
*/
class LazyJsonEncoder extends JsonEncoder
{

/**
* @var string
*/
protected $encoding;
protected string $encoding;

/**
* LazyJsonEncoder constructor.
Expand All @@ -37,26 +37,30 @@ public function __construct($encoding = 'utf-8')
* @param mixed $data data to encode
* @return mixed data encoded
*/
public function utf8Encode($data)
public function utf8Encode(mixed $data): mixed
{
if (is_string($data)) {
return utf8_encode($data);
} else if ($data instanceof \ArrayObject) {
}

if ($data instanceof \ArrayObject) {
$data = $data->getArrayCopy();
} else if($data instanceof \Exception) {
} elseif ($data instanceof \Exception) {
return $data->__toString();
} else if (is_object($data)) {
}
if (is_object($data)) {
$ovs = get_object_vars($data);
$new = clone $data;
foreach ($ovs as $k => $v) {
foreach ($ovs as $k => $v) {
if ($new instanceof \ArrayObject) {
$new[$k] = $this->utf8Encode($new[$k]);
} else {
$new->$k = $this->utf8Encode($new->$k);
}
}
return $new;
} else if (!is_array($data)) {
}
if (!is_array($data)) {
return $data;
}

Expand All @@ -72,7 +76,7 @@ public function utf8Encode($data)
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array())
public function encode(mixed $data, string $format, array $context = array()): string
{
try {
if ($this->encoding !== 'utf-8') {
Expand All @@ -82,7 +86,7 @@ public function encode($data, $format, array $context = array())
} catch (\Exception $e) {
$data = $this->utf8Encode($data); // safely try to force encoding
try {
return json_encode($data);
return json_encode($data, JSON_THROW_ON_ERROR);
} catch (\Exception $e) {
return "{}";
}
Expand All @@ -92,14 +96,12 @@ public function encode($data, $format, array $context = array())
/**
* {@inheritdoc}
*/
public function decode($data, $format, array $context = array())
public function decode(string $data, string $format, array $context = array()): mixed
{
try {
return $this->decodingImpl->decode($data, self::FORMAT, $context);
} catch (\Exception $e) {
return json_decode($data);
return json_decode($data, false, 512, JSON_THROW_ON_ERROR);
}
}


}
}
4 changes: 2 additions & 2 deletions DataCollector/ProfilerDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public function hasClientErrors()
*/
public function getClientErrors()
{
return array_filter($this->getCalls(), function ($call) {
return array_filter($this->getCalls(), static function ($call) {
if ($call['response']
&& array_key_exists('statusCode', $call['response'])
&& $call['response']['statusCode'] < 500
Expand Down Expand Up @@ -500,7 +500,7 @@ public function hasServerErrors()
*/
public function getServerErrors()
{
return array_filter($this->getCalls(), function ($call) {
return array_filter($this->getCalls(), static function ($call) {
if (is_array($call['response']) && array_key_exists('statusCode', $call['response']) && $call['response']['statusCode'] >= 500) {
return true;
}
Expand Down
1 change: 0 additions & 1 deletion Http/Exception/CurlTransportException.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class CurlTransportException extends TransportException
82 => 'CURLE_SSL_CRL_BADFILE',
83 => 'CURLE_SSL_ISSUER_ERROR',
84 => 'CURLE_FTP_PRET_FAILED',
84 => 'CURLE_FTP_PRET_FAILED',
85 => 'CURLE_RTSP_CSEQ_ERROR',
86 => 'CURLE_RTSP_SESSION_ERROR',
87 => 'CURLE_FTP_BAD_FILE_LIST',
Expand Down
Loading

0 comments on commit 34145b1

Please sign in to comment.