11# Basic Types
22
3+ <secondary-label ref =" phpstan " />
4+ <secondary-label ref =" psalm " />
5+ <secondary-label ref =" storm " />
36<show-structure for =" chapter " depth =" 2 " />
47
58The parser does not impose restrictions on type naming. The type name must begin
@@ -24,21 +27,18 @@ is **unacceptable**.
2427> ``` typescript
2528> ExampleTypeName
2629> ` ` `
27- > {style="note"}
2830
2931> Dashes ( ` - ` ) in <tooltip term="Identifier">Identifier</tooltip> are also
3032> acceptable.
3133> ` ` ` typescript
3234> example - type
3335> ` ` `
34- > {style="note"}
3536
3637> The reserved keyword ( ` true ` ) is allowed as part of the <tooltip
3738> term="Identifier">Identifier</tooltip>.
3839> ` ` ` typescript
3940> true - type
4041> ` ` `
41- > {style="note"}
4242
4343</tab>
4444<tab title="Counterexamples">
@@ -48,29 +48,38 @@ is **unacceptable**.
4848> literal value rather than an <tooltip term="Identifier">Identifier</tooltip>.
4949> ` ` ` typescript
5050> TrUe
51- >
52- > // TypeLang\Parser\Node\Literal\BoolLiteralNode {
53- > // +offset: 0
54- > // +raw: "TrUe"
55- > // +value: true
56- > // }
5751> ` ` `
52+ > ` ` ` php
53+ > TypeLang \Parser \Node \Literal \BoolLiteralNode {
54+ > + offset : 0
55+ > + raw : " TrUe"
56+ > + value : true
57+ > }
58+ > ` ` `
59+ > {collapsible="true" collapsed-title="TypeLang\P arser\N ode\L iteral\B oolLiteralNode"}
60+ >
5861> {style="warning"}
5962
6063> <tooltip term="Identifier">Identifiers</tooltip> cannot begin with digits
6164> ( ` 0 - 9 ` ) or a dash ( ` - ` ) symbol.
6265> ` ` ` typescript
6366> 42type
64- >
65- > // Syntax error, unexpected "type"
6667> ` ` `
68+ > ` ` `
69+ > Syntax error , unexpected " type"
70+ > ` ` `
71+ > {collapsible="true" collapsed-title="TypeLang\P arser\E xception\P arseException"}
6772> {style="warning"}
6873
6974</tab>
7075</tabs>
7176
7277## Namespace
7378
79+ <secondary-label ref="phpstan"/>
80+ <secondary-label ref="psalm"/>
81+ <secondary-label ref="storm"/>
82+
7483Each name can contain a namespace symbol ( ` \` — backslash), which is
7584[similar to that in PHP](https://www.php.net/manual/en/language.namespaces.rationale.php). The separator can be located either in the middle
7685or at the beginning of any <tooltip term="Identifier">Identifier</tooltip>. End
@@ -86,13 +95,11 @@ The namespace delimiter can be used in conjunction with keywords such as `true`,
8695> ` ` ` typescript
8796> Example \Name
8897> ` ` `
89- > {style="note"}
9098
9199> Absolute class <tooltip term="FQN">FQN</tooltip> reference.
92100> ` ` ` typescript
93101> \Absolute \Type \Name
94102> ` ` `
95- > {style="note"}
96103
97104</tab>
98105<tab title="Counterexamples">
@@ -101,17 +108,21 @@ The namespace delimiter can be used in conjunction with keywords such as `true`,
101108> reserved for literal values.
102109> ` ` ` typescript
103110> true \null
104- >
105- > // Syntax error, unexpected "\"
106111> ` ` `
112+ > ` ` `
113+ > Syntax error , unexpected " \"
114+ > ```
115+ > {collapsible = " true" collapsed - title = " TypeLang\P arser\E xception\P arseException" }
107116> {style = " warning" }
108117
109118> <tooltip term =" FQN" >FQN < / tooltip > type names cannot end in `\` delimiter.
110119> ```typescript
111120> example\name\
112- >
113- > // Syntax error, unexpected end of input
114121> ```
122+ > ```
123+ > Syntax error, unexpected end of input
124+ > ```
125+ > {collapsible= " true" collapsed -title =" TypeLang\P arser\E xception\P arseException" }
115126> {style = " warning" }
116127
117128< / tab >
0 commit comments