Skip to content

Commit 92964c9

Browse files
committed
Update + fix CI
1 parent 98edf7f commit 92964c9

8 files changed

Lines changed: 43 additions & 33 deletions

File tree

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"symfony/http-kernel": "^7.2"
1818
},
1919
"require-dev": {
20-
"21torr/janus": "^1.4",
21-
"bamarni/composer-bin-plugin": "^1.8",
20+
"21torr/janus": "^1.5.1",
21+
"bamarni/composer-bin-plugin": "^1.8.2",
2222
"doctrine/common": "^3.5",
23-
"roave/security-advisories": "dev-latest",
24-
"phpunit/phpunit": "^12.2.5"
23+
"phpunit/phpunit": "^12.2.5",
24+
"roave/security-advisories": "dev-latest"
2525
},
2626
"autoload": {
2727
"psr-4": {
@@ -35,6 +35,7 @@
3535
},
3636
"config": {
3737
"allow-plugins": {
38+
"21torr/janus": true,
3839
"bamarni/composer-bin-plugin": true
3940
},
4041
"sort-packages": true
@@ -48,11 +49,11 @@
4849
"scripts": {
4950
"fix-lint": [
5051
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi",
51-
"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"
52+
"PHP_CS_FIXER_IGNORE_ENV=1 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"
5253
],
5354
"lint": [
5455
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi",
55-
"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"
56+
"PHP_CS_FIXER_IGNORE_ENV=1 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"
5657
],
5758
"test": [
5859
"phpunit",

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
includes:
22
- vendor/21torr/janus/phpstan/lib.neon
3+
4+
parameters:
5+
6+
# These are temporarily copied here, as normally they should be in the lib.neon of janus.
7+
# However, due to a bug in PHPStan, this currently doesn't work (https://github.com/phpstan/phpstan/issues/12844)
8+
excludePaths:
9+
analyse:
10+
- vendor
11+
analyseAndScan:
12+
- node_modules (?)
13+
- var (?)
14+
- vendor-bin

src/Normalizer/SimpleNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* = the object normalizers), as this way we can provide a full path to the invalid element in the JSON.
1919
*
2020
* @readonly
21+
*
2122
* @final
2223
*/
2324
class SimpleNormalizer
@@ -44,6 +45,7 @@ public function normalize (mixed $value, array $context = []) : mixed
4445

4546
return $normalizedValue;
4647
}
48+
4749
/**
4850
*/
4951
public function normalizeArray (array $array, array $context = []) : array
@@ -75,8 +77,6 @@ public function normalizeMap (array $array, array $context = []) : array|\stdCla
7577
return $normalizedValue;
7678
}
7779

78-
79-
8080
/**
8181
* The actual normalize logic, that recursively normalizes the value.
8282
* It must never call one of the public methods above and just normalizes the value.

src/Normalizer/Validator/ValidJsonVerifier.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function ensureValidOnlyJsonTypes (mixed $value) : void
2121
if (null !== $invalidElement)
2222
{
2323
throw new IncompleteNormalizationException(
24-
sprintf(
24+
\sprintf(
2525
"Found a JSON-incompatible value when normalizing. Found '%s' at path '%s', but expected only scalars, arrays and empty objects.",
2626
get_debug_type($invalidElement->value),
2727
implode(".", $invalidElement->path),
@@ -30,12 +30,11 @@ public function ensureValidOnlyJsonTypes (mixed $value) : void
3030
}
3131
}
3232

33-
3433
/**
3534
* Searches through the value and looks for anything that isn't valid JSON
3635
* (scalars, arrays or empty objects).
3736
*
38-
* @return InvalidJsonElement|null Returns null if everything is valid, otherwise the invalid value.
37+
* @return InvalidJsonElement|null returns null if everything is valid, otherwise the invalid value
3938
*/
4039
private function findInvalidJsonElement (mixed $value, array $path = ["$"]) : ?InvalidJsonElement
4140
{
@@ -46,14 +45,14 @@ private function findInvalidJsonElement (mixed $value, array $path = ["$"]) : ?I
4645
}
4746

4847
// only empty stdClass objects are allowed (as they are used to serialize to `{}`)
49-
if (is_object($value))
48+
if (\is_object($value))
5049
{
5150
return $value instanceof \stdClass && [] === get_object_vars($value)
5251
? null
5352
: new InvalidJsonElement($value, $path);
5453
}
5554

56-
if (is_array($value))
55+
if (\is_array($value))
5756
{
5857
foreach ($value as $key => $item)
5958
{

tests/Normalizer/SimpleNormalizerTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
namespace Tests\Torr\SimpleNormalizer\Normalizer;
44

55
use PHPUnit\Framework\Attributes\DataProvider;
6+
use PHPUnit\Framework\TestCase;
67
use Symfony\Component\DependencyInjection\ServiceLocator;
78
use Tests\Torr\SimpleNormalizer\Fixture\DummyVO;
89
use Torr\SimpleNormalizer\Exception\IncompleteNormalizationException;
910
use Torr\SimpleNormalizer\Normalizer\SimpleNormalizer;
10-
use PHPUnit\Framework\TestCase;
1111
use Torr\SimpleNormalizer\Normalizer\SimpleObjectNormalizerInterface;
1212
use Torr\SimpleNormalizer\Normalizer\Validator\ValidJsonVerifier;
1313

14-
class SimpleNormalizerTest extends TestCase
14+
/**
15+
* @internal
16+
*/
17+
final class SimpleNormalizerTest extends TestCase
1518
{
1619
/**
1720
*
@@ -40,7 +43,7 @@ public function testJsonVerifierEnabled (callable $call) : void
4043
$verifier = $this->createMock(ValidJsonVerifier::class);
4144

4245
$verifier
43-
->expects($this->once())
46+
->expects(self::once())
4447
->method('ensureValidOnlyJsonTypes');
4548

4649
$normalizer = new SimpleNormalizer(
@@ -59,7 +62,6 @@ public function testJsonVerifierEnabled (callable $call) : void
5962
]);
6063
}
6164

62-
6365
/**
6466
*
6567
*/
@@ -68,7 +70,7 @@ public function testJsonVerifierDisabled () : void
6870
$verifier = $this->createMock(ValidJsonVerifier::class);
6971

7072
$verifier
71-
->expects($this->never())
73+
->expects(self::never())
7274
->method('ensureValidOnlyJsonTypes');
7375

7476
$normalizer = new SimpleNormalizer(
@@ -83,7 +85,6 @@ public function testJsonVerifierDisabled () : void
8385
self::assertTrue(true); // Just to ensure the test runs without exceptions
8486
}
8587

86-
8788
/**
8889
*
8990
*/
@@ -100,7 +101,6 @@ public function testInvalidNormalizer () : void
100101
$normalizer->normalize(new DummyVO(42));
101102
}
102103

103-
104104
/**
105105
*
106106
*/
@@ -124,15 +124,13 @@ public function testInvalidNestedNormalizer () : void
124124
]);
125125
}
126126

127-
128127
/**
129-
*
128+
* @return ServiceLocator<mixed>
130129
*/
131130
private function createNormalizerObjectNormalizers (mixed $returnValue) : ServiceLocator
132131
{
133132
return new ServiceLocator([
134-
DummyVO::class => static fn () => new readonly class ($returnValue) implements SimpleObjectNormalizerInterface
135-
{
133+
DummyVO::class => static fn () => new readonly class($returnValue) implements SimpleObjectNormalizerInterface {
136134
public function __construct (
137135
private mixed $returnValue,
138136
) {}

vendor-bin/c-norm/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require-dev": {
3-
"ergebnis/composer-normalize": "^2.42",
3+
"ergebnis/composer-normalize": "^2.47",
44
"roave/security-advisories": "dev-latest"
55
},
66
"config": {

vendor-bin/cs-fixer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require-dev": {
3-
"21torr/php-cs-fixer": "^1.1.1",
3+
"21torr/php-cs-fixer": "^1.1.5",
44
"roave/security-advisories": "dev-latest"
55
}
66
}

vendor-bin/phpstan/composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"php": "^8.3"
44
},
55
"require-dev": {
6-
"phpstan/extension-installer": "^1.3.1",
7-
"phpstan/phpstan": "^1.11",
8-
"phpstan/phpstan-deprecation-rules": "^1.2",
9-
"phpstan/phpstan-doctrine": "^1.4",
10-
"phpstan/phpstan-phpunit": "^1.4",
11-
"phpstan/phpstan-symfony": "^1.4",
6+
"phpstan/extension-installer": "^1.4.2",
7+
"phpstan/phpstan": "^2.1.11",
8+
"phpstan/phpstan-deprecation-rules": "^2.0.1",
9+
"phpstan/phpstan-doctrine": "^2.0.2",
10+
"phpstan/phpstan-phpunit": "^2.0.6",
11+
"phpstan/phpstan-symfony": "^2.0.4",
1212
"roave/security-advisories": "dev-latest",
13-
"staabm/phpstan-todo-by": "^0.1.25"
13+
"staabm/phpstan-todo-by": "^0.2"
1414
},
1515
"config": {
1616
"sort-packages": true,

0 commit comments

Comments
 (0)