Skip to content

Commit

Permalink
php cs
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag committed Nov 21, 2023
1 parent 90a777c commit 7cdc637
Show file tree
Hide file tree
Showing 18 changed files with 373 additions and 268 deletions.
83 changes: 83 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

return (new PhpCsFixer\Config())
->setRiskyAllowed(false)
->setRules([
'@Symfony' => true,
'@PHP80Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
// one should use PHPUnit methods to set up expected exception instead of annotations
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author',
'package',
'expectedException',
'expectedExceptionMessage',
'expectedExceptionMessageRegExp',
],
],
'function_typehint_space' => false,
'no_empty_phpdoc' => true,
'global_namespace_import' => ['import_classes' => true, 'import_functions' => true, 'import_constants' => true],
'no_superfluous_phpdoc_tags' => ['allow_mixed' => false, 'allow_unused_params' => false],
'phpdoc_line_span' => ['property' => 'single'],
'heredoc_to_nowdoc' => true,
'list_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => ['statements' => ['if', 'break', 'continue', 'declare', 'return', 'throw', 'try', 'yield']],
'no_extra_blank_lines' => [
'tokens' => [
'break',
'continue',
'extra',
'return',
'throw',
'use',
'parenthesis_brace_block',
'square_brace_block',
'curly_brace_block',
],
],
'echo_tag_syntax' => true,
'method_argument_space' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
'php_unit_test_class_requires_covers' => true,
'phpdoc_align' => [
'tags' => [
'param', 'return', 'throws', 'type', 'var'
],
],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_no_alias_tag' => ['replacements' => ['link' => 'website']],
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'phpdoc_types_order' => false, // breaks psalm-specific notation sometimes!
'semicolon_after_instruction' => true,
'single_blank_line_at_eof' => true,
'single_line_throw' => false,
'types_spaces' => false,
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=' => 'align_single_space_minimal',
'-=' => 'align_single_space_minimal',
'+=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
'===' => null,
'??=' => 'align_single_space_minimal',
],
],
'concat_space' => [
'spacing' => 'one',
],
'operator_linebreak' => ['only_booleans' => true, 'position' => 'end'],
'yoda_style' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
);
18 changes: 10 additions & 8 deletions src/Bridge/ElFinderBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace FM\ElfinderBundle\Bridge;

use Symfony\Component\HttpFoundation\Session\SessionInterface;
use FM\ElfinderBundle\ElFinder\ElFinder;
use elFinderVolumeDriver;
use FM\ElfinderBundle\ElFinder\ElFinder;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class ElFinderBridge extends ElFinder
{
Expand All @@ -19,21 +19,27 @@ public function __construct($opts)
parent::__construct($opts);
}

/** @param $session */
public function setSession($session)
{
$this->session = $session;
}

public function getVolumes(): array
{
return $this->volumes;
}

/**
* @param array $opts
*/
protected function mountVolumes($opts)
{
foreach ($opts['roots'] as $i => $o) {
$volume = null;

if (isset($o['service'])) {
$driver = $o['service'];

if ($driver instanceof elFinderVolumeDriver) {
$volume = $driver;
unset($opts['roots'][$i]);
Expand All @@ -45,16 +51,12 @@ protected function mountVolumes($opts)
$id = $volume->id();

$this->volumes[$id] = $volume;

if (!$this->default && $volume->isReadable()) {
$this->default = $this->volumes[$id];
}
}
}
parent::mountVolumes($opts);
}

public function getVolumes(): array
{
return $this->volumes;
}
}
30 changes: 15 additions & 15 deletions src/Command/ElFinderInstallerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FM\ElfinderBundle\Command;

use ReflectionClass;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -12,17 +13,16 @@

final class ElFinderInstallerCommand extends Command
{
private const ELFINDER_CSS_DIR = 'vendor/studio-42/elfinder/css';
private const ELFINDER_CSS_DIR = 'vendor/studio-42/elfinder/css';

private const ELFINDER_JS_DIR = 'vendor/studio-42/elfinder/js';
private const ELFINDER_JS_DIR = 'vendor/studio-42/elfinder/js';

private const ELFINDER_SOUNDS_DIR = 'vendor/studio-42/elfinder/sounds';

private const ELFINDER_IMG_DIR = 'vendor/studio-42/elfinder/img';
private const ELFINDER_IMG_DIR = 'vendor/studio-42/elfinder/img';

protected static $defaultName = 'elfinder:install';


public function __construct(
protected Filesystem $filesystem,
protected ParameterBagInterface $parameterBag
Expand All @@ -36,13 +36,13 @@ protected function configure(): void
->setDescription('Copies elfinder assets to public directory')
->addOption('docroot', null, InputOption::VALUE_OPTIONAL, 'Website document root.', 'public')
->setHelp(<<<'EOF'
Default docroot:
<info>public</info>
Default docroot:
<info>public</info>
You can pass docroot:
<info>Where to install elfinder</info>
<info>php %command.full_name% --docroot=public_html</info>
EOF
You can pass docroot:
<info>Where to install elfinder</info>
<info>php %command.full_name% --docroot=public_html</info>
EOF
);
}

Expand All @@ -57,15 +57,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$publicDir = sprintf('%s/%s/bundles/fmelfinder', $rootDir, $dr);

$reflection = new \ReflectionClass(\Composer\Autoload\ClassLoader::class);
$reflection = new ReflectionClass(\Composer\Autoload\ClassLoader::class);
$vendorRootDir = dirname($reflection->getFileName(), 3);

$io->note(sprintf('Starting to install elfinder to %s folder', $publicDir));

$this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_CSS_DIR, $publicDir.'/css');
$this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_IMG_DIR, $publicDir.'/img');
$this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_JS_DIR, $publicDir.'/js');
$this->fileSystem->mirror($vendorRootDir.'/'.self::ELFINDER_SOUNDS_DIR, $publicDir.'/sounds');
$this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_CSS_DIR, $publicDir . '/css');
$this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_IMG_DIR, $publicDir . '/img');
$this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_JS_DIR, $publicDir . '/js');
$this->fileSystem->mirror($vendorRootDir . '/' . self::ELFINDER_SOUNDS_DIR, $publicDir . '/sounds');

$io->success('elFinder assets successfully installed');

Expand Down
Loading

0 comments on commit 7cdc637

Please sign in to comment.