Skip to content

Commit

Permalink
Merge pull request #9210 from weirdan/fix-cs-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 2, 2023
2 parents d7e9cbc + 5d930a4 commit ab9d745
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private static function scrapeEqualityAssertions(
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);

if ($source instanceof StatementsAnalyzer) {
Expand All @@ -536,7 +536,7 @@ private static function scrapeEqualityAssertions(
$this_class_name,
$other_type,
$codebase,
$conditional
$conditional,
);
}
}
Expand Down Expand Up @@ -794,7 +794,7 @@ private static function scrapeInequalityAssertions(
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);

if ($source instanceof StatementsAnalyzer) {
Expand All @@ -812,7 +812,7 @@ private static function scrapeInequalityAssertions(
$this_class_name,
$other_type,
$codebase,
$conditional
$conditional,
);
}
}
Expand Down Expand Up @@ -4048,7 +4048,7 @@ private static function getGreaterAssertions(
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlened_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);

if ($var_name) {
Expand Down Expand Up @@ -4223,7 +4223,7 @@ private static function getSmallerAssertions(
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);

if ($var_name) {
Expand Down Expand Up @@ -4251,7 +4251,7 @@ private static function getSmallerAssertions(
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);

if ($var_name) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Internal/CliUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CliUtilsTest extends TestCase
/**
* @var list<string>
*/
private $argv = [];
private array $argv = [];

protected function setUp(): void
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public function provideGetPathsToCheck(): iterable
$dummyProjectDir = (string)realpath(
__DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR. 'fixtures'
. DIRECTORY_SEPARATOR . 'fixtures'
. DIRECTORY_SEPARATOR . 'DummyProject',
);
$currentDir = (string)realpath('.');
Expand Down
2 changes: 2 additions & 0 deletions tests/ReturnTypeProvider/GetObjectVarsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function __construct(public string $t) {}
'assertions' => [
'$test===' => "array{t: 'test'}",
],
'ignored_issues' => [],
'php_version' => '8.2',
];

Expand All @@ -168,6 +169,7 @@ public function __construct(public string $t) {}
'assertions' => [
'$test===' => "array{t: 'test'}",
],
'ignored_issues' => [],
'php_version' => '8.2',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/ValidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract public function providerValidCodeParse(): iterable;
public function testValidCode(
string $code,
array $assertions = [],
$ignored_issues = [],
array $ignored_issues = [],
string $php_version = '7.3'
): void {
$test_name = $this->getTestName();
Expand Down
32 changes: 16 additions & 16 deletions tests/TypeReconciliation/EmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,63 +419,63 @@ function foo(array $arr): void {
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) > 0 ? $str : "string";
}'
}',
],
'strlenRighthandWithGreaterZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return 0 < strlen($str) ? $str : "string";
}'
}',
],
'strlenWithGreaterEqualsOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) >= 1 ? $str : "string";
}'
}',
],
'strlenRighthandWithGreaterEqualsOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return 1 <= strlen($str) ? $str : "string";
}'
}',
],
'strlenWithInequalZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) !== 0 ? $str : "string";
}'
}',
],
'strlenRighthandWithInequalZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return 0 !== strlen($str) ? $str : "string";
}'
}',
],
'strlenWithEqualOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) === 1 ? $str : "string";
}'
}',
],
'strlenRighthandWithEqualOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return 1 === strlen($str) ? $str : "string";
}'
}',
],
'mb_strlen' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return mb_strlen($str) === 1 ? $str : "string";
}'
}',
],
'SKIPPED-countWithLiteralIntVariable' => [ // #8163
'code' => '<?php
Expand Down Expand Up @@ -564,55 +564,55 @@ function foo(array $r) {
function nonEmptyString(string $str): string {
return strlen($str) > -1 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventRighthandStrlenGreaterMinusOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return -1 < strlen($str) ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventStrlenGreaterEqualsZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) >= 0 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventStrlenEqualsZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) === 0 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenLessThanOne' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) < 1 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenLessEqualsZero' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen($str) <= 0 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenWithConcatenatedString' => [
'code' => '<?php
/** @return non-empty-string */
function nonEmptyString(string $str): string {
return strlen("a" . $str . "b") > 2 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
];
}
Expand Down

0 comments on commit ab9d745

Please sign in to comment.