diff --git a/composer.json b/composer.json index 88a0668..5de7094 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,15 @@ "contao/image": "^1.2", "symfony/config": "^5.4 || ^6.4 || ^7.1", "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.1", + "symfony/filesystem": "^5.4 || ^6.4 || ^7.1", "symfony/http-foundation": "^5.4 || ^6.4 || ^7.1", "symfony/http-kernel": "^5.4 || ^6.4 || ^7.1", "symfony/security-core": "^5.4 || ^6.4 || ^7.1", - "webmozart/path-util": "^2.3", "symfony/service-contracts": "^2.5 || ^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0" + "contao/easy-coding-standard": "^6.0", + "contao/rector": "^1.0" }, "autoload": { "psr-4": { @@ -51,7 +52,8 @@ "config": { "allow-plugins": { "contao-components/installer": true, - "php-http/discovery": false + "php-http/discovery": false, + "dealerdirect/phpcodesniffer-composer-installer": true } } } diff --git a/contao/dca/tl_files.php b/contao/dca/tl_files.php index 0d5c123..2bd9b49 100644 --- a/contao/dca/tl_files.php +++ b/contao/dca/tl_files.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/dca/tl_member.php b/contao/dca/tl_member.php index e294328..9fe693d 100644 --- a/contao/dca/tl_member.php +++ b/contao/dca/tl_member.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/de/modules.php b/contao/languages/de/modules.php index c1a1166..39662bc 100644 --- a/contao/languages/de/modules.php +++ b/contao/languages/de/modules.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/de/tl_files.php b/contao/languages/de/tl_files.php index 291b5f1..b3ed12f 100644 --- a/contao/languages/de/tl_files.php +++ b/contao/languages/de/tl_files.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/de/tl_member.php b/contao/languages/de/tl_member.php index 432ac99..f6016c7 100644 --- a/contao/languages/de/tl_member.php +++ b/contao/languages/de/tl_member.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/en/modules.php b/contao/languages/en/modules.php index c1a1166..39662bc 100644 --- a/contao/languages/en/modules.php +++ b/contao/languages/en/modules.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/en/tl_files.php b/contao/languages/en/tl_files.php index 93cd4bf..488bcd1 100644 --- a/contao/languages/en/tl_files.php +++ b/contao/languages/en/tl_files.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/contao/languages/en/tl_member.php b/contao/languages/en/tl_member.php index c96a292..4b90806 100644 --- a/contao/languages/en/tl_member.php +++ b/contao/languages/en/tl_member.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/src/ContaoFileAccessBundle.php b/src/ContaoFileAccessBundle.php index 1641690..d9374f0 100644 --- a/src/ContaoFileAccessBundle.php +++ b/src/ContaoFileAccessBundle.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 13844e5..d1f5079 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ @@ -24,11 +24,8 @@ /** * Plugin for the Contao Manager. */ -class ContaoManagerPlugin implements BundlePluginInterface, RoutingPluginInterface +class Plugin implements BundlePluginInterface, RoutingPluginInterface { - /** - * {@inheritdoc} - */ public function getBundles(ParserInterface $parser) { return [ @@ -37,9 +34,6 @@ public function getBundles(ParserInterface $parser) ]; } - /** - * {@inheritdoc} - */ public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel) { return $resolver diff --git a/src/Controller/AbstractFilesController.php b/src/Controller/AbstractFilesController.php index c2f022f..0be222d 100644 --- a/src/Controller/AbstractFilesController.php +++ b/src/Controller/AbstractFilesController.php @@ -99,7 +99,7 @@ protected function setRootPage(Request $request): void { $root = $this->findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale()); - if (null !== $root) { + if ($root) { $root->loadDetails(); $request->attributes->set('pageModel', $root); $GLOBALS['objPage'] = $root; @@ -130,7 +130,7 @@ protected function tokenChecker(): TokenChecker return $this->container->get(__METHOD__); } - private function findFirstPublishedRootByHostAndLanguage(string $host, string $language): ?PageModel + private function findFirstPublishedRootByHostAndLanguage(string $host, string $language): PageModel|null { $t = PageModel::getTable(); $columns = ["$t.type='root' AND ($t.dns=? OR $t.dns='') AND ($t.language=? OR $t.fallback='1')"]; diff --git a/src/Controller/FilesController.php b/src/Controller/FilesController.php index d1286da..1a84e0a 100644 --- a/src/Controller/FilesController.php +++ b/src/Controller/FilesController.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ @@ -16,21 +16,16 @@ use Contao\CoreBundle\Framework\ContaoFramework; use Contao\Dbafs; use Contao\FilesModel; -use Contao\PageModel; +use Symfony\Component\Filesystem\Path; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\Session; -use Webmozart\PathUtil\Path; class FilesController extends AbstractFilesController { - protected $framework; - protected $projectDir; - - public function __construct(ContaoFramework $framework, string $projectDir) - { - $this->framework = $framework; - $this->projectDir = $projectDir; + public function __construct( + private readonly ContaoFramework $framework, + private readonly string $projectDir, + ) { } public function fileAction(Request $request, string $file): BinaryFileResponse @@ -43,7 +38,7 @@ public function fileAction(Request $request, string $file): BinaryFileResponse } // Initialize the Contao framework - $this->framework->initialize(true); + $this->framework->initialize(); // Set the root page for the domain as the pageModel attribute $this->setRootPage($request); diff --git a/src/Controller/ProtectedImagesController.php b/src/Controller/ProtectedImagesController.php index 6e8532a..60df393 100644 --- a/src/Controller/ProtectedImagesController.php +++ b/src/Controller/ProtectedImagesController.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ @@ -22,37 +22,22 @@ use Contao\Image\DeferredResizerInterface; use Contao\Image\Exception\FileNotExistsException; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Webmozart\PathUtil\Path; class ProtectedImagesController extends AbstractFilesController { - private ImageFactoryInterface $imageFactory; - private DeferredResizerInterface $resizer; - private DeferredImageStorageInterface $deferredImageStorage; - private Filesystem $filesystem; - private ContaoFramework $framework; - private string $targetDir; - private string $projectDir; - public function __construct( - ImageFactoryInterface $imageFactory, - DeferredResizerInterface $resizer, - DeferredImageStorageInterface $deferredImageStorage, - Filesystem $filesystem, - ContaoFramework $framework, - string $targetDir, - string $projectDir + private readonly ImageFactoryInterface $imageFactory, + private readonly DeferredResizerInterface $resizer, + private readonly DeferredImageStorageInterface $deferredImageStorage, + private readonly Filesystem $filesystem, + private readonly ContaoFramework $framework, + private readonly string $targetDir, + private readonly string $projectDir, ) { - $this->imageFactory = $imageFactory; - $this->resizer = $resizer; - $this->deferredImageStorage = $deferredImageStorage; - $this->filesystem = $filesystem; - $this->framework = $framework; - $this->targetDir = $targetDir; - $this->projectDir = $projectDir; } public function __invoke(Request $request, string $path): Response @@ -66,7 +51,7 @@ public function __invoke(Request $request, string $path): Response $filePath = Path::join($this->targetDir, $config['path']); // Initialize the Contao framework - $this->framework->initialize(true); + $this->framework->initialize(); // Set the root page for the domain as the pageModel attribute $this->setRootPage($request); diff --git a/src/DataContainer/FilesCallbacks.php b/src/DataContainer/FilesCallbacks.php index cb42c3a..cfa1020 100644 --- a/src/DataContainer/FilesCallbacks.php +++ b/src/DataContainer/FilesCallbacks.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ @@ -19,15 +19,12 @@ use Contao\FilesModel; use Contao\Folder; use Contao\Input; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; class FilesCallbacks { - private $projectDir; - - public function __construct(string $projectDir) + public function __construct(private readonly string $projectDir) { - $this->projectDir = $projectDir; } /** diff --git a/src/DependencyInjection/Compiler/AdjustProtectedResizerServicePass.php b/src/DependencyInjection/Compiler/AdjustProtectedResizerServicePass.php index 33c8d74..cfeaa52 100644 --- a/src/DependencyInjection/Compiler/AdjustProtectedResizerServicePass.php +++ b/src/DependencyInjection/Compiler/AdjustProtectedResizerServicePass.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/src/DependencyInjection/Compiler/AdjustResizerServicePass.php b/src/DependencyInjection/Compiler/AdjustResizerServicePass.php index a62ff50..2114a3a 100644 --- a/src/DependencyInjection/Compiler/AdjustResizerServicePass.php +++ b/src/DependencyInjection/Compiler/AdjustResizerServicePass.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 710d159..0c3d1f9 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ @@ -14,15 +14,12 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; class Configuration implements ConfigurationInterface { - private string $projectDir; - - public function __construct(string $projectDir) + public function __construct(private readonly string $projectDir) { - $this->projectDir = $projectDir; } public function getConfigTreeBuilder(): TreeBuilder diff --git a/src/DependencyInjection/ContaoFileAccessExtension.php b/src/DependencyInjection/ContaoFileAccessExtension.php index c8ac970..330cc23 100644 --- a/src/DependencyInjection/ContaoFileAccessExtension.php +++ b/src/DependencyInjection/ContaoFileAccessExtension.php @@ -3,9 +3,9 @@ declare(strict_types=1); /* - * This file is part of the ContaoFileAccessBundle. + * This file is part of the Contao File Access extension. * - * (c) inspiredminds + * (c) INSPIRED MINDS * * @license LGPL-3.0-or-later */ diff --git a/src/Image/Resizer.php b/src/Image/Resizer.php index 19c072e..3a682fe 100644 --- a/src/Image/Resizer.php +++ b/src/Image/Resizer.php @@ -19,31 +19,20 @@ use Contao\Image\ResizeConfiguration; use Contao\Image\ResizeOptions; use Imagine\Image\ImagineInterface; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; class Resizer implements DeferredResizerInterface { - private $inner; - private $protectedResizer; - private $projectDir; - private $uploadPath; - private $protectedCacheDir; - public function __construct( - DeferredResizerInterface $inner, - DeferredResizerInterface $protectedResizer, - string $projectDir, - string $uploadPath, - string $protectedCacheDir + private readonly DeferredResizerInterface $inner, + private readonly DeferredResizerInterface $protectedResizer, + private readonly string $projectDir, + private readonly string $uploadPath, + private readonly string $protectedCacheDir, ) { - $this->inner = $inner; - $this->protectedResizer = $protectedResizer; - $this->projectDir = $projectDir; - $this->uploadPath = $uploadPath; - $this->protectedCacheDir = $protectedCacheDir; } - public function getDeferredImage(string $targetPath, ImagineInterface $imagine): ?DeferredImageInterface + public function getDeferredImage(string $targetPath, ImagineInterface $imagine): DeferredImageInterface|null { if (Path::isBasePath($this->protectedCacheDir, $targetPath)) { return $this->protectedResizer->getDeferredImage($targetPath, $imagine); @@ -52,7 +41,7 @@ public function getDeferredImage(string $targetPath, ImagineInterface $imagine): return $this->inner->getDeferredImage($targetPath, $imagine); } - public function resizeDeferredImage(DeferredImageInterface $image, bool $blocking = true): ?ImageInterface + public function resizeDeferredImage(DeferredImageInterface $image, bool $blocking = true): ImageInterface|null { if (Path::isBasePath($this->protectedCacheDir, $image->getPath())) { return $this->protectedResizer->resizeDeferredImage($image, $blocking); diff --git a/src/Routing/ProtectedImagesLoader.php b/src/Routing/ProtectedImagesLoader.php index 40bf6c8..fb28931 100644 --- a/src/Routing/ProtectedImagesLoader.php +++ b/src/Routing/ProtectedImagesLoader.php @@ -20,14 +20,14 @@ class ProtectedImagesLoader extends Loader { - private string $pathPrefix; + private readonly string $pathPrefix; public function __construct(string $projectDir, string $imageTargetDir) { $this->pathPrefix = Path::makeRelative($imageTargetDir, $projectDir); } - public function load($resource, string $type = null): RouteCollection + public function load($resource, string|null $type = null): RouteCollection { $routes = new RouteCollection(); @@ -37,13 +37,13 @@ public function load($resource, string $type = null): RouteCollection '_controller' => ProtectedImagesController::class, '_scope' => 'frontend', ], - ['path' => '.+'] + ['path' => '.+'], )); return $routes; } - public function supports($resource, string $type = null): bool + public function supports($resource, string|null $type = null): bool { return 'protected_images' === $type; }