Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7019 from zoonru/no_ksort_list
- Loading branch information
Showing
11 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# RedundantFunctionCall | ||
|
||
Emitted when a function call (`array_values`, `strtolower`, `ksort` etc.) is redundant. | ||
|
||
```php | ||
<?php | ||
|
||
$a = ['already', 'a', 'list']; | ||
|
||
$redundant = array_values($a); | ||
$alreadyLower = strtolower($redundant[0]); | ||
``` |
21 changes: 21 additions & 0 deletions
21
docs/running_psalm/issues/RedundantFunctionCallGivenDocblockType .md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# RedundantFunctionCallGivenDocblockType | ||
|
||
Emitted when function call is redundant given information supplied in one or more docblocks. | ||
|
||
This may be desired (e.g. when checking user input) so is distinct from RedundantFunctionCall, which only applies to non-docblock types. | ||
|
||
```php | ||
<?php | ||
|
||
/** | ||
* @param array{0: lowercase-string, 1: non-empty-list<lowercase-string>} $s | ||
* | ||
* @return lowercase-string | ||
*/ | ||
function foo($s): string { | ||
$redundantList = array_values($s); | ||
$redundantSubList = array_values($s[1]); | ||
$redundantLowercase = strtolower($redundantSubList[0]); | ||
return $redundantLowercase; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Psalm\Issue; | ||
|
||
class RedundantFunctionCall extends CodeIssue | ||
{ | ||
public const ERROR_LEVEL = 4; | ||
public const SHORTCODE = 280; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Psalm\Issue; | ||
|
||
class RedundantFunctionCallGivenDocblockType extends CodeIssue | ||
{ | ||
public const ERROR_LEVEL = 2; | ||
public const SHORTCODE = 281; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters