Skip to content

Commit

Permalink
refactor: Use friendsofphp/php-cs-fixer instead of squizlabs/php_code…
Browse files Browse the repository at this point in the history
…sniffer (#22)
  • Loading branch information
roadiz-ci committed Nov 6, 2024
1 parent 7f39198 commit 6f91007
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 454 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ jobs:
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install Dependencies
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
3 changes: 0 additions & 3 deletions Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"roadiz/jwt": "2.4.x-dev",
"roadiz/markdown": "2.4.x-dev",
"roadiz/models": "2.4.x-dev",
"roadiz/random": "2.4.x-dev",
"squizlabs/php_codesniffer": "^3.5"
"roadiz/random": "2.4.x-dev"
},
"config": {
"optimize-autoloader": true,
Expand Down
1 change: 1 addition & 0 deletions deprecated.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

use RZ\Roadiz\CompatBundle\Aliases;
Expand Down
13 changes: 0 additions & 13 deletions phpcs.xml.dist

This file was deleted.

6 changes: 3 additions & 3 deletions src/Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ final class Aliases
public static function getAliases(): array
{
return [
\RZ\Roadiz\CompatBundle\Controller\AppController::class => \RZ\Roadiz\CMS\Controllers\AppController::class,
\RZ\Roadiz\CompatBundle\Controller\Controller::class => \RZ\Roadiz\CMS\Controllers\Controller::class,
\RZ\Roadiz\CompatBundle\Theme\ThemeResolverInterface::class => \RZ\Roadiz\Utils\Theme\ThemeResolverInterface::class,
Controller\AppController::class => \RZ\Roadiz\CMS\Controllers\AppController::class,
Controller\Controller::class => \RZ\Roadiz\CMS\Controllers\Controller::class,
Theme\ThemeResolverInterface::class => \RZ\Roadiz\Utils\Theme\ThemeResolverInterface::class,
\RZ\Roadiz\CoreBundle\Bag\NodeTypes::class => \RZ\Roadiz\Core\Bags\NodeTypes::class,
\RZ\Roadiz\CoreBundle\Bag\Roles::class => \RZ\Roadiz\Core\Bags\Roles::class,
\RZ\Roadiz\CoreBundle\Bag\Settings::class => \RZ\Roadiz\Core\Bags\Settings::class,
Expand Down
9 changes: 5 additions & 4 deletions src/Console/ThemeAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ThemeAssetsCommand extends Command
public function __construct(
#[Autowire('%kernel.project_dir%')]
private readonly string $projectDir,
private readonly ThemeGenerator $themeGenerator
private readonly ThemeGenerator $themeGenerator,
) {
parent::__construct();
}
Expand Down Expand Up @@ -61,18 +61,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$themeInfo = new ThemeInfo($name, $this->projectDir);

if (!$themeInfo->exists()) {
throw new InvalidArgumentException($themeInfo->getThemePath() . ' does not exist.');
throw new InvalidArgumentException($themeInfo->getThemePath().' does not exist.');
}

$io->table([
'Description', 'Value'
'Description', 'Value',
], [
['Given name', $themeInfo->getName()],
['Theme path', $themeInfo->getThemePath()],
['Assets path', $themeInfo->getThemePath() . '/static'],
['Assets path', $themeInfo->getThemePath().'/static'],
]);

$this->themeGenerator->installThemeAssets($themeInfo, $expectedMethod);

return 0;
}
}
9 changes: 5 additions & 4 deletions src/Console/ThemeInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$themeInfo = new ThemeInfo($name, $this->projectDir);

if (!$themeInfo->exists()) {
throw new InvalidArgumentException($themeInfo->getClassname() . ' does not exist.');
throw new InvalidArgumentException($themeInfo->getClassname().' does not exist.');
}

if (!$themeInfo->isValid()) {
throw new InvalidArgumentException($themeInfo->getClassname() . ' is not a valid theme.');
throw new InvalidArgumentException($themeInfo->getClassname().' is not a valid theme.');
}
$io->table([
'Description', 'Value'
'Description', 'Value',
], [
['Given name', $themeInfo->getName()],
['Theme classname', $themeInfo->getClassname()],
['Theme path', $themeInfo->getThemePath()],
['Assets path', $themeInfo->getThemePath() . '/static'],
['Assets path', $themeInfo->getThemePath().'/static'],
]);

return 0;
}
}
19 changes: 7 additions & 12 deletions src/Console/ThemesListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class ThemesListCommand extends Command
{
public function __construct(
private readonly ThemeResolverInterface $themeResolver
private readonly ThemeResolverInterface $themeResolver,
) {
parent::__construct();
}
Expand All @@ -34,12 +34,6 @@ protected function configure(): void
);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
Expand All @@ -54,21 +48,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$name = str_replace('/', '\\', $name);
$theme = $this->themeResolver->findThemeByClass($name);
if (null === $theme) {
throw new InvalidArgumentException($name . ' theme cannot be found.');
throw new InvalidArgumentException($name.' theme cannot be found.');
}
$tableContent[] = [
str_replace('\\', '/', $theme->getClassName()),
($theme->isAvailable() ? 'X' : ''),
($theme->isBackendTheme() ? 'Backend' : 'Frontend'),
$theme->isAvailable() ? 'X' : '',
$theme->isBackendTheme() ? 'Backend' : 'Frontend',
];
} else {
$themes = $this->themeResolver->findAll();
if (count($themes) > 0) {
foreach ($themes as $theme) {
$tableContent[] = [
str_replace('\\', '/', $theme->getClassName()),
($theme->isAvailable() ? 'X' : ''),
($theme->isBackendTheme() ? 'Backend' : 'Frontend'),
$theme->isAvailable() ? 'X' : '',
$theme->isBackendTheme() ? 'Backend' : 'Frontend',
];
}
} else {
Expand All @@ -77,6 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$io->table(['Class (with / instead of \)', 'Enabled', 'Type'], $tableContent);

return 0;
}
}
Loading

0 comments on commit 6f91007

Please sign in to comment.