From 2beba8d5c3569187b40a0d852af2d91366520414 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 3 Mar 2022 14:20:10 -0500 Subject: [PATCH] Remove more redundant phpdoc properties --- .gitignore | 4 +- composer.json | 3 +- src/AnimeClient/Command/SyncLists.php | 5 -- src/AnimeClient/Types/Config.php | 14 +--- src/Ion/Di/Container.php | 19 ++--- src/Ion/View/HttpView.php | 8 +- tools/composer.json | 6 ++ tools/phinx/composer.json | 5 ++ tools/rector.php | 102 ++++++++++++++++++++++++++ 9 files changed, 125 insertions(+), 41 deletions(-) create mode 100644 tools/composer.json create mode 100644 tools/phinx/composer.json create mode 100644 tools/rector.php diff --git a/.gitignore b/.gitignore index 772e5fe4..02d5513e 100644 --- a/.gitignore +++ b/.gitignore @@ -150,4 +150,6 @@ public/mal_mappings.json .is-dev -tmp \ No newline at end of file +tmp +tools/vendor/ +tools/phinx/vendor/ \ No newline at end of file diff --git a/composer.json b/composer.json index 225341ab..1b47692d 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "aura/html": "^2.5.0", "aura/router": "^3.1.0", "aura/session": "^2.1.0", - "aviat/banker": "^3.0.0 || ^4.0.0", + "aviat/banker": "^3.0.0", "aviat/query": "^3.0.0", "danielstjules/stringy": "^3.1.0", "ext-dom": "*", @@ -53,7 +53,6 @@ "php": ">= 8.0.0", "psr/http-message": "^1.0.1", "psr/log": "*", - "robmorgan/phinx": "^0.12.4", "symfony/polyfill-mbstring": "^1.0.0", "symfony/polyfill-util": "^1.0.0", "tracy/tracy": "^2.8.0", diff --git a/src/AnimeClient/Command/SyncLists.php b/src/AnimeClient/Command/SyncLists.php index 431e8246..c8b3d1d7 100644 --- a/src/AnimeClient/Command/SyncLists.php +++ b/src/AnimeClient/Command/SyncLists.php @@ -46,27 +46,22 @@ final class SyncLists extends BaseCommand { /** * Model for making requests to Anilist API - * @var Anilist\Model */ private Anilist\Model $anilistModel; /** * Model for making requests to Kitsu API - * @var API\Kitsu\Model */ private API\Kitsu\Model $kitsuModel; /** * Does the Kitsu API have valid authentication? - * @var bool */ private bool $isKitsuAuthenticated = FALSE; /** * Sync Kitsu <=> Anilist * - * @param array $args - * @param array $options * @throws ContainerException * @throws NotFoundException * @throws Throwable diff --git a/src/AnimeClient/Types/Config.php b/src/AnimeClient/Types/Config.php index b9aba3ee..84ff5c12 100644 --- a/src/AnimeClient/Types/Config.php +++ b/src/AnimeClient/Types/Config.php @@ -81,19 +81,9 @@ class Config extends AbstractType { public ?string $whose_list; - // ------------------------------------------------------------------------ - // Application config - // ------------------------------------------------------------------------ + public array $menus = []; - /** - * @var array - */ - public array $menus; - - /** - * @var array - */ - public array $routes; + public array $routes = []; // ------------------------------------------------------------------------ // Generated config values diff --git a/src/Ion/Di/Container.php b/src/Ion/Di/Container.php index c24b64fe..8e91fc70 100644 --- a/src/Ion/Di/Container.php +++ b/src/Ion/Di/Container.php @@ -24,35 +24,26 @@ use Psr\Log\LoggerInterface; */ class Container implements ContainerInterface { - /** - * Array of container Generator functions - * - * @var Callable[] - */ - protected array $container = []; - /** * Array of object instances - * - * @var array */ protected array $instances = []; /** * Map of logger instances - * - * @var array */ protected array $loggers = []; /** * Constructor * - * @param array $values (optional) + * @param (callable)[] $container (optional) */ - public function __construct(array $values = []) + public function __construct(/** + * Array of container Generator functions + */ + protected array $container = []) { - $this->container = $values; $this->loggers = []; } diff --git a/src/Ion/View/HttpView.php b/src/Ion/View/HttpView.php index 42f0b8f8..a3a16dab 100644 --- a/src/Ion/View/HttpView.php +++ b/src/Ion/View/HttpView.php @@ -26,27 +26,21 @@ use Psr\Http\Message\ResponseInterface; /** * Base view class for Http output */ -class HttpView implements HttpViewInterface{ +class HttpView implements HttpViewInterface, \Stringable{ /** * HTTP response Object - * - * @var ResponseInterface */ public ResponseInterface $response; /** * If the view has sent output via * __toString or send method - * - * @var boolean */ protected bool $hasRendered = FALSE; /** * Response mime type - * - * @var string */ protected string $contentType = ''; diff --git a/tools/composer.json b/tools/composer.json new file mode 100644 index 00000000..3e6d249f --- /dev/null +++ b/tools/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "friendsofphp/php-cs-fixer": "^3.6", + "rector/rector": "^0.12.16" + } +} diff --git a/tools/phinx/composer.json b/tools/phinx/composer.json new file mode 100644 index 00000000..e8d4e05d --- /dev/null +++ b/tools/phinx/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "robmorgan/phinx": "^0.12.4" + } +} \ No newline at end of file diff --git a/tools/rector.php b/tools/rector.php new file mode 100644 index 00000000..09a55ec9 --- /dev/null +++ b/tools/rector.php @@ -0,0 +1,102 @@ +parameters(); + $parameters->set(Option::AUTO_IMPORT_NAMES, false); + $parameters->set(Option::IMPORT_SHORT_CLASSES, false); + $parameters->set(Option::SKIP, [ + ReadOnlyPropertyRector::class, + ]); + + walk_array([$config, 'import'], [ + LevelSetList::UP_TO_PHP_80, + ]); + + $services = $config->services(); + walk_array([$services, 'set'], [ + AddArrayDefaultToArrayPropertyRector::class, + AddArrayParamDocTypeRector::class, + AddArrayReturnDocTypeRector::class, + AddClosureReturnTypeRector::class, + AddMethodCallBasedStrictParamTypeRector::class, + CallUserFuncArrayToVariadicRector::class, + CallUserFuncToMethodCallRector::class, + ChangeIfElseValueAssignToEarlyReturnRector::class, + ChangeNestedForeachIfsToEarlyContinueRector::class, + CompleteDynamicPropertiesRector::class, + ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, + CountArrayToEmptyArrayComparisonRector::class, + ForRepeatedCountToOwnVariableRector::class, + ForToForeachRector::class, + // MakeTypedPropertyNullableIfCheckedRector::class, + NewlineAfterStatementRector::class, + NewlineBeforeNewAssignSetRector::class, + ParamTypeByMethodCallTypeRector::class, + ParamTypeByParentCallTypeRector::class, + RemoveAlwaysElseRector::class, + RemoveDuplicatedCaseInSwitchRector::class, + RemoveFinalFromConstRector::class, + RemoveUnusedForeachKeyRector::class, + RemoveUselessParamTagRector::class, + RemoveUselessReturnTagRector::class, + RemoveUselessVarTagRector::class, + // SimplifyDeMorganBinaryRector::class, + SimplifyDuplicatedTernaryRector::class, + SimplifyIfElseToTernaryRector::class, + SimplifyIfReturnBoolRector::class, + SimplifyTautologyTernaryRector::class, + SwitchNegatedTernaryRector::class, + TypedPropertyFromAssignsRector::class, + WrapEncapsedVariableInCurlyBracesRector::class, + ]); +};