Skip to content

Commit 05fa55d

Browse files
committed
More formatting
I'm not sure how phpcbf didn't fix this already??
1 parent 489a040 commit 05fa55d

File tree

1 file changed

+51
-54
lines changed

1 file changed

+51
-54
lines changed

src/Type/Php/PregMatchTypeSpecifyingExtension.php

+51-54
Original file line numberDiff line numberDiff line change
@@ -21,68 +21,65 @@
2121
final class PregMatchTypeSpecifyingExtension implements FunctionTypeSpecifyingExtension, TypeSpecifierAwareExtension
2222
{
2323

24-
private TypeSpecifier $typeSpecifier;
24+
private TypeSpecifier $typeSpecifier;
2525

26-
public function __construct(
27-
private RegexArrayShapeMatcher $regexShapeMatcher,
28-
)
29-
{
30-
}
26+
public function __construct(
27+
private RegexArrayShapeMatcher $regexShapeMatcher,
28+
) {
29+
}
3130

32-
public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
33-
{
34-
$this->typeSpecifier = $typeSpecifier;
35-
}
31+
public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
32+
{
33+
$this->typeSpecifier = $typeSpecifier;
34+
}
3635

37-
public function isFunctionSupported(FunctionReflection $functionReflection, FuncCall $node, TypeSpecifierContext $context): bool
38-
{
39-
return in_array(strtolower($functionReflection->getName()), ['safe\preg_match', 'safe\preg_match_all'], true) && !$context->null();
40-
}
36+
public function isFunctionSupported(FunctionReflection $functionReflection, FuncCall $node, TypeSpecifierContext $context): bool
37+
{
38+
return in_array(strtolower($functionReflection->getName()), ['safe\preg_match', 'safe\preg_match_all'], true) && !$context->null();
39+
}
4140

42-
public function specifyTypes(FunctionReflection $functionReflection, FuncCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
43-
{
44-
$args = $node->getArgs();
45-
$patternArg = $args[0] ?? null;
46-
$matchesArg = $args[2] ?? null;
47-
$flagsArg = $args[3] ?? null;
41+
public function specifyTypes(FunctionReflection $functionReflection, FuncCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
42+
{
43+
$args = $node->getArgs();
44+
$patternArg = $args[0] ?? null;
45+
$matchesArg = $args[2] ?? null;
46+
$flagsArg = $args[3] ?? null;
4847

49-
if (
50-
$patternArg === null || $matchesArg === null
51-
) {
52-
return new SpecifiedTypes();
53-
}
48+
if ($patternArg === null || $matchesArg === null
49+
) {
50+
return new SpecifiedTypes();
51+
}
5452

55-
$flagsType = null;
56-
if ($flagsArg !== null) {
57-
$flagsType = $scope->getType($flagsArg->value);
58-
}
53+
$flagsType = null;
54+
if ($flagsArg !== null) {
55+
$flagsType = $scope->getType($flagsArg->value);
56+
}
5957

60-
if ($functionReflection->getName() === 'Safe\preg_match') {
61-
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
62-
} else {
63-
$matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
64-
}
65-
if ($matchedType === null) {
66-
return new SpecifiedTypes();
67-
}
58+
if ($functionReflection->getName() === 'Safe\preg_match') {
59+
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
60+
} else {
61+
$matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
62+
}
63+
if ($matchedType === null) {
64+
return new SpecifiedTypes();
65+
}
6866

69-
$overwrite = false;
70-
if ($context->false()) {
71-
$overwrite = true;
72-
$context = $context->negate();
73-
}
67+
$overwrite = false;
68+
if ($context->false()) {
69+
$overwrite = true;
70+
$context = $context->negate();
71+
}
7472

75-
$types = $this->typeSpecifier->create(
76-
$matchesArg->value,
77-
$matchedType,
78-
$context,
79-
$scope,
80-
)->setRootExpr($node);
81-
if ($overwrite) {
82-
$types = $types->setAlwaysOverwriteTypes();
83-
}
84-
85-
return $types;
86-
}
73+
$types = $this->typeSpecifier->create(
74+
$matchesArg->value,
75+
$matchedType,
76+
$context,
77+
$scope,
78+
)->setRootExpr($node);
79+
if ($overwrite) {
80+
$types = $types->setAlwaysOverwriteTypes();
81+
}
8782

83+
return $types;
84+
}
8885
}

0 commit comments

Comments
 (0)