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

Merge #6

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .build/phpcs.xml

This file was deleted.

23 changes: 2 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
### IDE ###
nbproject/
.idea/

### Composer ###
composer.phar

### Node ###
node_modules/

### General ###
*.log
cache.properties

### CI ###
.build/bin/
.build/vendor/
.build/web/
.build/logs/
.build/coverage/
.build/pdepend/
/vendor
/public
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"recommendations": [
"benjaminkott.typo3-typoscript",
"devsense.phptools-vscode",
"obliviousharmony.vscode-php-codesniffer"
"obliviousharmony.vscode-php-codesniffer",
"sanderronde.phpstan-vscode",
],
"unwantedRecommendations": []
}
8 changes: 3 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"phpCodeSniffer.exec.linux": "./.build/bin/phpcs",
"phpCodeSniffer.exec.linux": "./vendor/bin/phpcs",
"phpCodeSniffer.standard": "Custom",
"phpCodeSniffer.standardCustom": "./.build/phpcs.xml",
"phpCodeSniffer.exclude": [
"**/vendor/{,!(remind)/**}"
]
"phpCodeSniffer.standardCustom": "./phpcs.xml",
"phpCodeSniffer.exclude": []
}
10 changes: 7 additions & 3 deletions Classes/Command/DeleteBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ final class DeleteBackupCommand extends Command
private const INPUT_DIR = 'dir';
private const INPUT_FILE = 'file';
private const INPUT_KEEP_COUNT = 'keep-count';

/**
* @var mixed[]
*/
private array $extensionConfiguration;

public function __construct(
Expand Down Expand Up @@ -68,12 +72,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$files = array_values(array_diff(scandir($dir, SCANDIR_SORT_ASCENDING), ['.', '..']));
$files = array_values(array_diff(scandir($dir, SCANDIR_SORT_ASCENDING) ?: [], ['.', '..']));
$matches = array_filter($files, function (string $fileToCheck) use ($file) {
return preg_match(FileNamingUtility::getRegexPattern($file), $fileToCheck);
return (bool) preg_match(FileNamingUtility::getRegexPattern($file), $fileToCheck);
});

$filesToBeDeleted = array_slice($matches, 0, -$input->getOption(self::INPUT_KEEP_COUNT));
$filesToBeDeleted = array_slice($matches, 0, -(int)$input->getOption(self::INPUT_KEEP_COUNT));

foreach ($filesToBeDeleted as $file) {
unlink(FileNamingUtility::buildPath($dir, $file));
Expand Down
6 changes: 5 additions & 1 deletion Classes/Command/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ final class ExportCommand extends Command
'be_sessions',
'fe_sessions',
'fe_users',
'sys_file_processedfile',
'sys_history',
'sys_http_report',
'sys_lockedrecords',
'sys_log',
];

/**
* @var mixed[]
*/
private array $extensionConfiguration;

public function __construct(
Expand Down Expand Up @@ -138,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
];

foreach ($processes as $process) {
$exitCode = $process->run(function ($type, $buffer) use ($output, $path) {
$exitCode = $process->run(function ($type, $buffer) use ($output, $path): void {
if ($type === Process::ERR) {
$output->writeln($buffer);
} else {
Expand Down
7 changes: 5 additions & 2 deletions Classes/Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ final class ImportCommand extends Command
private const INPUT_DIR = 'dir';
private const INPUT_FILE = 'file';

/**
* @var mixed[]
*/
private array $extensionConfiguration;

public function __construct(
Expand Down Expand Up @@ -66,9 +69,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$files = array_values(array_diff(scandir($dir, SCANDIR_SORT_ASCENDING), ['.', '..']));
$files = array_values(array_diff(scandir($dir, SCANDIR_SORT_ASCENDING) ?: [], ['.', '..']));
$matches = array_filter($files, function (string $fileToCheck) use ($file) {
return preg_match(FileNamingUtility::getRegexPattern($file), $fileToCheck);
return (bool) preg_match(FileNamingUtility::getRegexPattern($file), $fileToCheck);
});
if (!empty($matches)) {
$path = FileNamingUtility::buildPath($dir, array_pop($matches));
Expand Down
30 changes: 26 additions & 4 deletions Classes/Service/DatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
class DatabaseService
{
private const CONNECTION_NAME = 'Default';

/**
* @var mixed[]
*/
private array $connectionConfig;

private Connection $connection;

private ?string $myCnf = null;

public function __construct()
Expand All @@ -26,25 +32,38 @@ public function __construct()
public function mysql(mixed $input = null): Process
{
$command = ['mysql', ...$this->buildConnectionArguments()];
return new Process($command, null, null, $input);
$process = new Process($command, null, null, $input);
$process->setTimeout(null);
return $process;
}

/**
* @param string[] $args
*/
public function mysqldump(array $args = []): Process
{
$command = ['mysqldump', ...$this->buildConnectionArguments(), ...$args];
return new Process($command);
$process = new Process($command);
$process->setTimeout(null);
return $process;
}

public function getDbName(): string
{
return $this->connectionConfig['dbname'];
}

/**
* @return string[]
*/
public function getTableNames(): array
{
return $this->connection->getSchemaManager()->listTableNames();
}

/**
* @return string[]
*/
private function buildConnectionArguments(): array
{
return [
Expand All @@ -57,12 +76,15 @@ private function buildConnectionArguments(): array
];
}

private function createMyCnf()
private function createMyCnf(): string
{
$user = $this->connectionConfig['user'] ?? null;
$password = $this->connectionConfig['password'] ?? null;

if ($this->myCnf && file_exists($this->myCnf)) {
if (
$this->myCnf &&
file_exists($this->myCnf)
) {
return $this->myCnf;
}

Expand Down
29 changes: 19 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
"typo3/cms-core": "^12.4"
},
"require-dev": {
"slevomat/coding-standard": "^8.14",
"squizlabs/php_codesniffer": "^3.7"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"remind/coding-standard": "^1.0",
"saschaegerer/phpstan-typo3": "^1.10",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.10",
"symfony/process": "^7.2"
},
"autoload": {
"psr-4": {
Expand All @@ -28,25 +34,28 @@
"config": {
"optimize-autoloader": true,
"apcu-autoloader": true,
"vendor-dir": ".build/vendor",
"bin-dir": ".build/bin",
"sort-packages": true,
"allow-plugins": {
"typo3/cms-composer-installers": true,
"typo3/class-alias-loader": true,
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": ".build/web",
"extension-key": "rmnd_backup"
}
},
"scripts": {
"phpcs": "@php ./.build/bin/phpcs --standard=.build/phpcs.xml --extensions=php --ignore=.build --report=full -n .",
"phpcbf": "@php ./.build/bin/phpcbf --standard=.build/phpcs.xml --extensions=php --ignore=.build ."
"phpcs": "@php ./vendor/bin/phpcs --standard=phpcs.xml --extensions=php --report=full -n .",
"phpcbf": "@php ./vendor/bin/phpcbf --standard=phpcs.xml --extensions=php .",
"phpstan": "@php ./vendor/bin/phpstan analyse -c phpstan.neon",
"static-analysis": [
"@composer phpcs",
"@composer phpstan"
]
}
}
}
Loading
Loading