Skip to content

Commit a39eb18

Browse files
committed
Code: apple codesniffer
1 parent 865384c commit a39eb18

27 files changed

+128
-159
lines changed

src/Cache/Cleaners/LocalFilesystemCleaner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class LocalFilesystemCleaner implements ICleaner
1010
{
1111

1212
/** @var string[] */
13-
private $directories;
13+
private array $directories;
1414

1515
/** @var string[] */
16-
private $ignored;
16+
private array $ignored;
1717

1818
/**
1919
* @param string[] $directories

src/Cache/Cleaners/MemcachedCleaner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MemcachedCleaner implements ICleaner
1111
{
1212

1313
/** @var Memcached[]|Memcache[] */
14-
private $memcaches;
14+
private array $memcaches;
1515

1616
/**
1717
* @param Memcached[]|Memcache[] $memcaches

src/Cache/Cleaners/NetteCachingStorageCleaner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NetteCachingStorageCleaner implements ICleaner
1111
{
1212

1313
/** @var IStorage[] */
14-
private $storages;
14+
private array $storages;
1515

1616
/**
1717
* @param IStorage[] $storages

src/Cache/Generators/DiContainersCacheGenerator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ class DiContainersCacheGenerator implements IGenerator
1010
{
1111

1212
/** @var mixed[] */
13-
private $config;
13+
private array $config;
1414

15-
/** @var Configurator */
16-
private $configurator;
15+
private Configurator $configurator;
1716

1817
/**
1918
* @param mixed[] $config

src/Cache/Generators/LatteTemplatesCacheGenerator.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@
1313
class LatteTemplatesCacheGenerator implements IGenerator
1414
{
1515

16-
/** @var ITemplateFactory */
17-
private $templateFactory;
16+
private ITemplateFactory $templateFactory;
1817

1918
/** @var string[] */
20-
private $dirs;
19+
private array $dirs;
2120

2221
/** @var string[] */
23-
private $excludeDirs;
22+
private array $excludeDirs;
2423

25-
/** @var string|null */
26-
private $rootDir;
24+
private ?string $rootDir = null;
2725

2826
/**
2927
* @param string[] $dirs

src/Command/AdvancedCache/CacheCleanCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,36 @@
55
use Contributte\Console\Extra\Cache\Cleaners\ICleaner;
66
use Contributte\Console\Extra\Exception\Logical\InvalidArgumentException;
77
use Contributte\Console\Extra\Utils\Utils;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Helper\Table;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Input\InputOption;
1213
use Symfony\Component\Console\Output\OutputInterface;
1314
use Symfony\Component\Console\Style\SymfonyStyle;
1415

16+
#[AsCommand(
17+
name: 'contributte:cache:clean',
18+
description: 'Clean cache',
19+
)]
1520
class CacheCleanCommand extends Command
1621
{
1722

18-
/** @var string */
19-
protected static $defaultName = 'contributte:cache:clean';
20-
2123
/** @var ICleaner[] */
22-
private $cleaners = [];
24+
private array $cleaners = [];
2325

2426
/**
2527
* @param ICleaner[] $cleaners
2628
*/
2729
public function __construct(array $cleaners)
2830
{
2931
parent::__construct();
32+
3033
$this->cleaners = $cleaners;
3134
}
3235

3336
protected function configure(): void
3437
{
35-
$this->setName(static::$defaultName);
36-
$this->setDescription('Clean cache');
3738
$this->addOption('list', 'l', InputOption::VALUE_NONE, 'List all available cleaners');
3839
$this->addOption('cleaner', 'c', InputOption::VALUE_REQUIRED, 'Use only one cleaner');
3940
}

src/Command/AdvancedCache/CacheGenerateCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,36 @@
55
use Contributte\Console\Extra\Cache\Generators\IGenerator;
66
use Contributte\Console\Extra\Exception\Logical\InvalidArgumentException;
77
use Contributte\Console\Extra\Utils\Utils;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Helper\Table;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Input\InputOption;
1213
use Symfony\Component\Console\Output\OutputInterface;
1314
use Symfony\Component\Console\Style\SymfonyStyle;
1415

16+
#[AsCommand(
17+
name: 'contributte:cache:generate',
18+
description: 'Generate cache',
19+
)]
1520
class CacheGenerateCommand extends Command
1621
{
1722

18-
/** @var string */
19-
protected static $defaultName = 'contributte:cache:generate';
20-
2123
/** @var IGenerator[] */
22-
private $generators = [];
24+
private array $generators = [];
2325

2426
/**
2527
* @param IGenerator[] $generators
2628
*/
2729
public function __construct(array $generators)
2830
{
2931
parent::__construct();
32+
3033
$this->generators = $generators;
3134
}
3235

3336
protected function configure(): void
3437
{
35-
$this->setName(static::$defaultName);
36-
$this->setDescription('Generate cache');
3738
$this->addOption('list', 'l', InputOption::VALUE_NONE, 'List all available generators');
3839
$this->addOption('generator', 'g', InputOption::VALUE_REQUIRED, 'Use only one generator');
3940
}

src/Command/Cache/CachePurgeCommand.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,30 @@
33
namespace Contributte\Console\Extra\Command\Cache;
44

55
use Contributte\Console\Extra\Utils\Files;
6+
use Symfony\Component\Console\Attribute\AsCommand;
67
use Symfony\Component\Console\Command\Command;
78
use Symfony\Component\Console\Input\InputInterface;
89
use Symfony\Component\Console\Output\OutputInterface;
910
use Symfony\Component\Console\Style\SymfonyStyle;
1011

12+
#[AsCommand(
13+
name: 'nette:cache:purge',
14+
description: 'Clear temp folders and others',
15+
)]
1116
class CachePurgeCommand extends Command
1217
{
1318

14-
/** @var string */
15-
protected static $defaultName = 'nette:cache:purge';
16-
1719
/** @var string[] */
18-
private $dirs;
20+
private array $dirs;
1921

2022
/**
2123
* @param string[] $dirs
2224
*/
2325
public function __construct(array $dirs)
2426
{
2527
parent::__construct();
26-
$this->dirs = $dirs;
27-
}
2828

29-
protected function configure(): void
30-
{
31-
$this->setName(static::$defaultName);
32-
$this->setDescription('Clear temp folders and others');
29+
$this->dirs = $dirs;
3330
}
3431

3532
protected function execute(InputInterface $input, OutputInterface $output): int

src/Command/Caching/CachingClearCommand.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,32 @@
44

55
use Contributte\Console\Extra\Utils\Utils;
66
use Nette\Caching\Cache;
7-
use Nette\Caching\IStorage;
87
use Nette\Caching\Storage;
8+
use Symfony\Component\Console\Attribute\AsCommand;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Input\InputOption;
1212
use Symfony\Component\Console\Output\OutputInterface;
1313
use Symfony\Component\Console\Style\SymfonyStyle;
1414

15+
#[AsCommand(
16+
name: 'nette:caching:clear',
17+
description: 'Clear Nette Caching Storage',
18+
)]
1519
class CachingClearCommand extends Command
1620
{
1721

18-
/** @var string */
19-
protected static $defaultName = 'nette:caching:clear';
20-
21-
/** @var IStorage */
22-
private $storage;
22+
private Storage $storage;
2323

2424
public function __construct(Storage $storage)
2525
{
2626
parent::__construct();
27+
2728
$this->storage = $storage;
2829
}
2930

3031
protected function configure(): void
3132
{
32-
$this->setName(static::$defaultName);
33-
$this->setDescription('Clear Nette Caching Storage');
3433
$this->addOption('all', null, InputOption::VALUE_OPTIONAL, 'Clear whole storage', false);
3534
$this->addOption('tag', 't', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Clear by tag(s)', []);
3635
$this->addOption('priority', 'p', InputOption::VALUE_OPTIONAL, 'Clear by priority');

src/Command/DI/DIPurgeCommand.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,30 @@
33
namespace Contributte\Console\Extra\Command\DI;
44

55
use Contributte\Console\Extra\Utils\Files;
6+
use Symfony\Component\Console\Attribute\AsCommand;
67
use Symfony\Component\Console\Command\Command;
78
use Symfony\Component\Console\Input\InputInterface;
89
use Symfony\Component\Console\Output\OutputInterface;
910
use Symfony\Component\Console\Style\SymfonyStyle;
1011

12+
#[AsCommand(
13+
name: 'nette:di:purge',
14+
description: 'Clear temp/cache/Nette.Configurator folder',
15+
)]
1116
class DIPurgeCommand extends Command
1217
{
1318

14-
/** @var string */
15-
protected static $defaultName = 'nette:di:purge';
16-
1719
/** @var string[] */
18-
private $dirs;
20+
private array $dirs;
1921

2022
/**
2123
* @param string[] $dirs
2224
*/
2325
public function __construct(array $dirs)
2426
{
2527
parent::__construct();
26-
$this->dirs = $dirs;
27-
}
2828

29-
protected function configure(): void
30-
{
31-
$this->setName(static::$defaultName);
32-
$this->setDescription('Clear temp/cache/Nette.Configurator folder');
29+
$this->dirs = $dirs;
3330
}
3431

3532
protected function execute(InputInterface $input, OutputInterface $output): int

src/Command/Database/BackupCommand.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44

55
use Contributte\Console\Extra\Utils\Database;
66
use Contributte\Console\Extra\Utils\Utils;
7+
use Symfony\Component\Console\Attribute\AsCommand;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213

14+
#[AsCommand(
15+
name: 'contributte:database:backup',
16+
description: "Dump database to defined file and path, this command internally use 'mysqldump' or 'pg_dump' and 'gzip' and can not work without these installed binaries",
17+
)]
1318
class BackupCommand extends Command
1419
{
1520

16-
/** @var string */
17-
protected static $defaultName = 'contributte:database:backup';
18-
19-
/** @var string */
20-
private $backupPath;
21+
private string $backupPath;
2122

2223
public function __construct(string $backupPath = '')
2324
{
2425
parent::__construct();
26+
2527
$this->backupPath = $backupPath;
2628
}
2729

2830
protected function configure(): void
2931
{
30-
$this->setName(self::$defaultName)
31-
->setDescription('Dump database to defined file and path, this command internally use "mysqldump" or "pg_dump" and "gzip" and can not work without these installed binaries');
32-
3332
$this->addArgument('platform', InputArgument::REQUIRED, 'mysql|postgresql')
3433
->addArgument('host', InputArgument::REQUIRED, 'SQL server IP')
3534
->addArgument('port', InputArgument::REQUIRED, 'SQL server port')
@@ -42,6 +41,13 @@ protected function configure(): void
4241
->addOption('bin-path', 'b', InputOption::VALUE_OPTIONAL, 'path to mysqldump or pg_dump binary');
4342
}
4443

44+
protected function isGzipEnabled(): bool
45+
{
46+
exec('which gzip > /dev/null', $retParams, $retVal);
47+
48+
return $retVal === 0;
49+
}
50+
4551
protected function execute(InputInterface $input, OutputInterface $output): int
4652
{
4753
// Gzip compression
@@ -159,11 +165,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int
159165
return 1;
160166
}
161167

162-
public function isGzipEnabled(): bool
163-
{
164-
exec('which gzip > /dev/null', $retParams, $retVal);
165-
166-
return $retVal === 0;
167-
}
168-
169168
}

src/Command/Database/LoadCommand.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44

55
use Contributte\Console\Extra\Utils\Database;
66
use Contributte\Console\Extra\Utils\Utils;
7+
use Symfony\Component\Console\Attribute\AsCommand;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213

14+
#[AsCommand(
15+
name: 'contributte:database:load',
16+
description: "Import given .sql or .gz file into database, this command internally use 'mysql' or 'psql' and 'gunzip' and can not work without these installed binaries",
17+
)]
1318
class LoadCommand extends Command
1419
{
1520

16-
/** @var string */
17-
protected static $defaultName = 'contributte:database:load';
18-
1921
protected function configure(): void
2022
{
21-
$this->setName(self::$defaultName)
22-
->setDescription('Import given .sql or .gz file into database, this command internally use \'mysql\' or \'psql\' and \'gunzip\' and can not work without these installed binaries');
23-
2423
$this->addArgument('platform', InputArgument::REQUIRED, 'mysql|postgresql')
2524
->addArgument('host', InputArgument::REQUIRED, 'SQL server IP')
2625
->addArgument('port', InputArgument::REQUIRED, 'SQL server port')
@@ -126,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
126125
return 1;
127126
}
128127

129-
public function isGunzipEnabled(): bool
128+
protected function isGunzipEnabled(): bool
130129
{
131130
exec('which gunzip > /dev/null', $retParams, $retVal);
132131

0 commit comments

Comments
 (0)