Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for UnusedMethodCall (#18)
* Add support for UnusedMethodCall * pr feedback
- Loading branch information
1 parent
2e95cc6
commit 604afab
Showing
9 changed files
with
155 additions
and
32 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
4 changes: 2 additions & 2 deletions
4
tests/unused/UnusedExpression/unusedFunctionCallAsync/output.txt
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 @@ | ||
ERROR: UnusedFunctionCall - input.hack:7:5 - This function is annotated with MustUse but the returned value is not used | ||
ERROR: UnusedFunctionCall - input.hack:11:5 - This function is annotated with MustUse but the returned value is not used | ||
ERROR: UnusedFunctionCall - input.hack:7:5 - This is annotated with MustUse but the returned value is not used | ||
ERROR: UnusedFunctionCall - input.hack:11:5 - This is annotated with MustUse but the returned value is not used |
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,16 @@ | ||
class UnusedMethodClass { | ||
<<Hakana\MustUse>> | ||
public function getEncodedId(): string { | ||
return ''; | ||
} | ||
|
||
public function doWork(): string { | ||
return ''; | ||
} | ||
} | ||
|
||
function foo(): void { | ||
$c = new UnusedMethodClass(); | ||
$c->getEncodedId(); | ||
$c->doWork(); | ||
} |
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 @@ | ||
UnusedMethodCall |
22 changes: 22 additions & 0 deletions
22
tests/unused/UnusedExpression/unusedMethodCallAsync/input.hack
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,22 @@ | ||
class UnusedMethodClass { | ||
<<Hakana\MustUse>> | ||
public async function getEncodedId(): Awaitable<string> { | ||
return ''; | ||
} | ||
|
||
public async function doWork(): Awaitable<string> { | ||
return ''; | ||
} | ||
} | ||
|
||
async function foo(): Awaitable<void> { | ||
$c = new UnusedMethodClass(); | ||
await $c->getEncodedId(); | ||
await $c->doWork(); | ||
} | ||
|
||
function foo2(): void { | ||
$c = new UnusedMethodClass(); | ||
Asio\join($c->getEncodedId()); | ||
Asio\join($c->doWork()); | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/unused/UnusedExpression/unusedMethodCallAsync/output.txt
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,2 @@ | ||
ERROR: UnusedMethodCall - input.hack:14:5 - This is annotated with MustUse but the returned value is not used | ||
ERROR: UnusedMethodCall - input.hack:20:5 - This is annotated with MustUse but the returned value is not used |