Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelbox committed Jun 26, 2024
1 parent 4687b76 commit c737bed
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 81 deletions.
120 changes: 60 additions & 60 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
{
"name": "21torr/simple-normalizer",
"description": "A simple and fast normalizer bundle for Symfony.",
"license": "MIT",
"type": "symfony-bundle",
"authors": [
{
"name": "21TORR",
"homepage": "https://www.21torr.com/"
}
],
"homepage": "https://github.com/21TORR/simple-normalizer",
"require": {
"php": ">= 8.3",
"21torr/bundle-helpers": "^2.1",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"require-dev": {
"21torr/janus": "^1.3",
"bamarni/composer-bin-plugin": "^1.8",
"doctrine/common": "^3.4",
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^7.0"
},
"autoload": {
"psr-4": {
"Torr\\SimpleNormalizer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Torr\\SimpleNormalizer\\": "tests/"
}
},
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true
},
"sort-packages": true
},
"extra": {
"bamarni-bin": {
"bin-links": false,
"forward-command": true
}
},
"scripts": {
"fix-lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi",
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
],
"lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi",
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
],
"test": [
"simple-phpunit",
"vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v"
]
}
"name": "21torr/simple-normalizer",
"description": "A simple and fast normalizer bundle for Symfony.",
"license": "MIT",
"type": "symfony-bundle",
"authors": [
{
"name": "21TORR",
"homepage": "https://www.21torr.com/"
}
],
"homepage": "https://github.com/21TORR/simple-normalizer",
"require": {
"php": ">= 8.3",
"21torr/bundle-helpers": "^2.1",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"require-dev": {
"21torr/janus": "^1.3",
"bamarni/composer-bin-plugin": "^1.8",
"doctrine/common": "^3.4",
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^7.0"
},
"autoload": {
"psr-4": {
"Torr\\SimpleNormalizer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Torr\\SimpleNormalizer\\": "tests/"
}
},
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true
},
"sort-packages": true
},
"extra": {
"bamarni-bin": {
"bin-links": false,
"forward-command": true
}
},
"scripts": {
"fix-lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi",
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
],
"lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi",
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
],
"test": [
"simple-phpunit",
"vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v"
]
}
}
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ includes:

# If you use simple-phpunit, you need to uncomment the following line.
# Always make sure to first run simple-phpunit and then PHPStan.
# parameters:
# bootstrapFiles:
# - vendor/bin/.phpunit/phpunit/vendor/autoload.php
parameters:
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
1 change: 1 addition & 0 deletions src/Normalizer/SimpleNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
readonly class SimpleNormalizer
{
/**
* @param ServiceLocator<SimpleObjectNormalizerInterface> $objectNormalizers
*/
public function __construct (
private ServiceLocator $objectNormalizers,
Expand Down
15 changes: 9 additions & 6 deletions tests/Normalizer/ArrayNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use PHPUnit\Framework\TestCase;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;

/**
* @internal
*/
final class ArrayNormalizerTest extends TestCase
{
use SimpleNormalizerTestTrait;

/**
*
*/
public function provideListArray () : iterable
public static function provideListArray () : iterable
{
yield [[1, 2, 3, 4], [1, 2, 3, 4]];
yield [[1, null, 3, null], [1, 3]];
Expand All @@ -28,14 +31,14 @@ public function testListArray (array $input, array $expected) : void
$normalizer = $this->createNormalizer();
$actual = $normalizer->normalize($input);

self::assertEquals($expected, $actual);
self::assertTrue(\array_is_list($actual));
self::assertSame($expected, $actual);
self::assertTrue(array_is_list($actual));
}

/**
*
*/
public function provideAssociativeArray () : iterable
public static function provideAssociativeArray () : iterable
{
yield [["a" => 1, "b" => 2, "c" => 3, "d" => 4], ["a" => 1, "b" => 2, "c" => 3, "d" => 4]];
yield [["a" => 1, "b" => null, "c" => 3, "d" => null], ["a" => 1, "b" => null, "c" => 3, "d" => null]];
Expand All @@ -50,7 +53,7 @@ public function testAssociativeArray (array $input, array $expected) : void
$normalizer = $this->createNormalizer();
$actual = $normalizer->normalize($input);

self::assertEquals($expected, $actual);
self::assertFalse(\array_is_list($actual));
self::assertSame($expected, $actual);
self::assertFalse(array_is_list($actual));
}
}
9 changes: 6 additions & 3 deletions tests/Normalizer/BasicTypesNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
namespace Tests\Torr\SimpleNormalizer\Normalizer;

use PHPUnit\Framework\TestCase;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;
use Torr\SimpleNormalizer\Exception\UnsupportedTypeException;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;

/**
* @internal
*/
final class BasicTypesNormalizerTest extends TestCase
{
use SimpleNormalizerTestTrait;

/**
*
*/
public function provideBasicValue () : iterable
public static function provideBasicValue () : iterable
{
yield [null, null];
yield [5, 5];
Expand All @@ -34,7 +37,7 @@ public function testBasicValue (mixed $input, mixed $expected) : void
/**
*
*/
public function provideInvalidValue () : iterable
public static function provideInvalidValue () : iterable
{
yield [fopen("php://memory", "rb")];
}
Expand Down
8 changes: 5 additions & 3 deletions tests/Normalizer/MapNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
use Symfony\Component\DependencyInjection\ServiceLocator;
use Torr\SimpleNormalizer\Normalizer\SimpleNormalizer;

/**
* @internal
*/
final class MapNormalizerTest extends TestCase
{
/**
*
*/
public function testNonEmptyMap () : void
{

$normalizer = new SimpleNormalizer(new ServiceLocator([]));
$result = $normalizer->normalizeMap([
"o" => "hai",
], []);

self::assertSame('{"o":"hai"}', \json_encode($result));
self::assertSame('{"o":"hai"}', json_encode($result));
}

/**
Expand All @@ -30,6 +32,6 @@ public function testEmptyMap () : void
$normalizer = new SimpleNormalizer(new ServiceLocator([]));
$result = $normalizer->normalizeMap([], []);

self::assertSame('{}', \json_encode($result));
self::assertSame('{}', json_encode($result));
}
}
11 changes: 7 additions & 4 deletions tests/Normalizer/ObjectNormalizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use PHPUnit\Framework\TestCase;
use Tests\Torr\SimpleNormalizer\Fixture\DummyVO;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;
use Torr\SimpleNormalizer\Exception\ObjectTypeNotSupportedException;
use Torr\SimpleNormalizer\Normalizer\SimpleNormalizer;
use Torr\SimpleNormalizer\Normalizer\SimpleObjectNormalizerInterface;
use Torr\SimpleNormalizer\Test\SimpleNormalizerTestTrait;

/**
* @internal
*/
final class ObjectNormalizationTest extends TestCase
{
use SimpleNormalizerTestTrait;
Expand All @@ -18,11 +21,11 @@ final class ObjectNormalizationTest extends TestCase
*/
public function testNormalizeObject () : void
{
$dummyNormalizer = new class implements SimpleObjectNormalizerInterface
{
$dummyNormalizer = new class() implements SimpleObjectNormalizerInterface {
public function normalize (object $value, array $context, SimpleNormalizer $normalizer) : mixed
{
\assert($value instanceof DummyVO);

return [
"id" => $value->id,
];
Expand All @@ -37,7 +40,7 @@ public static function getNormalizedType () : string
$value = new DummyVO(42);
$normalizer = $this->createNormalizer($dummyNormalizer);

self::assertEquals(["id" => 42], $normalizer->normalize($value));
self::assertSame(["id" => 42], $normalizer->normalize($value));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Torr\SimpleNormalizer\Normalizer\SimpleNormalizer;
use Torr\SimpleNormalizer\Normalizer\SimpleObjectNormalizerInterface;

/**
* @internal
*/
final class ValueWithContextNormalizerTest extends TestCase
{
/**
Expand Down Expand Up @@ -37,8 +40,8 @@ public function testContextPassing () : void
);

$normalizer = new SimpleNormalizer(new ServiceLocator([
ValueWithContext::class => fn () => new ValueWithContextNormalizer(),
DummyVO::class => fn () => $dummyNormalizer,
ValueWithContext::class => static fn () => new ValueWithContextNormalizer(),
DummyVO::class => static fn () => $dummyNormalizer,
]));

$normalizer->normalize($value, [
Expand Down

0 comments on commit c737bed

Please sign in to comment.