Skip to content

Commit fb9cf75

Browse files
committed
Update build-cs
1 parent 1a90161 commit fb9cf75

20 files changed

+41
-61
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
with:
5757
repository: "phpstan/build-cs"
5858
path: "build-cs"
59-
ref: "1.x"
59+
ref: "2.x"
6060

6161
- name: "Install PHP"
6262
uses: "shivammathur/setup-php@v2"

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ lint:
1414
.PHONY: cs-install
1515
cs-install:
1616
git clone https://github.com/phpstan/build-cs.git || true
17-
git -C build-cs fetch origin && git -C build-cs reset --hard origin/1.x
17+
git -C build-cs fetch origin && git -C build-cs reset --hard origin/2.x
1818
composer install --working-dir build-cs
1919

2020
.PHONY: cs

src/Reflection/Nette/HtmlMethodReflection.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
class HtmlMethodReflection implements MethodReflection
1919
{
2020

21-
/** @var string */
22-
private $name;
21+
private string $name;
2322

24-
/** @var ClassReflection */
25-
private $declaringClass;
23+
private ClassReflection $declaringClass;
2624

2725
public function __construct(string $name, ClassReflection $declaringClass)
2826
{
@@ -56,7 +54,7 @@ public function getVariants(): array
5654
TemplateTypeMap::createEmpty(),
5755
[],
5856
true,
59-
substr($this->name, 0, 3) === 'get' ? new MixedType() : new ObjectType('Nette\Utils\Html')
57+
substr($this->name, 0, 3) === 'get' ? new MixedType() : new ObjectType('Nette\Utils\Html'),
6058
),
6159
];
6260
}

src/Reflection/Nette/HtmlPropertyReflection.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
class HtmlPropertyReflection implements PropertyReflection
1212
{
1313

14-
/** @var ClassReflection */
15-
private $declaringClass;
14+
private ClassReflection $declaringClass;
1615

17-
/** @var Type */
18-
private $type;
16+
private Type $type;
1917

2018
public function __construct(ClassReflection $declaringClass)
2119
{

src/Reflection/Nette/NetteObjectEventListenerMethodReflection.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
class NetteObjectEventListenerMethodReflection implements MethodReflection
1616
{
1717

18-
/** @var string */
19-
private $name;
18+
private string $name;
2019

21-
/** @var ClassReflection */
22-
private $declaringClass;
20+
private ClassReflection $declaringClass;
2321

2422
public function __construct(string $name, ClassReflection $declaringClass)
2523
{
@@ -58,7 +56,7 @@ public function getVariants(): array
5856
TemplateTypeMap::createEmpty(),
5957
[],
6058
true,
61-
new VoidType()
59+
new VoidType(),
6260
),
6361
];
6462
}

src/Reflection/Nette/NetteObjectPropertyReflection.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
class NetteObjectPropertyReflection implements PropertyReflection
1111
{
1212

13-
/** @var ClassReflection */
14-
private $declaringClass;
13+
private ClassReflection $declaringClass;
1514

16-
/** @var Type */
17-
private $type;
15+
private Type $type;
1816

1917
public function __construct(ClassReflection $declaringClass, Type $type)
2018
{

src/Rule/Nette/DoNotExtendNetteObjectRule.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3434
"Class %s extends %s - it's better to use %s trait.",
3535
$classReflection->getDisplayName(),
3636
'Nette\Object',
37-
'Nette\SmartObject'
37+
'Nette\SmartObject',
3838
))->identifier('class.extendsNetteObject')->build(),
3939
];
4040
}

src/Rule/Nette/RethrowExceptionRule.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RethrowExceptionRule implements Rule
2828
{
2929

3030
/** @var array<string, string[]> */
31-
private $methods;
31+
private array $methods;
3232

3333
/**
3434
* @param string[][] $methods
@@ -68,9 +68,7 @@ public function processNode(Node $node, Scope $scope): array
6868
foreach ($exceptions as $exceptionName) {
6969
$exceptionType = new ObjectType($exceptionName);
7070
foreach ($node->catches as $catch) {
71-
$caughtType = TypeCombinator::union(...array_map(static function (Name $class): ObjectType {
72-
return new ObjectType((string) $class);
73-
}, $catch->types));
71+
$caughtType = TypeCombinator::union(...array_map(static fn (Name $class): ObjectType => new ObjectType((string) $class), $catch->types));
7472
if (!$caughtType->isSuperTypeOf($exceptionType)->yes()) {
7573
continue;
7674
}

src/Type/Nette/ComponentGetPresenterDynamicReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2727
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2828
{
2929
$methodDefinition = ParametersAcceptorSelector::selectSingle(
30-
$methodReflection->getVariants()
30+
$methodReflection->getVariants(),
3131
);
3232
$defaultReturnType = $methodDefinition->getReturnType();
3333
$firstParameterExists = count($methodDefinition->getParameters()) > 0;

src/Type/Nette/ComponentLookupDynamicReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2727
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
2828
{
2929
$defaultReturnType = ParametersAcceptorSelector::selectSingle(
30-
$methodReflection->getVariants()
30+
$methodReflection->getVariants(),
3131
)->getReturnType();
3232
if (count($methodCall->getArgs()) < 2) {
3333
return $defaultReturnType;

src/Type/Nette/StringsMatchAllDynamicReturnTypeExtension.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
class StringsMatchAllDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
2323
{
2424

25-
/** @var RegexArrayShapeMatcher */
26-
private $regexArrayShapeMatcher;
25+
private RegexArrayShapeMatcher $regexArrayShapeMatcher;
2726

2827
public function __construct(RegexArrayShapeMatcher $regexArrayShapeMatcher)
2928
{
@@ -53,7 +52,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
5352
$patternArg->value,
5453
$this->resolveFlagsType($args, $scope),
5554
TrinaryLogic::createYes(),
56-
$scope
55+
$scope,
5756
);
5857
}
5958

@@ -83,7 +82,7 @@ private function resolveFlagsType(array $args, Scope $scope): ConstantIntegerTyp
8382
$patternOrder = $patternOrderType->isTrue()->yes();
8483

8584
return new ConstantIntegerType(
86-
($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0) | ($patternOrder ? PREG_PATTERN_ORDER : 0)
85+
($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0) | ($patternOrder ? PREG_PATTERN_ORDER : 0),
8786
);
8887
}
8988

src/Type/Nette/StringsMatchDynamicReturnTypeExtension.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
class StringsMatchDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
2323
{
2424

25-
/** @var RegexArrayShapeMatcher */
26-
private $regexArrayShapeMatcher;
25+
private RegexArrayShapeMatcher $regexArrayShapeMatcher;
2726

2827
public function __construct(RegexArrayShapeMatcher $regexArrayShapeMatcher)
2928
{
@@ -53,7 +52,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
5352
$patternArg->value,
5453
$this->resolveFlagsType($args, $scope),
5554
TrinaryLogic::createYes(),
56-
$scope
55+
$scope,
5756
);
5857

5958
if ($arrayShape === null) {
@@ -84,7 +83,7 @@ private function resolveFlagsType(array $args, Scope $scope): ConstantIntegerTyp
8483
$unmatchedAsNull = $unmatchedAsNullType->isTrue()->yes();
8584

8685
return new ConstantIntegerType(
87-
($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0)
86+
($captureOffset ? PREG_OFFSET_CAPTURE : 0) | ($unmatchedAsNull ? PREG_UNMATCHED_AS_NULL : 0),
8887
);
8988
}
9089

src/Type/Nette/StringsReplaceCallbackClosureTypeExtension.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
final class StringsReplaceCallbackClosureTypeExtension implements StaticMethodParameterClosureTypeExtension
2525
{
2626

27-
/** @var RegexArrayShapeMatcher */
28-
private $regexArrayShapeMatcher;
27+
private RegexArrayShapeMatcher $regexArrayShapeMatcher;
2928

3029
public function __construct(RegexArrayShapeMatcher $regexArrayShapeMatcher)
3130
{
@@ -59,7 +58,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
5958
$patternArg->value,
6059
$this->resolveFlagsType($args, $scope),
6160
TrinaryLogic::createYes(),
62-
$scope
61+
$scope,
6362
);
6463

6564
if ($matchesType === null) {
@@ -70,7 +69,7 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
7069
[
7170
$this->createParameterReflectionClass($parameter, $matchesType),
7271
],
73-
new StringType()
72+
new StringType(),
7473
);
7574
}
7675

@@ -92,11 +91,9 @@ private function createParameterReflectionClass(ParameterReflection $parameter,
9291
{
9392
return new class($parameter, $matchesType) implements ParameterReflection {
9493

95-
/** @var ParameterReflection */
96-
private $parameter;
94+
private ParameterReflection $parameter;
9795

98-
/** @var Type */
99-
private $matchesType;
96+
private Type $matchesType;
10097

10198
public function __construct(
10299
ParameterReflection $parameter,

tests/NetteObjectChild.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class NetteObjectChild extends LegacyObject
88
{
99

1010
/** @var callable[] */
11-
public $onPublicEvent = [];
11+
public array $onPublicEvent = [];
1212

1313
/** @var callable[] */
14-
protected $onProtectedEvent = [];
14+
protected array $onProtectedEvent = [];
1515

1616
public static function getStaticProperty(): string
1717
{

tests/Reflection/Nette/HtmlClassReflectionExtensionTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
class HtmlClassReflectionExtensionTest extends PHPStanTestCase
1313
{
1414

15-
/** @var Broker */
16-
private $broker;
15+
private Broker $broker;
1716

18-
/** @var HtmlClassReflectionExtension */
19-
private $extension;
17+
private HtmlClassReflectionExtension $extension;
2018

2119
protected function setUp(): void
2220
{

tests/Reflection/Nette/NetteObjectClassReflectionExtensionTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
class NetteObjectClassReflectionExtensionTest extends PHPStanTestCase
1212
{
1313

14-
/** @var Broker */
15-
private $broker;
14+
private Broker $broker;
1615

17-
/** @var NetteObjectClassReflectionExtension */
18-
private $extension;
16+
private NetteObjectClassReflectionExtension $extension;
1917

2018
protected function setUp(): void
2119
{

tests/Rule/Nette/RegularExpressionPatternRuleTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testValidRegexPatternBefore73(): void
6767
'Regex pattern is invalid: Compilation failed: missing ) at offset 1 in pattern: ~(~',
6868
26,
6969
],
70-
]
70+
],
7171
);
7272
}
7373

@@ -128,7 +128,7 @@ public function testValidRegexPatternAfter73(): void
128128
'Regex pattern is invalid: Compilation failed: missing closing parenthesis at offset 1 in pattern: ~(~',
129129
26,
130130
],
131-
]
131+
],
132132
);
133133
}
134134

tests/Rule/Nette/RethrowExceptionRuleTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RethrowExceptionRuleTest extends RuleTestCase
1616
protected function getRule(): Rule
1717
{
1818
return new RethrowExceptionRule(
19-
[FooPresenter::class => ['redirect' => AbortException::class]]
19+
[FooPresenter::class => ['redirect' => AbortException::class]],
2020
);
2121
}
2222

tests/SmartObjectChild.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class SmartObjectChild
1010
use SmartObject;
1111

1212
/** @var callable[] */
13-
public $onPublicEvent = [];
13+
public array $onPublicEvent = [];
1414

1515
/** @var callable[] */
16-
protected $onProtectedEvent = [];
16+
protected array $onProtectedEvent = [];
1717

1818
}

tests/Type/Nette/FormContainerValuesDynamicReturnTypeExtensionTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
final class FormContainerValuesDynamicReturnTypeExtensionTest extends TestCase
2323
{
2424

25-
/** @var FormContainerValuesDynamicReturnTypeExtension */
26-
private $extension;
25+
private FormContainerValuesDynamicReturnTypeExtension $extension;
2726

2827
protected function setUp(): void
2928
{
@@ -40,7 +39,7 @@ public function testParameterAsArray(): void
4039
TemplateTypeMap::createEmpty(),
4140
[],
4241
true,
43-
new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(ArrayHash::class))])
42+
new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(ArrayHash::class))]),
4443
)]);
4544

4645
$scope = $this->createMock(Scope::class);

0 commit comments

Comments
 (0)