Skip to content

Commit 6d995f7

Browse files
committed
Add close/open-resource type
1 parent 5abbe96 commit 6d995f7

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/PseudoTypes/ClosedResource.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\PseudoTypes;
15+
16+
use phpDocumentor\Reflection\Type;
17+
use phpDocumentor\Reflection\PseudoType;
18+
use phpDocumentor\Reflection\Types\Resource_;
19+
20+
/**
21+
* Value Object representing the 'closed-resource' Type.
22+
*
23+
* @psalm-immutable
24+
*/
25+
final class ClosedResource implements PseudoType
26+
{
27+
public function underlyingType(): Type
28+
{
29+
return new Resource_();
30+
}
31+
32+
/**
33+
* Returns a rendered output of the Type as it would be used in a DocBlock.
34+
*/
35+
public function __toString(): string
36+
{
37+
return 'closed-resource';
38+
}
39+
}

src/PseudoTypes/OpenResource.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\PseudoTypes;
15+
16+
use phpDocumentor\Reflection\Type;
17+
use phpDocumentor\Reflection\PseudoType;
18+
use phpDocumentor\Reflection\Types\Resource_;
19+
20+
/**
21+
* Value Object representing the 'open-resource' Type.
22+
*
23+
* @psalm-immutable
24+
*/
25+
final class OpenResource implements PseudoType
26+
{
27+
public function underlyingType(): Type
28+
{
29+
return new Resource_();
30+
}
31+
32+
/**
33+
* Returns a rendered output of the Type as it would be used in a DocBlock.
34+
*/
35+
public function __toString(): string
36+
{
37+
return 'open-resource';
38+
}
39+
}

0 commit comments

Comments
 (0)