Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports functions whose side effects are flipped by parameters
- Loading branch information
Showing
5 changed files
with
165 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
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
34 changes: 34 additions & 0 deletions
34
tests/PHPStan/Rules/Functions/data/function-call-statement-no-side-effects-8.0.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,34 @@ | ||
<?php | ||
|
||
namespace FunctionCallStatementNoSideEffects; | ||
|
||
use PHPStan\TrinaryLogic; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param ?resource $resourceOrNull | ||
*/ | ||
public function noEffect(string $url, $resourceOrNull) | ||
{ | ||
file_get_contents(filename: $url, offset: 1, length: 100); | ||
file_get_contents($url, length: 100, offset: 1); | ||
file_get_contents($url, false, null, length: 100); | ||
file_get_contents($url, context: $resourceOrNull); | ||
var_export([], return: true); | ||
print_r([], return: true); | ||
} | ||
|
||
/** | ||
* @param resource $resource | ||
*/ | ||
public function hasSideEffect(string $url, $resource) | ||
{ | ||
file_get_contents($url, false, $resource, length: 100); | ||
file_get_contents($url, context: $resource); | ||
var_export(value: []); | ||
print_r(value: []); | ||
} | ||
|
||
} |
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