-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consistently use phpstan's testing framework to test phpstan bits
- Loading branch information
Showing
6 changed files
with
35 additions
and
35 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
22 changes: 0 additions & 22 deletions
22
tests/Type/Php/ReplaceSafeFunctionsDynamicReturnTypeExtensionTest.php
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace TheCodingMachine\Safe\PHPStan\Type\Php\data; | ||
|
||
// Checking that preg_match and Safe\preg_match are equivalent | ||
$pattern = '/H(.)ll(o) (World)?/'; | ||
$string = 'Hello World'; | ||
|
||
// when return value isn't checked, we may-or-may-not have matches | ||
$type = "array{0?: string, 1?: non-empty-string, 2?: 'o', 3?: 'World'}"; | ||
|
||
// @phpstan-ignore-next-line - use of unsafe is intentional | ||
\preg_match($pattern, $string, $matches); | ||
\PHPStan\Testing\assertType($type, $matches); | ||
|
||
\Safe\preg_match($pattern, $string, $matches); | ||
\PHPStan\Testing\assertType($type, $matches); |
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,11 @@ | ||
<?php | ||
|
||
namespace TheCodingMachine\Safe\PHPStan\Type\Php\data; | ||
|
||
// preg_replace with a string pattern should return a string | ||
$x = \Safe\preg_replace('/foo/', 'bar', 'baz'); | ||
\PHPStan\Testing\assertType("string", $x); | ||
|
||
// preg_replace with an array pattern should return an array | ||
$x = \Safe\preg_replace(['/foo/'], ['bar'], ['baz']); | ||
\PHPStan\Testing\assertType("array", $x); |