Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Fix rector CS
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Oct 14, 2023
1 parent d0debf3 commit 7e04094
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 96 deletions.
2 changes: 1 addition & 1 deletion app/Application/Console/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function progress(int $max = 0): ProgressBar
*/
protected function count(iterable $items): int
{
if ($items instanceof \Countable || \is_array($items)) {
if (\is_countable($items)) {
return \count($items);
}

Expand Down
30 changes: 4 additions & 26 deletions app/Application/Console/Commands/DocsDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
class DocsDiffCommand extends DocsTranslationCommand
{
/**
* @var string
*/
private const ERROR_BAD_COMMIT = '<error>The commit indicated on the page "%s" is not correct</error>';

/**
Expand All @@ -41,11 +38,6 @@ class DocsDiffCommand extends DocsTranslationCommand
'Calculate and update the number of differences ' .
'between the original and the translation documentation pages';

/**
* @param Documentation $page
* @param FileInterface $file
* @return void
*/
protected function each(Documentation $page, FileInterface $file): void
{
//
Expand Down Expand Up @@ -74,26 +66,17 @@ protected function each(Documentation $page, FileInterface $file): void
$page->translation->applyTranslateChanges($slice->count());
}

/**
* @param FileInterface $file
* @return FileInterface
*/
protected function getSourceFile(FileInterface $file): FileInterface
{
$branch = $file->getBranch();

return $this->source->getBranches()
->first(fn(BranchInterface $b) => $b->getName() === $branch->getName())
->first(fn(BranchInterface $b): bool => $b->getName() === $branch->getName())
->getFiles()
->first(fn(FileInterface $f) => $f->getPathname() === $file->getPathname())
->first(fn(FileInterface $f): bool => $f->getPathname() === $file->getPathname())
;
}

/**
* @param Enumerable $commits
* @param string|null $needle
* @return Enumerable|null
*/
private function search(Enumerable $commits, ?string $needle): ?Enumerable
{
if ($needle === null) {
Expand All @@ -103,12 +86,12 @@ private function search(Enumerable $commits, ?string $needle): ?Enumerable
$found = false;

$result = $commits
->filter(static function (array $commit) use ($needle, &$found) {
->filter(static function (array $commit) use ($needle, &$found): bool {
if ($found === false && $needle === $commit['sha']) {
$found = true;
}

return ! $found;
return !$found;
});

if ($found === false) {
Expand All @@ -118,11 +101,6 @@ private function search(Enumerable $commits, ?string $needle): ?Enumerable
return $result;
}

/**
* @param Documentation $page
* @param Enumerable $history
* @return void
*/
private function writeCommitError(Documentation $page, Enumerable $history): void
{
$this->line('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function handle(
foreach ($versions->all() as $version) {
$progress = $this->progress();

$generator = new KeywordsGenerator(function (Entry $entry, Documentation $page) use ($progress) {
$generator = new KeywordsGenerator(function (Entry $entry, Documentation $page) use ($progress): void {
$progress->setMessage(\vsprintf(
'Вычисление TF-IDF: <comment>%s</comment> -> [<info>%5f</info>] <info>%s</info>',
[
Expand Down
23 changes: 5 additions & 18 deletions app/Application/Http/View/Composers/YandexMetrikaComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,18 @@
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\View\View;

class YandexMetrikaComposer implements ViewComposerInterface
final readonly class YandexMetrikaComposer implements ViewComposerInterface
{
/**
* @var Repository
*/
private Repository $config;
public function __construct(
private Repository $config,
) {}

/**
* @param Repository $config
*/
public function __construct(Repository $config)
{
$this->config = $config;
}

/**
* @param View $view
* @return void
*/
public function compose(View $view): void
{
$id = $this->config->get('services.metrika.id');

$view->with('metrika', (object)[
'id' => $id,
'id' => $id,
'enabled' => (bool)$id,
]);
}
Expand Down
7 changes: 0 additions & 7 deletions app/Application/Http/View/Directives/ActiveDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@

class ActiveDirective implements GeneratedDirectiveInterface
{
/**
* @var string
*/
private const TEMPLATE_EXPRESSION = 'app(\Illuminate\Routing\Router::class)->is(%s) ? \'active\' : \'\'';

/**
* @param string $expression
* @return string
*/
public function generate(string $expression): string
{
return '<?=' . \sprintf(self::TEMPLATE_EXPRESSION, $expression) . '?>';
Expand Down
4 changes: 0 additions & 4 deletions app/Application/Http/View/Directives/IfDirectiveInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@

interface IfDirectiveInterface extends DirectiveInterface
{
/**
* @param mixed ...$args
* @return bool
*/
public function match(mixed ...$args): bool;
}
21 changes: 4 additions & 17 deletions app/Application/Http/View/Directives/NavDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,12 @@

use Illuminate\Routing\Router;

final class NavDirective implements IfDirectiveInterface
final readonly class NavDirective implements IfDirectiveInterface
{
/**
* @var Router
*/
private Router $router;
public function __construct(
private Router $router,
) {}

/**
* @param Router $router
*/
public function __construct(Router $router)
{
$this->router = $router;
}

/**
* @param mixed ...$args
* @return bool
*/
public function match(mixed ...$args): bool
{
return $this->router->is(...$args);
Expand Down
5 changes: 0 additions & 5 deletions app/Domain/Article/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function getId(): ArticleId

/**
* @param non-empty-string $title
* @return $this
*/
public function rename(string $title): self
{
Expand All @@ -71,10 +70,6 @@ public function rename(string $title): self
return $this;
}

/**
* @param string $description
* @return $this
*/
public function describe(string $description): self
{
$this->description = $description;
Expand Down
6 changes: 3 additions & 3 deletions app/Domain/Article/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use App\ContentRenderer\ContentRendererInterface;

final class Body
final class Body implements \Stringable
{
protected ?string $source = null;
protected ?string $rendered = null;
private ?string $source = null;
private ?string $rendered = null;

public function clear(): void
{
Expand Down
1 change: 0 additions & 1 deletion app/Domain/Documentation/KeywordsGenerator/QueueMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ final class QueueMap implements \IteratorAggregate, \Countable
private array $entries = [];

/**
* @param DocumentMap $documents
* @param int<1, max> $limit
*/
public function __construct(
Expand Down
4 changes: 0 additions & 4 deletions app/Infrastructure/Persistence/Doctrine/Type/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): stri

/**
* @param TValue $value
*
* @return string
*/
abstract protected function pack(mixed $value): string;

Expand Down Expand Up @@ -68,8 +66,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?array
}

/**
* @param string $value
*
* @return TValue
*/
abstract protected function unpack(string $value): mixed;
Expand Down
8 changes: 2 additions & 6 deletions app/Infrastructure/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
class ViewServiceProvider extends ServiceProvider
{
/**
* @param Repository $config
* @param Factory $factory
* @param BladeCompiler $compiler
* @return void
* @throws BindingResolutionException
*/
public function boot(Repository $config, Factory $factory, BladeCompiler $compiler): void
Expand All @@ -35,11 +31,11 @@ public function boot(Repository $config, Factory $factory, BladeCompiler $compil
$impl = $this->app->make($directive);

if ($impl instanceof GeneratedDirectiveInterface) {
$compiler->directive($name, fn(...$args): string => $impl->generate(...$args));
$compiler->directive($name, static fn(...$args): string => $impl->generate(...$args));
}

if ($impl instanceof IfDirectiveInterface) {
$compiler->if($name, fn(...$args): bool => $impl->match(...$args));
$compiler->if($name, static fn(...$args): bool => $impl->match(...$args));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
$config->sets([
// CodeStyle
SetList::TYPE_DECLARATION,
SetList::CODING_STYLE,
SetList::EARLY_RETURN,
SetList::PRIVATIZATION,
// Lang/Frames
LevelSetList::UP_TO_PHP_82,
Expand All @@ -37,7 +35,7 @@

$config->parallel(360);

$config->importNames();
//$config->importNames();
$config->importShortClasses(false);

$config->skip([
Expand Down Expand Up @@ -81,5 +79,7 @@

// Не умеет в касты к анонимке/каррирование
PrivatizeLocalGetterToPropertyRector::class,

\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class,
]);
};

0 comments on commit 7e04094

Please sign in to comment.