-
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.
Consider
get_defined_vars()
to be a read (#92)
* Tests: add tests for get_defined_vars * Tests: add a variable named get_defined_vars * Remove unused import * Add some phpdoc * Mark all vars read at get_defined_vars * Add more guards to checkForPassByReferenceFunctionCall
- Loading branch information
1 parent
8611e83
commit acfe65c
Showing
4 changed files
with
112 additions
and
2 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
31 changes: 31 additions & 0 deletions
31
VariableAnalysis/Tests/CodeAnalysis/fixtures/GetDefinedVarsFixture.php
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,31 @@ | ||
<?php | ||
|
||
function send_vars_to_method( $object, $data ) { | ||
$some_number = 4; | ||
$some_string = 'hello'; | ||
echo $undefined_data; // should be a warning | ||
$new_data = $object->transform_data( $data ); | ||
$object->continue_things( get_defined_vars() ); | ||
} | ||
|
||
function send_vars_to_method_with_global( $object, $data ) { | ||
global $global_data; | ||
$new_data = $object->transform_data( $data ); | ||
$object->continue_things( get_defined_vars() ); | ||
} | ||
|
||
function send_vars_to_method_with_scope_import( $object, $data ) { | ||
$unused_data = 42; // should be a warning | ||
$imported_data = 76; | ||
return array_map( function( $datum ) use ( $object, $imported_data ) { | ||
$new_data = $object->transform_data( $datum ); | ||
echo $undefined_data; // should be a warning | ||
$object->continue_things( get_defined_vars() ); | ||
}, $data ); | ||
} | ||
|
||
function send_var_with_var_named_get_defined_vars( $object, $data ) { | ||
$get_defined_vars = 'hi'; | ||
$new_data = $object->transform_data( $data ); // should be a warning | ||
$object->continue_things( $get_defined_vars ); | ||
} |