Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#93411 Cleanup, php cs fixer, pest #6

Merged
merged 18 commits into from
Apr 7, 2023
Merged

#93411 Cleanup, php cs fixer, pest #6

merged 18 commits into from
Apr 7, 2023

Conversation

Se7en-RU
Copy link
Contributor

@Se7en-RU Se7en-RU commented Mar 3, 2023

  • Почистил и обновил код в пакете, куда дотянулись руки
  • Добавил php cs fixer, pest взамен phpunit, github actions для них
  • Улучшил патчеры енамов, но потом их отключил в коде, т.к они сейчас ничего не делают (все это реализовано в шаблонах)
  • Поправил тесты, до этого они работали лишь из-за отсутствия строгой типизации в коде в некоторых местах

Обновление не ломает обратную совместимость, по-сути тут просто причесывание старого кода

@Se7en-RU Se7en-RU requested a review from MsNatali March 3, 2023 16:10
@Se7en-RU Se7en-RU self-assigned this Mar 3, 2023
@Se7en-RU Se7en-RU changed the title #93411 #93411 Cleanup, php cs fixer, pest Mar 3, 2023
@@ -4,7 +4,6 @@ composer.lock
npm-debug.log
yarn-error.log
.php_cs.cache
composer.lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем это из игнора убрал?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

он там 2 раза указывался, на 3 строке есть


return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

скопируй конфиг из наших сервисов https://gitlab.com/greensight/ensi/units/admin-auth/-/blob/master/.php-cs-fixer.php

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сделал, до этого был от серверного генератора, надо бы его там тоже будет обновить

composer.json Outdated
"scripts": {
"test": "phpunit"
}
"name": "ensi/laravel-openapi-client-generator",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут надо вернуть пробелы, сейчас появились табы откуда-то

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

там до этого было в разнобой вообще, сделал 4 пробела вместо табов

$patcher = new NodeJSEnumPatcher($file);
$patcher->patch();
} catch (Exception) {
$this->info("Patch enum: $file\t[SKIP]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выглядит так, как будто тут должен быть "error" и вывод текста ошибки ещё

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил вывод ошибки


$this->disableComposerPatchRequire = (bool) config('openapi-client-generator.php_args.composer_disable_patch_require', false);
$this->composerName = config("openapi-client-generator.{$this->client}_args.composer_name", 'ensi/openapi-client-php-example');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мне кажется что тут лучше не невалидное значение по-умолчанию делать, а кидать исключение, если не задано значение в конфиге

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрал значение по-умолчанию, теперь будет ошибка если этот параметр не задан

$patcher = new PhpEnumPatcher($file);
$patcher->patch();
} catch (Exception) {
$this->info("Patch enum: $file\t[SKIP]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

аналогично

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил вывод ошибки

}

file_put_contents($this->enumFile, $enum);
}

private function patchConstantProperties(string $enum, string $value, string $name, string $title): string
{
$enum = preg_replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не поняла что в итоге делает этот класс, если это удалено

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Решили в чате пока патчеры енамов оставить как есть


/**
* @var string
*/
protected $manifestName = 'package.json';

/**
* @var boolean
* @var bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в этом файле тоже можно вынести типизацию на уровень самого php

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сделал


public function getEnvironmentSetUp($app): void
{
config()->set('openapi-client-generator.apidoc_dir', ('./tests/api-docs'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишние скобочки круглые

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправил

// PHP client params
config()->set('openapi-client-generator.php_args.params', [
'apiPackage' => 'Api',
'invokerPackage' => 'Baristanko\\OpenapiClientPHPExample',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай без Baristanko, пусть тут будет Ensi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

изменил

@MsNatali MsNatali marked this pull request as draft March 9, 2023 07:23
@Se7en-RU Se7en-RU marked this pull request as ready for review March 10, 2023 15:10
@MsNatali MsNatali self-requested a review March 17, 2023 08:36
@MsNatali MsNatali merged commit 1f09415 into master Apr 7, 2023
@MsNatali MsNatali deleted the task-93411 branch April 7, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants