Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'resource (closed)' type check in IsType for closed resources
- Loading branch information
1 parent
f971401
commit a30201d
Showing
6 changed files
with
175 additions
and
31 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
24 changes: 24 additions & 0 deletions
24
tests/static-analysis/happy-path/assert-is-closed-resource.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,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Framework\StaticAnalysis\HappyPath\AssertIsClosedResource; | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @param mixed $value | ||
* | ||
* @return resource | ||
*/ | ||
function consume($value) | ||
{ | ||
Assert::assertIsClosedResource($value); | ||
|
||
return $value; | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/static-analysis/happy-path/assert-is-not-closed-resource.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,20 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Framework\StaticAnalysis\HappyPath\AssertIsNotClosedResource; | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
/** @param int|resource $value */ | ||
function consume($value): int | ||
{ | ||
Assert::assertIsNotClosedResource($value); | ||
|
||
return $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