1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Merge pull request #9210 from weirdan/fix-cs-issues

This commit is contained in:
Bruce Weirdan 2023-02-02 13:16:05 -04:00 committed by GitHub
commit ab9d745fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 26 deletions

View File

@ -518,7 +518,7 @@ class AssertionFinder
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);
if ($source instanceof StatementsAnalyzer) {
@ -536,7 +536,7 @@ class AssertionFinder
$this_class_name,
$other_type,
$codebase,
$conditional
$conditional,
);
}
}
@ -794,7 +794,7 @@ class AssertionFinder
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);
if ($source instanceof StatementsAnalyzer) {
@ -812,7 +812,7 @@ class AssertionFinder
$this_class_name,
$other_type,
$codebase,
$conditional
$conditional,
);
}
}
@ -4048,7 +4048,7 @@ class AssertionFinder
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlened_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);
if ($var_name) {
@ -4223,7 +4223,7 @@ class AssertionFinder
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);
if ($var_name) {
@ -4251,7 +4251,7 @@ class AssertionFinder
$var_name = ExpressionIdentifier::getExtendedVarId(
$strlen_expr->getArgs()[0]->value,
$this_class_name,
$source
$source,
);
if ($var_name) {

View File

@ -14,7 +14,7 @@ class CliUtilsTest extends TestCase
/**
* @var list<string>
*/
private $argv = [];
private array $argv = [];
protected function setUp(): void
{
@ -68,7 +68,7 @@ class CliUtilsTest extends TestCase
$dummyProjectDir = (string)realpath(
__DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR. 'fixtures'
. DIRECTORY_SEPARATOR . 'fixtures'
. DIRECTORY_SEPARATOR . 'DummyProject',
);
$currentDir = (string)realpath('.');

View File

@ -154,6 +154,7 @@ class GetObjectVarsTest extends TestCase
'assertions' => [
'$test===' => "array{t: 'test'}",
],
'ignored_issues' => [],
'php_version' => '8.2',
];
@ -168,6 +169,7 @@ class GetObjectVarsTest extends TestCase
'assertions' => [
'$test===' => "array{t: 'test'}",
],
'ignored_issues' => [],
'php_version' => '8.2',
];

View File

@ -39,7 +39,7 @@ trait ValidCodeAnalysisTestTrait
public function testValidCode(
string $code,
array $assertions = [],
$ignored_issues = [],
array $ignored_issues = [],
string $php_version = '7.3'
): void {
$test_name = $this->getTestName();

View File

@ -419,63 +419,63 @@ class EmptyTest extends TestCase
/** @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
@ -564,7 +564,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen($str) > -1 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventRighthandStrlenGreaterMinusOne' => [
'code' => '<?php
@ -572,7 +572,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return -1 < strlen($str) ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventStrlenGreaterEqualsZero' => [
'code' => '<?php
@ -580,7 +580,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen($str) >= 0 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
'preventStrlenEqualsZero' => [
'code' => '<?php
@ -588,7 +588,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen($str) === 0 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenLessThanOne' => [
'code' => '<?php
@ -596,7 +596,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen($str) < 1 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenLessEqualsZero' => [
'code' => '<?php
@ -604,7 +604,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen($str) <= 0 ? $str : "string";
}',
'error_message' => 'InvalidReturnStatement'
'error_message' => 'InvalidReturnStatement',
],
'preventStrlenWithConcatenatedString' => [
'code' => '<?php
@ -612,7 +612,7 @@ class EmptyTest extends TestCase
function nonEmptyString(string $str): string {
return strlen("a" . $str . "b") > 2 ? $str : "string";
}',
'error_message' => 'LessSpecificReturnStatement'
'error_message' => 'LessSpecificReturnStatement',
],
];
}