Skip to content

Commit 25003b7

Browse files
Rename
1 parent db744e7 commit 25003b7

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

conf/config.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ parameters:
7979
reportStaticMethodSignatures: false
8080
reportWrongPhpDocTypeInVarTag: false
8181
reportAnyTypeWideningInVarTag: false
82-
reportArrayKeyCast: false
82+
allowFloatBoolNullAsArrayKey: true
8383
reportPossiblyNonexistentGeneralArrayOffset: false
8484
reportPossiblyNonexistentConstantArrayOffset: false
8585
checkMissingOverrideMethodAttribute: false

conf/parametersSchema.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ parametersSchema:
8888
reportStaticMethodSignatures: bool()
8989
reportWrongPhpDocTypeInVarTag: bool()
9090
reportAnyTypeWideningInVarTag: bool()
91-
reportArrayKeyCast: bool()
91+
allowFloatBoolNullAsArrayKey: bool()
9292
reportPossiblyNonexistentGeneralArrayOffset: bool()
9393
reportPossiblyNonexistentConstantArrayOffset: bool()
9494
checkMissingOverrideMethodAttribute: bool()

src/Rules/Arrays/AllowedArrayKeysTypes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
final class AllowedArrayKeysTypes
2323
{
2424

25-
public static function getType(?PhpVersion $phpVersion = null, bool $strict = false): Type
25+
public static function getType(?PhpVersion $phpVersion = null, bool $allowFloatBoolNull = true): Type
2626
{
2727
$types = [
2828
new IntegerType(),
2929
new StringType(),
3030
];
3131

32-
if (!$strict) {
32+
if (!$allowFloatBoolNull) {
3333
$types[] = new BooleanType();
3434

3535
if ($phpVersion === null || !$phpVersion->deprecatesImplicitlyFloatConversionToInt()) {

src/Rules/Arrays/InvalidKeyInArrayDimFetchRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
#[AutowiredParameter]
2929
private bool $reportMaybes,
3030
#[AutowiredParameter]
31-
private bool $reportArrayKeyCast,
31+
private bool $allowFloatBoolNullAsArrayKey,
3232
)
3333
{
3434
}
@@ -60,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6060
return [];
6161
}
6262

63-
$allowedArrayKeys = AllowedArrayKeysTypes::getType($this->phpVersion, $this->reportArrayKeyCast);
63+
$allowedArrayKeys = AllowedArrayKeysTypes::getType($this->phpVersion, $this->allowFloatBoolNullAsArrayKey);
6464
$dimensionType = $this->ruleLevelHelper->findTypeToCheck(
6565
$scope,
6666
$node->dim,

src/Rules/Arrays/InvalidKeyInArrayItemRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
private RuleLevelHelper $ruleLevelHelper,
2727
private PhpVersion $phpVersion,
2828
#[AutowiredParameter]
29-
private bool $reportArrayKeyCast,
29+
private bool $allowFloatBoolNullAsArrayKey,
3030
)
3131
{
3232
}
@@ -42,7 +42,7 @@ public function processNode(Node $node, Scope $scope): array
4242
return [];
4343
}
4444

45-
$allowedArrayKeys = AllowedArrayKeysTypes::getType($this->phpVersion, $this->reportArrayKeyCast);
45+
$allowedArrayKeys = AllowedArrayKeysTypes::getType($this->phpVersion, $this->allowFloatBoolNullAsArrayKey);
4646
$dimensionType = $this->ruleLevelHelper->findTypeToCheck(
4747
$scope,
4848
$node->key,

tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class InvalidKeyInArrayDimFetchRuleTest extends RuleTestCase
1616
{
1717

18-
private bool $reportCastedArrayKey = false;
18+
private bool $allowFloatBoolNullAsArrayKey = true;
1919

2020
protected function getRule(): Rule
2121
{
@@ -24,7 +24,7 @@ protected function getRule(): Rule
2424
$ruleLevelHelper,
2525
self::getContainer()->getByType(PhpVersion::class),
2626
true,
27-
$this->reportCastedArrayKey,
27+
$this->allowFloatBoolNullAsArrayKey,
2828
);
2929
}
3030

@@ -168,7 +168,7 @@ public function testBug12981(): void
168168

169169
public function testUnsetFalseKey(): void
170170
{
171-
$this->reportCastedArrayKey = true;
171+
$this->allowFloatBoolNullAsArrayKey = false;
172172

173173
$this->analyse([__DIR__ . '/data/unset-false-key.php'], [
174174
[

tests/PHPStan/Rules/Arrays/InvalidKeyInArrayItemRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class InvalidKeyInArrayItemRuleTest extends RuleTestCase
1616
{
1717

18-
private bool $reportCastedArrayKey = false;
18+
private bool $allowFloatBoolNullAsArrayKey = true;
1919

2020
private bool $checkExplicitMixed = false;
2121

@@ -28,7 +28,7 @@ protected function getRule(): Rule
2828
return new InvalidKeyInArrayItemRule(
2929
$ruleLevelHelper,
3030
self::getContainer()->getByType(PhpVersion::class),
31-
$this->reportCastedArrayKey,
31+
$this->allowFloatBoolNullAsArrayKey,
3232
);
3333
}
3434

@@ -107,7 +107,7 @@ public function testInvalidMixedKey(): void
107107

108108
public function testInvalidKeyReportingCastedArrayKey(): void
109109
{
110-
$this->reportCastedArrayKey = true;
110+
$this->allowFloatBoolNullAsArrayKey = false;
111111

112112
$this->analyse([__DIR__ . '/data/invalid-key-array-item.php'], [
113113
[

0 commit comments

Comments
 (0)