Skip to content

Commit

Permalink
fix: format files (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
rancoud authored Apr 28, 2023
1 parent 2f549a7 commit c128e64
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 43 deletions.
47 changes: 24 additions & 23 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use PhpCsFixer\Finder;

$rules = [
'@Symfony' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => [
'array_syntax' => [
'syntax' => 'short'
],
'binary_operator_spaces' => [
Expand All @@ -19,32 +19,32 @@
'concat_space' => [
'spacing' => 'one'
],
'declare_strict_types' => true,
'global_namespace_import' => false,
'declare_strict_types' => true,
'global_namespace_import' => false,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'native_function_invocation' => [
'mb_str_functions' => true,
'native_function_invocation' => [
'include' => [
'@all'
]
],
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => false,
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'semicolon_after_instruction' => true,
'single_import_per_statement' => false,
'strict_comparison' => true,
'strict_param' => true,
'single_line_throw' => false,
'trailing_comma_in_multiline' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'semicolon_after_instruction' => true,
'single_import_per_statement' => false,
'strict_comparison' => true,
'strict_param' => true,
'single_line_throw' => false,
'trailing_comma_in_multiline' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false
],
];
Expand All @@ -59,7 +59,8 @@
->ignoreVCS(true);

$config = new Config();

return $config->setFinder($finder)
->setRules($rules)
->setRiskyAllowed(true)
->setUsingCache(true);
->setUsingCache(true);
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ $stream = $factory->createStream('foobar');
### Constructor
#### Mandatory
| Parameter | Type | Description |
| --------- | ------ | ----------- |
|-----------|--------|-------------|
| method | string | HTTP method |
| uri | mixed | Uri |

#### Optionnals
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | --------------------- |
|-----------|--------|---------------|-----------------------|
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |
Expand Down Expand Up @@ -139,7 +139,7 @@ $stream = $factory->createStream('foobar');
### Constructor
#### Optionnals
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | ----------------------------- |
|-----------|--------|---------------|-------------------------------|
| status | int | 200 | Status code |
| headers | array | [] | Response headers |
| body | mixed | [] | Response body |
Expand Down Expand Up @@ -326,13 +326,13 @@ $stream = $factory->createStream('foobar');
### Constructor
#### Mandatory
| Parameter | Type | Description |
| --------- | ------ | ----------- |
|-----------|--------|-------------|
| method | string | HTTP method |
| uri | mixed | Uri |

#### Optionnals
| Parameter | Type | Default value | Description |
| ------------ | ------ | ------------- | --------------------- |
|--------------|--------|---------------|-----------------------|
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |
Expand Down Expand Up @@ -396,14 +396,14 @@ $stream = $factory->createStream('foobar');
### Constructor
#### Mandatory
| Parameter | Type | Description |
| ------------ | ----- | -------------- |
|--------------|-------|----------------|
| streamOrFile | mixed | Stream or file |
| size | int | Filesize |
| errorStatus | int | Upload errors |

#### Optionnals
| Parameter | Type | Default value | Description |
| --------------- | ------------ | ------------- | ----------- |
|-----------------|--------------|---------------|-------------|
| clientFilename | string\|null | null | Filename |
| clientMediaType | string\|null | null | Media type |

Expand All @@ -430,7 +430,7 @@ $stream = $factory->createStream('foobar');
### Constructor
#### Optionnals
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | ----------- |
|-----------|--------|---------------|-------------|
| uri | string | '' | Uri |

### Methods
Expand All @@ -454,4 +454,4 @@ $stream = $factory->createStream('foobar');
## How to Dev
`composer ci` for php-cs-fixer and phpunit and coverage
`composer lint` for php-cs-fixer
`composer test` for phpunit and coverage
`composer test` for phpunit and coverage
2 changes: 2 additions & 0 deletions src/Message/Factory/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ public function createServerRequestFromArray(array $server): ServerRequest
* @throws \InvalidArgumentException
*
* @return ServerRequest
*
* @noinspection PhpTooManyParametersInspection
*/
public function createServerRequestFromArrays(
array $server,
Expand Down
7 changes: 4 additions & 3 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand All @@ -9,7 +11,6 @@
use Rancoud\Http\Client\Exception\RequestException;
use Rancoud\Http\Message\Request;
use Rancoud\Http\Message\Stream;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class ClientTest extends TestCase
Expand All @@ -23,11 +24,11 @@ class ClientTest extends TestCase

public static function setUpBeforeClass(): void
{
static::$process = new Process(['php', '-S', static::$localPHPServer, '-t', realpath(__DIR__ . \DIRECTORY_SEPARATOR .'fake_server')]);
static::$process = new Process(['php', '-S', static::$localPHPServer, '-t', \realpath(__DIR__ . \DIRECTORY_SEPARATOR . 'fake_server')]);

static::$process->disableOutput();

static::$process->start(function($type, $data){
static::$process->start(function ($type, $data) {
\sleep(1);

if (\mb_stripos($data, 'started') === false) {
Expand Down
2 changes: 2 additions & 0 deletions tests/ExtendingClass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use Rancoud\Http\Message\Uri;
Expand Down
2 changes: 2 additions & 0 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 2 additions & 0 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 2 additions & 0 deletions tests/ServerRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand Down
4 changes: 4 additions & 0 deletions tests/StreamTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -145,6 +147,8 @@ public function testCanDetachStream(): void

$stream->close();
$content = (string) $stream;

static::assertNull($content);
}

public function testCloseClearProperties(): void
Expand Down
2 changes: 2 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace tests;

use PHPUnit\Framework\TestCase;
Expand Down
10 changes: 6 additions & 4 deletions tests/fake_server/big-body.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

$dataFromPost = file_get_contents('php://input');
$dataFromFolder = file_get_contents('noise.jpg');
declare(strict_types=1);

if($dataFromPost === $dataFromFolder) {
$dataFromPost = \file_get_contents('php://input');
$dataFromFolder = \file_get_contents('noise.jpg');

if ($dataFromPost === $dataFromFolder) {
echo 'ok';
}
}
6 changes: 4 additions & 2 deletions tests/fake_server/headers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

header("X-my-custom-header:hello", true);
declare(strict_types=1);

echo $_SERVER['HTTP_X_YOLO'];
\header('X-my-custom-header:hello');

echo $_SERVER['HTTP_X_YOLO'];
6 changes: 4 additions & 2 deletions tests/fake_server/small-body.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

if($_POST['a'] === 'b') {
declare(strict_types=1);

if ($_POST['a'] === 'b') {
echo 'c';
}
}

0 comments on commit c128e64

Please sign in to comment.