Skip to content

Commit 3b797d3

Browse files
committed
Add dereferenceType() function
1 parent 96e1289 commit 3b797d3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"Typhoon\\Type\\": "src/"
2929
},
3030
"files": [
31+
"src/dereferenceType.php",
3132
"src/types.php"
3233
]
3334
},

src/dereferenceType.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Typhoon\Type;
6+
7+
use Typhoon\Type\Visitor\RecursiveTypeReplacer;
8+
9+
/**
10+
* @api
11+
*/
12+
function dereferenceType(Type $type): Type
13+
{
14+
/** @var ?RecursiveTypeReplacer */
15+
static $dereferencer = null;
16+
$dereferencer ??= new class extends RecursiveTypeReplacer {};
17+
18+
return $type->accept($dereferencer);
19+
}

0 commit comments

Comments
 (0)