Skip to content

Commit

Permalink
Merge 4369557 into 648bb44
Browse files Browse the repository at this point in the history
  • Loading branch information
lahaxearnaud committed Jan 4, 2022
2 parents 648bb44 + 4369557 commit 0ff2404
Show file tree
Hide file tree
Showing 22 changed files with 3,713 additions and 1,543 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 --coverage-clover build/logs/clover.xml"
- name: "Upload coverage results to Coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: "php vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v"
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 0ff2404

Please sign in to comment.