Skip to content

Commit

Permalink
Merge pull request vimeo#7302 from weirdan/rector-null-coalescing-ope…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
weirdan committed Jan 5, 2022
2 parents 0f84dd3 + dfb14cb commit 2bc7b9b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions phpcs.xml
Expand Up @@ -190,11 +190,30 @@
</properties>
</rule>

<!--
Requires using a underscore separator for long numbers.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardnumbersrequirenumericliteralseparator
-->
<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator">
<properties>
<property name="enable" value="true"/>
<property name="minDigitsBeforeDecimalPoint" value="5"/>
</properties>
</rule>

<!--
Requires use of null coalesce operator when possible.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardcontrolstructuresrequirenullcoalesceoperator-
-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />

<!--
Requires use of null coalesce equal operator when possible.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardcontrolstructuresrequirenullcoalesceequaloperator-
-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator">
<properties>
<property name="enable" value="true"/>
</properties>
</rule>
</ruleset>
Expand Up @@ -279,7 +279,7 @@ public static function analyze(
}

if ($stmt->keyVar instanceof PhpParser\Node\Expr\Variable && is_string($stmt->keyVar->name)) {
$key_type = $key_type ?? Type::getMixed();
$key_type ??= Type::getMixed();

AssignmentAnalyzer::analyze(
$statements_analyzer,
Expand All @@ -292,7 +292,7 @@ public static function analyze(
);
}

$value_type = $value_type ?? Type::getMixed();
$value_type ??= Type::getMixed();

if ($stmt->byRef) {
$value_type->by_ref = true;
Expand Down
Expand Up @@ -419,7 +419,7 @@ function (Assertion $assertion) use ($generic_params, $codebase): Assertion {
}
}

$return_type_candidate = $return_type_candidate ?? Type::getMixed();
$return_type_candidate ??= Type::getMixed();

StaticCallAnalyzer::taintReturnType(
$statements_analyzer,
Expand Down
Expand Up @@ -246,7 +246,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev
]);
}

$inner_key_type = $inner_key_type ?? Type::getArrayKey();
$inner_key_type ??= Type::getArrayKey();

if ($any_nonempty) {
return new Union([
Expand Down

0 comments on commit 2bc7b9b

Please sign in to comment.