Skip to content

Commit 8584150

Browse files
authored
Merge pull request #4 from laraneat/laravel-10
v1
2 parents e9b78a0 + a5853a5 commit 8584150

File tree

149 files changed

+1916
-2044
lines changed

Some content is hidden

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

149 files changed

+1916
-2044
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ coverage
88
.env.backup
99
.php_cs.cache
1010
.phpunit.result.cache
11+
.phpunit.cache
1112
.phpstorm.meta.php
1213
_ide_helper*.php
1314
_ide_macros*.php

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
"require": {
2727
"php": "^8.0",
2828
"ext-json": "*",
29-
"laravel/framework": "^8.0"
29+
"laravel/framework": "^10.0"
3030
},
3131
"require-dev": {
32-
"friendsofphp/php-cs-fixer": "^2.16",
32+
"friendsofphp/php-cs-fixer": "^3.48",
3333
"mockery/mockery": "~1.0",
34-
"orchestra/testbench": "^6.2",
35-
"phpstan/phpstan": "^0.12.14",
36-
"phpunit/phpunit": "^9.5",
34+
"orchestra/testbench": "^8.2",
35+
"phpstan/phpstan": "^1.10",
36+
"phpunit/phpunit": "^10.5",
3737
"roave/security-advisories": "dev-latest",
38-
"spatie/phpunit-snapshot-assertions": "^2.1.0|^4.2"
38+
"spatie/phpunit-snapshot-assertions": "^5.1"
3939
},
4040
"autoload": {
4141
"psr-4": {
@@ -77,7 +77,10 @@
7777
"config": {
7878
"optimize-autoloader": true,
7979
"preferred-install": "dist",
80-
"sort-packages": true
80+
"sort-packages": true,
81+
"allow-plugins": {
82+
"pestphp/pest-plugin": true
83+
}
8184
},
8285
"minimum-stability": "dev",
8386
"prefer-stable": true

config/config.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@
117117
'path' => 'UI/CLI/Tests',
118118
'generate' => false
119119
],
120-
'config' => [
121-
'path' => 'Config',
122-
'generate' => true
123-
],
124120
'dto' => [
125121
'path' => 'DTO',
126122
'generate' => true
@@ -245,10 +241,10 @@
245241
|
246242
*/
247243
'composer' => [
248-
'vendor' => 'laraneat',
244+
'vendor' => 'example',
249245
'author' => [
250-
'name' => 'Salakhutdinov Salavat',
251-
'email' => 'salahutdinov.salavat@gmail.com',
246+
'name' => 'Example name',
247+
'email' => 'example@example.com',
252248
],
253249
'composer-output' => false,
254250
],

phpunit.xml.dist

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
74
<report>
85
<clover outputFile="build/logs/clover.xml"/>
96
<html outputDirectory="build/coverage"/>
@@ -18,4 +15,9 @@
1815
<logging>
1916
<junit outputFile="build/report.junit.xml"/>
2017
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
2123
</phpunit>

src/Commands/Generators/ActionMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function getTemplateContents(): string
100100
];
101101

102102
if ($this->stub !== 'plain') {
103-
if ($this->stub === 'create') {
103+
if ($this->stub === 'create' || $this->stub === 'update') {
104104
$dto = $this->getOptionOrAsk(
105105
'dto',
106106
'Enter the class name of the DTO to be used in the request',

src/Commands/Generators/DTOMakeCommand.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Laraneat\Modules\Module;
66
use Laraneat\Modules\Support\Stub;
77
use Laraneat\Modules\Traits\ModuleCommandTrait;
8-
use Symfony\Component\Console\Input\InputOption;
98

109
/**
1110
* @group generator
@@ -56,9 +55,7 @@ class DTOMakeCommand extends ComponentGeneratorCommand
5655
*/
5756
protected function getOptions(): array
5857
{
59-
return [
60-
['strict', 's', InputOption::VALUE_NONE, 'Create strict DTO.'],
61-
];
58+
return [];
6259
}
6360

6461
protected function prepare()
@@ -79,8 +76,6 @@ protected function getTemplateContents(): string
7976
'class' => $this->getClass($this->nameArgument)
8077
];
8178

82-
$stub = $this->option('strict') ? 'strict' : 'default';
83-
84-
return Stub::create("dto/{$stub}.stub", $stubReplaces)->render();
79+
return Stub::create("dto/default.stub", $stubReplaces)->render();
8580
}
8681
}

src/Commands/Generators/RequestMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected function getTemplateContents(): string
114114
];
115115

116116
if ($this->stub !== 'plain') {
117-
if ($this->stub === 'create') {
117+
if ($this->stub === 'create' || $this->stub === 'update') {
118118
$dto = $this->getOptionOrAsk(
119119
'dto',
120120
'Enter the class name of the DTO to be used in the request',

src/Commands/Generators/stubs/action/create.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class {{ class }} extends Action
1313
{
1414
public function handle({{ dto }} $dto): {{ model }}
1515
{
16-
return {{ model }}::create($dto->toArray());
16+
return {{ model }}::create($dto->all());
1717
}
1818

1919
public function asController({{ request }} $request): JsonResponse

src/Commands/Generators/stubs/action/update.stub

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ namespace {{ namespace }};
44

55
use App\Ship\Abstracts\Actions\Action;
66
use App\Ship\Exceptions\UpdateResourceFailedException;
7+
use {{ dtoNamespace }}\{{ dto }};
78
use {{ modelNamespace }}\{{ model }};
89
use {{ requestNamespace }}\{{ request }};
910
use {{ resourceNamespace }}\{{ resource }};
1011

1112
class {{ class }} extends Action
1213
{
13-
public function handle({{ model }} ${{ modelEntity }}, array $data): {{ model }}
14+
public function handle({{ model }} ${{ modelEntity }}, {{ dto }} $dto): {{ model }}
1415
{
16+
$data = $dto->all();
17+
1518
if (empty($data)) {
1619
throw new UpdateResourceFailedException();
1720
}
@@ -23,7 +26,7 @@ class {{ class }} extends Action
2326

2427
public function asController({{ request }} $request, {{ model }} ${{ modelEntity }}): {{ resource }}
2528
{
26-
${{ modelEntity }} = $this->handle(${{ modelEntity }}, $request->validated());
29+
${{ modelEntity }} = $this->handle(${{ modelEntity }}, $request->toDTO());
2730

2831
return new {{ resource }}(${{ modelEntity }});
2932
}

src/Commands/Generators/stubs/config.stub

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)