Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
joelwurtz committed Apr 10, 2024
1 parent 9b364b7 commit 044a20f
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 94 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"require-dev": {
"amphp/http-client": "^5.0.1",
"friendsofphp/php-cs-fixer": "^3.16.0",
"friendsofphp/php-cs-fixer": "^3.53.0",
"phpstan/phpstan": "^1.10"
},
"conflict": {
Expand Down
37 changes: 1 addition & 36 deletions src/Assert/AssertCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function setUpTest(Test $test): void
/**
* Asserts that an array has a specified key.
*
* @param mixed $key
* @param array|\ArrayAccess $array
* @param string $message
*/
Expand All @@ -73,7 +72,6 @@ public function assertArrayHasKey($key, $array, $message = null)
/**
* Asserts that an array does not have a specified key.
*
* @param mixed $key
* @param array|\ArrayAccess $array
* @param string $message
*/
Expand All @@ -89,8 +87,6 @@ public function assertArrayNotHasKey($key, $array, $message = null)
* $checkForNonObjectIdentity to a non-default value will cause a fallback
* to PHPUnit's constraint.
*
* @param mixed $needle
* @param mixed $haystack
* @param string $message
*/
public function assertContains($needle, $haystack, $message = null)
Expand All @@ -105,8 +101,6 @@ public function assertContains($needle, $haystack, $message = null)
* $checkForNonObjectIdentity to a non-default value will cause a fallback
* to PHPUnit's constraint.
*
* @param mixed $needle
* @param mixed $haystack
* @param string $message
*/
public function assertNotContains($needle, $haystack, $message = null)
Expand Down Expand Up @@ -178,7 +172,6 @@ public function assertNotContainsOnly($type, $haystack, $isNativeType = null, $m
* Asserts the number of elements of an array, Countable or Traversable.
*
* @param int $expectedCount
* @param mixed $haystack
* @param string $message
*/
public function assertCount($expectedCount, $haystack, $message = null)
Expand All @@ -190,7 +183,6 @@ public function assertCount($expectedCount, $haystack, $message = null)
* Asserts the number of elements of an array, Countable or Traversable.
*
* @param int $expectedCount
* @param mixed $haystack
* @param string $message
*/
public function assertNotCount($expectedCount, $haystack, $message = null)
Expand All @@ -204,8 +196,6 @@ public function assertNotCount($expectedCount, $haystack, $message = null)
* Please note that setting $canonicalize or $ignoreCase to true will cause
* a fallback to PHPUnit's constraint.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
* @param float $delta
*/
Expand All @@ -220,8 +210,6 @@ public function assertEquals($expected, $actual, $message = null, $delta = 0.0)
* Please note that setting $canonicalize or $ignoreCase to true will cause
* a fallback to PHPUnit's constraint.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
* @param float $delta
*/
Expand All @@ -233,7 +221,6 @@ public function assertNotEquals($expected, $actual, $message = null, $delta = 0.
/**
* Asserts that a variable is empty.
*
* @param mixed $actual
* @param string $message
*/
public function assertEmpty($actual, $message = null)
Expand All @@ -244,7 +231,6 @@ public function assertEmpty($actual, $message = null)
/**
* Asserts that a variable is not empty.
*
* @param mixed $actual
* @param string $message
*/
public function assertNotEmpty($actual, $message = null)
Expand All @@ -255,8 +241,6 @@ public function assertNotEmpty($actual, $message = null)
/**
* Asserts that a value is greater than another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertGreaterThan($expected, $actual, $message = null)
Expand All @@ -267,8 +251,6 @@ public function assertGreaterThan($expected, $actual, $message = null)
/**
* Asserts that a value is greater than or equal to another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertGreaterThanOrEqual($expected, $actual, $message = null)
Expand All @@ -279,8 +261,6 @@ public function assertGreaterThanOrEqual($expected, $actual, $message = null)
/**
* Asserts that a value is smaller than another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertLessThan($expected, $actual, $message = null)
Expand All @@ -291,8 +271,6 @@ public function assertLessThan($expected, $actual, $message = null)
/**
* Asserts that a value is smaller than or equal to another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertLessThanOrEqual($expected, $actual, $message = null)
Expand Down Expand Up @@ -347,7 +325,6 @@ public function assertFalse($condition, $message = null)
/**
* Asserts that a variable is not null.
*
* @param mixed $actual
* @param string $message
*/
public function assertNotNull($actual, $message = null)
Expand All @@ -358,7 +335,6 @@ public function assertNotNull($actual, $message = null)
/**
* Asserts that a variable is null.
*
* @param mixed $actual
* @param string $message
*/
public function assertNull($actual, $message = null)
Expand All @@ -369,7 +345,6 @@ public function assertNull($actual, $message = null)
/**
* Asserts that a variable is finite.
*
* @param mixed $actual
* @param string $message
*/
public function assertFinite($actual, $message = null)
Expand All @@ -380,7 +355,6 @@ public function assertFinite($actual, $message = null)
/**
* Asserts that a variable is infinite.
*
* @param mixed $actual
* @param string $message
*/
public function assertInfinite($actual, $message = null)
Expand All @@ -391,7 +365,6 @@ public function assertInfinite($actual, $message = null)
/**
* Asserts that a variable is nan.
*
* @param mixed $actual
* @param string $message
*/
public function assertNan($actual, $message = null)
Expand All @@ -404,8 +377,6 @@ public function assertNan($actual, $message = null)
* Used on objects, it asserts that two variables reference
* the same object.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertSame($expected, $actual, $message = null)
Expand All @@ -418,8 +389,6 @@ public function assertSame($expected, $actual, $message = null)
* Used on objects, it asserts that two variables do not reference
* the same object.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public function assertNotSame($expected, $actual, $message = null)
Expand All @@ -431,7 +400,6 @@ public function assertNotSame($expected, $actual, $message = null)
* Asserts that a variable is of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public function assertInstanceOf($expected, $actual, $message = null)
Expand All @@ -443,7 +411,6 @@ public function assertInstanceOf($expected, $actual, $message = null)
* Asserts that a variable is not of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public function assertNotInstanceOf($expected, $actual, $message = null)
Expand All @@ -455,7 +422,6 @@ public function assertNotInstanceOf($expected, $actual, $message = null)
* Asserts that a variable is of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public function assertInternalType($expected, $actual, $message = null)
Expand All @@ -467,7 +433,6 @@ public function assertInternalType($expected, $actual, $message = null)
* Asserts that a variable is not of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public function assertNotInternalType($expected, $actual, $message = null)
Expand Down Expand Up @@ -568,7 +533,7 @@ public function assertContainsSubset(array $other, array $subset, bool $strict =
$this->assert($subset, containsSubset($other, $strict), $message);
}

public function assert($value, callable $predicate, string $description = null): bool
public function assert($value, callable $predicate, ?string $description = null): bool
{
return (new Assertion($value, exporter(), $this->test))
->evaluate(counting(Predicate::castFrom($predicate)), $description);
Expand Down
10 changes: 4 additions & 6 deletions src/Assert/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class Assertion extends BaseAssertion

/**
* constructor.
*
* @param mixed $value
*/
public function __construct($value, Exporter $exporter, Test $test)
{
Expand All @@ -32,7 +30,7 @@ public function __construct($value, Exporter $exporter, Test $test)
$this->test = $test;
}

public function evaluate(Predicate $predicate, string $description = null): bool
public function evaluate(Predicate $predicate, ?string $description = null): bool
{
try {
$result = parent::evaluate($predicate, $description);
Expand Down Expand Up @@ -60,10 +58,10 @@ public function evaluate(Predicate $predicate, string $description = null): bool
/**
* creates failure description when value failed the test with given predicate.
*
* @param \bovigo\assert\predicate\Predicate $predicate predicate that failed
* @param string $description additional description for failure message
* @param Predicate $predicate predicate that failed
* @param string $description additional description for failure message
*/
private function describeSuccess(Predicate $predicate, string $description = null): string
private function describeSuccess(Predicate $predicate, ?string $description = null): string
{
if ($description) {
return $description;
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/HttpTimeout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{
public function __construct(
public float $timeout,
)
{
) {
}
}
}
6 changes: 0 additions & 6 deletions src/Command/AsynitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class AsynitCommand extends Command
{
private string $defaultBootstrapFilename = '';

/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this->defaultBootstrapFilename = getcwd().'/vendor/autoload.php';
Expand All @@ -35,9 +32,6 @@ protected function configure(): void
;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string $bootstrapFilename */
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiResponse extends HttpResponse implements \ArrayAccess
/**
* @var array<string, mixed>|null
*/
private array|null $data = null;
private ?array $data = null;

public function __construct(private readonly Response $response)
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public function hasHeader(string $name): bool
return $this->response->hasHeader($name);
}

public function getHeader(string $name): null|string
public function getHeader(string $name): ?string
{
return $this->response->getHeader($name);
}
Expand Down
14 changes: 7 additions & 7 deletions src/HttpClient/HttpClientApiCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ protected function getApiContentType(): string
return 'application/json';
}

final protected function get(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function get(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('GET', $uri, $headers, $json)));
}

final protected function post(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function post(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('POST', $uri, $headers, $json)));
}

final protected function patch(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function patch(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('PATCH', $uri, $headers, $json)));
}

final protected function put(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function put(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('PUT', $uri, $headers, $json)));
}

final protected function delete(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function delete(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('DELETE', $uri, $headers, $json)));
}

final protected function options(string $uri, array|null $json = null, array $headers = []): ApiResponse
final protected function options(string $uri, ?array $json = null, array $headers = []): ApiResponse
{
return new ApiResponse($this->sendRequest($this->createApiRequest('OPTIONS', $uri, $headers, $json)));
}

private function createApiRequest(string $method, string $uri, array $headers = [], array|null $json = null): Request
private function createApiRequest(string $method, string $uri, array $headers = [], ?array $json = null): Request
{
$request = new Request($uri, $method);
$request->addHeader('Content-Type', $this->getApiContentType());
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClient/HttpClientCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ trait HttpClientCaseTrait
{
use AssertWebCaseTrait;

private HttpClient|null $httpClient = null;
private ?HttpClient $httpClient = null;

private \Closure|null $configureRequest = null;
private ?\Closure $configureRequest = null;

protected $allowSelfSignedCertificate = false;

Expand Down Expand Up @@ -72,7 +72,7 @@ final public function setUpHttpClient(Test $test): void
*/
final protected function sendRequest(Request $request): Response
{
if ($this->configureRequest !== null) {
if (null !== $this->configureRequest) {
$configureRequest = $this->configureRequest;
$configureRequest($request);
}
Expand Down
Loading

0 comments on commit 044a20f

Please sign in to comment.