From e2b9e08ad3f547884a3fe51f310dd5320047b03b Mon Sep 17 00:00:00 2001 From: fizk Date: Wed, 26 Jun 2024 10:18:22 +0000 Subject: [PATCH] Fixinf formatting errors --- config/service.php | 28 +++++++++++++------ .../AssemblyCommitteeController.php | 1 + src/Controller/AssemblyController.php | 3 +- src/Controller/CabinetController.php | 1 + src/Controller/CategoryController.php | 1 + src/Controller/Cli/IndexController.php | 2 +- .../Cli/IndexerAssemblyController.php | 2 +- .../Cli/IndexerCabinetController.php | 2 +- .../Cli/IndexerCategoryController.php | 2 +- .../Cli/IndexerCommitteeController.php | 2 +- .../IndexerCommitteeDocumentController.php | 14 ++++++---- .../Cli/IndexerCommitteeSittingController.php | 14 ++++++---- .../Cli/IndexerCongressmanController.php | 2 +- .../IndexerCongressmanDocumentController.php | 2 +- .../Cli/IndexerConstituencyController.php | 2 +- .../Cli/IndexerDocumentController.php | 2 +- .../Cli/IndexerDocumentVoteController.php | 2 +- .../Cli/IndexerDocumentVoteItemController.php | 2 +- .../Cli/IndexerInflationController.php | 2 +- .../Cli/IndexerIssueCategoryController.php | 2 +- src/Controller/Cli/IndexerIssueController.php | 2 +- .../Cli/IndexerMinisterSittingController.php | 2 +- .../Cli/IndexerMinistryController.php | 2 +- src/Controller/Cli/IndexerPartyController.php | 2 +- .../Cli/IndexerPlenaryAgentaController.php | 2 +- .../Cli/IndexerPlenaryController.php | 2 +- .../Cli/IndexerPresidentController.php | 2 +- .../Cli/IndexerSessionController.php | 2 +- .../Cli/IndexerSpeechController.php | 2 +- src/Controller/CommitteeController.php | 3 +- .../CommitteeDocumentController.php | 9 ++++-- .../CommitteeMeetingAgendaController.php | 7 +++-- src/Controller/CommitteeMeetingController.php | 1 + src/Controller/CommitteeSittingController.php | 11 +++++--- src/Controller/CongressmanController.php | 9 ++++-- .../CongressmanDocumentController.php | 7 +++-- src/Controller/CongressmanIssueController.php | 1 + src/Controller/ConstituencyController.php | 9 ++++-- src/Controller/DocumentController.php | 1 + src/Controller/InflationController.php | 9 ++++-- src/Controller/IssueCategoryController.php | 1 + src/Controller/IssueController.php | 1 + src/Controller/IssueLinkController.php | 1 + src/Controller/MinisterController.php | 1 + src/Controller/MinisterSittingController.php | 9 ++++-- src/Controller/MinistryController.php | 9 ++++-- src/Controller/PartyController.php | 9 ++++-- src/Controller/PlenaryAgendaController.php | 2 ++ src/Controller/PlenaryController.php | 2 ++ .../PresidentAssemblyController.php | 1 + src/Controller/PresidentController.php | 9 ++++-- src/Controller/SessionController.php | 9 ++++-- src/Controller/SpeechController.php | 1 + src/Controller/SuperCategoryController.php | 9 ++++-- src/Controller/VoteController.php | 1 + src/Controller/VoteItemController.php | 1 + src/Filter/ItemStatusFilter.php | 12 +++++--- src/Form/Assembly.php | 7 +++-- src/Form/Cabinet.php | 16 +++++------ src/Form/Category.php | 15 +++++----- src/Hydrator/AssemblyStatus.php | 1 - src/Hydrator/Cabinet.php | 1 - src/Hydrator/Congressman.php | 1 - src/Hydrator/CongressmanAndCabinet.php | 1 - src/Hydrator/CongressmanAndParty.php | 1 - src/Hydrator/HydrateDate.php | 1 + src/Hydrator/ValueAndCount.php | 1 - src/Injector/DatabaseAwareInterface.php | 2 +- src/Injector/EventsAwareInterface.php | 1 - src/Injector/MessageBrokerAwareInterface.php | 1 + src/Injector/QueueAwareInterface.php | 1 + src/Model/Constituency.php | 2 +- src/Model/ConstituencyDate.php | 1 + src/Model/ConstituencyValue.php | 1 + src/Model/KindEnum.php | 2 +- src/Model/ModelInterface.php | 1 + src/Model/PlenaryAgenda.php | 1 + src/Model/PlenaryAgendaProperties.php | 1 + src/Model/President.php | 2 +- src/Presenters/IndexableAssemblyPresenter.php | 5 ++-- src/Presenters/IndexableCabinetPresenter.php | 5 ++-- src/Presenters/IndexableCategoryPresenter.php | 5 ++-- .../IndexableCommitteeDocumentPresenter.php | 5 ++-- .../IndexableCommitteePresenter.php | 5 ++-- .../IndexableCommitteeSittingPresenter.php | 5 ++-- .../IndexableCongressmanDocumentPresenter.php | 5 ++-- .../IndexableCongressmanPresenter.php | 5 ++-- .../IndexableConstituencyPresenter.php | 5 ++-- src/Presenters/IndexableDocumentPresenter.php | 5 ++-- .../IndexableInflationPresenter.php | 5 ++-- .../IndexableIssueCategoryPresenter.php | 5 ++-- .../IndexableIssueLinkPresenter.php | 5 ++-- src/Presenters/IndexableIssuePresenter.php | 5 ++-- .../IndexableMinisterSittingPresenter.php | 5 ++-- src/Presenters/IndexableMinistryPresenter.php | 5 ++-- src/Presenters/IndexablePartyPresenter.php | 5 ++-- .../IndexablePlenaryAgendaPresenter.php | 5 ++-- src/Presenters/IndexablePlenaryPresenter.php | 5 ++-- .../IndexablePresenterAwareInterface.php | 1 + .../IndexablePresidentPresenter.php | 5 ++-- src/Presenters/IndexableSessionPresenter.php | 5 ++-- src/Presenters/IndexableSpeechPresenter.php | 5 ++-- .../IndexableSuperCategoryPresenter.php | 5 ++-- src/Presenters/IndexableVoteItemPresenter.php | 5 ++-- src/Presenters/IndexableVotePresenter.php | 5 ++-- src/Router/Http/Hostname.php | 19 +++++++------ src/Router/Http/Part.php | 3 +- src/Router/Http/Segment.php | 19 +++++++------ src/Router/Http/TreeRouteStack.php | 6 ++-- src/Router/RestControllerTrait.php | 2 +- src/Service/Assembly.php | 18 ++++++------ src/Service/Cabinet.php | 6 ++-- src/Service/Category.php | 8 +++--- src/Service/Committee.php | 6 ++-- src/Service/CommitteeDocument.php | 4 +-- src/Service/CommitteeMeeting.php | 2 +- src/Service/CommitteeMeetingAgenda.php | 2 +- src/Service/CommitteeSitting.php | 4 +-- src/Service/Congressman.php | 12 ++++---- src/Service/CongressmanDocument.php | 8 +++--- src/Service/Constituency.php | 10 +++---- src/Service/Document.php | 4 +-- src/Service/Election.php | 4 +-- src/Service/Inflation.php | 6 ++-- src/Service/Issue.php | 24 +++++++++------- src/Service/IssueCategory.php | 9 +++--- src/Service/MinisterSitting.php | 6 ++-- src/Service/Ministry.php | 12 ++++---- src/Service/Party.php | 10 +++---- src/Service/Plenary.php | 4 +-- src/Service/PlenaryAgenda.php | 11 ++++---- src/Service/President.php | 8 +++--- src/Service/Session.php | 4 +-- src/Service/Speech.php | 17 +++++++---- src/Service/SuperCategory.php | 6 ++-- src/Service/Vote.php | 4 +-- src/Service/VoteItem.php | 6 ++-- src/Utils/ConsoleResponse.php | 1 + src/Utils/ErrorFormResponse.php | 1 + src/Utils/OpenAPI.php | 1 - src/Utils/RouteInspector.php | 4 ++- src/Validator/SignedDigits.php | 6 ++-- tests/Controller/AssemblyControllerTest.php | 5 ++-- tests/Controller/DocumentControllerTest.php | 4 +-- tests/Controller/InflationControllerTest.php | 2 +- .../MinisterSittingControllerTest.php | 2 +- tests/DatabaseConnection.php | 5 ++-- tests/Filter/ItemStatusFilterTest.php | 1 - tests/Filter/ToIntTest.php | 2 +- tests/Form/PlenaryTest.php | 1 - tests/Service/AssemblyTest.php | 2 +- tests/Service/CabinetTest.php | 2 +- tests/Service/CommitteeTest.php | 21 +++++++------- tests/Service/CongressmanDocumentTest.php | 4 +-- tests/Service/ConstituencyTest.php | 2 +- tests/Service/MinistryTest.php | 1 - tests/Service/PresidentTest.php | 6 ++-- tests/ServiceHelper.php | 2 +- tests/Utils/CategoryParamConcreteClass.php | 1 + 159 files changed, 453 insertions(+), 325 deletions(-) diff --git a/config/service.php b/config/service.php index bbcd44e4..7a216c62 100644 --- a/config/service.php +++ b/config/service.php @@ -141,7 +141,7 @@ ->setCommitteeService($container->get(Service\Committee::class)); }, Controller\CommitteeDocumentController::class => function (ContainerInterface $container) { - return (new Controller\CommitteeDocumentController) + return (new Controller\CommitteeDocumentController()) ->setCommitteeDocumentService($container->get(Service\CommitteeDocument::class)) ->setRouter($container->get(RouteInterface::class)) ; @@ -518,7 +518,8 @@ [ PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', " . - "sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO';", + "sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO," . + "NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO';", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, ] @@ -541,7 +542,11 @@ }); $provider->subscribeTo(AddEvent::class, function (AddEvent $event) use ($logger, $container) { - $result = (new Add($container->get(MessageBrokerInterface::class), strtolower(getenv('QUEUE_FORCED')) === 'true'))( + (new Add( + $container->get(MessageBrokerInterface::class), + strtolower(getenv('QUEUE_FORCED')) === 'true' + ) + )( $event->getPresenter(), $event->getParams() ); @@ -549,7 +554,11 @@ }); $provider->subscribeTo(UpdateEvent::class, function (UpdateEvent $event) use ($logger, $container) { - $result = (new Update($container->get(MessageBrokerInterface::class), strtolower(getenv('QUEUE_FORCED')) === 'true'))( + (new Update( + $container->get(MessageBrokerInterface::class), + strtolower(getenv('QUEUE_FORCED')) === 'true' + ) + )( $event->getPresenter(), $event->getParams() ); @@ -557,7 +566,11 @@ }); $provider->subscribeTo(DeleteEvent::class, function (DeleteEvent $event) use ($logger, $container) { - $result = (new Delete($container->get(MessageBrokerInterface::class), strtolower(getenv('QUEUE_FORCED')) === 'true'))( + (new Delete( + $container->get(MessageBrokerInterface::class), + strtolower(getenv('QUEUE_FORCED')) === 'true' + ) + )( $event->getPresenter(), $event->getParams() ); @@ -570,12 +583,11 @@ Psr\Log\LoggerInterface::class => function (ContainerInterface $container) { return (new Logger('source')) ->pushHandler((new StreamHandler('php://stdout', Logger::DEBUG)) - ->setFormatter(new LineFormatter("[%datetime%] %level_name% %message%\n")) - ); + ->setFormatter(new LineFormatter("[%datetime%] %level_name% %message%\n"))); }, MessageBrokerInterface::class => function (ContainerInterface $container) { - switch(strtolower(getenv('BROKER'))) { + switch (strtolower(getenv('BROKER'))) { case 'kafka': return new KafkaMessageBroker( $container->get(KafkaProducer::class) diff --git a/src/Controller/AssemblyCommitteeController.php b/src/Controller/AssemblyCommitteeController.php index 55a10a84..bda62768 100644 --- a/src/Controller/AssemblyCommitteeController.php +++ b/src/Controller/AssemblyCommitteeController.php @@ -20,6 +20,7 @@ class AssemblyCommitteeController implements ServiceCommitteeAwareInterface { use RestControllerTrait; + private Committee $committeeService; /** diff --git a/src/Controller/AssemblyController.php b/src/Controller/AssemblyController.php index 237affe9..c09aae6a 100644 --- a/src/Controller/AssemblyController.php +++ b/src/Controller/AssemblyController.php @@ -24,6 +24,7 @@ class AssemblyController implements ServiceAssemblyAwareInterface { use RestControllerTrait; + private Assembly $assemblyService; /** @@ -59,7 +60,7 @@ public function getList(ServerRequest $request): ResponseInterface public function optionsList(ServerRequest $request): ResponseInterface { return new EmptyResponse(200, [ - 'Allow' =>'GET, OPTIONS' + 'Allow' => 'GET, OPTIONS' ]); } diff --git a/src/Controller/CabinetController.php b/src/Controller/CabinetController.php index dd72fc97..35182175 100644 --- a/src/Controller/CabinetController.php +++ b/src/Controller/CabinetController.php @@ -28,6 +28,7 @@ class CabinetController implements ServiceAssemblyAwareInterface { use RestControllerTrait; + private Cabinet $cabinetService; private Assembly $assemblyService; diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php index efb74c96..379748a3 100644 --- a/src/Controller/CategoryController.php +++ b/src/Controller/CategoryController.php @@ -22,6 +22,7 @@ class CategoryController implements ServiceCategoryAwareInterface { use RestControllerTrait; + private Service\Category $categoryService; /** diff --git a/src/Controller/Cli/IndexController.php b/src/Controller/Cli/IndexController.php index a2cb7fa4..03883faa 100644 --- a/src/Controller/Cli/IndexController.php +++ b/src/Controller/Cli/IndexController.php @@ -8,12 +8,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexController { use EventService; + private Assembly $assemblyService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerAssemblyController.php b/src/Controller/Cli/IndexerAssemblyController.php index 863ee560..296c307b 100644 --- a/src/Controller/Cli/IndexerAssemblyController.php +++ b/src/Controller/Cli/IndexerAssemblyController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerAssemblyController implements ServiceAssemblyAwareInterface, EventsAwareInterface { use EventService; + private Assembly $assemblyService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerCabinetController.php b/src/Controller/Cli/IndexerCabinetController.php index 3a4a76c1..4a2e362e 100644 --- a/src/Controller/Cli/IndexerCabinetController.php +++ b/src/Controller/Cli/IndexerCabinetController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCabinetController implements ServiceCabinetAwareInterface, EventsAwareInterface { use EventService; + private Cabinet $cabinetService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerCategoryController.php b/src/Controller/Cli/IndexerCategoryController.php index 39048f29..8865ace9 100644 --- a/src/Controller/Cli/IndexerCategoryController.php +++ b/src/Controller/Cli/IndexerCategoryController.php @@ -15,7 +15,6 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCategoryController implements @@ -24,6 +23,7 @@ class IndexerCategoryController implements EventsAwareInterface { use EventService; + private Category $categoryService; private SuperCategory $superCategory; diff --git a/src/Controller/Cli/IndexerCommitteeController.php b/src/Controller/Cli/IndexerCommitteeController.php index c09fa1d3..2218451c 100644 --- a/src/Controller/Cli/IndexerCommitteeController.php +++ b/src/Controller/Cli/IndexerCommitteeController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCommitteeController implements ServiceCommitteeAwareInterface, EventsAwareInterface { use EventService; + private Committee $committeeService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerCommitteeDocumentController.php b/src/Controller/Cli/IndexerCommitteeDocumentController.php index b6ab9caa..68ac8c43 100644 --- a/src/Controller/Cli/IndexerCommitteeDocumentController.php +++ b/src/Controller/Cli/IndexerCommitteeDocumentController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCommitteeDocumentController implements ServiceCommitteeDocumentAwareInterface, EventsAwareInterface { use EventService; + private CommitteeDocument $serviceCommitteeDocument; public function handle(ServerRequestInterface $request): ResponseInterface @@ -29,11 +29,13 @@ public function handle(ServerRequestInterface $request): ResponseInterface $documentId = $request->getAttribute('document_id', null); /** @var \Althingi\Model\CommitteeDocument $model */ - foreach ($this->serviceCommitteeDocument->fetchAllGenerator( - $congressmanId, - $assemblyId, - $documentId - ) as $model) { + foreach ( + $this->serviceCommitteeDocument->fetchAllGenerator( + $congressmanId, + $assemblyId, + $documentId + ) as $model + ) { $this->getEventDispatcher()->dispatch( new AddEvent(new IndexableCommitteeDocumentPresenter($model), ['rows' => 1]), ); diff --git a/src/Controller/Cli/IndexerCommitteeSittingController.php b/src/Controller/Cli/IndexerCommitteeSittingController.php index 2225affd..8fab2a76 100644 --- a/src/Controller/Cli/IndexerCommitteeSittingController.php +++ b/src/Controller/Cli/IndexerCommitteeSittingController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCommitteeSittingController implements ServiceCommitteeSittingAwareInterface, EventsAwareInterface { use EventService; + private CommitteeSitting $committeeSittingService; public function handle(ServerRequestInterface $request): ResponseInterface @@ -29,11 +29,13 @@ public function handle(ServerRequestInterface $request): ResponseInterface $committeeId = $request->getAttribute('committee_id', null); /** @var \Althingi\Model\CommitteeSitting $model */ - foreach ($this->committeeSittingService->fetchAllGenerator( - $assemblyId, - $congressmanId, - $committeeId - ) as $model) { + foreach ( + $this->committeeSittingService->fetchAllGenerator( + $assemblyId, + $congressmanId, + $committeeId + ) as $model + ) { $this->getEventDispatcher()->dispatch( new AddEvent(new IndexableCommitteeSittingPresenter($model), ['rows' => 1]), ); diff --git a/src/Controller/Cli/IndexerCongressmanController.php b/src/Controller/Cli/IndexerCongressmanController.php index e1893e0d..7e13a88b 100644 --- a/src/Controller/Cli/IndexerCongressmanController.php +++ b/src/Controller/Cli/IndexerCongressmanController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCongressmanController implements ServiceCongressmanAwareInterface, EventsAwareInterface { use EventService; + private Congressman $congressman; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerCongressmanDocumentController.php b/src/Controller/Cli/IndexerCongressmanDocumentController.php index b880214f..7736732b 100644 --- a/src/Controller/Cli/IndexerCongressmanDocumentController.php +++ b/src/Controller/Cli/IndexerCongressmanDocumentController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerCongressmanDocumentController implements ServiceCongressmanDocumentAwareInterface, EventsAwareInterface { use EventService; + private CongressmanDocument $congressmanDocument; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerConstituencyController.php b/src/Controller/Cli/IndexerConstituencyController.php index dc7362e0..25374a54 100644 --- a/src/Controller/Cli/IndexerConstituencyController.php +++ b/src/Controller/Cli/IndexerConstituencyController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerConstituencyController implements ServiceConstituencyAwareInterface, EventsAwareInterface { use EventService; + private Constituency $constituencyService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerDocumentController.php b/src/Controller/Cli/IndexerDocumentController.php index 521c5f05..4942963a 100644 --- a/src/Controller/Cli/IndexerDocumentController.php +++ b/src/Controller/Cli/IndexerDocumentController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\Document; class IndexerDocumentController implements ServiceDocumentAwareInterface, EventsAwareInterface { use EventService; + private Document $documentService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerDocumentVoteController.php b/src/Controller/Cli/IndexerDocumentVoteController.php index 3cdeb481..f1d6ec9d 100644 --- a/src/Controller/Cli/IndexerDocumentVoteController.php +++ b/src/Controller/Cli/IndexerDocumentVoteController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\Vote; class IndexerDocumentVoteController implements ServiceVoteAwareInterface, EventsAwareInterface { use EventService; + private Vote $voteService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerDocumentVoteItemController.php b/src/Controller/Cli/IndexerDocumentVoteItemController.php index 4427691c..e8b61c7f 100644 --- a/src/Controller/Cli/IndexerDocumentVoteItemController.php +++ b/src/Controller/Cli/IndexerDocumentVoteItemController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\VoteItem; class IndexerDocumentVoteItemController implements ServiceVoteItemAwareInterface, EventsAwareInterface { use EventService; + private VoteItem $voteItemService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerInflationController.php b/src/Controller/Cli/IndexerInflationController.php index 27fd71a8..971bc8fb 100644 --- a/src/Controller/Cli/IndexerInflationController.php +++ b/src/Controller/Cli/IndexerInflationController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerInflationController implements ServiceInflationAwareInterface, EventsAwareInterface { use EventService; + private Inflation $inflationService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerIssueCategoryController.php b/src/Controller/Cli/IndexerIssueCategoryController.php index f15c8ce1..b94c9c50 100644 --- a/src/Controller/Cli/IndexerIssueCategoryController.php +++ b/src/Controller/Cli/IndexerIssueCategoryController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\IssueCategory; class IndexerIssueCategoryController implements ServiceIssueCategoryAwareInterface, EventsAwareInterface { use EventService; + private IssueCategory $issueCategoryService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerIssueController.php b/src/Controller/Cli/IndexerIssueController.php index 13bbc9f5..0a104ecd 100644 --- a/src/Controller/Cli/IndexerIssueController.php +++ b/src/Controller/Cli/IndexerIssueController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerIssueController implements ServiceIssueAwareInterface, EventsAwareInterface { use EventService; + private Issue $issueService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerMinisterSittingController.php b/src/Controller/Cli/IndexerMinisterSittingController.php index 0f5bd430..53deee20 100644 --- a/src/Controller/Cli/IndexerMinisterSittingController.php +++ b/src/Controller/Cli/IndexerMinisterSittingController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerMinisterSittingController implements ServiceMinisterSittingAwareInterface, EventsAwareInterface { use EventService; + private MinisterSitting $ministerSittingService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerMinistryController.php b/src/Controller/Cli/IndexerMinistryController.php index 37fd0808..6ab490c7 100644 --- a/src/Controller/Cli/IndexerMinistryController.php +++ b/src/Controller/Cli/IndexerMinistryController.php @@ -14,12 +14,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerMinistryController implements ServiceMinistryAwareInterface, EventsAwareInterface { use EventService; + private Ministry $ministryService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerPartyController.php b/src/Controller/Cli/IndexerPartyController.php index e76bdaf2..9caa26bd 100644 --- a/src/Controller/Cli/IndexerPartyController.php +++ b/src/Controller/Cli/IndexerPartyController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\Party; class IndexerPartyController implements ServicePartyAwareInterface, EventsAwareInterface { use EventService; + private Party $partyService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerPlenaryAgentaController.php b/src/Controller/Cli/IndexerPlenaryAgentaController.php index 2d86df43..ec214758 100644 --- a/src/Controller/Cli/IndexerPlenaryAgentaController.php +++ b/src/Controller/Cli/IndexerPlenaryAgentaController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\PlenaryAgenda; class IndexerPlenaryAgentaController implements ServicePlenaryAgendaAwareInterface, EventsAwareInterface { use EventService; + private PlenaryAgenda $plenaryAgendaService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerPlenaryController.php b/src/Controller/Cli/IndexerPlenaryController.php index 53d7e574..a5a399c9 100644 --- a/src/Controller/Cli/IndexerPlenaryController.php +++ b/src/Controller/Cli/IndexerPlenaryController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\Plenary; class IndexerPlenaryController implements ServicePlenaryAwareInterface, EventsAwareInterface { use EventService; + private Plenary $plenaryService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerPresidentController.php b/src/Controller/Cli/IndexerPresidentController.php index 57c73ea3..a7bc5211 100644 --- a/src/Controller/Cli/IndexerPresidentController.php +++ b/src/Controller/Cli/IndexerPresidentController.php @@ -15,12 +15,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerPresidentController implements ServicePresidentAwareInterface, EventsAwareInterface { use EventService; + private President $presidentService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerSessionController.php b/src/Controller/Cli/IndexerSessionController.php index 03d1231f..c8810fa4 100644 --- a/src/Controller/Cli/IndexerSessionController.php +++ b/src/Controller/Cli/IndexerSessionController.php @@ -13,13 +13,13 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; use Althingi\Service\Session; class IndexerSessionController implements ServiceSessionAwareInterface, EventsAwareInterface { use EventService; + private Session $session; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/Cli/IndexerSpeechController.php b/src/Controller/Cli/IndexerSpeechController.php index 4f542721..a9c1735e 100644 --- a/src/Controller/Cli/IndexerSpeechController.php +++ b/src/Controller/Cli/IndexerSpeechController.php @@ -15,12 +15,12 @@ ServerRequestInterface, ResponseInterface }; - use Althingi\Service\EventService; class IndexerSpeechController implements ServiceSpeechAwareInterface, EventsAwareInterface { use EventService; + private Speech $speechService; public function handle(ServerRequestInterface $request): ResponseInterface diff --git a/src/Controller/CommitteeController.php b/src/Controller/CommitteeController.php index ea856369..7bc9b7c3 100644 --- a/src/Controller/CommitteeController.php +++ b/src/Controller/CommitteeController.php @@ -22,6 +22,7 @@ class CommitteeController implements ServiceCommitteeAwareInterface { use RestControllerTrait; + private Service\Committee $committeeService; /** @@ -106,7 +107,7 @@ public function patch(ServerRequest $request): ResponseInterface */ public function optionsList(ServerRequest $request): ResponseInterface { - return new EmptyResponse(200, ['Allow' =>'GET, OPTIONS']); + return new EmptyResponse(200, ['Allow' => 'GET, OPTIONS']); } /** diff --git a/src/Controller/CommitteeDocumentController.php b/src/Controller/CommitteeDocumentController.php index 495164c0..a2f9743e 100644 --- a/src/Controller/CommitteeDocumentController.php +++ b/src/Controller/CommitteeDocumentController.php @@ -33,6 +33,7 @@ class CommitteeDocumentController implements RouterAwareInterface { use RestControllerTrait; + private RouteInterface $router; private Service\CommitteeDocument $committeeDocumentService; @@ -153,9 +154,11 @@ public function post(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($committeeDocument = $this->committeeDocumentService->get( - $request->getAttribute('document_committee_id') - )) != null) { + if ( + ($committeeDocument = $this->committeeDocumentService->get( + $request->getAttribute('document_committee_id') + )) != null + ) { $form = new Form\CommitteeDocument([ ...$committeeDocument->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/CommitteeMeetingAgendaController.php b/src/Controller/CommitteeMeetingAgendaController.php index 2207aa8d..fcd51f00 100644 --- a/src/Controller/CommitteeMeetingAgendaController.php +++ b/src/Controller/CommitteeMeetingAgendaController.php @@ -22,6 +22,7 @@ class CommitteeMeetingAgendaController implements ServiceCommitteeMeetingAgendaAwareInterface { use RestControllerTrait; + private Service\CommitteeMeetingAgenda $committeeMeetingAgendaService; /** @@ -90,8 +91,10 @@ public function patch(ServerRequest $request): ResponseInterface $committeeMeetingId = $request->getAttribute('committee_meeting_id'); $committeeMeetingAgendaId = $request->getAttribute('committee_meeting_agenda_id'); - if (($committeeMeetingAgenda = $this->committeeMeetingAgendaService - ->get($committeeMeetingId, $committeeMeetingAgendaId)) != null) { + if ( + ($committeeMeetingAgenda = $this->committeeMeetingAgendaService + ->get($committeeMeetingId, $committeeMeetingAgendaId)) != null + ) { $form = new Form\CommitteeMeetingAgenda([ ...$committeeMeetingAgenda->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/CommitteeMeetingController.php b/src/Controller/CommitteeMeetingController.php index 96f35bfd..73f335cf 100644 --- a/src/Controller/CommitteeMeetingController.php +++ b/src/Controller/CommitteeMeetingController.php @@ -22,6 +22,7 @@ class CommitteeMeetingController implements ServiceCommitteeMeetingAwareInterface { use RestControllerTrait; + private Service\CommitteeMeeting $committeeMeetingService; /** diff --git a/src/Controller/CommitteeSittingController.php b/src/Controller/CommitteeSittingController.php index 0ec8edff..cba30b62 100644 --- a/src/Controller/CommitteeSittingController.php +++ b/src/Controller/CommitteeSittingController.php @@ -32,6 +32,7 @@ class CommitteeSittingController implements RouterAwareInterface { use RestControllerTrait; + private RouteInterface $router; private Service\CommitteeSitting $committeeSittingService; @@ -138,13 +139,15 @@ public function post(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($committeeSitting = $this->committeeSittingService->get( - $request->getAttribute('committee_sitting_id') - )) != null) { + if ( + ($committeeSitting = $this->committeeSittingService->get( + $request->getAttribute('committee_sitting_id') + )) != null + ) { $form = new Form\CommitteeSitting([ ...$committeeSitting->toArray(), ...$request->getParsedBody(), - 'committee_sitting_id' =>$request->getAttribute('committee_sitting_id'), + 'committee_sitting_id' => $request->getAttribute('committee_sitting_id'), ]); if ($form->isValid()) { diff --git a/src/Controller/CongressmanController.php b/src/Controller/CongressmanController.php index 41b4634a..89b07b4e 100644 --- a/src/Controller/CongressmanController.php +++ b/src/Controller/CongressmanController.php @@ -22,6 +22,7 @@ class CongressmanController implements ServiceCongressmanAwareInterface { use RestControllerTrait; + private Service\Congressman $congressmanService; /** @@ -86,9 +87,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($congressman = $this->congressmanService->get( - $request->getAttribute('congressman_id') - )) != null) { + if ( + ($congressman = $this->congressmanService->get( + $request->getAttribute('congressman_id') + )) != null + ) { $form = new Form\Congressman([ ...$congressman->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/CongressmanDocumentController.php b/src/Controller/CongressmanDocumentController.php index f033a1be..ce573b74 100644 --- a/src/Controller/CongressmanDocumentController.php +++ b/src/Controller/CongressmanDocumentController.php @@ -20,6 +20,7 @@ class CongressmanDocumentController implements ServiceProponentAwareInterface { use RestControllerTrait; + private Service\CongressmanDocument $congressmanDocumentService; /** @@ -65,8 +66,10 @@ public function patch(ServerRequest $request): ResponseInterface $documentId = $request->getAttribute('document_id'); $congressmanId = $request->getAttribute('congressman_id'); - if (($congressmanDocument = $this->congressmanDocumentService - ->get($assemblyId, $issueId, $documentId, $congressmanId)) != null) { + if ( + ($congressmanDocument = $this->congressmanDocumentService + ->get($assemblyId, $issueId, $documentId, $congressmanId)) != null + ) { $form = new Form\CongressmanDocument([ ...$congressmanDocument->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/CongressmanIssueController.php b/src/Controller/CongressmanIssueController.php index 984a5272..5df26600 100644 --- a/src/Controller/CongressmanIssueController.php +++ b/src/Controller/CongressmanIssueController.php @@ -21,6 +21,7 @@ class CongressmanIssueController implements ServiceIssueAwareInterface { use RestControllerTrait; + private Service\Issue $issueService; /** diff --git a/src/Controller/ConstituencyController.php b/src/Controller/ConstituencyController.php index 4655386a..61958d9e 100644 --- a/src/Controller/ConstituencyController.php +++ b/src/Controller/ConstituencyController.php @@ -23,6 +23,7 @@ class ConstituencyController implements ServiceConstituencyAwareInterface { use RestControllerTrait; + private Service\Constituency $constituencyService; /** @@ -68,9 +69,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($constituency = $this->constituencyService->get( - $request->getAttribute('id') - )) !== null) { + if ( + ($constituency = $this->constituencyService->get( + $request->getAttribute('id') + )) !== null + ) { $form = new Form\Constituency([ ...$constituency->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/DocumentController.php b/src/Controller/DocumentController.php index 7b369cca..ee1c7b3c 100644 --- a/src/Controller/DocumentController.php +++ b/src/Controller/DocumentController.php @@ -23,6 +23,7 @@ class DocumentController implements ServiceDocumentAwareInterface { use RestControllerTrait; + private Service\Document $documentService; /** diff --git a/src/Controller/InflationController.php b/src/Controller/InflationController.php index 0b20fa85..00143d7e 100644 --- a/src/Controller/InflationController.php +++ b/src/Controller/InflationController.php @@ -29,6 +29,7 @@ class InflationController implements ServiceAssemblyAwareInterface { use RestControllerTrait; + private Service\Inflation $inflationService; private Service\Cabinet $cabinetService; private Service\Assembly $assemblyService; @@ -131,9 +132,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($committee = $this->inflationService->get( - $request->getAttribute('id') - )) != null) { + if ( + ($committee = $this->inflationService->get( + $request->getAttribute('id') + )) != null + ) { $form = new Form\Inflation([ ...$committee->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/IssueCategoryController.php b/src/Controller/IssueCategoryController.php index 0b9585aa..afa965c8 100644 --- a/src/Controller/IssueCategoryController.php +++ b/src/Controller/IssueCategoryController.php @@ -29,6 +29,7 @@ class IssueCategoryController implements ServiceCategoryAwareInterface { use RestControllerTrait; + private Service\IssueCategory $issueCategoryService; private Service\Category $categoryService; diff --git a/src/Controller/IssueController.php b/src/Controller/IssueController.php index 34bdc198..3c8bec68 100644 --- a/src/Controller/IssueController.php +++ b/src/Controller/IssueController.php @@ -21,6 +21,7 @@ class IssueController implements ServiceIssueAwareInterface { use RestControllerTrait; + private Service\Issue $issueService; /** diff --git a/src/Controller/IssueLinkController.php b/src/Controller/IssueLinkController.php index 9da4ebff..84f716f9 100644 --- a/src/Controller/IssueLinkController.php +++ b/src/Controller/IssueLinkController.php @@ -22,6 +22,7 @@ class IssueLinkController implements ServiceIssueLinkAwareInterface { use RestControllerTrait; + private Service\IssueLink $issueLinkService; /** diff --git a/src/Controller/MinisterController.php b/src/Controller/MinisterController.php index 17a9dee6..d958b8c1 100644 --- a/src/Controller/MinisterController.php +++ b/src/Controller/MinisterController.php @@ -24,6 +24,7 @@ class MinisterController implements ServiceMinistryAwareInterface { use RestControllerTrait; + private Service\Ministry $ministryService; /** diff --git a/src/Controller/MinisterSittingController.php b/src/Controller/MinisterSittingController.php index 8ebe3a45..7e24bfa0 100644 --- a/src/Controller/MinisterSittingController.php +++ b/src/Controller/MinisterSittingController.php @@ -32,6 +32,7 @@ class MinisterSittingController implements RouterAwareInterface { use RestControllerTrait; + private RouteInterface $router; private Service\MinisterSitting $ministerSittingService; @@ -125,9 +126,11 @@ public function post(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($ministerSitting = $this->ministerSittingService->get( - $request->getAttribute('ministry_sitting_id') - )) != null) { + if ( + ($ministerSitting = $this->ministerSittingService->get( + $request->getAttribute('ministry_sitting_id') + )) != null + ) { $form = new Form\MinisterSitting([ ...$ministerSitting->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/MinistryController.php b/src/Controller/MinistryController.php index f81faf2b..473301dd 100644 --- a/src/Controller/MinistryController.php +++ b/src/Controller/MinistryController.php @@ -22,6 +22,7 @@ class MinistryController implements ServiceMinistryAwareInterface { use RestControllerTrait; + private Service\Ministry $ministryService; /** @@ -99,9 +100,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($ministry = $this->ministryService->get( - $request->getAttribute('id') - )) !== null) { + if ( + ($ministry = $this->ministryService->get( + $request->getAttribute('id') + )) !== null + ) { $form = new Form\Ministry([ ...$ministry->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/PartyController.php b/src/Controller/PartyController.php index df907fab..481cb7b3 100644 --- a/src/Controller/PartyController.php +++ b/src/Controller/PartyController.php @@ -23,6 +23,7 @@ class PartyController implements ServicePartyAwareInterface { use RestControllerTrait; + private Service\Party $partyService; /** @@ -97,9 +98,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($party = $this->partyService->get( - $request->getAttribute('id') - )) !== null) { + if ( + ($party = $this->partyService->get( + $request->getAttribute('id') + )) !== null + ) { $form = new Form\Party([ ...$party->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/PlenaryAgendaController.php b/src/Controller/PlenaryAgendaController.php index 8328be4f..adf18770 100644 --- a/src/Controller/PlenaryAgendaController.php +++ b/src/Controller/PlenaryAgendaController.php @@ -1,4 +1,5 @@ presidentService->get( - $request->getAttribute('id') - )) != null) { + if ( + ($president = $this->presidentService->get( + $request->getAttribute('id') + )) != null + ) { $form = new Form\President([ ...$president->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/SessionController.php b/src/Controller/SessionController.php index 3edf4b37..a1be8923 100644 --- a/src/Controller/SessionController.php +++ b/src/Controller/SessionController.php @@ -33,6 +33,7 @@ class SessionController implements RouterAwareInterface { use RestControllerTrait; + private RouteInterface $router; private Session $sessionService; @@ -146,9 +147,11 @@ public function post(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($session = $this->sessionService->get( - $request->getAttribute('session_id') - )) !== null) { + if ( + ($session = $this->sessionService->get( + $request->getAttribute('session_id') + )) !== null + ) { $form = new Form\Session([ ...$session->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/SpeechController.php b/src/Controller/SpeechController.php index 5bef5af4..d3fdd460 100644 --- a/src/Controller/SpeechController.php +++ b/src/Controller/SpeechController.php @@ -39,6 +39,7 @@ class SpeechController implements ServiceConstituencyAwareInterface { use RestControllerTrait; + private Service\Speech $speechService; private Service\Congressman $congressmanService; private Service\Party $partyService; diff --git a/src/Controller/SuperCategoryController.php b/src/Controller/SuperCategoryController.php index b0480948..9c256572 100644 --- a/src/Controller/SuperCategoryController.php +++ b/src/Controller/SuperCategoryController.php @@ -22,6 +22,7 @@ class SuperCategoryController implements ServiceSuperCategoryAwareInterface { use RestControllerTrait; + private SuperCategory $superCategoryService; /** @@ -77,9 +78,11 @@ public function put(ServerRequest $request): ResponseInterface */ public function patch(ServerRequest $request): ResponseInterface { - if (($superCategory = $this->superCategoryService->get( - $request->getAttribute('super_category_id') - )) != null) { + if ( + ($superCategory = $this->superCategoryService->get( + $request->getAttribute('super_category_id') + )) != null + ) { $form = new Form\SuperCategory([ ...$superCategory->toArray(), ...$request->getParsedBody(), diff --git a/src/Controller/VoteController.php b/src/Controller/VoteController.php index e7e4ba92..c9e8aa55 100644 --- a/src/Controller/VoteController.php +++ b/src/Controller/VoteController.php @@ -23,6 +23,7 @@ class VoteController implements ServiceVoteAwareInterface { use RestControllerTrait; + private Vote $voteService; /** diff --git a/src/Controller/VoteItemController.php b/src/Controller/VoteItemController.php index a79a6df0..3a0ee8c5 100644 --- a/src/Controller/VoteItemController.php +++ b/src/Controller/VoteItemController.php @@ -46,6 +46,7 @@ class VoteItemController implements RouterAwareInterface { use RestControllerTrait; + private RouteInterface $router; private VoteItem $voteItemService; private Vote $voteService; diff --git a/src/Filter/ItemStatusFilter.php b/src/Filter/ItemStatusFilter.php index 3f19fa64..9de83c20 100644 --- a/src/Filter/ItemStatusFilter.php +++ b/src/Filter/ItemStatusFilter.php @@ -38,13 +38,17 @@ public function filter($value) $matches = []; - if (1 === preg_match('/(Bíður\s|Beið\s)([0-9]\.|fyrri|síðari)(\sumræðu)/', $value, $matches) - && 4 == count($matches)) { + if ( + 1 === preg_match('/(Bíður\s|Beið\s)([0-9]\.|fyrri|síðari)(\sumræðu)/', $value, $matches) + && 4 == count($matches) + ) { return sprintf('Bíður %s umræðu', $this->wordToNumber($matches[2])); } - if (1 === preg_match('/(nefnd eftir\s)([0-9]\.|fyrri|síðari)(\sumræðu)/', $value, $matches) - && 4 == count($matches)) { + if ( + 1 === preg_match('/(nefnd eftir\s)([0-9]\.|fyrri|síðari)(\sumræðu)/', $value, $matches) + && 4 == count($matches) + ) { return sprintf('Í nefnd eftir %s umræðu', $this->wordToNumber($matches[2])); } diff --git a/src/Form/Assembly.php b/src/Form/Assembly.php index 308b6218..127417dc 100644 --- a/src/Form/Assembly.php +++ b/src/Form/Assembly.php @@ -20,13 +20,16 @@ public function getValidationConfig(): array (new Input('assembly_id')) ->attachFilter(new ToInt()) ->attachValidator(new NotEmpty()) - ->attachValidator(new SignedDigits()), + ->attachValidator(new SignedDigits()) + , (new Input('from')) ->attachValidator(new NotEmpty()) - ->attachValidator(new Date()), + ->attachValidator(new Date()) + , (new Input('to', true)) ->attachValidator(new Date()) ->attachFilter(new ToNull(['type' => 'all'])) + , ]; } diff --git a/src/Form/Cabinet.php b/src/Form/Cabinet.php index 8ef18f15..bc037e73 100644 --- a/src/Form/Cabinet.php +++ b/src/Form/Cabinet.php @@ -29,19 +29,19 @@ public function getValidationConfig(): array (new Input('cabinet_id')) ->attachFilter(new ToInt()) ->attachValidator(new NotEmpty()) - ->attachValidator(new SignedDigits()), - + ->attachValidator(new SignedDigits()) + , (new Input('from')) ->attachValidator(new Date()) - ->attachValidator(new NotEmpty()), - + ->attachValidator(new NotEmpty()) + , (new Input('to', true)) ->attachValidator(new Date()) - ->attachFilter(new ToNull(['type' => 'all'])), - + ->attachFilter(new ToNull(['type' => 'all'])) + , (new Input('title')) - ->attachValidator(new NotEmpty()), - + ->attachValidator(new NotEmpty()) + , (new Input('description', true)) ->attachFilter(new ToNull(['type' => 'all'])), ]; diff --git a/src/Form/Category.php b/src/Form/Category.php index fb15a630..dc7b3565 100644 --- a/src/Form/Category.php +++ b/src/Form/Category.php @@ -28,18 +28,19 @@ public function getValidationConfig(): array (new Input('super_category_id')) ->attachValidator(new NotEmpty()) ->attachValidator(new SignedDigits()) - ->attachFilter(new ToInt()), - + ->attachFilter(new ToInt()) + , (new Input('category_id')) ->attachValidator(new NotEmpty()) ->attachValidator(new SignedDigits()) - ->attachFilter(new ToInt()), - + ->attachFilter(new ToInt()) + , (new Input('title')) - ->attachValidator(new NotEmpty()), - + ->attachValidator(new NotEmpty()) + , (new Input('description', true)) - ->attachFilter(new ToNull(['type' => 'all'])), + ->attachFilter(new ToNull(['type' => 'all'])) + , ]; } } diff --git a/src/Hydrator/AssemblyStatus.php b/src/Hydrator/AssemblyStatus.php index cb481c74..0fc43628 100644 --- a/src/Hydrator/AssemblyStatus.php +++ b/src/Hydrator/AssemblyStatus.php @@ -6,7 +6,6 @@ class AssemblyStatus implements HydratorInterface { - /** * Hydrate $object with the provided $data. * diff --git a/src/Hydrator/Cabinet.php b/src/Hydrator/Cabinet.php index abfb0d60..b6f5e632 100644 --- a/src/Hydrator/Cabinet.php +++ b/src/Hydrator/Cabinet.php @@ -7,7 +7,6 @@ class Cabinet implements HydratorInterface { - /** * Hydrate $object with the provided $data. * diff --git a/src/Hydrator/Congressman.php b/src/Hydrator/Congressman.php index ad554f6e..5d6bdf5a 100644 --- a/src/Hydrator/Congressman.php +++ b/src/Hydrator/Congressman.php @@ -7,7 +7,6 @@ class Congressman implements HydratorInterface { - /** * Hydrate $object with the provided $data. * diff --git a/src/Hydrator/CongressmanAndCabinet.php b/src/Hydrator/CongressmanAndCabinet.php index 81312d4d..b55fe949 100644 --- a/src/Hydrator/CongressmanAndCabinet.php +++ b/src/Hydrator/CongressmanAndCabinet.php @@ -7,7 +7,6 @@ class CongressmanAndCabinet implements HydratorInterface { - /** * Hydrate $object with the provided $data. * diff --git a/src/Hydrator/CongressmanAndParty.php b/src/Hydrator/CongressmanAndParty.php index deb02ca3..94dc3b23 100644 --- a/src/Hydrator/CongressmanAndParty.php +++ b/src/Hydrator/CongressmanAndParty.php @@ -7,7 +7,6 @@ class CongressmanAndParty implements HydratorInterface { - /** * Hydrate $object with the provided $data. * diff --git a/src/Hydrator/HydrateDate.php b/src/Hydrator/HydrateDate.php index 39e17e88..2b7c7ee6 100644 --- a/src/Hydrator/HydrateDate.php +++ b/src/Hydrator/HydrateDate.php @@ -1,4 +1,5 @@ self::A, 'b' => self::B, default => throw new Exception("'$value' is not a valid string"), diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index 59f26336..b411fe7c 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -1,4 +1,5 @@ [^:.{\[\]]+)(?:{(?P[^}]+)})?:?)', - $def, - $matches, - 0, - $currentPos - )) { + if ( + ! preg_match( + '(\G(?P[^:.{\[\]]+)(?:{(?P[^}]+)})?:?)', + $def, + $matches, + 0, + $currentPos + ) + ) { throw new Exception\RuntimeException('Found empty parameter name'); } @@ -243,7 +245,8 @@ protected function buildHost(array $parts, array $mergedParams, $isOptional) } return ''; - } elseif (! $isOptional + } elseif ( + ! $isOptional || ! isset($this->defaults[$part[1]]) || $this->defaults[$part[1]] !== $mergedParams[$part[1]] ) { diff --git a/src/Router/Http/Part.php b/src/Router/Http/Part.php index 60e067a7..e520ee3a 100644 --- a/src/Router/Http/Part.php +++ b/src/Router/Http/Part.php @@ -158,7 +158,8 @@ public function match(RequestInterface $request, $pathOffset = null, array $opti return $match; } - if (isset($options['translator']) + if ( + isset($options['translator']) && ! isset($options['locale']) && null !== ($locale = $match->getParam('locale', null)) ) { diff --git a/src/Router/Http/Segment.php b/src/Router/Http/Segment.php index 193ad4b4..7ab3dc69 100644 --- a/src/Router/Http/Segment.php +++ b/src/Router/Http/Segment.php @@ -97,13 +97,15 @@ protected function parseRouteDefinition(string $def): array } if ($matches['token'] === ':') { - if (! preg_match( - '(\G(?P[^:/{\[\]]+)(?:{(?P[^}]+)})?:?)', - $def, - $matches, - 0, - $currentPos - )) { + if ( + ! preg_match( + '(\G(?P[^:/{\[\]]+)(?:{(?P[^}]+)})?:?)', + $def, + $matches, + 0, + $currentPos + ) + ) { throw new Exception\RuntimeException('Found empty parameter name'); } @@ -210,7 +212,8 @@ protected function buildPath( } return ''; - } elseif (! $isOptional + } elseif ( + ! $isOptional || $hasChild || ! isset($this->defaults[$part[1]]) || $this->defaults[$part[1]] !== $mergedParams[$part[1]] diff --git a/src/Router/Http/TreeRouteStack.php b/src/Router/Http/TreeRouteStack.php index dfb6270a..cdb9e806 100644 --- a/src/Router/Http/TreeRouteStack.php +++ b/src/Router/Http/TreeRouteStack.php @@ -172,7 +172,8 @@ public function match( } foreach ($this->routes as $name => $route) { - if (($match = $route->match($request, $baseUrlLength, $options)) instanceof RouteMatch + if ( + ($match = $route->match($request, $baseUrlLength, $options)) instanceof RouteMatch && ($pathLength === null || $match->getLength() === $pathLength) ) { $match->setMatchedRouteName($name); @@ -248,7 +249,8 @@ public function assemble(array $params = [], array $options = [])/* : mixed*/ $uri = $uri->withFragment($options['fragment']); } - if ((isset($options['force_canonical']) + if ( + (isset($options['force_canonical']) && $options['force_canonical']) || $uri->getHost() !== null || $uri->getScheme() !== null diff --git a/src/Router/RestControllerTrait.php b/src/Router/RestControllerTrait.php index b513bdaa..b7a166f1 100644 --- a/src/Router/RestControllerTrait.php +++ b/src/Router/RestControllerTrait.php @@ -159,7 +159,7 @@ public function setRouteMatch(RouteMatch $routeMatch): self public function url() { - return new class($this->router) + return new class ($this->router) { private SimpleRouteStack $r; public function __construct(SimpleRouteStack $router) diff --git a/src/Service/Assembly.php b/src/Service/Assembly.php index fcc9657f..43ff8297 100644 --- a/src/Service/Assembly.php +++ b/src/Service/Assembly.php @@ -15,32 +15,32 @@ class Assembly implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - const ALLOWED_TYPES = [ + private const ALLOWED_TYPES = [ 'a', 'f', 's', 'b', 'm', 'q', 'v', 'l', 'n', // A 'mi', 'fh', 'dr', 'sr', 'st', 'ra', 'uu', 'þi', 'um', // B 'ff', 'ft', 'ko', 'ud' ]; - const MAX_ROW_COUNT = '18446744073709551615'; + private const MAX_ROW_COUNT = '18446744073709551615'; - public function get(int $id): ? Model\Assembly + public function get(int $id): ?Model\Assembly { $statement = $this->getDriver()->prepare("select * from `Assembly` where assembly_id = :id"); $statement->execute(['id' => $id]); $assembly = $statement->fetch(PDO::FETCH_ASSOC); return $assembly - ? (new Hydrator\Assembly)->hydrate($assembly, new Model\Assembly()) + ? (new Hydrator\Assembly())->hydrate($assembly, new Model\Assembly()) : null; } - public function getCurrent(): ? Model\Assembly + public function getCurrent(): ?Model\Assembly { $statement = $this->getDriver()->prepare("select * from `Assembly` order by `assembly_id` desc limit 0, 1"); $statement->execute(); $assembly = $statement->fetch(PDO::FETCH_ASSOC); return $assembly - ? (new Hydrator\Assembly)->hydrate($assembly, new Model\Assembly()) + ? (new Hydrator\Assembly())->hydrate($assembly, new Model\Assembly()) : null; } @@ -57,7 +57,7 @@ public function fetchAll(int $offset = 0, int $size = null, string $order = 'asc $statement->execute(); return array_map(function ($assembly) { - return (new Hydrator\Assembly)->hydrate($assembly, new Model\Assembly()); + return (new Hydrator\Assembly())->hydrate($assembly, new Model\Assembly()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -69,7 +69,7 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Assembly)->hydrate($object, new Model\Assembly()); + yield (new Hydrator\Assembly())->hydrate($object, new Model\Assembly()); } $statement->closeCursor(); return null; @@ -97,7 +97,7 @@ public function fetchByCabinet(int $id): array $statement->execute(['id' => $id]); return array_map(function ($assembly) { - return (new Hydrator\Assembly)->hydrate($assembly, new Model\Assembly()); + return (new Hydrator\Assembly())->hydrate($assembly, new Model\Assembly()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } diff --git a/src/Service/Cabinet.php b/src/Service/Cabinet.php index 3181a8d3..c5904ea8 100644 --- a/src/Service/Cabinet.php +++ b/src/Service/Cabinet.php @@ -53,7 +53,7 @@ public function fetchAll(?DateTime $from = null, ?DateTime $to = null): array } return array_map(function ($object) { - return (new Hydrator\Cabinet)->hydrate($object, new Model\Cabinet()); + return (new Hydrator\Cabinet())->hydrate($object, new Model\Cabinet()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -65,13 +65,13 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Cabinet)->hydrate($object, new Model\Cabinet()); + yield (new Hydrator\Cabinet())->hydrate($object, new Model\Cabinet()); } $statement->closeCursor(); return null; } - public function get(int $id): ? Model\Cabinet + public function get(int $id): ?Model\Cabinet { $statement = $this->getDriver()->prepare("select * from `Cabinet` where cabinet_id = :id"); $statement->execute(['id' => $id]); diff --git a/src/Service/Category.php b/src/Service/Category.php index ccd247b6..ce149c70 100644 --- a/src/Service/Category.php +++ b/src/Service/Category.php @@ -13,7 +13,7 @@ class Category implements DatabaseAwareInterface { use DatabaseService; - public function get(int $id): ? Model\Category + public function get(int $id): ?Model\Category { $statement = $this->getDriver()->prepare(' select * from `Category` where category_id = :category_id @@ -27,7 +27,7 @@ public function get(int $id): ? Model\Category : null; } - public function fetch(int $superId): ? array + public function fetch(int $superId): ?array { $statement = $this->getDriver()->prepare(' select * from `Category` where super_category_id = :super_category_id @@ -46,7 +46,7 @@ public function fetchAllGenerator(): Generator $statement->execute(); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Category)->hydrate($object, new Model\Category()); + yield (new Hydrator\Category())->hydrate($object, new Model\Category()); } $statement->closeCursor(); return null; @@ -94,7 +94,7 @@ public function fetchByAssemblyAndIssue(int $assemblyId, int $issueId): array }, $statement->fetchAll(PDO::FETCH_ASSOC)); } - public function fetchByAssemblyIssueAndCategory(int $assemblyId, int $issueId, int $categoryId): ? Model\Category + public function fetchByAssemblyIssueAndCategory(int $assemblyId, int $issueId, int $categoryId): ?Model\Category { $statement = $this->getDriver()->prepare(' select C.* from `Category_has_Issue` CI diff --git a/src/Service/Committee.php b/src/Service/Committee.php index 2b4ef05c..18eda13d 100644 --- a/src/Service/Committee.php +++ b/src/Service/Committee.php @@ -15,7 +15,7 @@ class Committee implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Committee + public function get(int $id): ?Model\Committee { $statement = $this->getDriver()->prepare('select * from `Committee` C where C.`committee_id` = :committee_id;'); $statement->execute(['committee_id' => $id]); @@ -27,7 +27,7 @@ public function get(int $id): ? Model\Committee : null; } - public function getByName(string $name): ? Model\Committee + public function getByName(string $name): ?Model\Committee { $statement = $this->getDriver()->prepare(' select * from `Committee` C where C.`name` = :name; @@ -65,7 +65,7 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Committee)->hydrate($object, new Model\Committee()); + yield (new Hydrator\Committee())->hydrate($object, new Model\Committee()); } $statement->closeCursor(); return null; diff --git a/src/Service/CommitteeDocument.php b/src/Service/CommitteeDocument.php index 0fd40a5a..7332cf27 100644 --- a/src/Service/CommitteeDocument.php +++ b/src/Service/CommitteeDocument.php @@ -18,7 +18,7 @@ class CommitteeDocument implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\CommitteeDocument + public function get(int $id): ?Model\CommitteeDocument { $statement = $this->getDriver()->prepare(" select * from `Document_has_Committee` @@ -81,7 +81,7 @@ public function fetchAllGenerator(?int $assemblyId = null, ?int $issueId = null, while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\CommitteeDocument)->hydrate($object, new Model\CommitteeDocument()); + yield (new Hydrator\CommitteeDocument())->hydrate($object, new Model\CommitteeDocument()); } $statement->closeCursor(); return null; diff --git a/src/Service/CommitteeMeeting.php b/src/Service/CommitteeMeeting.php index 202b51b0..f0b0bc47 100644 --- a/src/Service/CommitteeMeeting.php +++ b/src/Service/CommitteeMeeting.php @@ -11,7 +11,7 @@ class CommitteeMeeting implements DatabaseAwareInterface { use DatabaseService; - public function get(int $id): ? Model\CommitteeMeeting + public function get(int $id): ?Model\CommitteeMeeting { $statement = $this->getDriver()->prepare(' select * from `CommitteeMeeting` where committee_meeting_id = :committee_meeting_id diff --git a/src/Service/CommitteeMeetingAgenda.php b/src/Service/CommitteeMeetingAgenda.php index b1633fb3..2ea6c19a 100644 --- a/src/Service/CommitteeMeetingAgenda.php +++ b/src/Service/CommitteeMeetingAgenda.php @@ -11,7 +11,7 @@ class CommitteeMeetingAgenda implements DatabaseAwareInterface { use DatabaseService; - public function get(int $meetingId, int $agendaId): ? Model\CommitteeMeetingAgenda + public function get(int $meetingId, int $agendaId): ?Model\CommitteeMeetingAgenda { $statement = $this->getDriver()->prepare(' select * from `CommitteeMeetingAgenda` C diff --git a/src/Service/CommitteeSitting.php b/src/Service/CommitteeSitting.php index b1699678..ad5facf1 100644 --- a/src/Service/CommitteeSitting.php +++ b/src/Service/CommitteeSitting.php @@ -16,7 +16,7 @@ class CommitteeSitting implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\CommitteeSitting + public function get(int $id): ?Model\CommitteeSitting { $statement = $this->getDriver()->prepare( "select * from `CommitteeSitting` where committee_sitting_id = :committee_sitting_id" @@ -50,7 +50,7 @@ public function fetchAllGenerator( $statement->execute($filteredParams); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\CommitteeSitting)->hydrate($object, new Model\CommitteeSitting()); + yield (new Hydrator\CommitteeSitting())->hydrate($object, new Model\CommitteeSitting()); } $statement->closeCursor(); return null; diff --git a/src/Service/Congressman.php b/src/Service/Congressman.php index abb158dd..37f5bbb5 100644 --- a/src/Service/Congressman.php +++ b/src/Service/Congressman.php @@ -14,14 +14,14 @@ class Congressman implements DatabaseAwareInterface, EventsAwareInterface { - const CONGRESSMAN_TYPE_MP = 'parliamentarian'; - const CONGRESSMAN_TYPE_SUBSTITUTE = 'substitute'; - const CONGRESSMAN_TYPE_WITH_SUBSTITUTE = 'with-substitute'; - use DatabaseService; use EventService; - public function get(int $id): ? Model\Congressman + public const CONGRESSMAN_TYPE_MP = 'parliamentarian'; + public const CONGRESSMAN_TYPE_SUBSTITUTE = 'substitute'; + public const CONGRESSMAN_TYPE_WITH_SUBSTITUTE = 'with-substitute'; + + public function get(int $id): ?Model\Congressman { $statement = $this->getDriver()->prepare("select * from `Congressman` C where congressman_id = :id"); $statement->execute(['id' => $id]); @@ -70,7 +70,7 @@ public function fetchAllGenerator(?int $assemblyId = null): Generator } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Congressman)->hydrate($object, new Model\Congressman()); + yield (new Hydrator\Congressman())->hydrate($object, new Model\Congressman()); } $statement->closeCursor(); return null; diff --git a/src/Service/CongressmanDocument.php b/src/Service/CongressmanDocument.php index 102b729b..a5fc803a 100644 --- a/src/Service/CongressmanDocument.php +++ b/src/Service/CongressmanDocument.php @@ -15,7 +15,7 @@ class CongressmanDocument implements DatabaseAwareInterface, EventsAwareInterfac use DatabaseService; use EventService; - public function get(int $assemblyId, int $issueId, int $documentId, int $congressmanId): ? Model\CongressmanDocument + public function get(int $assemblyId, int $issueId, int $documentId, int $congressmanId): ?Model\CongressmanDocument { $statement = $this->getDriver()->prepare(" select * from `Document_has_Congressman` D @@ -61,7 +61,7 @@ public function fetchAllGenerator( $statement->execute($filteredParams); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\CongressmanDocument)->hydrate($object, new Model\CongressmanDocument()); + yield (new Hydrator\CongressmanDocument())->hydrate($object, new Model\CongressmanDocument()); } $statement->closeCursor(); @@ -93,7 +93,7 @@ public function fetchByDocument(int $assemblyId, int $issueId, int $documentId): /** * @deprecated */ - public function countProponents(int $assemblyId, int $issueId, int $documentId): ? int + public function countProponents(int $assemblyId, int $issueId, int $documentId): ?int { $statement = $this->getDriver()->prepare(" select count(*) @@ -112,7 +112,7 @@ public function countProponents(int $assemblyId, int $issueId, int $documentId): /** * @deprecated */ - public function fetchProponents($assemblyId, $issueId, $documentId): ? Model\CongressmanValue + public function fetchProponents($assemblyId, $issueId, $documentId): ?Model\CongressmanValue { $statement = $this->getDriver()->prepare(" select C.*, DC.`order` as `value` from Document_has_Congressman DC diff --git a/src/Service/Constituency.php b/src/Service/Constituency.php index afbeb4e5..aa71cba5 100644 --- a/src/Service/Constituency.php +++ b/src/Service/Constituency.php @@ -17,7 +17,7 @@ class Constituency implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Constituency + public function get(int $id): ?Model\Constituency { $statement = $this->getDriver()->prepare( 'select * from `Constituency` @@ -38,13 +38,13 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Constituency)->hydrate($object, new Model\Constituency()); + yield (new Hydrator\Constituency())->hydrate($object, new Model\Constituency()); } $statement->closeCursor(); return null; } - public function getByCongressman(int $congressmanId, DateTime $date): ? Model\ConstituencyDate + public function getByCongressman(int $congressmanId, DateTime $date): ?Model\ConstituencyDate { $statement = $this->getDriver()->prepare(' select C.*, S.`from` as `date` from Session S @@ -68,7 +68,7 @@ public function getByCongressman(int $congressmanId, DateTime $date): ? Model\Co /** * @deprecated */ - public function getByCongressmanAndConstituency(int $congressmanId, int $assemblyId): ? Model\ConstituencyDate + public function getByCongressmanAndConstituency(int $congressmanId, int $assemblyId): ?Model\ConstituencyDate { $statement = $this->getDriver()->prepare(' select C.*, S.`from` as `date` from Session S @@ -88,7 +88,7 @@ public function getByCongressmanAndConstituency(int $congressmanId, int $assembl : null ; } - public function getByAssemblyAndCongressman(int $congressmanId, int $assemblyId): ? Model\ConstituencyDate + public function getByAssemblyAndCongressman(int $congressmanId, int $assemblyId): ?Model\ConstituencyDate { $statement = $this->getDriver()->prepare(' select C.*, S.`from` as `date` from Session S diff --git a/src/Service/Document.php b/src/Service/Document.php index eb1eba34..f29c136a 100644 --- a/src/Service/Document.php +++ b/src/Service/Document.php @@ -17,7 +17,7 @@ class Document implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $assemblyId, int $issueId, int $documentId): ? Model\Document + public function get(int $assemblyId, int $issueId, int $documentId): ?Model\Document { $statement = $this->getDriver()->prepare(" select * from `Document` D @@ -90,7 +90,7 @@ public function fetchAllGenerator(?int $assemblyId = null, ?int $issueId = null) } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Document)->hydrate($object, new Model\Document()); + yield (new Hydrator\Document())->hydrate($object, new Model\Document()); } $statement->closeCursor(); return null; diff --git a/src/Service/Election.php b/src/Service/Election.php index 1c7e3773..4e3e0443 100644 --- a/src/Service/Election.php +++ b/src/Service/Election.php @@ -11,7 +11,7 @@ class Election implements DatabaseAwareInterface { use DatabaseService; - public function get(int $id): ? Model\Election + public function get(int $id): ?Model\Election { $statement = $this->getDriver()->prepare(" select * from `Election` where election_id = :election_id @@ -24,7 +24,7 @@ public function get(int $id): ? Model\Election : null; } - public function getByAssembly(int $assemblyId): ? Model\Election + public function getByAssembly(int $assemblyId): ?Model\Election { $statement = $this->getDriver()->prepare(" select E.* from `Election` E diff --git a/src/Service/Inflation.php b/src/Service/Inflation.php index 4485184b..c66ba0a5 100644 --- a/src/Service/Inflation.php +++ b/src/Service/Inflation.php @@ -58,7 +58,7 @@ public function fetchAll(?DateTime $from = null, ?DateTime $to = null): array } return array_map(function ($object) { - return (new Hydrator\Inflation)->hydrate($object, new Model\Inflation()); + return (new Hydrator\Inflation())->hydrate($object, new Model\Inflation()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -70,13 +70,13 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Inflation)->hydrate($object, new Model\Inflation()); + yield (new Hydrator\Inflation())->hydrate($object, new Model\Inflation()); } $statement->closeCursor(); return null; } - public function get(int $id): ? Model\Inflation + public function get(int $id): ?Model\Inflation { $statement = $this->getDriver()->prepare("select * from `Inflation` where id = :id"); $statement->execute(['id' => $id]); diff --git a/src/Service/Issue.php b/src/Service/Issue.php index be7ca174..6994c80c 100644 --- a/src/Service/Issue.php +++ b/src/Service/Issue.php @@ -21,14 +21,14 @@ class Issue implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - const ALLOWED_TYPES = [ + private const ALLOWED_TYPES = [ 'a', 'f', 's', 'b', 'm', 'q', 'v', 'l', 'n', // A 'mi', 'fh', 'dr', 'sr', 'st', 'ra', 'uu', 'þi', 'um', // B 'ff', 'ft', 'ko', 'ud' ]; - const ALLOWED_ORDER = ['asc', 'desc']; + private const ALLOWED_ORDER = ['asc', 'desc']; - public function get(int $issue_id, int $assembly_id, $kind = KindEnum::A): ? Model\Issue + public function get(int $issue_id, int $assembly_id, $kind = KindEnum::A): ?Model\Issue { $issueStatement = $this->getDriver()->prepare(' select * from `Issue` I @@ -82,7 +82,7 @@ public function fetchAllGenerator(?int $assemblyId = null): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Issue)->hydrate($object, new Model\Issue()); + yield (new Hydrator\Issue())->hydrate($object, new Model\Issue()); } $statement->closeCursor(); return null; @@ -91,7 +91,7 @@ public function fetchAllGenerator(?int $assemblyId = null): Generator /** * Get one Issue along with some metadata. */ - public function getWithDate(int $issue_id, int $assembly_id, $kind = KindEnum::A): ? Model\IssueAndDate + public function getWithDate(int $issue_id, int $assembly_id, $kind = KindEnum::A): ?Model\IssueAndDate { $issueStatement = $this->getDriver()->prepare( 'select @@ -196,8 +196,12 @@ public function fetchByAssembly( }, $statement->fetchAll(PDO::FETCH_ASSOC)); } - public function countByAssembly(int $id, array $type = [], array $categoryTypes = [], ?array $kind = [KindEnum::A]): int - { + public function countByAssembly( + int $id, + array $type = [], + array $categoryTypes = [], + ?array $kind = [KindEnum::A] + ): int { $typeFilterString = $this->typeFilterString($type); $categoryFilterString = $this->categoryTypeFilterString($categoryTypes); $kindString = $this->categoryString($kind); @@ -623,8 +627,8 @@ public function update(Model\Issue $data): int $this->toUpdateString( 'Issue', $data, - "issue_id = {$data->getIssueId()} and ". - "assembly_id = {$data->getAssemblyId()} and ". + "issue_id = {$data->getIssueId()} and " . + "assembly_id = {$data->getAssemblyId()} and " . "kind = '{$data->getKind()->value}'" ) ); @@ -649,7 +653,7 @@ private function typeFilterString(array $type = []): string ); } - return ' and I.`type` in (' .implode( + return ' and I.`type` in (' . implode( ',', array_map(function ($t) { return "'" . $t . "'"; diff --git a/src/Service/IssueCategory.php b/src/Service/IssueCategory.php index 66c5ab44..4c4ff8d5 100644 --- a/src/Service/IssueCategory.php +++ b/src/Service/IssueCategory.php @@ -1,4 +1,5 @@ getDriver()->prepare(' select * from `Category_has_Issue` C @@ -71,7 +72,7 @@ public function fetchAllGenerator(?int $assemblyId = null): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\IssueCategory)->hydrate($object, new Model\IssueCategory()); + yield (new Hydrator\IssueCategory())->hydrate($object, new Model\IssueCategory()); } $statement->closeCursor(); return null; @@ -119,8 +120,8 @@ public function update(Model\IssueCategory $data): int $this->toUpdateString( 'Category_has_Issue', $data, - "category_id={$data->getCategoryId()} ". - "and issue_id={$data->getIssueId()} ". + "category_id={$data->getCategoryId()} " . + "and issue_id={$data->getIssueId()} " . "and assembly_id={$data->getAssemblyId()}" ) ); diff --git a/src/Service/MinisterSitting.php b/src/Service/MinisterSitting.php index 6ef31802..5488f423 100644 --- a/src/Service/MinisterSitting.php +++ b/src/Service/MinisterSitting.php @@ -16,14 +16,14 @@ class MinisterSitting implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\MinisterSitting + public function get(int $id): ?Model\MinisterSitting { $statement = $this->getDriver()->prepare("select * from `MinisterSitting` where minister_sitting_id = :id"); $statement->execute(['id' => $id]); $assembly = $statement->fetch(PDO::FETCH_ASSOC); return $assembly - ? (new Hydrator\MinisterSitting)->hydrate($assembly, new Model\MinisterSitting()) + ? (new Hydrator\MinisterSitting())->hydrate($assembly, new Model\MinisterSitting()) : null; } @@ -78,7 +78,7 @@ public function fetchAllGenerator(?int $assemblyId = null): Generator } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\MinisterSitting)->hydrate($object, new Model\MinisterSitting()); + yield (new Hydrator\MinisterSitting())->hydrate($object, new Model\MinisterSitting()); } $statement->closeCursor(); return null; diff --git a/src/Service/Ministry.php b/src/Service/Ministry.php index d6726d56..b21a4a3d 100644 --- a/src/Service/Ministry.php +++ b/src/Service/Ministry.php @@ -15,14 +15,14 @@ class Ministry implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Ministry + public function get(int $id): ?Model\Ministry { $statement = $this->getDriver()->prepare("select * from `Ministry` where ministry_id = :id"); $statement->execute(['id' => $id]); $assembly = $statement->fetch(PDO::FETCH_ASSOC); return $assembly - ? (new Hydrator\Ministry)->hydrate($assembly, new Model\Ministry()) + ? (new Hydrator\Ministry())->hydrate($assembly, new Model\Ministry()) : null; } @@ -35,7 +35,7 @@ public function fetchAll(): array $statement->execute(); return array_map(function ($assembly) { - return (new Hydrator\Ministry)->hydrate($assembly, new Model\Ministry()); + return (new Hydrator\Ministry())->hydrate($assembly, new Model\Ministry()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -47,7 +47,7 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Ministry)->hydrate($object, new Model\Ministry()); + yield (new Hydrator\Ministry())->hydrate($object, new Model\Ministry()); } $statement->closeCursor(); return null; @@ -69,7 +69,7 @@ public function fetchByCongressmanAssembly(int $assemblyId, int $congressmanId) ]); return array_map(function ($assembly) { - return (new Hydrator\Ministry)->hydrate($assembly, new Model\Ministry()); + return (new Hydrator\Ministry())->hydrate($assembly, new Model\Ministry()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -91,7 +91,7 @@ public function getByCongressmanAssembly(int $assemblyId, int $congressmanId, in $object = $statement->fetch(PDO::FETCH_ASSOC); return $object - ? (new Hydrator\Ministry)->hydrate($object, new Model\Ministry()) + ? (new Hydrator\Ministry())->hydrate($object, new Model\Ministry()) : null; } diff --git a/src/Service/Party.php b/src/Service/Party.php index 0d779cad..9a28520f 100644 --- a/src/Service/Party.php +++ b/src/Service/Party.php @@ -17,7 +17,7 @@ class Party implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Party + public function get(int $id): ?Model\Party { $statement = $this->getDriver()->prepare(' select * from `Party` where party_id = :party_id @@ -53,13 +53,13 @@ public function fetchAllGenerator(): Generator while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Party)->hydrate($object, new Model\Party()); + yield (new Hydrator\Party())->hydrate($object, new Model\Party()); } $statement->closeCursor(); return null; } - public function getByCongressman(int $congressmanId, DateTime $date): ? Model\Party + public function getByCongressman(int $congressmanId, DateTime $date): ?Model\Party { $statement = $this->getDriver()->prepare(' select P.* from Session S @@ -84,7 +84,7 @@ public function getByCongressman(int $congressmanId, DateTime $date): ? Model\Pa /** * @deprecated */ - public function getByCongressmanAndAssembly(int $congressmanId, int $assemblyId): ? Model\Party + public function getByCongressmanAndAssembly(int $congressmanId, int $assemblyId): ?Model\Party { $statement = $this->getDriver()->prepare(' select P.*, S.`from` as `date` from Session S @@ -182,7 +182,7 @@ public function fetchByAssembly(int $assemblyId, array $exclude = []): array $query = ' select P.* from `Session` S join `Party` P on (P.`party_id` = S.`party_id`) - where S.`assembly_id` = :assembly_id and P.`party_id` not in ('.implode(',', $exclude).') + where S.`assembly_id` = :assembly_id and P.`party_id` not in (' . implode(',', $exclude) . ') group by S.`party_id`; '; } diff --git a/src/Service/Plenary.php b/src/Service/Plenary.php index a70993a8..6c981de5 100644 --- a/src/Service/Plenary.php +++ b/src/Service/Plenary.php @@ -17,7 +17,7 @@ class Plenary implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $assemblyId, int $plenaryId): ? Model\Plenary + public function get(int $assemblyId, int $plenaryId): ?Model\Plenary { $statement = $this->getDriver()->prepare(' select * from `Plenary` where assembly_id = :assembly_id and plenary_id = :plenary_id @@ -67,7 +67,7 @@ public function fetchAllGenerator(?int $assembly_id): Generator $statement->execute($filteredParams); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Plenary)->hydrate($object, new Model\Plenary()); + yield (new Hydrator\Plenary())->hydrate($object, new Model\Plenary()); } $statement->closeCursor(); return null; diff --git a/src/Service/PlenaryAgenda.php b/src/Service/PlenaryAgenda.php index 566c7255..87d77b6f 100644 --- a/src/Service/PlenaryAgenda.php +++ b/src/Service/PlenaryAgenda.php @@ -11,7 +11,8 @@ class PlenaryAgenda implements DatabaseAwareInterface { use DatabaseService; - public function get(int $assemblyId, int $plenaryId, int $itemId): ? Model\PlenaryAgenda + + public function get(int $assemblyId, int $plenaryId, int $itemId): ?Model\PlenaryAgenda { $statement = $this->getDriver()->prepare(" select * from `PlenaryAgenda` @@ -27,14 +28,14 @@ public function get(int $assemblyId, int $plenaryId, int $itemId): ? Model\Plena $assembly = $statement->fetch(PDO::FETCH_ASSOC); return $assembly - ? (new Hydrator\PlenaryAgenda)->hydrate($assembly, new Model\PlenaryAgenda()) + ? (new Hydrator\PlenaryAgenda())->hydrate($assembly, new Model\PlenaryAgenda()) : null; } /** * @return Model\PlenaryAgenda[] */ - public function fetch(int $assemblyId, int $plenaryId): ? array + public function fetch(int $assemblyId, int $plenaryId): ?array { $statement = $this->getDriver()->prepare(" select * from PlenaryAgenda PA @@ -48,7 +49,7 @@ public function fetch(int $assemblyId, int $plenaryId): ? array ]); return array_map(function ($item) { - return (new Hydrator\PlenaryAgenda)->hydrate($item, new Model\PlenaryAgenda()); + return (new Hydrator\PlenaryAgenda())->hydrate($item, new Model\PlenaryAgenda()); }, $statement->fetchAll(PDO::FETCH_ASSOC)); } @@ -68,7 +69,7 @@ public function fetchAllGenerator(?int $assembly_id): Generator $statement->execute($filteredParams); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\PlenaryAgenda)->hydrate($object, new Model\PlenaryAgenda()); + yield (new Hydrator\PlenaryAgenda())->hydrate($object, new Model\PlenaryAgenda()); } $statement->closeCursor(); return null; diff --git a/src/Service/President.php b/src/Service/President.php index 74c44045..7a2d4bd7 100644 --- a/src/Service/President.php +++ b/src/Service/President.php @@ -16,7 +16,7 @@ class President implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\President + public function get(int $id): ?Model\President { $statement = $this->getDriver()->prepare( "select * @@ -58,13 +58,13 @@ public function fetchAllGenerator(?int $assembly = null): Generator } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\President)->hydrate($object, new Model\President()); + yield (new Hydrator\President())->hydrate($object, new Model\President()); } $statement->closeCursor(); return null; } - public function getWithCongressman(int $id): ? Model\PresidentCongressman + public function getWithCongressman(int $id): ?Model\PresidentCongressman { $statement = $this->getDriver()->prepare( "select P.`president_id`, P.`assembly_id`, P.`from`, P.`to`, P.`title`, P.`abbr`, C.* @@ -85,7 +85,7 @@ public function getByUnique( int $congressmanId, DateTime $from, string $title - ): ? Model\PresidentCongressman { + ): ?Model\PresidentCongressman { $statement = $this->getDriver()->prepare(" select P.`president_id`, P.`assembly_id`, P.`from`, P.`to`, P.`title`, P.`abbr`, C.* from `President` P diff --git a/src/Service/Session.php b/src/Service/Session.php index 43400512..1bb102f3 100644 --- a/src/Service/Session.php +++ b/src/Service/Session.php @@ -16,7 +16,7 @@ class Session implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Session + public function get(int $id): ?Model\Session { $statement = $this->getDriver()->prepare( "select * from `Session` where session_id = :session_id" @@ -46,7 +46,7 @@ public function fetchAllGenerator(?int $assembly_id = null, ?int $congressman_id $statement->execute($filteredParams); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Session)->hydrate($object, new Model\Session()); + yield (new Hydrator\Session())->hydrate($object, new Model\Session()); } $statement->closeCursor(); return null; diff --git a/src/Service/Speech.php b/src/Service/Speech.php index c01e4ad0..c317dd5b 100644 --- a/src/Service/Speech.php +++ b/src/Service/Speech.php @@ -16,9 +16,9 @@ class Speech implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - const MAX_ROW_COUNT = '18446744073709551615'; + private const MAX_ROW_COUNT = '18446744073709551615'; - public function get(string $id): ? Model\Speech + public function get(string $id): ?Model\Speech { $statement = $this->getDriver()->prepare( 'select * from `Speech` where speech_id = :speech_id' @@ -31,7 +31,7 @@ public function get(string $id): ? Model\Speech : null ; } - public function getLastActive(): ? Model\Speech + public function getLastActive(): ?Model\Speech { $statement = $this->getDriver()->prepare( 'select * from `Speech` where `text` is not null order by `from` desc;' @@ -192,8 +192,13 @@ public function fetchByIssue( * * @return \Althingi\Model\SpeechAndPosition[] */ - public function fetch(string $id, int $assemblyId, int $issueId, ?int $size = 25, ?KindEnum $kind = KindEnum::A): array - { + public function fetch( + string $id, + int $assemblyId, + int $issueId, + ?int $size = 25, + ?KindEnum $kind = KindEnum::A + ): array { $pointer = 0; $hasResult = false; $statement = $this->getDriver()->prepare( @@ -273,7 +278,7 @@ public function fetchAllGenerator(?int $assemblyId = null, ?int $issueId = null) } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Speech)->hydrate($object, new Model\Speech()); + yield (new Hydrator\Speech())->hydrate($object, new Model\Speech()); } $statement->closeCursor(); return null; diff --git a/src/Service/SuperCategory.php b/src/Service/SuperCategory.php index 2f2b6260..f9b64b4e 100644 --- a/src/Service/SuperCategory.php +++ b/src/Service/SuperCategory.php @@ -12,7 +12,7 @@ class SuperCategory implements DatabaseAwareInterface { use DatabaseService; - public function get(int $id): ? Model\SuperCategory + public function get(int $id): ?Model\SuperCategory { $statement = $this->getDriver()->prepare(' select * from `SuperCategory` where super_category_id = :super_category_id @@ -47,7 +47,7 @@ public function fetchAllGenerator(): Generator $statement->execute(); while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\SuperCategory)->hydrate($object, new Model\SuperCategory()); + yield (new Hydrator\SuperCategory())->hydrate($object, new Model\SuperCategory()); } $statement->closeCursor(); return null; @@ -56,7 +56,7 @@ public function fetchAllGenerator(): Generator /** * @return \Althingi\Model\SuperCategory[] */ - public function fetchByIssue(int $assemblyId, int $issueId, string$category = 'A'): array + public function fetchByIssue(int $assemblyId, int $issueId, string $category = 'A'): array { $statement = $this->getDriver()->prepare(' select SC.* from Category_has_Issue CI diff --git a/src/Service/Vote.php b/src/Service/Vote.php index 951c7c2b..d5c7d902 100644 --- a/src/Service/Vote.php +++ b/src/Service/Vote.php @@ -18,7 +18,7 @@ class Vote implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\Vote + public function get(int $id): ?Model\Vote { $statement = $this->getDriver()->prepare(' select * from `Vote` where vote_id = :vote_id @@ -81,7 +81,7 @@ public function fetchAllGenerator(?int $assemblyId = null, ?int $issueId = null, } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\Vote)->hydrate($object, new Model\Vote()); + yield (new Hydrator\Vote())->hydrate($object, new Model\Vote()); } $statement->closeCursor(); return null; diff --git a/src/Service/VoteItem.php b/src/Service/VoteItem.php index 355e0840..cf9f0452 100644 --- a/src/Service/VoteItem.php +++ b/src/Service/VoteItem.php @@ -15,7 +15,7 @@ class VoteItem implements DatabaseAwareInterface, EventsAwareInterface use DatabaseService; use EventService; - public function get(int $id): ? Model\VoteItem + public function get(int $id): ?Model\VoteItem { $statement = $this->getDriver()->prepare( 'select * from `VoteItem` where vote_item_id = :vote_item_id' @@ -73,7 +73,7 @@ public function fetchAllGenerator(?int $assemblyId = null, ?int $issueId = null, } while (($object = $statement->fetch(PDO::FETCH_ASSOC)) !== false) { - yield (new Hydrator\VoteItem)->hydrate($object, new Model\VoteItem()); + yield (new Hydrator\VoteItem())->hydrate($object, new Model\VoteItem()); } $statement->closeCursor(); @@ -99,7 +99,7 @@ public function fetchByVote(int $id): array * If you don't have the vote-item's unique ID, you can get an individual * vote-item by the vote-id and congressman-id, since that is unique. */ - public function getByVote(int $voteId, int $congressmanId): ? Model\VoteItemAndAssemblyIssue + public function getByVote(int $voteId, int $congressmanId): ?Model\VoteItemAndAssemblyIssue { $statement = $this->getDriver()->prepare( 'select vi.*, v.assembly_id, v.issue_id from `VoteItem` vi diff --git a/src/Utils/ConsoleResponse.php b/src/Utils/ConsoleResponse.php index 5c9a543a..7156932e 100644 --- a/src/Utils/ConsoleResponse.php +++ b/src/Utils/ConsoleResponse.php @@ -1,4 +1,5 @@ $value) { - if (array_key_exists('action', $value['options']['defaults']) && + if ( + array_key_exists('action', $value['options']['defaults']) && ! empty($value['options']['defaults']['action']) ) { $action = str_replace(' ', '', ucwords(str_replace('-', ' ', $value['options']['defaults']['action']))); diff --git a/src/Validator/SignedDigits.php b/src/Validator/SignedDigits.php index 4bd21c2d..3f0c88c3 100644 --- a/src/Validator/SignedDigits.php +++ b/src/Validator/SignedDigits.php @@ -13,9 +13,9 @@ class SignedDigits extends AbstractValidator { - const NOT_DIGITS = 'notDigits'; - const STRING_EMPTY = 'digitsStringEmpty'; - const INVALID = 'digitsInvalid'; + private const NOT_DIGITS = 'notDigits'; + private const STRING_EMPTY = 'digitsStringEmpty'; + private const INVALID = 'digitsInvalid'; /** * Digits filter used for validation diff --git a/tests/Controller/AssemblyControllerTest.php b/tests/Controller/AssemblyControllerTest.php index f7c49d3e..781f234e 100644 --- a/tests/Controller/AssemblyControllerTest.php +++ b/tests/Controller/AssemblyControllerTest.php @@ -49,8 +49,7 @@ public function testGet() ->shouldReceive('get') ->andReturn((new Model\Assembly()) ->setAssemblyId(144) - ->setFrom(new DateTime()) - ) + ->setFrom(new DateTime())) ->once() ->getMock(); @@ -245,7 +244,7 @@ public function testOptions() ->getHeader('Allow'); $actualMethods = array_map(function ($item) { return trim($item); - }, explode(',', count($allow) ? $allow[0] : '')); + }, explode(',', count($allow) ? $allow[0] : '')); $this->assertCount(0, array_diff($expectedMethods, $actualMethods)); } diff --git a/tests/Controller/DocumentControllerTest.php b/tests/Controller/DocumentControllerTest.php index 515612d9..6d8336a2 100644 --- a/tests/Controller/DocumentControllerTest.php +++ b/tests/Controller/DocumentControllerTest.php @@ -52,8 +52,7 @@ public function testGet() ->setIssueId(2) ->setKind(KindEnum::A) ->setAssemblyId(145) - ->setType('type') - ) + ->setType('type')) ->getMock(); $this->dispatch('/loggjafarthing/145/thingmal/a/2/thingskjal/2', 'GET'); @@ -108,7 +107,6 @@ public function testGetList() ->setKind(KindEnum::A) ->setAssemblyId(145) ->setType('type') - ), ]) ->once() diff --git a/tests/Controller/InflationControllerTest.php b/tests/Controller/InflationControllerTest.php index 193b2000..cb1227a3 100644 --- a/tests/Controller/InflationControllerTest.php +++ b/tests/Controller/InflationControllerTest.php @@ -58,7 +58,7 @@ public function testGet() ->setId(1) ->setValue(1) ->setDate(new \DateTime()) - ) + ) ->once() ->getMock(); diff --git a/tests/Controller/MinisterSittingControllerTest.php b/tests/Controller/MinisterSittingControllerTest.php index a6611c4e..500749a5 100644 --- a/tests/Controller/MinisterSittingControllerTest.php +++ b/tests/Controller/MinisterSittingControllerTest.php @@ -305,7 +305,7 @@ public function testGet() ->setAssemblyId(1) ->setMinistryId(3) ->setCongressmanId(2) - ) + ) ->getMock(); $this->dispatch('/thingmenn/2/radherraseta/1', 'GET'); diff --git a/tests/DatabaseConnection.php b/tests/DatabaseConnection.php index d404a2ce..1263fd30 100644 --- a/tests/DatabaseConnection.php +++ b/tests/DatabaseConnection.php @@ -28,8 +28,9 @@ protected function getConnection() getenv('DB_PASSWORD') ?: '', [ PDO::MYSQL_ATTR_INIT_COMMAND => - "SET NAMES 'utf8', ". - "sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO';", + "SET NAMES 'utf8', " . + "sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO," . + "NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO';", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, ] diff --git a/tests/Filter/ItemStatusFilterTest.php b/tests/Filter/ItemStatusFilterTest.php index a11461cb..84972078 100644 --- a/tests/Filter/ItemStatusFilterTest.php +++ b/tests/Filter/ItemStatusFilterTest.php @@ -8,7 +8,6 @@ class ItemStatusFilterTest extends TestCase { - public static function filterStringProvider() { return [ diff --git a/tests/Filter/ToIntTest.php b/tests/Filter/ToIntTest.php index f9ff2f84..5e684bfa 100644 --- a/tests/Filter/ToIntTest.php +++ b/tests/Filter/ToIntTest.php @@ -11,7 +11,7 @@ class ToIntTest extends TestCase public function testTrue($in, $out) { - $this->assertEquals((new ToInt)->filter($in), $out); + $this->assertEquals((new ToInt())->filter($in), $out); } public static function provider() diff --git a/tests/Form/PlenaryTest.php b/tests/Form/PlenaryTest.php index df1df32d..bfd17622 100644 --- a/tests/Form/PlenaryTest.php +++ b/tests/Form/PlenaryTest.php @@ -35,5 +35,4 @@ public function testNegativeValue() $this->assertTrue($isValid); } - } diff --git a/tests/Service/AssemblyTest.php b/tests/Service/AssemblyTest.php index fb02a326..9c2e4b38 100644 --- a/tests/Service/AssemblyTest.php +++ b/tests/Service/AssemblyTest.php @@ -129,7 +129,7 @@ public function testCreate() $eventDispatcher = Mockery::mock(EventDispatcherInterface::class) ->shouldReceive('dispatch') ->once() - ->withArgs(function($args) { + ->withArgs(function ($args) { return $args instanceof AddEvent; }) ->getMock(); diff --git a/tests/Service/CabinetTest.php b/tests/Service/CabinetTest.php index d9191e9b..6712ad4c 100644 --- a/tests/Service/CabinetTest.php +++ b/tests/Service/CabinetTest.php @@ -47,7 +47,7 @@ public function testFetchByAssembly(int $assembly, array $cabinets) $assemblyService->setDriver($this->pdo); $expectedData = array_map(function ($cabinet) { - return (new \Althingi\Hydrator\Cabinet())->hydrate($cabinet, new CabinetModel); + return (new \Althingi\Hydrator\Cabinet())->hydrate($cabinet, new CabinetModel()); }, $cabinets); $actualData = $assemblyService->fetchByAssembly($assembly); diff --git a/tests/Service/CommitteeTest.php b/tests/Service/CommitteeTest.php index 4a2b242b..80342d86 100644 --- a/tests/Service/CommitteeTest.php +++ b/tests/Service/CommitteeTest.php @@ -9,6 +9,7 @@ use Althingi\Events\{UpdateEvent, AddEvent}; use Mockery; use PDO; + class CommitteeTest extends TestCase { use DatabaseConnection; @@ -123,29 +124,29 @@ public function testCreateNegative() 'last_assembly_id' => null, 'abbr_long' => null, 'abbr_short' => null - ], - [ + ], + [ 'committee_id' => 1, 'name' => 'committee1', 'first_assembly_id' => 1, 'last_assembly_id' => 2, 'abbr_long' => 'com1', 'abbr_short' => 'c1' - ], [ + ], [ 'committee_id' => 2, 'name' => 'committee2', 'first_assembly_id' => 1, 'last_assembly_id' => 2, 'abbr_long' => 'com2', 'abbr_short' => 'c2' - ], [ + ], [ 'committee_id' => 3, 'name' => null, 'first_assembly_id' => 1, 'last_assembly_id' => null, 'abbr_long' => null, 'abbr_short' => null - ], + ], ], ])->getTable('Committee'); $actualTable = $this->getConnection()->createQueryTable('Committee', 'SELECT * FROM Committee'); @@ -229,29 +230,29 @@ public function testSaveNegative() 'last_assembly_id' => null, 'abbr_long' => null, 'abbr_short' => null - ], - [ + ], + [ 'committee_id' => 1, 'name' => 'committee1', 'first_assembly_id' => 1, 'last_assembly_id' => 2, 'abbr_long' => 'com1', 'abbr_short' => 'c1' - ], [ + ], [ 'committee_id' => 2, 'name' => 'committee2', 'first_assembly_id' => 1, 'last_assembly_id' => 2, 'abbr_long' => 'com2', 'abbr_short' => 'c2' - ], [ + ], [ 'committee_id' => 3, 'name' => null, 'first_assembly_id' => 1, 'last_assembly_id' => null, 'abbr_long' => null, 'abbr_short' => null - ], + ], ], ])->getTable('Committee'); $actualTable = $this->getConnection()->createQueryTable('Committee', 'SELECT * FROM Committee'); diff --git a/tests/Service/CongressmanDocumentTest.php b/tests/Service/CongressmanDocumentTest.php index b0c3eeb8..6a22a666 100644 --- a/tests/Service/CongressmanDocumentTest.php +++ b/tests/Service/CongressmanDocumentTest.php @@ -12,6 +12,7 @@ use Psr\EventDispatcher\EventDispatcherInterface; use Mockery; use PDO; + class CongressmanDocumentTest extends TestCase { use DatabaseConnection; @@ -149,7 +150,6 @@ public function testCreateFireEventOne() ->setDriver($this->pdo) ->setEventDispatcher($eventDispatcher) ->create($congressman); - } public function testUpdateFireEventOne() @@ -175,7 +175,6 @@ public function testUpdateFireEventOne() ->setDriver($this->pdo) ->setEventDispatcher($eventDispatcher) ->update($congressman); - } public function testUpdateFireEventZero() { @@ -200,7 +199,6 @@ public function testUpdateFireEventZero() ->setDriver($this->pdo) ->setEventDispatcher($eventDispatcher) ->update($congressman); - } public function testSaveFireEventZero() diff --git a/tests/Service/ConstituencyTest.php b/tests/Service/ConstituencyTest.php index ee54e34e..55e412b2 100644 --- a/tests/Service/ConstituencyTest.php +++ b/tests/Service/ConstituencyTest.php @@ -21,7 +21,7 @@ public function testGet() $service = new Constituency(); $service->setDriver($this->pdo); - $expectedData = (new ConstituencyModel) + $expectedData = (new ConstituencyModel()) ->setConstituencyId(1) ->setName('some-place') ->setAbbrShort('s-p') diff --git a/tests/Service/MinistryTest.php b/tests/Service/MinistryTest.php index a404ba2f..f84b1ee2 100644 --- a/tests/Service/MinistryTest.php +++ b/tests/Service/MinistryTest.php @@ -303,7 +303,6 @@ public function testCreateFireEventCreateResource() ->setEventDispatcher($eventDispatcher) ->setDriver($this->pdo) ->create($ministry); - } public function testUpdateFireEventResourceFoundUpdateRequired() diff --git a/tests/Service/PresidentTest.php b/tests/Service/PresidentTest.php index 5d5e6538..a4a07184 100644 --- a/tests/Service/PresidentTest.php +++ b/tests/Service/PresidentTest.php @@ -104,7 +104,7 @@ public function testFetchAllGeneratorAll() ->setTitle('t')]; $actualData = []; - foreach($presidentService->fetchAllGenerator() as $item) { + foreach ($presidentService->fetchAllGenerator() as $item) { $actualData[] = $item; } @@ -123,7 +123,7 @@ public function testFetchAllGeneratorByAssembly() ->setTitle('t')]; $actualData = []; - foreach($presidentService->fetchAllGenerator(1) as $item) { + foreach ($presidentService->fetchAllGenerator(1) as $item) { $actualData[] = $item; } @@ -137,7 +137,7 @@ public function testFetchAllGeneratorNotFound() $expectedData = []; $actualData = []; - foreach($presidentService->fetchAllGenerator(2) as $item) { + foreach ($presidentService->fetchAllGenerator(2) as $item) { $actualData[] = $item; } diff --git a/tests/ServiceHelper.php b/tests/ServiceHelper.php index 4773546c..0c82cf10 100644 --- a/tests/ServiceHelper.php +++ b/tests/ServiceHelper.php @@ -117,7 +117,7 @@ public function assertResponseHeaderContains($name, $value) { $this->assertEquals( $value, - count($this->response->getHeader($name)) ? $this->response->getHeader($name)[0]: null + count($this->response->getHeader($name)) ? $this->response->getHeader($name)[0] : null ); } diff --git a/tests/Utils/CategoryParamConcreteClass.php b/tests/Utils/CategoryParamConcreteClass.php index c416d1a4..747f080b 100644 --- a/tests/Utils/CategoryParamConcreteClass.php +++ b/tests/Utils/CategoryParamConcreteClass.php @@ -1,4 +1,5 @@