2
2
3
3
use phpDocumentor \Reflection \Type ;
4
4
use phpDocumentor \Reflection \Types \String_ ;
5
+ use function PHPUnit \Framework \assertEquals ;
6
+ use function Spatie \Snapshots \assertMatchesSnapshot ;
7
+ use function Spatie \Snapshots \assertMatchesTextSnapshot ;
5
8
use Spatie \TypeScriptTransformer \Attributes \Hidden ;
6
9
use Spatie \TypeScriptTransformer \Attributes \LiteralTypeScriptType ;
7
10
use Spatie \TypeScriptTransformer \Attributes \Optional ;
13
16
use Spatie \TypeScriptTransformer \Tests \FakeClasses \Integration \Enum ;
14
17
use Spatie \TypeScriptTransformer \Tests \FakeClasses \Integration \LevelUp \YetAnotherDto ;
15
18
use Spatie \TypeScriptTransformer \Tests \FakeClasses \Integration \OtherDto ;
19
+
16
20
use Spatie \TypeScriptTransformer \Transformers \DtoTransformer ;
17
21
use Spatie \TypeScriptTransformer \TypeProcessors \TypeProcessor ;
18
22
use Spatie \TypeScriptTransformer \TypeScriptTransformerConfig ;
19
23
20
- use function PHPUnit \Framework \assertEquals ;
21
- use function Spatie \Snapshots \assertMatchesSnapshot ;
22
- use function Spatie \Snapshots \assertMatchesTextSnapshot ;
23
-
24
24
beforeEach (function () {
25
25
$ config = TypeScriptTransformerConfig::create ()
26
26
->defaultTypeReplacements ([
49
49
it ('a type processor can remove properties ' , function () {
50
50
$ config = TypeScriptTransformerConfig::create ();
51
51
52
- $ transformer = new class ($ config ) extends DtoTransformer {
52
+ $ transformer = new class ($ config ) extends DtoTransformer {
53
53
protected function typeProcessors (): array
54
54
{
55
- $ onlyStringPropertiesProcessor = new class () implements TypeProcessor {
55
+ $ onlyStringPropertiesProcessor = new class () implements TypeProcessor {
56
56
public function process (
57
57
Type $ type ,
58
58
ReflectionProperty | ReflectionParameter | ReflectionMethod $ reflection ,
@@ -75,7 +75,7 @@ public function process(
75
75
});
76
76
77
77
it ('will take transform as typescript attributes into account ' , function () {
78
- $ class = new class () {
78
+ $ class = new class () {
79
79
#[TypeScriptType('int ' )]
80
80
public $ int ;
81
81
@@ -103,7 +103,7 @@ public function process(
103
103
});
104
104
105
105
it ('transforms properties to optional ones when using optional attribute ' , function () {
106
- $ class = new class () {
106
+ $ class = new class () {
107
107
#[Optional]
108
108
public string $ string ;
109
109
};
@@ -134,7 +134,7 @@ class DummyOptionalDto
134
134
135
135
136
136
it ('transforms properties to hidden ones when using hidden attribute ' , function () {
137
- $ class = new class () {
137
+ $ class = new class () {
138
138
public string $ visible ;
139
139
#[Hidden]
140
140
public string $ hidden ;
@@ -149,7 +149,7 @@ class DummyOptionalDto
149
149
});
150
150
151
151
it ('transforms nullable properties to optional ones according to config ' , function () {
152
- $ class = new class () {
152
+ $ class = new class () {
153
153
public ?string $ string ;
154
154
};
155
155
0 commit comments