Skip to content

Commit 6007c11

Browse files
committed
Fix CS
1 parent 08dbe82 commit 6007c11

File tree

7 files changed

+60
-90
lines changed

7 files changed

+60
-90
lines changed

tests/PHPStan/Reflection/GenericParametersAcceptorResolverTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ class GenericParametersAcceptorResolverTest extends PHPStanTestCase
2929
*/
3030
public function dataResolve(): array
3131
{
32-
$templateType = static function (string $name, ?Type $type = null): Type {
33-
/** @var non-empty-string $name */
34-
return TemplateTypeFactory::create(
35-
TemplateTypeScope::createWithFunction('a'),
36-
$name,
37-
$type,
38-
TemplateTypeVariance::createInvariant(),
39-
);
40-
};
32+
$templateType = static fn ($name, ?Type $type = null): Type => TemplateTypeFactory::create(
33+
TemplateTypeScope::createWithFunction('a'),
34+
$name,
35+
$type,
36+
TemplateTypeVariance::createInvariant(),
37+
);
4138

4239
return [
4340
'one param, one arg' => [

tests/PHPStan/Type/ArrayTypeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,12 @@ public function testDescribe(
179179

180180
public function dataInferTemplateTypes(): array
181181
{
182-
$templateType = static function (string $name): Type {
183-
/** @var non-empty-string $name */
184-
return TemplateTypeFactory::create(
185-
TemplateTypeScope::createWithFunction('a'),
186-
$name,
187-
new MixedType(),
188-
TemplateTypeVariance::createInvariant(),
189-
);
190-
};
182+
$templateType = static fn ($name): Type => TemplateTypeFactory::create(
183+
TemplateTypeScope::createWithFunction('a'),
184+
$name,
185+
new MixedType(),
186+
TemplateTypeVariance::createInvariant(),
187+
);
191188

192189
return [
193190
'valid templated item' => [

tests/PHPStan/Type/CallableTypeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,12 @@ public function dataInferTemplateTypes(): array
177177
null,
178178
);
179179

180-
$templateType = static function (string $name): Type {
181-
/** @var non-empty-string $name */
182-
return TemplateTypeFactory::create(
183-
TemplateTypeScope::createWithFunction('a'),
184-
$name,
185-
new MixedType(),
186-
TemplateTypeVariance::createInvariant(),
187-
);
188-
};
180+
$templateType = static fn ($name): Type => TemplateTypeFactory::create(
181+
TemplateTypeScope::createWithFunction('a'),
182+
$name,
183+
new MixedType(),
184+
TemplateTypeVariance::createInvariant(),
185+
);
189186

190187
return [
191188
'template param' => [

tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,12 @@ public function testIsSuperTypeOf(ConstantArrayType $type, Type $otherType, Trin
610610

611611
public function dataInferTemplateTypes(): array
612612
{
613-
$templateType = static function (string $name): Type {
614-
/** @var non-empty-string $name */
615-
return TemplateTypeFactory::create(
616-
TemplateTypeScope::createWithFunction('a'),
617-
$name,
618-
new MixedType(),
619-
TemplateTypeVariance::createInvariant(),
620-
);
621-
};
613+
$templateType = static fn ($name): Type => TemplateTypeFactory::create(
614+
TemplateTypeScope::createWithFunction('a'),
615+
$name,
616+
new MixedType(),
617+
TemplateTypeVariance::createInvariant(),
618+
);
622619

623620
return [
624621
'receive constant array' => [

tests/PHPStan/Type/Generic/GenericObjectTypeTest.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,12 @@ public function testAccepts(
351351
/** @return array<string,array{Type,Type,array<string,string>}> */
352352
public function dataInferTemplateTypes(): array
353353
{
354-
$templateType = static function (string $name, ?Type $bound = null): Type {
355-
/** @var non-empty-string $name */
356-
return TemplateTypeFactory::create(
357-
TemplateTypeScope::createWithFunction('a'),
358-
$name,
359-
$bound ?? new MixedType(),
360-
TemplateTypeVariance::createInvariant(),
361-
);
362-
};
354+
$templateType = static fn ($name, ?Type $bound = null): Type => TemplateTypeFactory::create(
355+
TemplateTypeScope::createWithFunction('a'),
356+
$name,
357+
$bound ?? new MixedType(),
358+
TemplateTypeVariance::createInvariant(),
359+
);
363360

364361
return [
365362
'simple' => [
@@ -467,15 +464,12 @@ public function testResolveTemplateTypes(Type $received, Type $template, array $
467464
/** @return array<array{TemplateTypeVariance,Type,bool,array<TemplateTypeReference>}> */
468465
public function dataGetReferencedTypeArguments(): array
469466
{
470-
$templateType = static function (string $name, ?Type $bound = null): Type {
471-
/** @var non-empty-string $name */
472-
return TemplateTypeFactory::create(
473-
TemplateTypeScope::createWithFunction('a'),
474-
$name,
475-
$bound ?? new MixedType(),
476-
TemplateTypeVariance::createInvariant(),
477-
);
478-
};
467+
$templateType = static fn ($name, ?Type $bound = null): Type => TemplateTypeFactory::create(
468+
TemplateTypeScope::createWithFunction('a'),
469+
$name,
470+
$bound ?? new MixedType(),
471+
TemplateTypeVariance::createInvariant(),
472+
);
479473

480474
return [
481475
'param: Invariant<T>' => [

tests/PHPStan/Type/IterableTypeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,12 @@ public function testIsSubTypeOfInversed(IterableType $type, Type $otherType, Tri
185185

186186
public function dataInferTemplateTypes(): array
187187
{
188-
$templateType = static function (string $name): Type {
189-
/** @var non-empty-string $name */
190-
return TemplateTypeFactory::create(
191-
TemplateTypeScope::createWithFunction('a'),
192-
$name,
193-
new MixedType(),
194-
TemplateTypeVariance::createInvariant(),
195-
);
196-
};
188+
$templateType = static fn ($name): Type => TemplateTypeFactory::create(
189+
TemplateTypeScope::createWithFunction('a'),
190+
$name,
191+
new MixedType(),
192+
TemplateTypeVariance::createInvariant(),
193+
);
197194

198195
return [
199196
'receive iterable' => [

tests/PHPStan/Type/TemplateTypeTest.php

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ class TemplateTypeTest extends PHPStanTestCase
2525

2626
public function dataAccepts(): array
2727
{
28-
$templateType = static function (string $name, ?Type $bound, ?string $functionName = null): Type {
29-
/** @var non-empty-string $name */
30-
return TemplateTypeFactory::create(
31-
TemplateTypeScope::createWithFunction($functionName ?? '_'),
32-
$name,
33-
$bound,
34-
TemplateTypeVariance::createInvariant(),
35-
);
36-
};
28+
$templateType = static fn ($name, ?Type $bound, ?string $functionName = null): Type => TemplateTypeFactory::create(
29+
TemplateTypeScope::createWithFunction($functionName ?? '_'),
30+
$name,
31+
$bound,
32+
TemplateTypeVariance::createInvariant(),
33+
);
3734

3835
return [
3936
0 => [
@@ -130,15 +127,12 @@ public function testAccepts(
130127

131128
public function dataIsSuperTypeOf(): array
132129
{
133-
$templateType = static function (string $name, ?Type $bound, ?string $functionName = null): Type {
134-
/** @var non-empty-string $name */
135-
return TemplateTypeFactory::create(
136-
TemplateTypeScope::createWithFunction($functionName ?? '_'),
137-
$name,
138-
$bound,
139-
TemplateTypeVariance::createInvariant(),
140-
);
141-
};
130+
$templateType = static fn ($name, ?Type $bound, ?string $functionName = null): Type => TemplateTypeFactory::create(
131+
TemplateTypeScope::createWithFunction($functionName ?? '_'),
132+
$name,
133+
$bound,
134+
TemplateTypeVariance::createInvariant(),
135+
);
142136

143137
return [
144138
0 => [
@@ -321,15 +315,12 @@ public function testIsSuperTypeOf(
321315
/** @return array<string,array{Type,Type,array<string,string>}> */
322316
public function dataInferTemplateTypes(): array
323317
{
324-
$templateType = static function (string $name, ?Type $bound = null, ?string $functionName = null): Type {
325-
/** @var non-empty-string $name */
326-
return TemplateTypeFactory::create(
327-
TemplateTypeScope::createWithFunction($functionName ?? '_'),
328-
$name,
329-
$bound,
330-
TemplateTypeVariance::createInvariant(),
331-
);
332-
};
318+
$templateType = static fn ($name, ?Type $bound = null, ?string $functionName = null): Type => TemplateTypeFactory::create(
319+
TemplateTypeScope::createWithFunction($functionName ?? '_'),
320+
$name,
321+
$bound,
322+
TemplateTypeVariance::createInvariant(),
323+
);
333324
return [
334325
'simple' => [
335326
new IntegerType(),

0 commit comments

Comments
 (0)