-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for compact being used with variable strings (#223)
- Loading branch information
1 parent
6a0b28f
commit 0775e0c
Showing
2 changed files
with
35 additions
and
7 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 |
---|---|---|
@@ -1,32 +1,37 @@ | ||
<?php | ||
function function_with_literal_compact($param1, $param2, $param3, $param4) { | ||
function function_with_literal_compact($param1, $param2, $param3, $param4) { // unused variable param2 | ||
$var1 = 'value1'; | ||
$var2 = 'value2'; | ||
$var4 = 'value4'; | ||
$squish = compact('var1'); | ||
$squish = compact('var3'); | ||
$squish = compact('var3'); // undefined variable var3 | ||
$squish = compact('param1'); | ||
$squish = compact('var2', /*comment*/ 'param3'); | ||
$squish = compact(array('var4'), array('param4', 'var5')); | ||
$squish = compact(array('var4'), array('param4', 'var5')); // undefined variable var5 | ||
echo $squish; | ||
} | ||
|
||
function function_with_expression_compact($param1, $param2, $param3, $param4) { | ||
function function_with_expression_compact($param1, $param2, $param3, $param4) { // unused variable param2 | ||
$var1 = "value1"; | ||
$var2 = "value2"; | ||
$var4 = "value4"; | ||
$var6 = "value6"; | ||
$var7 = "value7"; | ||
$var7 = "value7"; // unused variale var7 (not actually unused but it's hard to detect that line 28 uses it) | ||
$var8 = "value8"; | ||
$var9 = "value9"; | ||
$squish = compact("var1"); | ||
$squish = compact("var3"/*comment*/ ); | ||
$squish = compact("var3"/*comment*/ ); // undefined variable var3 | ||
$squish = compact("param1"); | ||
$squish = compact("var2", "param3"); | ||
$squish = compact(array("var4"), array("param4", /*comment*/ "var5")); | ||
$squish = compact(array("var4"), array("param4", /*comment*/ "var5")); // undefined variable var5 | ||
$squish = compact($var6); | ||
$squish = compact("var" . "7"); | ||
$squish = compact("blah $var8"); | ||
$squish = compact("$var9"); | ||
echo $squish; | ||
} | ||
|
||
function foo() { | ||
$a = 'Hello'; | ||
$c = compact( $a, $b ); // Unused variable c and undefined variable b | ||
} |