Skip to content

Commit 759689f

Browse files
authored
Rename repo (#70)
1 parent 04fa695 commit 759689f

File tree

85 files changed

+367
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+367
-367
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# dto-converter [![Latest Version on Packagist](https://img.shields.io/packagist/v/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter) [![Tests](https://github.com/riverwaysoft/dto-converter/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/dto-converter/actions/workflows/php.yml) [![PHPStan](https://github.com/riverwaysoft/dto-converter/actions/workflows/static_analysis.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/dto-converter/actions/workflows/static_analysis.yml) [![Total Downloads](https://img.shields.io/packagist/dt/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter)
1+
# php-converter [![Latest Version on Packagist](https://img.shields.io/packagist/v/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter) [![Tests](https://github.com/riverwaysoft/php-converter/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/php-converter/actions/workflows/php.yml) [![PHPStan](https://github.com/riverwaysoft/php-converter/actions/workflows/static_analysis.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/php-converter/actions/workflows/static_analysis.yml) [![Total Downloads](https://img.shields.io/packagist/dt/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter)
22

33
<img width="818" alt="Screen Shot 2022-10-07 at 09 04 35" src="https://user-images.githubusercontent.com/22447849/194478818-7276da5c-bf5e-4ad2-8efd-6463c53d01d3.png">
44

@@ -21,7 +21,7 @@ composer require riverwaysoft/php-converter --dev
2121

2222
2) Mark a few classes with `#[Dto]` annotation to convert them into TypeScript or Dart
2323
```php
24-
use Riverwaysoft\DtoConverter\ClassFilter\Dto;
24+
use Riverwaysoft\PhpConverter\ClassFilter\Dto;
2525

2626
#[Dto]
2727
class UserOutput
@@ -36,7 +36,7 @@ class UserOutput
3636

3737
4) Run CLI command to generate TypeScript
3838
```bash
39-
vendor/bin/dto-converter-ts generate --from=/path/to/project/src --to=.
39+
vendor/bin/php-converter-ts generate --from=/path/to/project/src --to=.
4040
```
4141

4242
You'll get file `generated.ts` with the following contents:
@@ -60,16 +60,16 @@ type UserOutput = {
6060
- Flexible class filters with an option to use your own filters
6161
6262
## Customize
63-
If you'd like to customize `dto-converter-ts` you need to copy the generator script to your project folder:
63+
If you'd like to customize `php-converter-ts` you need to copy the generator script to your project folder:
6464
6565
```
66-
cp vendor/bin/dto-converter-ts bin/dto-converter-ts
66+
cp vendor/bin/php-converter-ts bin/php-converter-ts
6767
```
6868
69-
Now you can start customizing the dto-converter by editing the executable file.
69+
Now you can start customizing the php-converter by editing the executable file.
7070
7171
### How to customize generated output?
72-
By default `dto-converter` writes all the types into one file. You can configure it to put each type / class in a separate file with all the required imports. Here is an example how to achieve it:
72+
By default `php-converter` writes all the types into one file. You can configure it to put each type / class in a separate file with all the required imports. Here is an example how to achieve it:
7373
7474
```diff
7575
+ $fileNameGenerator = new KebabCaseFileNameGenerator('.ts');
@@ -127,13 +127,13 @@ $application->add(
127127
);
128128
```
129129

130-
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).
130+
You can even go further and use `NegationFilter` to exclude specific files as shown in [unit tests](https://github.com/riverwaysoft/php-converter/blob/a8d5df2c03303c02bc9148bd1d7822d7fe48c5d8/tests/EndToEndTest.php#L297).
131131

132132
### How to write custom type resolvers?
133-
`dto-converter` takes care of converting basic PHP types like number, string and so on. But what if you have a type that isn't a DTO? For example `\DateTimeImmutable`. You can write a class that implements [UnknownTypeResolverInterface](https://github.com/riverwaysoft/dto-converter/blob/2d434562c1bc73bcb6819257b31dd75c818f4ab1/src/Language/UnknownTypeResolverInterface.php). There is also a shortcut to achieve it - use [InlineTypeResolver](https://github.com/riverwaysoft/dto-converter/blob/2d434562c1bc73bcb6819257b31dd75c818f4ab1/src/Language/TypeScript/InlineTypeResolver.php):
133+
`php-converter` takes care of converting basic PHP types like number, string and so on. But what if you have a type that isn't a DTO? For example `\DateTimeImmutable`. You can write a class that implements [UnknownTypeResolverInterface](https://github.com/riverwaysoft/php-converter/blob/2d434562c1bc73bcb6819257b31dd75c818f4ab1/src/Language/UnknownTypeResolverInterface.php). There is also a shortcut to achieve it - use [InlineTypeResolver](https://github.com/riverwaysoft/php-converter/blob/2d434562c1bc73bcb6819257b31dd75c818f4ab1/src/Language/TypeScript/InlineTypeResolver.php):
134134

135135
```diff
136-
+use Riverwaysoft\DtoConverter\Dto\PhpType\PhpBaseType;
136+
+use Riverwaysoft\PhpConverter\Dto\PhpType\PhpBaseType;
137137

138138
$application->add(
139139
new ConvertCommand(
@@ -191,7 +191,7 @@ $application->add(
191191
);
192192
```
193193

194-
Feel free to create your own processor based on [PrependAutogeneratedNoticeFileProcessor](https://github.com/riverwaysoft/dto-converter/blob/26ee25f07ac97a942e1327165424fc65777b80b0/src/OutputWriter/OutputProcessor/PrependAutogeneratedNoticeFileProcessor.php) source.
194+
Feel free to create your own processor based on [PrependAutogeneratedNoticeFileProcessor](https://github.com/riverwaysoft/php-converter/blob/26ee25f07ac97a942e1327165424fc65777b80b0/src/OutputWriter/OutputProcessor/PrependAutogeneratedNoticeFileProcessor.php) source.
195195

196196
Here is an example how [Prettier](https://prettier.io/) formatter could look like:
197197

@@ -253,7 +253,7 @@ $application->add(
253253
To write a custom converter you can implement [LanguageGeneratorInterface](./src/Language/LanguageGeneratorInterface.php). Here is an example how to do it for Go language: [GoGeneratorSimple](./tests/GoGeneratorSimple.php). Check how to use it [here](./tests/GoGeneratorSimpleTest.php). It covers only basic scenarios to get you an idea, so feel free to modify it to your needs.
254254

255255
## Error list
256-
Here is a list of errors `dto-converter` can throw and description what to do if you encounter these errors:
256+
Here is a list of errors `php-converter` can throw and description what to do if you encounter these errors:
257257

258258
### 1. Property z of class X has no type. Please add PHP type
259259
It means that you've forgotten to add type for property `a` of class Y. Example:
@@ -265,11 +265,11 @@ class X {
265265
}
266266
```
267267

268-
At the moment there is no strict / loose mode in `dto-converter`. It is always strict. 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`. It could silently convert such types to TypeScript `any` or Dart `Object` if we needed it. But we prefer an explicit approach. Feel free to raise an issue if having loose mode makes sense for you.
268+
At the moment there is no strict / loose mode in `php-converter`. It is always strict. 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`. It could silently convert such types to TypeScript `any` or Dart `Object` if we needed it. But we prefer an explicit approach. Feel free to raise an issue if having loose mode makes sense for you.
269269

270270

271271
### 2. PHP Type X is not supported
272-
It means `dto-converter` doesn't know 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:
272+
It means `php-converter` doesn't know 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:
273273

274274
```php
275275
#[Dto]
@@ -289,8 +289,8 @@ composer test
289289
```
290290

291291
## How it is different from alternatives?
292-
- Unlike [spatie/typescript-transformer](https://github.com/spatie/typescript-transformer) `dto-converter` supports not only TypeScript but also Dart. Support for other languages can be easily added by implementing LanguageInterface. `dto-converter` can also output generated types / classes into different files.
293-
- Unlike [grpc](https://github.com/grpc/grpc/tree/v1.40.0/examples/php) `dto-converter` doesn't require to modify your app or install some extensions.
292+
- Unlike [spatie/typescript-transformer](https://github.com/spatie/typescript-transformer) `php-converter` supports not only TypeScript but also Dart. Support for other languages can be easily added by implementing LanguageInterface. `php-converter` can also output generated types / classes into different files.
293+
- Unlike [grpc](https://github.com/grpc/grpc/tree/v1.40.0/examples/php) `php-converter` doesn't require to modify your app or install some extensions.
294294

295295
## Contributing
296296

bin/dto-converter-ts renamed to bin/php-converter-ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ declare(strict_types=1);
55

66
require_once __DIR__ . '/../vendor/autoload.php';
77

8-
use Riverwaysoft\DtoConverter\Ast\Converter;
9-
use Riverwaysoft\DtoConverter\Ast\DtoVisitor;
10-
use Riverwaysoft\DtoConverter\Bridge\Symfony\SymfonyControllerVisitor;
11-
use Riverwaysoft\DtoConverter\ClassFilter\PhpAttributeFilter;
12-
use Riverwaysoft\DtoConverter\Cli\ConvertCommand;
13-
use Riverwaysoft\DtoConverter\CodeProvider\FileSystemCodeProvider;
14-
use Riverwaysoft\DtoConverter\Language\TypeScript\TypeScriptGenerator;
15-
use Riverwaysoft\DtoConverter\Language\UnknownTypeResolver\ClassNameTypeResolver;
16-
use Riverwaysoft\DtoConverter\Language\UnknownTypeResolver\DateTimeTypeResolver;
17-
use Riverwaysoft\DtoConverter\OutputDiffCalculator\OutputDiffCalculator;
18-
use Riverwaysoft\DtoConverter\OutputWriter\SingleFileOutputWriter\SingleFileOutputWriter;
8+
use Riverwaysoft\PhpConverter\Ast\Converter;
9+
use Riverwaysoft\PhpConverter\Ast\DtoVisitor;
10+
use Riverwaysoft\PhpConverter\Bridge\Symfony\SymfonyControllerVisitor;
11+
use Riverwaysoft\PhpConverter\ClassFilter\PhpAttributeFilter;
12+
use Riverwaysoft\PhpConverter\Cli\ConvertCommand;
13+
use Riverwaysoft\PhpConverter\CodeProvider\FileSystemCodeProvider;
14+
use Riverwaysoft\PhpConverter\Language\TypeScript\TypeScriptGenerator;
15+
use Riverwaysoft\PhpConverter\Language\UnknownTypeResolver\ClassNameTypeResolver;
16+
use Riverwaysoft\PhpConverter\Language\UnknownTypeResolver\DateTimeTypeResolver;
17+
use Riverwaysoft\PhpConverter\OutputDiffCalculator\OutputDiffCalculator;
18+
use Riverwaysoft\PhpConverter\OutputWriter\SingleFileOutputWriter\SingleFileOutputWriter;
1919
use Symfony\Component\Console\Application;
2020
use Symfony\Component\Filesystem\Filesystem;
2121

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "riverwaysoft/php-converter",
3-
"description": "PHP DTO converter to TypeScript / Dart",
3+
"description": "PHP converter to TypeScript / Dart",
44
"authors": [
55
{
66
"name": "Egor Gorbachev",
@@ -30,7 +30,7 @@
3030
},
3131
"license": "GPL-3.0-or-later",
3232
"autoload": {
33-
"psr-4": {"Riverwaysoft\\DtoConverter\\": "src/"},
33+
"psr-4": {"Riverwaysoft\\PhpConverter\\": "src/"},
3434
"classmap": [
3535
"src"
3636
]
@@ -41,7 +41,7 @@
4141
}
4242
},
4343
"bin": [
44-
"bin/dto-converter-ts"
44+
"bin/php-converter-ts"
4545
],
4646
"require-dev": {
4747
"phpunit/phpunit": "^9",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "dto-converter",
2+
"name": "php-converter",
33
"version": "1.0.0",
44
"directories": {
55
"test": "tests"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: dto_converter
1+
name: php_converter
22

33
dependencies:
44
equatable: '^2.0.3'

src/Ast/Converter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
declare(strict_types=1);
44

5-
namespace Riverwaysoft\DtoConverter\Ast;
5+
namespace Riverwaysoft\PhpConverter\Ast;
66

77
use PhpParser\NodeTraverser;
88
use PhpParser\Parser;
99
use PhpParser\ParserFactory;
10-
use Riverwaysoft\DtoConverter\ClassFilter\ClassFilterInterface;
11-
use Riverwaysoft\DtoConverter\Dto\ApiClient\ApiEndpoint;
12-
use Riverwaysoft\DtoConverter\Dto\ApiClient\ApiEndpointList;
13-
use Riverwaysoft\DtoConverter\Dto\DtoList;
14-
use Riverwaysoft\DtoConverter\Dto\PhpType\PhpTypeFactory;
10+
use Riverwaysoft\PhpConverter\ClassFilter\ClassFilterInterface;
11+
use Riverwaysoft\PhpConverter\Dto\ApiClient\ApiEndpoint;
12+
use Riverwaysoft\PhpConverter\Dto\ApiClient\ApiEndpointList;
13+
use Riverwaysoft\PhpConverter\Dto\DtoList;
14+
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpTypeFactory;
1515

1616
/**
1717
* It converts PHP code string into a normalized DTO list suitable for converting into other languages

src/Ast/ConverterResult.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
declare(strict_types=1);
44

5-
namespace Riverwaysoft\DtoConverter\Ast;
5+
namespace Riverwaysoft\PhpConverter\Ast;
66

7-
use Riverwaysoft\DtoConverter\Dto\ApiClient\ApiEndpointList;
8-
use Riverwaysoft\DtoConverter\Dto\DtoList;
7+
use Riverwaysoft\PhpConverter\Dto\ApiClient\ApiEndpointList;
8+
use Riverwaysoft\PhpConverter\Dto\DtoList;
99

1010
class ConverterResult
1111
{

src/Ast/ConverterVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Riverwaysoft\DtoConverter\Ast;
5+
namespace Riverwaysoft\PhpConverter\Ast;
66

77
use PhpParser\NodeVisitorAbstract;
88

src/Ast/DtoVisitor.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
declare(strict_types=1);
44

5-
namespace Riverwaysoft\DtoConverter\Ast;
5+
namespace Riverwaysoft\PhpConverter\Ast;
66

77
use PhpParser\Node;
88
use PhpParser\Node\Stmt\Class_;
99
use PhpParser\Node\Stmt\Enum_;
10-
use Riverwaysoft\DtoConverter\ClassFilter\ClassFilterInterface;
11-
use Riverwaysoft\DtoConverter\Dto\DtoClassProperty;
12-
use Riverwaysoft\DtoConverter\Dto\DtoEnumProperty;
13-
use Riverwaysoft\DtoConverter\Dto\DtoType;
14-
use Riverwaysoft\DtoConverter\Dto\ExpressionType;
15-
use Riverwaysoft\DtoConverter\Dto\PhpType\PhpTypeFactory;
16-
use Riverwaysoft\DtoConverter\Dto\PhpType\PhpTypeInterface;
17-
use Riverwaysoft\DtoConverter\Dto\PhpType\PhpUnionType;
10+
use Riverwaysoft\PhpConverter\ClassFilter\ClassFilterInterface;
11+
use Riverwaysoft\PhpConverter\Dto\DtoClassProperty;
12+
use Riverwaysoft\PhpConverter\Dto\DtoEnumProperty;
13+
use Riverwaysoft\PhpConverter\Dto\DtoType;
14+
use Riverwaysoft\PhpConverter\Dto\ExpressionType;
15+
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpTypeFactory;
16+
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpTypeInterface;
17+
use Riverwaysoft\PhpConverter\Dto\PhpType\PhpUnionType;
1818

1919
class DtoVisitor extends ConverterVisitor
2020
{

0 commit comments

Comments
 (0)