diff --git a/.gitattributes b/.gitattributes index 5583f369..9f9e9af9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -26,7 +26,6 @@ /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.scrutinizer.yml export-ignore /phpunit.xml.dist export-ignore /tests export-ignore /docs export-ignore diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml new file mode 100644 index 00000000..b115ab1d --- /dev/null +++ b/.github/workflows/composer-require-checker.yml @@ -0,0 +1,33 @@ +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' + + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' + +name: Composer require checker + +jobs: + composer-require-checker: + uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master + with: + os: >- + ['ubuntu-latest'] + php: >- + ['8.1'] diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 0bf491f3..457772af 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -1,5 +1,5 @@ on: - pull_request: + pull_request_target: paths-ignore: - 'docs/**' - 'README.md' @@ -17,7 +17,8 @@ jobs: secrets: token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: + repository: ${{ github.event.pull_request.head.repo.full_name }} os: >- ['ubuntu-latest'] php: >- - ['8.1'] + ['8.3'] diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 0b8d28f7..00000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,35 +0,0 @@ -checks: - php: true - -filter: - paths: - - "src/*" - -build: - image: default-bionic - - environment: - php: - version: 8.1 - ini: - "xdebug.mode": coverage - - nodes: - analysis: - tests: - override: - - php-scrutinizer-run - - phpunit: - dependencies: - override: - - composer self-update - - composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - tests: - override: - - command: "./vendor/bin/phpunit --coverage-clover ./coverage.xml" - on_node: 1 - coverage: - file: coverage.xml - format: php-clover diff --git a/README.md b/README.md index 363bf1c8..76002594 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,10 @@

-[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii-gii/v/stable.png)](https://packagist.org/packages/yiisoft/yii-gii) -[![Total Downloads](https://poser.pugx.org/yiisoft/yii-gii/downloads.png)](https://packagist.org/packages/yiisoft/yii-gii) -[![Build Status](https://github.com/yiisoft/yii-gii/workflows/build/badge.svg)](https://github.com/yiisoft/yii-gii/actions?query=workflow%3Abuild) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/yii-gii/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/yii-gii/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/yii-gii/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/yii-gii/?branch=master) +[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii-gii/v)](https://packagist.org/packages/yiisoft/yii-gii) +[![Total Downloads](https://poser.pugx.org/yiisoft/yii-gii/downloads)](https://packagist.org/packages/yiisoft/yii-gii) +[![Build status](https://github.com/yiisoft/yii-gii/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/yii-gii/actions/workflows/build.yml) +[![Code coverage](https://codecov.io/gh/yiisoft/yii-gii/graph/badge.svg?token=JWRONWSQ5P)](https://codecov.io/gh/yiisoft/yii-gii) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fyii-gii%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/yii-gii/master) [![static analysis](https://github.com/yiisoft/yii-gii/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/yii-gii/actions?query=workflow%3A%22static+analysis%22) diff --git a/composer.json b/composer.json index 5473736d..1fc7bc49 100644 --- a/composer.json +++ b/composer.json @@ -33,9 +33,15 @@ "php": "^8.1", "httpsoft/http-basis": "^1.1", "phpspec/php-diff": "^1.1.3", + "psr/http-message": "^1.0|^2.0", + "symfony/console": "^6.0|^7.0", + "yiisoft/active-record": "dev-master", "yiisoft/aliases": "^3.0", "yiisoft/arrays": "^2.1|^3.0", + "yiisoft/csrf": "^2.1.1", "yiisoft/data-response": "^2.0", + "yiisoft/db": "*", + "yiisoft/friendly-exception": "^1.1", "yiisoft/http": "^1.2", "yiisoft/hydrator": "^1.0", "yiisoft/injector": "^1.1", @@ -43,22 +49,21 @@ "yiisoft/json": "^1.0", "yiisoft/router": "^3.0", "yiisoft/strings": "^2.1", - "yiisoft/validator": "^1.0", + "yiisoft/validator": "^2.0", "yiisoft/yii-console": "^2.0", "yiisoft/yii-middleware": "^1.0" }, "require-dev": { + "maglnet/composer-require-checker": "^4.2", "jetbrains/phpstorm-attributes": "^1.0", "nyholm/psr7": "^1.5", "phpunit/phpunit": "^10.2", - "rector/rector": "^1.0.0", + "rector/rector": "^1.2", "roave/infection-static-analysis-plugin": "^1.23", "spatie/phpunit-watcher": "^1.23", "vimeo/psalm": "^5.13", - "yiisoft/active-record": "dev-master", "yiisoft/cache": "^3.0", - "yiisoft/db": "1.2 as dev-master", - "yiisoft/db-sqlite": "^1.0", + "yiisoft/db-sqlite": "dev-master", "yiisoft/di": "^1.1", "yiisoft/dummy-provider": "^1.0", "yiisoft/event-dispatcher": "^1.0", diff --git a/src/Component/CodeFile/CodeFileWriteResult.php b/src/Component/CodeFile/CodeFileWriteResult.php index f0f6b406..6b3b1098 100644 --- a/src/Component/CodeFile/CodeFileWriteResult.php +++ b/src/Component/CodeFile/CodeFileWriteResult.php @@ -4,8 +4,6 @@ namespace Yiisoft\Yii\Gii\Component\CodeFile; -use JetBrains\PhpStorm\ArrayShape; - class CodeFileWriteResult { private array $results = []; @@ -28,11 +26,6 @@ public function addError(CodeFile $file, string $error): void ]; } - #[ArrayShape([ - 'id' => 'string', - 'status' => 'string', - 'error' => 'null|string', - ])] public function getResults(): array { return $this->results; diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index cce96e35..71b6e50e 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -142,7 +142,7 @@ public function diff( private function createErrorResponse(InvalidGeneratorCommandException $e): DataResponse { return $this->responseFactory->createResponse( - ['errors' => $e->getResult()->getErrorMessagesIndexedByAttribute()], + ['errors' => $e->getResult()->getErrorMessagesIndexedByProperty()], Status::UNPROCESSABLE_ENTITY ); } diff --git a/src/Generator/ActiveRecord/Command.php b/src/Generator/ActiveRecord/Command.php index ae26fd44..0c48c675 100644 --- a/src/Generator/ActiveRecord/Command.php +++ b/src/Generator/ActiveRecord/Command.php @@ -24,7 +24,7 @@ public function __construct( private readonly string $namespace = 'App\\Model', #[Required] #[Regex( - pattern: '/^(?:[a-z][a-z0-9]*)(?:\\\\[a-z][a-z0-9]*)*$/i', + pattern: '/^[\w\-.]+$/i', message: 'Invalid table name' )] #[TableExistsRule] diff --git a/src/Validator/ClassExistsRule.php b/src/Validator/ClassExistsRule.php index 4528ffd8..d3ab6781 100644 --- a/src/Validator/ClassExistsRule.php +++ b/src/Validator/ClassExistsRule.php @@ -11,11 +11,6 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class ClassExistsRule implements RuleInterface { - public function getName(): string - { - return 'gii_class_exists'; - } - public function getHandler(): string|RuleHandlerInterface { return ClassExistsHandler::class; diff --git a/src/Validator/NewClassRule.php b/src/Validator/NewClassRule.php index cda0b4a7..dbc0447b 100644 --- a/src/Validator/NewClassRule.php +++ b/src/Validator/NewClassRule.php @@ -11,11 +11,6 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class NewClassRule implements RuleInterface { - public function getName(): string - { - return 'gii_new_class'; - } - public function getHandler(): string|RuleHandlerInterface { return NewClassHandler::class; diff --git a/src/Validator/ReservedKeywordRule.php b/src/Validator/ReservedKeywordRule.php index 3f92c664..7bb2458b 100644 --- a/src/Validator/ReservedKeywordRule.php +++ b/src/Validator/ReservedKeywordRule.php @@ -11,11 +11,6 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class ReservedKeywordRule implements RuleInterface { - public function getName(): string - { - return 'gii_reserved_keyword'; - } - public function getHandler(): string|RuleHandlerInterface { return ReservedKeywordHandler::class; diff --git a/src/Validator/TableExistsHandler.php b/src/Validator/TableExistsHandler.php index 6f550940..87fba40c 100644 --- a/src/Validator/TableExistsHandler.php +++ b/src/Validator/TableExistsHandler.php @@ -28,7 +28,12 @@ public function validate(mixed $value, object $rule, ValidationContext $context) $result = new Result(); - $tableSchema = $this->connection->getTableSchema($value); + try { + $tableSchema = $this->connection->getTableSchema($value); + } catch (\Yiisoft\Db\Exception\Exception $e) { + $result->addError($e->getMessage()); + return $result; + } if ($tableSchema === null) { $result->addError(sprintf('Table "%s" does not exist.', $value)); diff --git a/src/Validator/TableExistsRule.php b/src/Validator/TableExistsRule.php index 1f5a3ef7..ca5a442c 100644 --- a/src/Validator/TableExistsRule.php +++ b/src/Validator/TableExistsRule.php @@ -11,11 +11,6 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class TableExistsRule implements RuleInterface { - public function getName(): string - { - return 'gii_table_exists'; - } - public function getHandler(): string|RuleHandlerInterface { return TableExistsHandler::class; diff --git a/src/Validator/TemplateRule.php b/src/Validator/TemplateRule.php index 06e73c03..798c3c46 100644 --- a/src/Validator/TemplateRule.php +++ b/src/Validator/TemplateRule.php @@ -11,11 +11,6 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class TemplateRule implements RuleInterface { - public function getName(): string - { - return 'gii_template_rule'; - } - public function getHandler(): string|RuleHandlerInterface { return TemplateRuleHandler::class;