yiisoft /
demo
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Blog; |
||
| 6 | |||
| 7 | use Yiisoft\Hydrator\Validator\Attribute\Validate; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Yiisoft\Input\Http\AbstractInput; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Input\Http\AbstractInput was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 9 | use Yiisoft\Input\Http\Attribute\Parameter\Body; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Input\Http\Attribute\Parameter\Body was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | use Yiisoft\Router\HydratorAttribute\RouteArgument; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Router\HydratorAttribute\RouteArgument was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 11 | use Yiisoft\Validator\Result; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Validator\Result was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | use Yiisoft\Validator\Rule\Length; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Validator\Rule\Length was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use Yiisoft\Validator\Rule\Required; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Validator\Rule\Required was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Yiisoft\Validator\RulesProviderInterface; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Validator\RulesProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use OpenApi\Attributes as OA; |
||
|
0 ignored issues
–
show
The type
OpenApi\Attributes was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | |||
| 17 | #[OA\Schema( |
||
| 18 | schema: 'EditPostRequest', |
||
| 19 | properties: [ |
||
| 20 | new OA\Property(property: 'title', type: 'string', example: 'Title post'), |
||
| 21 | new OA\Property(property: 'text', type: 'string', example: 'Text post'), |
||
| 22 | new OA\Property(property: 'status', type: 'int', example: '1'), |
||
| 23 | ] |
||
| 24 | )] |
||
| 25 | final class EditPostRequest extends AbstractInput implements RulesProviderInterface |
||
| 26 | { |
||
| 27 | #[RouteArgument('id')] |
||
| 28 | private int $id; |
||
| 29 | |||
| 30 | #[Body('title')] |
||
| 31 | #[Validate(new Required())] |
||
| 32 | private string $title = ''; |
||
| 33 | |||
| 34 | #[Body('text')] |
||
| 35 | #[Validate(new Required())] |
||
| 36 | private string $text = ''; |
||
| 37 | |||
| 38 | #[Body('status')] |
||
| 39 | #[Validate(new Required())] |
||
| 40 | private int $status; |
||
| 41 | |||
| 42 | public function getId(): int |
||
| 43 | { |
||
| 44 | return $this->id; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getTitle(): string |
||
| 48 | { |
||
| 49 | return $this->title; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getText(): string |
||
| 53 | { |
||
| 54 | return $this->text; |
||
| 55 | } |
||
| 56 | |||
| 57 | public function getStatus(): PostStatus |
||
| 58 | { |
||
| 59 | return PostStatus::from($this->status); |
||
| 60 | } |
||
| 61 | |||
| 62 | public function getRules(): array |
||
| 63 | { |
||
| 64 | return [ |
||
| 65 | 'title' => [ |
||
| 66 | new Length(min: 5, max: 255), |
||
| 67 | ], |
||
| 68 | 'text' => [ |
||
| 69 | new Length(min: 5, max: 1000), |
||
| 70 | ], |
||
| 71 | 'status' => [ |
||
| 72 | static function ($value): Result { |
||
| 73 | $result = new Result(); |
||
| 74 | if (!PostStatus::isValid($value)) { |
||
| 75 | $result->addError('Incorrect status'); |
||
| 76 | } |
||
| 77 | |||
| 78 | return $result; |
||
| 79 | }, |
||
| 80 | ], |
||
| 81 | ]; |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths