Skip to content

Commit

Permalink
Fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien-phi committed Jan 17, 2025
1 parent c4ac3b5 commit 4f4ab7f
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 49 deletions.
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidMethodException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class InvalidMethodException extends \Exception
{
}
class InvalidMethodException extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidPathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class InvalidPathException extends \Exception
{
}
class InvalidPathException extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exceptions/MalformedSpecException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class MalformedSpecException extends \Exception
{
}
class MalformedSpecException extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exceptions/MissingSpecException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class MissingSpecException extends \Exception
{
}
class MissingSpecException extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exceptions/RequestValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class RequestValidationException extends SchemaValidationException
{
}
class RequestValidationException extends SchemaValidationException {}
4 changes: 1 addition & 3 deletions src/Exceptions/ResponseValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Spectator\Exceptions;

class ResponseValidationException extends SchemaValidationException
{
}
class ResponseValidationException extends SchemaValidationException {}
4 changes: 2 additions & 2 deletions src/Exceptions/SchemaValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function withError(string $message, ValidationError $error): self
{
$instance = new static($message);

$formatter = new ErrorFormatter();
$formatter = new ErrorFormatter;

$instance->errors = $formatter->formatFlat($error);

Expand Down Expand Up @@ -113,7 +113,7 @@ public static function validationErrorMessage(stdClass $schema, ValidationError
*/
public static function formatValidationError(ValidationError $validationError, bool $flat = false): array
{
$formatter = new ErrorFormatter();
$formatter = new ErrorFormatter;

return ($flat) ? $formatter->formatFlat($validationError) :
$formatter->formatOutput($validationError, 'basic');
Expand Down
2 changes: 1 addition & 1 deletion src/SpectatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function registerMiddleware(): void

protected function decorateTestResponse(): void
{
TestResponse::mixin(new Assertions());
TestResponse::mixin(new Assertions);
}

protected function getConfigPath(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private function prepareProperty(stdClass $data, ?string $mode): stdClass
$data = $this->migrateNullableTo31Style($data);

if ($this->shouldHaveProperties($data)) {
$data->properties ??= new stdClass();
$data->properties ??= new stdClass;
}

match (true) {
Expand Down Expand Up @@ -105,7 +105,7 @@ function ($property) use ($filterBy) {
)
);

//Filter out properties from schema's properties.
// Filter out properties from schema's properties.
foreach ($filterProperties as $property) {
unset($data->properties->$property);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/RequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function validateParameters(): void
foreach ($parameters as $parameter) {
// Validate schemas, if provided.
if ($parameter->schema) {
$validator = new Validator();
$validator = new Validator;
$expectedParameterSchema = $parameter->schema->getSerializableData();
$result = null;
$parameterValue = null;
Expand Down Expand Up @@ -168,7 +168,7 @@ protected function validateBody(): void
$expectedBodySchema = $this->prepareData($expectedBodyRawSchema, 'write');

// Run validation.
$validator = new Validator();
$validator = new Validator;
$result = $validator->validate($actualBodySchema, $expectedBodySchema);

// If the result is not valid, then display failure reason.
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ResponseValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function validateResponse(Schema $schema, mixed $body): void
{
$expectedSchema = $this->prepareData($schema, 'read');

$validator = new Validator();
$validator = new Validator;
$result = $validator->validate($body, $expectedSchema);

if ($result->isValid() === false) {
Expand Down Expand Up @@ -169,7 +169,7 @@ protected function streamedContent(): string
return '';
});

($this->response->getCallback()?? fn() => null)();
($this->response->getCallback() ?? fn () => null)();

ob_end_clean();

Expand Down
2 changes: 1 addition & 1 deletion tests/AssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class AssertionsTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class MiddlewareTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand Down
18 changes: 9 additions & 9 deletions tests/RequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function test_sets_and_gets_spec_name()
{
$name = 'Test.v1.json';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -24,7 +24,7 @@ public function test_resets_spec_name()
{
$name = 'Test.v1.json';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -37,7 +37,7 @@ public function test_resolves_yaml_spec()
{
$name = 'Test.v1.yaml';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -51,7 +51,7 @@ public function test_resolves_yml_spec()
{
$name = 'Test.v1.yml';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -65,7 +65,7 @@ public function test_resolves_json_spec()
{
$name = 'Test.v1.json';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -84,7 +84,7 @@ public function test_throws_exception_on_invalid_source()

$name = 'Test.v1.json';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -96,7 +96,7 @@ public function test_throws_exception_on_missing_spec_name()
$this->expectException(MissingSpecException::class);
$this->expectExceptionMessage('Cannot resolve schema with missing or invalid spec.');

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->resolve();
}
Expand All @@ -108,7 +108,7 @@ public function test_throws_exception_on_invalid_spec_name()

$name = 'Missing.v1.json';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand All @@ -122,7 +122,7 @@ public function test_throws_exception_on_invalid_spec_extension()

$name = 'Invalid.v1.txt';

$factory = new RequestFactory();
$factory = new RequestFactory;

$factory->using($name);

Expand Down
10 changes: 5 additions & 5 deletions tests/RequestValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class RequestValidatorTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -296,7 +296,7 @@ public static function nullableProvider(): array
* @dataProvider oneOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_oneOf($payload, $isValid): void
public function test_handles_one_of($payload, $isValid): void
{
Spectator::using('OneOf.v1.yml');

Expand Down Expand Up @@ -356,7 +356,7 @@ public static function oneOfSchemaProvider(): array
* @dataProvider anyOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_anyOf($payload, $isValid): void
public function test_handles_any_of($payload, $isValid): void
{
Spectator::using('AnyOf.v1.yml');

Expand Down Expand Up @@ -414,7 +414,7 @@ public static function anyOfSchemaProvider(): array
* @dataProvider allOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_allOf($payload, $isValid): void
public function test_handles_all_of($payload, $isValid): void
{
Spectator::using('AllOf.v1.yml');

Expand Down Expand Up @@ -909,7 +909,7 @@ class TestUser extends Model
{
public function resolveRouteBinding($value, $field = null)
{
return new TestUser();
return new TestUser;
}
}

Expand Down
12 changes: 6 additions & 6 deletions tests/ResponseValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class ResponseValidatorTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -326,7 +326,7 @@ public function test_validates_problem_json_response_using_components()
->assertValidResponse(404);
}

public function test_fallback_to_request_uri_if_operationId_not_given(): void
public function test_fallback_to_request_uri_if_operation_id_not_given(): void
{
Spectator::using('Test.v1.json');

Expand Down Expand Up @@ -606,7 +606,7 @@ public static function nullableArrayOfNullableStringsProvider()
* @dataProvider oneOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_oneOf($response, $valid): void
public function test_handles_one_of($response, $valid): void
{
Spectator::using('OneOf.v1.yml');

Expand Down Expand Up @@ -671,7 +671,7 @@ public static function oneOfSchemaProvider(): array
* @dataProvider anyOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_anyOf($response, $isValid): void
public function test_handles_any_of($response, $isValid): void
{
Spectator::using('AnyOf.v1.yml');

Expand Down Expand Up @@ -733,7 +733,7 @@ public static function anyOfSchemaProvider(): array
* @dataProvider allOfSchemaProvider
*/
// https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
public function test_handles_allOf($response, $isValid): void
public function test_handles_all_of($response, $isValid): void
{
Spectator::using('AllOf.v1.yml');

Expand Down Expand Up @@ -804,7 +804,7 @@ public static function allOfSchemaProvider(): array
/**
* @dataProvider allOfWithNullableProvider
*/
public function test_handles_allOf_with_nullable($payload, $isValid): void
public function test_handles_all_of_with_nullable($payload, $isValid): void
{
Spectator::using('AllOf.v1.yml');

Expand Down

0 comments on commit 4f4ab7f

Please sign in to comment.