Skip to content

Commit d9a5776

Browse files
authored
Document errors (#21)
1 parent e795374 commit d9a5776

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,36 @@ $application->add(
126126
You can even go further and use `NegationFilter` to exclude specific files as shown in [unit tests](https://github.com/riverwaysoft/dto-converter/blob/a8d5df2c03303c02bc9148bd1d7822d7fe48c5d8/tests/EndToEndTest.php#L297).
127127

128128

129+
## Error list
130+
Here is a list of errors `dto-converter` can throw and description what to do if you encounter these errors:
131+
132+
### 1. Property z of class X has no type. Please add PHP type
133+
It means that you've forgotten to add type for property `a` of class Y. Example:
134+
135+
```php
136+
#[Dto]
137+
class X {
138+
public $z;
139+
}
140+
```
141+
142+
At the moment there is no strict / loose mode in `dto-converter`. It could silently convert such types to TypeScript `any` or Dart `Object` but we don't need that feature. Feel free to raise an issue if having loose mode makes sense for you. If you don't know the PHP type just use [mixed](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.mixed) type to explicitly convert it to `any`/`Object`.
143+
144+
145+
### 2. PHP Type X is not supported
146+
It means `dto-converter` doesn't understand how to convert the type X into TypeScript or Dart. If you are using `#[Dto]` attribute you probably forgot to add it to class `X`. Example:
147+
148+
```php
149+
#[Dto]
150+
class A {
151+
public X $x;
152+
}
153+
154+
class X {
155+
public int $foo;
156+
}
157+
```
158+
129159
## Testing
130160

131161
``` bash

0 commit comments

Comments
 (0)