mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Add Safe PHP functions
This commit is contained in:
parent
04a956886a
commit
58cc098058
260 changed files with 49458 additions and 45 deletions
34
vendor/thecodingmachine/phpstan-safe-rule/tests/Rules/UseSafeFunctionsRuleTest.php
vendored
Normal file
34
vendor/thecodingmachine/phpstan-safe-rule/tests/Rules/UseSafeFunctionsRuleTest.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace TheCodingMachine\Safe\PHPStan\Rules;
|
||||
|
||||
use PHPStan\Testing\RuleTestCase;
|
||||
use TheCodingMachine\Safe\PHPStan\Type\Php\ReplaceSafeFunctionsDynamicReturnTypeExtension;
|
||||
|
||||
class UseSafeFunctionsRuleTest extends RuleTestCase
|
||||
{
|
||||
protected function getRule(): \PHPStan\Rules\Rule
|
||||
{
|
||||
return new UseSafeFunctionsRule();
|
||||
}
|
||||
|
||||
public function testCatch()
|
||||
{
|
||||
$this->analyse([__DIR__ . '/data/fopen.php'], [
|
||||
[
|
||||
"Function fopen is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\\fopen;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.",
|
||||
4,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testNoCatchSafe()
|
||||
{
|
||||
$this->analyse([__DIR__ . '/data/safe_fopen.php'], []);
|
||||
}
|
||||
|
||||
public function testExprCall()
|
||||
{
|
||||
$this->analyse([__DIR__ . '/data/undirect_call.php'], []);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue