From 0886127a9df7973ffec52370b7edf6b48dba49e8 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Thu, 6 Jun 2024 16:46:15 +0200 Subject: [PATCH] Fix code style --- Admin/RedirectAdmin.php | 3 -- Command/ImportCommand.php | 6 ---- Controller/RedirectRouteImportController.php | 6 ---- DependencyInjection/Configuration.php | 3 -- DependencyInjection/SuluRedirectExtension.php | 6 ---- Entity/RedirectRoute.php | 36 ------------------- Entity/RedirectRouteRepository.php | 15 -------- GoneSubscriber/GoneDocumentSubscriber.php | 3 -- Import/Converter/Converter.php | 6 ---- Import/Converter/ConverterFacade.php | 6 ---- Import/FileImport.php | 2 -- Import/Item.php | 2 +- Import/Reader/CsvReader.php | 10 ++---- Import/Reader/ReaderFacade.php | 6 ---- Import/Reader/ReaderItem.php | 2 +- Import/Writer/Writer.php | 6 ---- Manager/RedirectRouteManager.php | 21 ++++------- Routing/RedirectRouteProvider.php | 9 ----- SuluRedirectBundle.php | 5 +-- Tests/Application/Kernel.php | 6 ---- Tests/Application/bin/console.php | 2 +- .../Controller/RedirectControllerTest.php | 3 -- .../GoneEntitySubscriberTest.php | 1 - Tests/Unit/Import/Reader/ReaderFacadeTest.php | 3 -- Tests/Unit/Import/Writer/WriterTest.php | 3 -- 25 files changed, 12 insertions(+), 159 deletions(-) diff --git a/Admin/RedirectAdmin.php b/Admin/RedirectAdmin.php index 36daa38..51c24e1 100644 --- a/Admin/RedirectAdmin.php +++ b/Admin/RedirectAdmin.php @@ -134,9 +134,6 @@ public function configureViews(ViewCollection $viewCollection): void ); } - /** - * {@inheritdoc} - */ public function getSecurityContexts() { return [ diff --git a/Command/ImportCommand.php b/Command/ImportCommand.php index 9fd931a..fc6030f 100644 --- a/Command/ImportCommand.php +++ b/Command/ImportCommand.php @@ -35,9 +35,6 @@ public function __construct(FileImport $import) $this->import = $import; } - /** - * {@inheritdoc} - */ public function configure(): void { $this->addArgument('fileName', InputArgument::REQUIRED) @@ -49,9 +46,6 @@ public function configure(): void ); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output) { $progressBar = new ProgressBar($output); diff --git a/Controller/RedirectRouteImportController.php b/Controller/RedirectRouteImportController.php index d8d4f11..ab674b0 100644 --- a/Controller/RedirectRouteImportController.php +++ b/Controller/RedirectRouteImportController.php @@ -47,17 +47,11 @@ public function __construct(FileImportInterface $import, $importPath) $this->importPath = $importPath; } - /** - * {@inheritdoc} - */ public function getSecurityContext(): string { return RedirectAdmin::SECURITY_CONTEXT; } - /** - * {@inheritdoc} - */ public function getLocale(Request $request) { return $request->get('locale', null); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 17d80be..d96b229 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -21,9 +21,6 @@ */ class Configuration implements ConfigurationInterface { - /** - * {@inheritdoc} - */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('sulu_redirect'); diff --git a/DependencyInjection/SuluRedirectExtension.php b/DependencyInjection/SuluRedirectExtension.php index 5c481a4..c87de12 100644 --- a/DependencyInjection/SuluRedirectExtension.php +++ b/DependencyInjection/SuluRedirectExtension.php @@ -28,9 +28,6 @@ class SuluRedirectExtension extends Extension implements PrependExtensionInterfa { use PersistenceExtensionTrait; - /** - * {@inheritdoc} - */ public function prepend(ContainerBuilder $container): void { if ($container->hasExtension('jms_serializer')) { @@ -91,9 +88,6 @@ public function prepend(ContainerBuilder $container): void } } - /** - * {@inheritdoc} - */ public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); diff --git a/Entity/RedirectRoute.php b/Entity/RedirectRoute.php index 70a109f..06dbeb0 100644 --- a/Entity/RedirectRoute.php +++ b/Entity/RedirectRoute.php @@ -52,17 +52,11 @@ class RedirectRoute implements RedirectRouteInterface, AuditableInterface */ protected $target; - /** - * {@inheritdoc} - */ public function getId() { return $this->id; } - /** - * {@inheritdoc} - */ public function setId($id) { $this->id = $id; @@ -70,17 +64,11 @@ public function setId($id) return $this; } - /** - * {@inheritdoc} - */ public function isEnabled() { return $this->enabled; } - /** - * {@inheritdoc} - */ public function setEnabled($enabled) { $this->enabled = $enabled; @@ -88,17 +76,11 @@ public function setEnabled($enabled) return $this; } - /** - * {@inheritdoc} - */ public function getStatusCode() { return $this->statusCode; } - /** - * {@inheritdoc} - */ public function setStatusCode($statusCode) { $this->statusCode = $statusCode; @@ -106,17 +88,11 @@ public function setStatusCode($statusCode) return $this; } - /** - * {@inheritdoc} - */ public function getSource() { return $this->source; } - /** - * {@inheritdoc} - */ public function setSource($source) { $this->source = mb_strtolower('/' . ltrim($source, '/')); @@ -124,17 +100,11 @@ public function setSource($source) return $this; } - /** - * {@inheritdoc} - */ public function getSourceHost() { return $this->sourceHost; } - /** - * {@inheritdoc} - */ public function setSourceHost($sourceHost) { $this->sourceHost = empty($sourceHost) ? null : mb_strtolower($sourceHost); @@ -142,17 +112,11 @@ public function setSourceHost($sourceHost) return $this; } - /** - * {@inheritdoc} - */ public function getTarget() { return $this->target; } - /** - * {@inheritdoc} - */ public function setTarget($target) { $this->target = $target; diff --git a/Entity/RedirectRouteRepository.php b/Entity/RedirectRouteRepository.php index b82cce8..9c68499 100644 --- a/Entity/RedirectRouteRepository.php +++ b/Entity/RedirectRouteRepository.php @@ -21,9 +21,6 @@ */ class RedirectRouteRepository extends EntityRepository implements RedirectRouteRepositoryInterface { - /** - * {@inheritdoc} - */ public function findById($id) { /** @var RedirectRouteInterface|null $redirectRoute */ @@ -32,9 +29,6 @@ public function findById($id) return $redirectRoute; } - /** - * {@inheritdoc} - */ public function findEnabledBySource($source, $sourceHost = null) { $queryBuilder = $this->createFindBySourceQueryBuilder($source, $sourceHost); @@ -43,9 +37,6 @@ public function findEnabledBySource($source, $sourceHost = null) return $queryBuilder->getQuery()->getOneOrNullResult(); } - /** - * {@inheritdoc} - */ public function findBySource($source, $sourceHost = null) { $queryBuilder = $this->createFindBySourceQueryBuilder($source, $sourceHost); @@ -53,17 +44,11 @@ public function findBySource($source, $sourceHost = null) return $queryBuilder->getQuery()->getOneOrNullResult(); } - /** - * {@inheritdoc} - */ public function persist(RedirectRouteInterface $entity): void { $this->_em->persist($entity); } - /** - * {@inheritdoc} - */ public function remove(RedirectRouteInterface $entity): void { $this->_em->remove($entity); diff --git a/GoneSubscriber/GoneDocumentSubscriber.php b/GoneSubscriber/GoneDocumentSubscriber.php index 4cc2b84..7b17e07 100644 --- a/GoneSubscriber/GoneDocumentSubscriber.php +++ b/GoneSubscriber/GoneDocumentSubscriber.php @@ -79,9 +79,6 @@ public function __construct( $this->environment = $environment; } - /** - * {@inheritdoc} - */ public static function getSubscribedEvents() { return [ diff --git a/Import/Converter/Converter.php b/Import/Converter/Converter.php index 1815a53..b399df0 100644 --- a/Import/Converter/Converter.php +++ b/Import/Converter/Converter.php @@ -41,9 +41,6 @@ public function __construct(RedirectRouteRepositoryInterface $repository) $this->repository = $repository; } - /** - * {@inheritdoc} - */ public function convert(array $item) { $accessor = PropertyAccess::createPropertyAccessor(); @@ -66,9 +63,6 @@ public function convert(array $item) return $entity; } - /** - * {@inheritdoc} - */ public function supports(array $item) { $keys = array_keys($item); diff --git a/Import/Converter/ConverterFacade.php b/Import/Converter/ConverterFacade.php index 1f04018..9a241f0 100644 --- a/Import/Converter/ConverterFacade.php +++ b/Import/Converter/ConverterFacade.php @@ -29,9 +29,6 @@ public function __construct(array $converters = []) $this->converters = $converters; } - /** - * {@inheritdoc} - */ public function convert(array $item) { foreach ($this->converters as $converter) { @@ -43,9 +40,6 @@ public function convert(array $item) return null; } - /** - * {@inheritdoc} - */ public function supports(array $item) { foreach ($this->converters as $converter) { diff --git a/Import/FileImport.php b/Import/FileImport.php index 80f984a..b4005ce 100644 --- a/Import/FileImport.php +++ b/Import/FileImport.php @@ -46,8 +46,6 @@ public function __construct(ReaderInterface $reader, ConverterInterface $convert } /** - * {@inheritdoc} - * * @return iterable */ public function import($fileName) diff --git a/Import/Item.php b/Import/Item.php index de6560d..1f34bf1 100644 --- a/Import/Item.php +++ b/Import/Item.php @@ -42,7 +42,7 @@ class Item * @param int $lineNumber * @param string $lineContent */ - public function __construct($lineNumber, $lineContent, RedirectRouteInterface $data = null, ImportException $exception = null) + public function __construct($lineNumber, $lineContent, ?RedirectRouteInterface $data = null, ?ImportException $exception = null) { $this->lineNumber = $lineNumber; $this->lineContent = $lineContent; diff --git a/Import/Reader/CsvReader.php b/Import/Reader/CsvReader.php index a9533cf..9642b7d 100644 --- a/Import/Reader/CsvReader.php +++ b/Import/Reader/CsvReader.php @@ -11,7 +11,6 @@ namespace Sulu\Bundle\RedirectBundle\Import\Reader; -use SplFileObject; use Sulu\Bundle\RedirectBundle\Import\Converter\Converter; /** @@ -20,17 +19,15 @@ class CsvReader implements ReaderInterface { /** - * {@inheritdoc} - * * @return iterable */ public function read($fileName) { ini_set('auto_detect_line_endings', true); // For mac's office excel csv - $csv = new SplFileObject($fileName); + $csv = new \SplFileObject($fileName); $csv->setCsvControl(); - $csv->setFlags(SplFileObject::READ_CSV); + $csv->setFlags(\SplFileObject::READ_CSV); $header = [Converter::SOURCE, Converter::TARGET, Converter::STATUS_CODE, Converter::ENABLED, Converter::SOURCE_HOST]; /** @var string[] $line */ @@ -51,9 +48,6 @@ public function read($fileName) } } - /** - * {@inheritdoc} - */ public function supports($fileName) { return 'csv' === pathinfo($fileName, PATHINFO_EXTENSION); diff --git a/Import/Reader/ReaderFacade.php b/Import/Reader/ReaderFacade.php index 29188a8..9b99666 100644 --- a/Import/Reader/ReaderFacade.php +++ b/Import/Reader/ReaderFacade.php @@ -29,9 +29,6 @@ public function __construct(array $readers = []) $this->readers = $readers; } - /** - * {@inheritdoc} - */ public function read($fileName) { foreach ($this->readers as $reader) { @@ -43,9 +40,6 @@ public function read($fileName) return null; } - /** - * {@inheritdoc} - */ public function supports($fileName) { foreach ($this->readers as $reader) { diff --git a/Import/Reader/ReaderItem.php b/Import/Reader/ReaderItem.php index 0cbf67e..f3813c3 100644 --- a/Import/Reader/ReaderItem.php +++ b/Import/Reader/ReaderItem.php @@ -38,7 +38,7 @@ class ReaderItem */ private $exception; - public function __construct(int $lineNumber, string $lineContent, array $data, ImportException $exception = null) + public function __construct(int $lineNumber, string $lineContent, array $data, ?ImportException $exception = null) { $this->lineNumber = $lineNumber; $this->lineContent = $lineContent; diff --git a/Import/Writer/Writer.php b/Import/Writer/Writer.php index 2339f81..cf479bb 100644 --- a/Import/Writer/Writer.php +++ b/Import/Writer/Writer.php @@ -48,9 +48,6 @@ public function __construct(RedirectRouteManagerInterface $manager, EntityManage $this->entityManager = $entityManager; } - /** - * {@inheritdoc} - */ public function write(RedirectRouteInterface $entity): void { $this->validate($entity); @@ -63,9 +60,6 @@ public function write(RedirectRouteInterface $entity): void } } - /** - * {@inheritdoc} - */ public function finalize(): void { $this->entityManager->flush(); diff --git a/Manager/RedirectRouteManager.php b/Manager/RedirectRouteManager.php index 8a3ba7e..427f129 100644 --- a/Manager/RedirectRouteManager.php +++ b/Manager/RedirectRouteManager.php @@ -32,9 +32,6 @@ public function __construct(RedirectRouteRepositoryInterface $redirectRouteRepos $this->redirectRouteRepository = $redirectRouteRepository; } - /** - * {@inheritdoc} - */ public function saveByData($data) { $source = $data['source']; @@ -65,9 +62,9 @@ public function saveByData($data) } if ( - $otherRoute && - $otherRoute->getId() !== $redirectRoute->getId() && - $otherRoute->getSourceHost() === $redirectRoute->getSourceHost() + $otherRoute + && $otherRoute->getId() !== $redirectRoute->getId() + && $otherRoute->getSourceHost() === $redirectRoute->getSourceHost() ) { throw new RedirectRouteNotUniqueException($source, $sourceHost); } @@ -77,9 +74,6 @@ public function saveByData($data) return $redirectRoute; } - /** - * {@inheritdoc} - */ public function save(RedirectRouteInterface $redirectRoute) { $otherRoute = $this->redirectRouteRepository->findBySource($redirectRoute->getSource(), $redirectRoute->getSourceHost()); @@ -89,9 +83,9 @@ public function save(RedirectRouteInterface $redirectRoute) } if ( - $otherRoute && - $otherRoute->getId() !== $redirectRoute->getId() && - $otherRoute->getSourceHost() === $redirectRoute->getSourceHost() + $otherRoute + && $otherRoute->getId() !== $redirectRoute->getId() + && $otherRoute->getSourceHost() === $redirectRoute->getSourceHost() ) { throw new RedirectRouteNotUniqueException($redirectRoute->getSource(), $redirectRoute->getSourceHost()); } @@ -105,9 +99,6 @@ public function save(RedirectRouteInterface $redirectRoute) return $redirectRoute; } - /** - * {@inheritdoc} - */ public function delete(RedirectRouteInterface $redirectRoute): void { $this->redirectRouteRepository->remove($redirectRoute); diff --git a/Routing/RedirectRouteProvider.php b/Routing/RedirectRouteProvider.php index 53301e8..d6468fa 100644 --- a/Routing/RedirectRouteProvider.php +++ b/Routing/RedirectRouteProvider.php @@ -41,9 +41,6 @@ public function __construct( $this->defaultOptions = $defaultOptions; } - /** - * {@inheritdoc} - */ public function getRouteCollectionForRequest(Request $request): RouteCollection { // server encodes the url and symfony does not encode it @@ -71,17 +68,11 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection return $routeCollection; } - /** - * {@inheritdoc} - */ public function getRouteByName($name): Route { throw new RouteNotFoundException('RedirectRouteProvider does not support getRouteByName.'); } - /** - * {@inheritdoc} - */ public function getRoutesByNames($names = null): iterable { return []; diff --git a/SuluRedirectBundle.php b/SuluRedirectBundle.php index 75aae18..6dc32e1 100644 --- a/SuluRedirectBundle.php +++ b/SuluRedirectBundle.php @@ -25,9 +25,6 @@ class SuluRedirectBundle extends Bundle { use PersistenceBundleTrait; - /** - * {@inheritdoc} - */ public function build(ContainerBuilder $container): void { $container->addCompilerPass( @@ -49,7 +46,7 @@ public function build(ContainerBuilder $container): void $this->buildPersistence( [ - RedirectRoute::class => 'sulu.model.redirect_route.class', + RedirectRoute::class => 'sulu.model.redirect_route.class', ], $container ); diff --git a/Tests/Application/Kernel.php b/Tests/Application/Kernel.php index 1f0f2ea..a637ec5 100644 --- a/Tests/Application/Kernel.php +++ b/Tests/Application/Kernel.php @@ -20,17 +20,11 @@ */ class Kernel extends SuluTestKernel { - /** - * {@inheritdoc} - */ public function registerBundles(): iterable { return array_merge(parent::registerBundles(), [new SuluRedirectBundle()]); } - /** - * {@inheritdoc} - */ public function registerContainerConfiguration(LoaderInterface $loader): void { parent::registerContainerConfiguration($loader); diff --git a/Tests/Application/bin/console.php b/Tests/Application/bin/console.php index 4ee8bff..b8e3082 100755 --- a/Tests/Application/bin/console.php +++ b/Tests/Application/bin/console.php @@ -33,7 +33,7 @@ if (class_exists(Debug::class)) { Debug::enable(); } else { - \Symfony\Component\Debug\Debug::enable(); + Symfony\Component\Debug\Debug::enable(); } } diff --git a/Tests/Unit/Controller/RedirectControllerTest.php b/Tests/Unit/Controller/RedirectControllerTest.php index 8b39c19..eb20eec 100644 --- a/Tests/Unit/Controller/RedirectControllerTest.php +++ b/Tests/Unit/Controller/RedirectControllerTest.php @@ -40,9 +40,6 @@ class RedirectControllerTest extends TestCase */ private $redirectRoute; - /** - * {@inheritdoc} - */ protected function setUp(): void { $this->controller = new WebsiteRedirectController(); diff --git a/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php b/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php index b68811d..1d8a767 100644 --- a/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php +++ b/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php @@ -19,7 +19,6 @@ use Sulu\Bundle\RedirectBundle\GoneSubscriber\GoneEntitySubscriber; use Sulu\Bundle\RedirectBundle\Manager\RedirectRouteManager; use Sulu\Bundle\RouteBundle\Model\RouteInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; class GoneEntitySubscriberTest extends TestCase { diff --git a/Tests/Unit/Import/Reader/ReaderFacadeTest.php b/Tests/Unit/Import/Reader/ReaderFacadeTest.php index 203c6a6..4119848 100644 --- a/Tests/Unit/Import/Reader/ReaderFacadeTest.php +++ b/Tests/Unit/Import/Reader/ReaderFacadeTest.php @@ -24,9 +24,6 @@ class ReaderFacadeTest extends TestCase */ private $fileName; - /** - * {@inheritdoc} - */ protected function setUp(): void { $this->fileName = '/import.csv'; diff --git a/Tests/Unit/Import/Writer/WriterTest.php b/Tests/Unit/Import/Writer/WriterTest.php index 60ff989..a96bdef 100644 --- a/Tests/Unit/Import/Writer/WriterTest.php +++ b/Tests/Unit/Import/Writer/WriterTest.php @@ -39,9 +39,6 @@ class WriterTest extends TestCase */ private $writer; - /** - * {@inheritdoc} - */ protected function setUp(): void { $this->redirectRouteManager = $this->prophesize(RedirectRouteManagerInterface::class);