Skip to content

Commit

Permalink
ci: apply rector/rector upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Jun 13, 2024
1 parent db21346 commit ea21156
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 88 deletions.
42 changes: 41 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<code><![CDATA[string]]></code>
</ImplicitToStringCast>
<InvalidDocblock>
<code><![CDATA[private SerializerInterface $serializer;]]></code>
<code><![CDATA[private readonly SerializerInterface $serializer;]]></code>
</InvalidDocblock>
<MixedAssignment>
<code><![CDATA[$normalizedResponse]]></code>
Expand Down Expand Up @@ -149,6 +149,21 @@
<code><![CDATA[bound]]></code>
<code><![CDATA[bound]]></code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code><![CDATA[it_registers_config]]></code>
<code><![CDATA[it_registers_encoders_registry]]></code>
<code><![CDATA[it_registers_normalizers_registry]]></code>
<code><![CDATA[it_registers_serializer]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/EncodersRegistryTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[all]]></code>
<code><![CDATA[construct_with_default_encoders]]></code>
<code><![CDATA[construct_with_encoders]]></code>
<code><![CDATA[has]]></code>
<code><![CDATA[register]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/Normalizers/RamseyUuidNormalizerTest.php">
<MixedArgument>
Expand All @@ -167,13 +182,21 @@
<code><![CDATA[get]]></code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code><![CDATA[serialize]]></code>
<code><![CDATA[serializeDataProvider]]></code>
<code><![CDATA[unserialize]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/NormalizersRegistryTest.php">
<MixedAssignment>
<code><![CDATA[$element]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[all]]></code>
<code><![CDATA[construct_with_default_normalizers]]></code>
<code><![CDATA[has]]></code>
<code><![CDATA[register]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/ResponseFactoryTest.php">
<MixedArgument>
Expand All @@ -183,6 +206,13 @@
<code><![CDATA[app(SerializerManager::class)]]></code>
<code><![CDATA[app(SerializerManager::class)]]></code>
</MixedArgument>
<PossiblyUnusedMethod>
<code><![CDATA[it_creates_from_array_iterator]]></code>
<code><![CDATA[it_creates_response]]></code>
<code><![CDATA[it_creates_response_from_array]]></code>
<code><![CDATA[it_sets_non_default_status_code]]></code>
<code><![CDATA[it_uses_given_context]]></code>
</PossiblyUnusedMethod>
</file>
<file src="tests/src/Functional/SerializerManagerTest.php">
<MixedAssignment>
Expand All @@ -192,7 +222,11 @@
<code><![CDATA[make]]></code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code><![CDATA[bad_serializer]]></code>
<code><![CDATA[get_serializer]]></code>
<code><![CDATA[serialize]]></code>
<code><![CDATA[serializeDataProvider]]></code>
<code><![CDATA[unserialize]]></code>
<code><![CDATA[unserializeDataProvider]]></code>
</PossiblyUnusedMethod>
</file>
Expand Down Expand Up @@ -227,7 +261,13 @@
<code><![CDATA[get]]></code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code><![CDATA[group_normalize]]></code>
<code><![CDATA[serialize]]></code>
<code><![CDATA[serializeDataProvider]]></code>
<code><![CDATA[unserialize]]></code>
<code><![CDATA[unserialize_date_time_interface]]></code>
<code><![CDATA[unserialize_nested_objects]]></code>
<code><![CDATA[unserialize_with_attributes]]></code>
</PossiblyUnusedMethod>
</file>
</files>
2 changes: 1 addition & 1 deletion src/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ResponseFactory
/**
* @property SerializerInterface $serializer
*/
private SerializerInterface $serializer;
private readonly SerializerInterface $serializer;

private array $context = [];

Expand Down
2 changes: 1 addition & 1 deletion tests/app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class Item
{
#[Groups(['default', 'private'])]
private UuidInterface $id;
private readonly UuidInterface $id;

#[Groups(['default'])]
private string $key = 'magic_number';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace WayOfDev\Tests\Functional\Bridge\Laravel\Providers;

use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use WayOfDev\Serializer\Config;
Expand All @@ -16,36 +17,28 @@

final class SerializerServiceProviderTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_registers_config(): void
{
self::assertTrue($this->app->bound(ConfigRepository::class));
self::assertInstanceOf(Config::class, $this->app->make(ConfigRepository::class));
}

/**
* @test
*/
#[Test]
public function it_registers_normalizers_registry(): void
{
self::assertTrue($this->app->bound(NormalizersRegistryInterface::class));
self::assertInstanceOf(NormalizersRegistry::class, $this->app->make(NormalizersRegistryInterface::class));
}

/**
* @test
*/
#[Test]
public function it_registers_encoders_registry(): void
{
self::assertTrue($this->app->bound(EncodersRegistryInterface::class));
self::assertInstanceOf(EncodersRegistry::class, $this->app->make(EncodersRegistryInterface::class));
}

/**
* @test
*/
#[Test]
public function it_registers_serializer(): void
{
self::assertTrue($this->app->bound(SerializerInterface::class));
Expand Down
20 changes: 6 additions & 14 deletions tests/src/Functional/EncodersRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace WayOfDev\Tests\Functional;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\Exception;
use Symfony\Component\Serializer\Encoder\CsvEncoder;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
Expand All @@ -14,9 +15,7 @@

final class EncodersRegistryTest extends TestCase
{
/**
* @test
*/
#[Test]
public function construct_with_default_encoders(): void
{
$registry = new EncodersRegistry();
Expand All @@ -29,9 +28,7 @@ public function construct_with_default_encoders(): void
self::assertTrue($registry->has(YamlEncoder::class));
}

/**
* @test
*/
#[Test]
public function construct_with_encoders(): void
{
$registry = new EncodersRegistry([new JsonEncoder(), new CsvEncoder()]);
Expand All @@ -44,9 +41,7 @@ public function construct_with_encoders(): void
self::assertFalse($registry->has(YamlEncoder::class));
}

/**
* @test
*/
#[Test]
public function register(): void
{
$registry = new EncodersRegistry();
Expand All @@ -63,9 +58,7 @@ public function register(): void
self::assertTrue($registry->has($encoder::class));
}

/**
* @test
*/
#[Test]
public function all(): void
{
$json = new JsonEncoder();
Expand All @@ -76,10 +69,9 @@ public function all(): void
}

/**
* @test
*
* @throws Exception
*/
#[Test]
public function has(): void
{
$encoder = $this->createMock(EncoderInterface::class);
Expand Down
9 changes: 3 additions & 6 deletions tests/src/Functional/Normalizers/RamseyUuidNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WayOfDev\Tests\Functional\Normalizers;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Ramsey\Uuid\Uuid;
use Traversable;
use WayOfDev\App\Object\Author;
Expand Down Expand Up @@ -34,20 +35,16 @@ public static function serializeDataProvider(): Traversable
];
}

/**
* @test
*/
#[DataProvider('serializeDataProvider')]
#[Test]
public function serialize(string $expected, mixed $payload, string $format): void
{
$manager = $this->app->get(SerializerManager::class);

self::assertSame($expected, preg_replace('/\s+/', '', $manager->serialize($payload, $format)));
}

/**
* @test
*/
#[Test]
public function unserialize(): void
{
$manager = $this->app->get(SerializerManager::class);
Expand Down
13 changes: 5 additions & 8 deletions tests/src/Functional/NormalizersRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace WayOfDev\Tests\Functional;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\Exception;
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
use Symfony\Component\Serializer\Normalizer;
Expand Down Expand Up @@ -34,10 +35,9 @@ public static function assertContainsInstanceOf(string $className, array $array)
}

/**
* @test
*
* @throws Exception
*/
#[Test]
public function construct_with_default_normalizers(): void
{
$registry = new NormalizersRegistry(
Expand Down Expand Up @@ -65,10 +65,9 @@ public function construct_with_default_normalizers(): void
}

/**
* @test
*
* @throws Exception
*/
#[Test]
public function register(): void
{
$registry = new NormalizersRegistry(
Expand All @@ -92,10 +91,9 @@ public function register(): void
}

/**
* @test
*
* @throws Exception
*/
#[Test]
public function all(): void
{
$registry = new NormalizersRegistry(
Expand All @@ -111,10 +109,9 @@ public function all(): void
}

/**
* @test
*
* @throws Exception
*/
#[Test]
public function has(): void
{
$normalizer = $this->createMock(Normalizer\NormalizerInterface::class);
Expand Down
21 changes: 6 additions & 15 deletions tests/src/Functional/ResponseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace WayOfDev\Tests\Functional;

use PHPUnit\Framework\Attributes\Test;
use WayOfDev\App\Item;
use WayOfDev\App\Object\Post;
use WayOfDev\App\Response;
Expand All @@ -12,9 +13,7 @@

final class ResponseFactoryTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_creates_response(): void
{
$responseFactory = new ResponseFactory(app(SerializerManager::class));
Expand All @@ -29,9 +28,7 @@ public function it_creates_response(): void
self::assertEquals('{"id":1,"text":"Some text","active":true,"views":777}', $response->getContent());
}

/**
* @test
*/
#[Test]
public function it_creates_from_array_iterator(): void
{
$responseFactory = new ResponseFactory(app(SerializerManager::class));
Expand All @@ -42,9 +39,7 @@ public function it_creates_from_array_iterator(): void
self::assertEquals('[{"id":"0cd74c72-8920-4e4e-86c3-19fdd5103514","key":"magic_number","value":12}]', $response->getContent());
}

/**
* @test
*/
#[Test]
public function it_creates_response_from_array(): void
{
$responseFactory = new ResponseFactory(app(SerializerManager::class));
Expand All @@ -57,9 +52,7 @@ public function it_creates_response_from_array(): void
);
}

/**
* @test
*/
#[Test]
public function it_sets_non_default_status_code(): void
{
$responseFactory = new ResponseFactory(app(SerializerManager::class));
Expand All @@ -71,9 +64,7 @@ public function it_sets_non_default_status_code(): void
self::assertEquals('{"id":"0cd74c72-8920-4e4e-86c3-19fdd5103514","key":"magic_number","value":12}', $response->getContent());
}

/**
* @test
*/
#[Test]
public function it_uses_given_context(): void
{
$responseFactory = new ResponseFactory(app(SerializerManager::class));
Expand Down
Loading

0 comments on commit ea21156

Please sign in to comment.