-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Offer an autofix when we know the best input type for the user to use. Also reword the lint message to be a little more concise. Reviewed By: vsiles Differential Revision: D39913756 fbshipit-source-id: fbf093f665e27b721c2bdca7d6fc4a53e676caad
- Loading branch information
1 parent
7687696
commit 87903e5
Showing
7 changed files
with
45 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?hh | ||
|
||
function nullable_str(): ?string { | ||
return null; | ||
} | ||
|
||
function demo(): void { | ||
$_ = HH\FIXME\UNSAFE_CAST<mixed, string>(nullable_str()); | ||
} |
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,19 @@ | ||
{ | ||
"errors":[ | ||
{ | ||
"descr":"The input type to `HH\\FIXME\\UNSAFE_CAST` should be as specific as possible. Consider using `?string` instead.", | ||
"severity":"error", | ||
"path":"test_quickfix_unsafe_cast.php", | ||
"line":8, | ||
"start":29, | ||
"end":33, | ||
"code":5636, | ||
"bypass_changed_lines":false, | ||
"original":"mixed", | ||
"replacement":"?string", | ||
"start_offset":111, | ||
"width":5 | ||
} | ||
], | ||
"version":" Wed Dec 31 16:00:00 1969" | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "unsafe_cast_lower_bound2.php", line 4, characters 25-29: | ||
HH\FIXME\UNSAFE_CAST input type annotation is too loose, please use a more specific type. The typechecker infers `string` as the most specific type. (Lint[5636]) | ||
The input type to `HH\FIXME\UNSAFE_CAST` should be as specific as possible. Consider using `string` instead. (Lint[5636]) |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "unsafe_cast_lower_bound3.php", line 4, characters 25-29: | ||
HH\FIXME\UNSAFE_CAST input type annotation is too loose, please use a more specific type. (Lint[5636]) | ||
The input type to `HH\FIXME\UNSAFE_CAST` should be as specific as possible. (Lint[5636]) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
File "unsafe_cast_lower_bound4.php", line 4, characters 25-29: | ||
HH\FIXME\UNSAFE_CAST input type annotation is too loose, please use a more specific type. The typechecker infers `arraykey` as the most specific type. (Lint[5636]) | ||
The input type to `HH\FIXME\UNSAFE_CAST` should be as specific as possible. Consider using `arraykey` instead. (Lint[5636]) | ||
File "unsafe_cast_lower_bound4.php", line 8, characters 25-29: | ||
HH\FIXME\UNSAFE_CAST input type annotation is too loose, please use a more specific type. The typechecker infers `num` as the most specific type. (Lint[5636]) | ||
The input type to `HH\FIXME\UNSAFE_CAST` should be as specific as possible. Consider using `num` instead. (Lint[5636]) |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
File "unsafe_cast_lower_bound5.php", line 4, characters 25-29: | ||
HH\FIXME\UNSAFE_CAST input type annotation is too loose, please use a more specific type. The typechecker infers `?int` as the most specific type. (Lint[5636]) | ||
The input type to `HH\FIXME\UNSAFE_CAST` should be as specific as possible. Consider using `?int` instead. (Lint[5636]) |