Skip to content

Commit ac3f4ba

Browse files
committed
Improve code styling
1 parent a198239 commit ac3f4ba

13 files changed

Lines changed: 72 additions & 48 deletions

File tree

src/Contract/ContractParser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ public static function substituteAliases(TypeNode $node, array $aliases): TypeNo
711711

712712
if ($node instanceof CallableTypeNode) {
713713
$parameters = array_map(
714-
fn(CallableTypeParameterNode $param) => new CallableTypeParameterNode(
714+
fn (CallableTypeParameterNode $param) => new CallableTypeParameterNode(
715715
self::substituteAliases($param->type, $aliases),
716716
$param->isReference,
717717
$param->isVariadic,
@@ -745,7 +745,7 @@ public static function substituteAliases(TypeNode $node, array $aliases): TypeNo
745745
if ($node instanceof GenericTypeNode) {
746746
$genericType = self::substituteAliases($node->type, $aliases);
747747
$genericTypes = array_map(
748-
fn($t) => self::substituteAliases($t, $aliases),
748+
fn ($t) => self::substituteAliases($t, $aliases),
749749
$node->genericTypes
750750
);
751751

@@ -762,14 +762,14 @@ public static function substituteAliases(TypeNode $node, array $aliases): TypeNo
762762

763763
if ($node instanceof UnionTypeNode) {
764764
return new UnionTypeNode(array_map(
765-
fn($t) => self::substituteAliases($t, $aliases),
765+
fn ($t) => self::substituteAliases($t, $aliases),
766766
$node->types
767767
));
768768
}
769769

770770
if ($node instanceof IntersectionTypeNode) {
771771
return new IntersectionTypeNode(array_map(
772-
fn($t) => self::substituteAliases($t, $aliases),
772+
fn ($t) => self::substituteAliases($t, $aliases),
773773
$node->types
774774
));
775775
}

src/Contract/DocblockExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,4 @@ public static function extractMagicMethodContract(string $doc, string $methodNam
424424

425425
return null;
426426
}
427-
}
427+
}

src/Resolver/SpecialTypeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,4 +1061,4 @@ private static function parseFileMetadata(string $fileName, string $source): voi
10611061
// Silently fall back to empty metadata if parsing fails
10621062
}
10631063
}
1064-
}
1064+
}

src/Validator/TypeValidatorRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ public function validate(mixed $value, TypeNode $node, string $context): ?ErrorM
8989

9090
return $err;
9191
}
92-
}
92+
}

tests/Contract/VendorIsolationPathTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
Config::set([
5454
'include' => [
5555
'src/**',
56-
'vendor/my-org/whitelisted-package/**',
56+
'vendor/my-org/whitelisted-package/**',
5757
],
5858
'exclude' => [
5959
'vendor/**',
@@ -80,7 +80,7 @@
8080
Config::set([
8181
'include' => [
8282
'src/**',
83-
'src/Core/Framework/**',
83+
'src/Core/Framework/**',
8484
'src/Core/Content/**',
8585
],
8686
'exclude' => [
@@ -97,7 +97,7 @@
9797
test('differentiates application folders from identical vendor folder names (e.g. lib/** in app vs lib/** in vendor)', function () {
9898
Config::set([
9999
'include' => [
100-
'lib/**',
100+
'lib/**',
101101
'modules/**',
102102
],
103103
'exclude' => [
@@ -118,4 +118,4 @@
118118
->and($refMethod->invoke(null, $vendorLibFile, $vendorLibFile))->toBeFalse()
119119
;
120120
});
121-
});
121+
});

tests/Fixtures/Shopware/Exception/BaseShopwareExceptionFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public function __construct(
1818
) {
1919
parent::__construct($message, 0, $e);
2020
}
21-
}
21+
}

tests/Fixtures/Shopware/Exception/TableHelperExceptionFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function __construct(
1212
) {
1313
parent::__construct($message, [], $previousException);
1414
}
15-
}
15+
}

tests/Internal/StreamWrapperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ function testGen(): Generator
5656
;
5757
});
5858

59-
test('strictly isolates vendor files with nested src directories when application includes specific src subpackages', function () {
59+
test('strictly isolates vendor files with nested src directories when application includes specific src subpackages', function () {
6060
Config::set([
6161
'include' => [
6262
'src/**',
63-
'src/Core/**',
63+
'src/Core/**',
6464
'src/Storefront/**',
6565
'src/Administration/**',
6666
],
6767
'exclude' => [
68-
'vendor/**',
68+
'vendor/**',
6969
'storage/**',
7070
'var/**',
7171
'cache/**',

tests/Resolver/TemplateManagerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@
231231
$variances = TemplateManager::getTemplateVariances($producer);
232232

233233
expect($variances)->toHaveKey('T')
234-
->and($variances['T'])->toBe('covariant');
234+
->and($variances['T'])->toBe('covariant')
235+
;
235236
});
236237
});
237238
});

tests/RuntimeChecker/InlineCheckerTest.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242

4343
$invalid = InlineChecker::checkVariable(-5, 'positive-int', 'age', __FILE__, $registry);
4444
expect($invalid)->toBeInstanceOf(ErrorMessage::class)
45-
->and($invalid->getMessage())->toContain('Variable $age must be of type positive-int');
45+
->and($invalid->getMessage())->toContain('Variable $age must be of type positive-int')
46+
;
4647
});
4748

4849
test('validates non-empty-string and numeric-string', function () {
@@ -77,7 +78,8 @@
7778
expect(InlineChecker::checkVariable([1, -5, 3], 'list<positive-int>', 'scores', __FILE__, $registry))->toBeInstanceOf(ErrorMessage::class);
7879

7980
expect(InlineChecker::checkVariable(['id' => 1, 'name' => 'Alice'], 'array{id: int, name: string}', 'user', __FILE__, $registry))
80-
->toBe(['id' => 1, 'name' => 'Alice']);
81+
->toBe(['id' => 1, 'name' => 'Alice'])
82+
;
8183

8284
expect(InlineChecker::checkVariable(['id' => 1], 'array{id: int, name: string}', 'user', __FILE__, $registry))->toBeInstanceOf(ErrorMessage::class);
8385
});
@@ -112,7 +114,8 @@
112114
$result = InlineChecker::checkVariable($collection, $typeString, 'dogs', __FILE__, $registry);
113115

114116
expect($result)->toBe($collection)
115-
->and(TypePHP::getGenericType($collection))->toBe(Dog::class);
117+
->and(TypePHP::getGenericType($collection))->toBe(Dog::class)
118+
;
116119
});
117120

118121
test('ignores object and generic checks when respective toggles are false', function () {
@@ -131,14 +134,15 @@
131134
describe('checkVariable: Callables & Direct Returns', function () {
132135
test('wraps callable variable in lazy proxy', function () {
133136
$registry = new TypeValidatorRegistry();
134-
$cb = fn(int $id): string => "user_{$id}";
137+
$cb = fn (int $id): string => "user_{$id}";
135138

136139
$wrapped = InlineChecker::checkVariable($cb, 'callable(positive-int): non-empty-string', 'formatter', __FILE__, $registry);
137140

138141
expect($wrapped)->toBeCallable()
139-
->and($wrapped(10))->toBe('user_10');
142+
->and($wrapped(10))->toBe('user_10')
143+
;
140144

141-
expect(fn() => $wrapped(-5))->toThrow(TypeError::class, 'positive-int');
145+
expect(fn () => $wrapped(-5))->toThrow(TypeError::class, 'positive-int');
142146
});
143147

144148
test('formats error message context as Return value when varName is return', function () {
@@ -147,7 +151,8 @@
147151
$invalid = InlineChecker::checkVariable(-5, 'positive-int', 'return', __FILE__, $registry);
148152

149153
expect($invalid)->toBeInstanceOf(ErrorMessage::class)
150-
->and($invalid->getMessage())->toContain('Return value must be of type positive-int');
154+
->and($invalid->getMessage())->toContain('Return value must be of type positive-int')
155+
;
151156
});
152157

153158
test('returns value immediately when all inline checks are disabled', function () {
@@ -181,7 +186,8 @@
181186

182187
$invalid = InlineChecker::checkProperty(['invalid'], $fixture, 'numbers', __FILE__, $registry);
183188
expect($invalid)->toBeInstanceOf(ErrorMessage::class)
184-
->and($invalid->getMessage())->toContain('numbers[0]');
189+
->and($invalid->getMessage())->toContain('numbers[0]')
190+
;
185191
});
186192

187193
test('validates static class properties against @var docblock', function () {
@@ -192,7 +198,8 @@
192198

193199
$invalid = InlineChecker::checkProperty(12345, ConfiguredProperty::class, 'staticTitle', __FILE__, $registry);
194200
expect($invalid)->toBeInstanceOf(ErrorMessage::class)
195-
->and($invalid->getMessage())->toContain('staticTitle must be of type string');
201+
->and($invalid->getMessage())->toContain('staticTitle must be of type string')
202+
;
196203
});
197204

198205
test('substitutes generic template types in class properties', function () {
@@ -205,14 +212,15 @@
205212
$registry = new TypeValidatorRegistry();
206213
$collection = new HookedCollection();
207214

208-
TemplateManager::bindTemplate(HookedCollection::class . '::__construct', $collection, 'T', new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(Dog::class));
215+
TemplateManager::bindTemplate(HookedCollection::class . '::__construct', $collection, 'T', new PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(Dog::class));
209216

210217
$valid = InlineChecker::checkProperty([new Dog()], $collection, 'items', __FILE__, $registry);
211218
expect($valid)->toBeArray();
212219

213220
$invalid = InlineChecker::checkProperty([new Car()], $collection, 'items', __FILE__, $registry);
214221
expect($invalid)->toBeInstanceOf(ErrorMessage::class)
215-
->and($invalid->getMessage())->toContain("items['0']");
222+
->and($invalid->getMessage())->toContain("items['0']")
223+
;
216224
});
217225

218226
test('ignores property checks when properties toggle is false', function () {

0 commit comments

Comments
 (0)