Skip to content

Commit fa496b8

Browse files
committed
fix cs
1 parent ac2b5a9 commit fa496b8

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/PHPStan/PregMatchParameterOutExtension.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,42 @@
2222
use PHPStan\TrinaryLogic;
2323
use PHPStan\Type\Php\RegexArrayShapeMatcher;
2424
use PHPStan\Type\StaticMethodParameterOutTypeExtension;
25+
use PHPStan\Type\Type;
2526

2627
final class PregMatchParameterOutExtension implements StaticMethodParameterOutTypeExtension
2728
{
2829
private RegexArrayShapeMatcher $regexShapeMatcher;
2930

3031
public function __construct(
3132
RegexArrayShapeMatcher $regexShapeMatcher
32-
)
33-
{
33+
) {
3434
$this->regexShapeMatcher = $regexShapeMatcher;
3535
}
3636

3737
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool
3838
{
3939
return
40-
$methodReflection->getDeclaringClass()->getName() === Preg::class
41-
&& $methodReflection->getName() === 'match'
42-
&& $parameter->getName() === 'matches';
40+
Preg::class === $methodReflection->getDeclaringClass()->getName()
41+
&& 'match' === $methodReflection->getName()
42+
&& 'matches' === $parameter->getName();
4343
}
4444

45-
public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?\PHPStan\Type\Type
45+
public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type
4646
{
4747
$args = $methodCall->getArgs();
4848
$patternArg = $args[0] ?? null;
4949
$matchesArg = $args[2] ?? null;
5050
$flagsArg = $args[3] ?? null;
5151

5252
if (
53-
$patternArg === null || $matchesArg === null
53+
null === $patternArg || null === $matchesArg
5454
) {
5555
return null;
5656
}
5757

5858
$patternType = $scope->getType($patternArg->value);
5959
$flagsType = null;
60-
if ($flagsArg !== null) {
60+
if (null !== $flagsArg) {
6161
$flagsType = $scope->getType($flagsArg->value);
6262
}
6363

src/PHPStan/PregMatchTypeSpecifyingExtension.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
use PHPStan\Analyser\TypeSpecifierAwareExtension;
2323
use PHPStan\Analyser\TypeSpecifierContext;
2424
use PHPStan\Reflection\MethodReflection;
25-
use PHPStan\Reflection\ParameterReflection;
2625
use PHPStan\TrinaryLogic;
2726
use PHPStan\Type\Php\RegexArrayShapeMatcher;
28-
use PHPStan\Type\StaticMethodParameterOutTypeExtension;
2927
use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
3028

3129
final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
@@ -36,8 +34,7 @@ final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyi
3634

3735
public function __construct(
3836
RegexArrayShapeMatcher $regexShapeMatcher
39-
)
40-
{
37+
) {
4138
$this->regexShapeMatcher = $regexShapeMatcher;
4239
}
4340

@@ -53,7 +50,7 @@ public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
5350

5451
public function isStaticMethodSupported(MethodReflection $staticMethodReflection, StaticCall $node, TypeSpecifierContext $context): bool
5552
{
56-
return $staticMethodReflection->getName() === 'match' && !$context->null();
53+
return 'match' === $staticMethodReflection->getName() && !$context->null();
5754
}
5855

5956
public function specifyTypes(MethodReflection $staticMethodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
@@ -64,19 +61,19 @@ public function specifyTypes(MethodReflection $staticMethodReflection, StaticCal
6461
$flagsArg = $args[3] ?? null;
6562

6663
if (
67-
$patternArg === null || $matchesArg === null
64+
null === $patternArg || null === $matchesArg
6865
) {
6966
return new SpecifiedTypes();
7067
}
7168

7269
$patternType = $scope->getType($patternArg->value);
7370
$flagsType = null;
74-
if ($flagsArg !== null) {
71+
if (null !== $flagsArg) {
7572
$flagsType = $scope->getType($flagsArg->value);
7673
}
7774

7875
$matchedType = $this->regexShapeMatcher->matchType($patternType, $flagsType, TrinaryLogic::createFromBoolean($context->true()));
79-
if ($matchedType === null) {
76+
if (null === $matchedType) {
8077
return new SpecifiedTypes();
8178
}
8279

@@ -95,5 +92,4 @@ public function specifyTypes(MethodReflection $staticMethodReflection, StaticCal
9592
$node,
9693
);
9794
}
98-
9995
}

0 commit comments

Comments
 (0)