Add PHPStan

In order to static analyze code and prevent bugs when changing code.
Fix issues in most of the files.
This commit is contained in:
Daniel Siepmann 2021-09-07 09:52:14 +02:00
parent ebb668221e
commit f618536ff9
21 changed files with 542 additions and 822 deletions

View file

@ -42,3 +42,12 @@ test:cgl:
script: script:
- composer install --prefer-dist --no-progress - composer install --prefer-dist --no-progress
- ./vendor/bin/ecs check --no-progress-bar --clear-cache --fix - ./vendor/bin/ecs check --no-progress-bar --clear-cache --fix
# Disabled due to high memory consumption in CI
# test:phpstan:
# image: php:7.3-alpine
# stage: test
# before_script:
# script:
# - composer install --prefer-dist --no-progress
# - ./vendor/bin/phpstan

View file

@ -13,7 +13,7 @@ use Wrm\Events\Service\DestinationDataImportService;
class DestinationDataImportCommand extends Command class DestinationDataImportCommand extends Command
{ {
public function configure() public function configure(): void
{ {
$this->setDescription('Import Destination Data Events'); $this->setDescription('Import Destination Data Events');
$this->setHelp('Destination Data Events are imported'); $this->setHelp('Destination Data Events are imported');

View file

@ -12,7 +12,7 @@ use Wrm\Events\Service\CleanupService;
class RemoveAllCommand extends Command class RemoveAllCommand extends Command
{ {
public function configure() public function configure(): void
{ {
$this->setDescription('Remove all event data'); $this->setDescription('Remove all event data');
$this->setHelp('All events and associated data will be removed.'); $this->setHelp('All events and associated data will be removed.');

View file

@ -12,7 +12,7 @@ use Wrm\Events\Service\CleanupService;
class RemovePastCommand extends Command class RemovePastCommand extends Command
{ {
public function configure() public function configure(): void
{ {
$this->setDescription('Remove past events'); $this->setDescription('Remove past events');
$this->setHelp('Past dates are removed, together with events that do not have any left dates.'); $this->setHelp('Past dates are removed, together with events that do not have any left dates.');
@ -22,8 +22,9 @@ class RemovePastCommand extends Command
{ {
Bootstrap::initializeBackendAuthentication(); Bootstrap::initializeBackendAuthentication();
return GeneralUtility::makeInstance(ObjectManager::class) GeneralUtility::makeInstance(ObjectManager::class)
->get(CleanupService::class) ->get(CleanupService::class)
->deletePastData(); ->deletePastData();
return 0;
} }
} }

View file

@ -66,15 +66,12 @@ class DateController extends AbstractController
/** /**
* @param DataProcessingForModels $dataProcessing * @param DataProcessingForModels $dataProcessing
*/ */
public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing) public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing): void
{ {
$this->dataProcessing = $dataProcessing; $this->dataProcessing = $dataProcessing;
} }
/** protected function initializeAction(): void
* Action initializer
*/
protected function initializeAction()
{ {
$this->dataProcessing->setConfigurationManager($this->configurationManager); $this->dataProcessing->setConfigurationManager($this->configurationManager);
$this->pluginSettings = $this->configurationManager->getConfiguration( $this->pluginSettings = $this->configurationManager->getConfiguration(
@ -82,12 +79,7 @@ class DateController extends AbstractController
); );
} }
/** public function listAction(): void
* action list
*
* @return void
*/
public function listAction()
{ {
if ( if (
($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '') ($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '')
@ -103,10 +95,7 @@ class DateController extends AbstractController
$this->view->assign('dates', $this->dateRepository->findByDemand($demand)); $this->view->assign('dates', $this->dateRepository->findByDemand($demand));
} }
/** public function searchAction(): void
* @return void
*/
public function searchAction()
{ {
$arguments = GeneralUtility::_GET('tx_events_datelist') ?? []; $arguments = GeneralUtility::_GET('tx_events_datelist') ?? [];
if (isset($arguments['events_search'])) { if (isset($arguments['events_search'])) {
@ -126,33 +115,20 @@ class DateController extends AbstractController
]); ]);
} }
/** public function teaserAction(): void
* action teaser
*
* @return void
*/
public function teaserAction()
{ {
$dates = $this->dateRepository->findByUids($this->settings['eventUids']); $dates = $this->dateRepository->findByUids($this->settings['eventUids']);
$this->view->assign('dates', $dates); $this->view->assign('dates', $dates);
} }
/** /**
* action show
*
* @Extbase\IgnoreValidation("date") * @Extbase\IgnoreValidation("date")
*
* @param \Wrm\Events\Domain\Model\Date $date
* @return void
*/ */
public function showAction(Date $date) public function showAction(Date $date): void
{ {
$this->view->assign('date', $date); $this->view->assign('date', $date);
} }
/**
* @return DateDemand
*/
protected function createDemandFromSettings(): DateDemand protected function createDemandFromSettings(): DateDemand
{ {
$demand = $this->objectManager->get(DateDemand::class); $demand = $this->objectManager->get(DateDemand::class);
@ -164,9 +140,13 @@ class DateController extends AbstractController
$demand->setIncludeSubCategories((bool)$this->settings['includeSubcategories']); $demand->setIncludeSubCategories((bool)$this->settings['includeSubcategories']);
$demand->setSortBy((string)$this->settings['sortByDate']); $demand->setSortBy((string)$this->settings['sortByDate']);
$demand->setSortOrder((string)$this->settings['sortOrder']); $demand->setSortOrder((string)$this->settings['sortOrder']);
$demand->setHighlight((int)$this->settings['highlight']); $demand->setHighlight((bool)$this->settings['highlight']);
$demand->setStart((string)$this->settings['start'] ?? ''); if (!empty($this->settings['start'])) {
$demand->setEnd((string)$this->settings['end'] ?? ''); $demand->setStart(strtotime($this->settings['start'] . ' 00:00') ?: null);
}
if (!empty($this->settings['end'])) {
$demand->setEnd(strtotime($this->settings['end'] . ' 00:00') ?: null);
}
if (!empty($this->settings['limit'])) { if (!empty($this->settings['limit'])) {
$demand->setLimit($this->settings['limit']); $demand->setLimit($this->settings['limit']);
@ -175,9 +155,6 @@ class DateController extends AbstractController
return $demand; return $demand;
} }
/**
* @return DateDemand
*/
protected function createDemandFromSearch(): DateDemand protected function createDemandFromSearch(): DateDemand
{ {
$arguments = $this->request->getArguments() ?? []; $arguments = $this->request->getArguments() ?? [];

View file

@ -36,7 +36,7 @@ class EventController extends AbstractController
$this->demandFactory = $demandFactory; $this->demandFactory = $demandFactory;
} }
protected function initializeAction() protected function initializeAction(): void
{ {
$this->dataProcessing->setConfigurationManager($this->configurationManager); $this->dataProcessing->setConfigurationManager($this->configurationManager);
} }

View file

@ -44,7 +44,7 @@ class DateDemand
/** /**
* @var bool * @var bool
*/ */
protected $highlight = 0; protected $highlight = false;
/** /**
* @var string * @var string
@ -52,14 +52,14 @@ class DateDemand
protected $limit = ''; protected $limit = '';
/** /**
* @var string * @var int|null
*/ */
protected $start = ''; protected $start = null;
/** /**
* @var string * @var int|null
*/ */
protected $end = ''; protected $end = null;
/** /**
* @var string * @var string
@ -78,7 +78,7 @@ class DateDemand
/** /**
* @var bool * @var bool
*/ */
protected $considerDate = 0; protected $considerDate = false;
public static function createFromRequestValues( public static function createFromRequestValues(
array $submittedValues, array $submittedValues,
@ -95,13 +95,13 @@ class DateDemand
} }
if (isset($submittedValues['start']) && $submittedValues['start'] !== '') { if (isset($submittedValues['start']) && $submittedValues['start'] !== '') {
$instance->setStart(strtotime($submittedValues['start'] . ' 00:00')); $instance->setStart(strtotime($submittedValues['start'] . ' 00:00') ?: null);
} }
if (isset($submittedValues['end']) && $submittedValues['end'] !== '') { if (isset($submittedValues['end']) && $submittedValues['end'] !== '') {
$instance->setEnd(strtotime($submittedValues['end'] . ' 23:59')); $instance->setEnd(strtotime($submittedValues['end'] . ' 23:59') ?: null);
} }
if (isset($submittedValues['considerDate']) && $submittedValues['considerDate'] !== '') { if (isset($submittedValues['considerDate']) && $submittedValues['considerDate'] !== '') {
$instance->setConsiderDate(strtotime($submittedValues['considerDate'])); $instance->setConsiderDate((bool)$submittedValues['considerDate']);
} }
if (is_array($submittedValues['userCategories'])) { if (is_array($submittedValues['userCategories'])) {
@ -118,41 +118,26 @@ class DateDemand
return $instance; return $instance;
} }
/**
* @return string
*/
public function getSortBy(): string public function getSortBy(): string
{ {
return $this->sortBy; return $this->sortBy;
} }
/** public function setSortBy(string $sortBy): void
* @param string $sortBy
*/
public function setSortBy(string $sortBy)
{ {
$this->sortBy = $sortBy; $this->sortBy = $sortBy;
} }
/**
* @return string
*/
public function getSortOrder(): string public function getSortOrder(): string
{ {
return $this->sortOrder; return $this->sortOrder;
} }
/** public function setSortOrder(string $sortOrder): void
* @param string $sortOrder
*/
public function setSortOrder(string $sortOrder)
{ {
$this->sortOrder = $sortOrder; $this->sortOrder = $sortOrder;
} }
/**
* @return string
*/
public function getCategories(): string public function getCategories(): string
{ {
return $this->categories; return $this->categories;
@ -163,105 +148,66 @@ class DateDemand
return $this->userCategories; return $this->userCategories;
} }
/** public function setCategories(string $categories): void
* @param string $categories
*/
public function setCategories(string $categories)
{ {
$this->categories = $categories; $this->categories = $categories;
} }
/**
* @return bool
*/
public function getIncludeSubCategories(): bool public function getIncludeSubCategories(): bool
{ {
return $this->includeSubCategories; return $this->includeSubCategories;
} }
/** public function setIncludeSubCategories(bool $includeSubCategories): void
* @param bool $includeSubCategories
*/
public function setIncludeSubCategories(bool $includeSubCategories)
{ {
$this->includeSubCategories = $includeSubCategories; $this->includeSubCategories = $includeSubCategories;
} }
/**
* @return string
*/
public function getCategoryCombination(): string public function getCategoryCombination(): string
{ {
return $this->categoryCombination; return $this->categoryCombination;
} }
/** public function setCategoryCombination(string $categoryCombination): void
* @param string $categoryCombination
*/
public function setCategoryCombination(string $categoryCombination)
{ {
$this->categoryCombination = $categoryCombination; $this->categoryCombination = $categoryCombination;
} }
/**
* @return string
*/
public function getRegion(): string public function getRegion(): string
{ {
return $this->region; return $this->region;
} }
/**
* @param \Wrm\DdEvents\Domain\Model\Region $region
*/
public function setRegion(string $region): void public function setRegion(string $region): void
{ {
$this->region = $region; $this->region = $region;
} }
/**
* @return bool
*/
public function getHighlight(): bool public function getHighlight(): bool
{ {
return $this->highlight; return $this->highlight;
} }
/**
* @param bool $highlight
*/
public function setHighlight(bool $highlight): void public function setHighlight(bool $highlight): void
{ {
$this->highlight = $highlight; $this->highlight = $highlight;
} }
/**
* @return string
*/
public function getLimit(): string public function getLimit(): string
{ {
return $this->limit; return $this->limit;
} }
/**
* @param string $limit
*/
public function setLimit(string $limit): void public function setLimit(string $limit): void
{ {
$this->limit = $limit; $this->limit = $limit;
} }
/**
* @return string
*/
public function getSearchword(): string public function getSearchword(): string
{ {
return $this->searchword; return $this->searchword;
} }
/**
* @param string $searchword
*/
public function setSearchword(string $searchword): void public function setSearchword(string $searchword): void
{ {
$this->searchword = $searchword; $this->searchword = $searchword;
@ -300,50 +246,32 @@ class DateDemand
return $this->synonyms[$searchWord] ?? []; return $this->synonyms[$searchWord] ?? [];
} }
/** public function getStart(): ?int
* @return string
*/
public function getStart(): string
{ {
return $this->start; return $this->start;
} }
/** public function setStart(?int $start): void
* @param string $start
*/
public function setStart(string $start): void
{ {
$this->start = $start; $this->start = $start;
} }
/** public function getEnd(): ?int
* @return string
*/
public function getEnd(): string
{ {
return $this->end; return $this->end;
} }
/** public function setEnd(?int $end): void
* @param string $end
*/
public function setEnd(string $end): void
{ {
$this->end = $end; $this->end = $end;
} }
/**
* @return bool
*/
public function getConsiderDate(): bool public function getConsiderDate(): bool
{ {
return $this->considerDate; return $this->considerDate;
} }
/** public function setConsiderDate(bool $considerDate): void
* @param bool $considerDate
*/
public function setConsiderDate(string $considerDate): void
{ {
$this->considerDate = $considerDate; $this->considerDate = $considerDate;
} }

View file

@ -2,6 +2,8 @@
namespace Wrm\Events\Domain\Model\Dto; namespace Wrm\Events\Domain\Model\Dto;
use Wrm\Events\Domain\Model\Region;
class EventDemand class EventDemand
{ {
/** /**
@ -49,145 +51,91 @@ class EventDemand
*/ */
protected $recordUids = []; protected $recordUids = [];
/**
* @return string
*/
public function getSortBy(): string public function getSortBy(): string
{ {
return $this->sortBy; return $this->sortBy;
} }
/** public function setSortBy(string $sortBy): void
* @param string $sortBy
*/
public function setSortBy(string $sortBy)
{ {
$this->sortBy = $sortBy; $this->sortBy = $sortBy;
} }
/**
* @return string
*/
public function getSortOrder(): string public function getSortOrder(): string
{ {
return $this->sortOrder; return $this->sortOrder;
} }
/** public function setSortOrder(string $sortOrder): void
* @param string $sortOrder
*/
public function setSortOrder(string $sortOrder)
{ {
$this->sortOrder = $sortOrder; $this->sortOrder = $sortOrder;
} }
/**
* @return string
*/
public function getCategories(): string public function getCategories(): string
{ {
return $this->categories; return $this->categories;
} }
/** public function setCategories(string $categories): void
* @param string $categories
*/
public function setCategories(string $categories)
{ {
$this->categories = $categories; $this->categories = $categories;
} }
/**
* @return bool
*/
public function getIncludeSubCategories(): bool public function getIncludeSubCategories(): bool
{ {
return $this->includeSubCategories; return $this->includeSubCategories;
} }
/** public function setIncludeSubCategories(bool $includeSubCategories): void
* @param bool $includeSubCategories
*/
public function setIncludeSubCategories(bool $includeSubCategories)
{ {
$this->includeSubCategories = $includeSubCategories; $this->includeSubCategories = $includeSubCategories;
} }
/**
* @return string
*/
public function getCategoryCombination(): string public function getCategoryCombination(): string
{ {
return $this->categoryCombination; return $this->categoryCombination;
} }
/** public function setCategoryCombination(string $categoryCombination): void
* @param string $categoryCombination
*/
public function setCategoryCombination(string $categoryCombination)
{ {
$this->categoryCombination = $categoryCombination; $this->categoryCombination = $categoryCombination;
} }
/**
* @return string
*/
public function getRegion(): string public function getRegion(): string
{ {
return $this->region; return $this->region;
} }
/**
* @param \Wrm\DdEvents\Domain\Model\Region $region
*/
public function setRegion(string $region): void public function setRegion(string $region): void
{ {
$this->region = $region; $this->region = $region;
} }
/**
* @return bool
*/
public function getHighlight(): bool public function getHighlight(): bool
{ {
return $this->highlight; return $this->highlight;
} }
/**
* @param bool $hightlight
*/
public function setHighlight(bool $highlight): void public function setHighlight(bool $highlight): void
{ {
$this->highlight = $highlight; $this->highlight = $highlight;
} }
/**
* @return string
*/
public function getLimit(): string public function getLimit(): string
{ {
return $this->limit; return $this->limit;
} }
/**
* @param string $limit
*/
public function setLimit(string $limit): void public function setLimit(string $limit): void
{ {
$this->limit = $limit; $this->limit = $limit;
} }
/**
* @return array
*/
public function getRecordUids(): array public function getRecordUids(): array
{ {
return $this->recordUids; return $this->recordUids;
} }
/**
* @param array $recordUids
*/
public function setRecordUids(array $recordUids): void public function setRecordUids(array $recordUids): void
{ {
$this->recordUids = $recordUids; $this->recordUids = $recordUids;

View file

@ -10,191 +10,136 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Wrm\Events\Domain\Repository\DateRepository; use Wrm\Events\Domain\Repository\DateRepository;
use Wrm\Events\Service\DataProcessingForModels; use Wrm\Events\Service\DataProcessingForModels;
/**
* Event
*/
class Event extends AbstractEntity class Event extends AbstractEntity
{ {
/** /**
* title
*
* @var string * @var string
*/ */
protected $title = ''; protected $title = '';
/** /**
* subtitle
*
* @var string * @var string
*/ */
protected $subtitle = ''; protected $subtitle = '';
/** /**
* globalId
*
* @var string * @var string
*/ */
protected $globalId = ''; protected $globalId = '';
/** /**
* slug
*
* @var string * @var string
*/ */
protected $slug = ''; protected $slug = '';
/** /**
* highlight
*
* @var bool * @var bool
*/ */
protected $highlight = false; protected $highlight = false;
/** /**
* teaser
*
* @var string * @var string
*/ */
protected $teaser = ''; protected $teaser = '';
/** /**
* details
*
* @var string * @var string
*/ */
protected $details = ''; protected $details = '';
/** /**
* priceInfo
*
* @var string * @var string
*/ */
protected $priceInfo = ''; protected $priceInfo = '';
/** /**
* name
*
* @var string * @var string
*/ */
protected $name = ''; protected $name = '';
/** /**
* street
*
* @var string * @var string
*/ */
protected $street = ''; protected $street = '';
/** /**
* district
*
* @var string * @var string
*/ */
protected $district = ''; protected $district = '';
/** /**
* city
*
* @var string * @var string
*/ */
protected $city = ''; protected $city = '';
/** /**
* zip
*
* @var string * @var string
*/ */
protected $zip = ''; protected $zip = '';
/** /**
* country
*
* @var string * @var string
*/ */
protected $country = ''; protected $country = '';
/** /**
* phone
*
* @var string * @var string
*/ */
protected $phone = ''; protected $phone = '';
/** /**
* web
*
* @var string * @var string
*/ */
protected $web = ''; protected $web = '';
/** /**
* ticket
*
* @var string * @var string
*/ */
protected $ticket = ''; protected $ticket = '';
/** /**
* facebook
*
* @var string * @var string
*/ */
protected $facebook = ''; protected $facebook = '';
/** /**
* youtube
*
* @var string * @var string
*/ */
protected $youtube = ''; protected $youtube = '';
/** /**
* instagram
*
* @var string * @var string
*/ */
protected $instagram = ''; protected $instagram = '';
/** /**
* latitude
*
* @var string * @var string
*/ */
protected $latitude = ''; protected $latitude = '';
/** /**
* longitude
*
* @var string * @var string
*/ */
protected $longitude = ''; protected $longitude = '';
/** /**
* images
*
* @var ObjectStorage<FileReference> * @var ObjectStorage<FileReference>
* @Extbase\ORM\Cascade remove * @Extbase\ORM\Cascade remove
*/ */
protected $images; protected $images;
/** /**
* dates
*
* @var ObjectStorage<Date> * @var ObjectStorage<Date>
* @Extbase\ORM\Cascade remove * @Extbase\ORM\Cascade remove
*/ */
protected $dates; protected $dates;
/** /**
* organizer
*
* @var \Wrm\Events\Domain\Model\Organizer * @var \Wrm\Events\Domain\Model\Organizer
*/ */
protected $organizer = null; protected $organizer = null;
/** /**
* region
*
* @var Region * @var Region
*/ */
protected $region = null; protected $region = null;
@ -205,8 +150,6 @@ class Event extends AbstractEntity
protected $pages = ''; protected $pages = '';
/** /**
* categories
*
* @var ObjectStorage<Category> * @var ObjectStorage<Category>
*/ */
protected $categories; protected $categories;
@ -239,20 +182,17 @@ class Event extends AbstractEntity
/** /**
* @param DataProcessingForModels $dataProcessing * @param DataProcessingForModels $dataProcessing
*/ */
public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing) public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing): void
{ {
$this->dataProcessing = $dataProcessing; $this->dataProcessing = $dataProcessing;
} }
public function initializeObject() public function initializeObject(): void
{ {
$this->initStorageObjects(); $this->initStorageObjects();
} }
/** protected function initStorageObjects(): void
* @return void
*/
protected function initStorageObjects()
{ {
$this->images = new ObjectStorage(); $this->images = new ObjectStorage();
$this->dates = new ObjectStorage(); $this->dates = new ObjectStorage();
@ -261,140 +201,82 @@ class Event extends AbstractEntity
$this->referencesEvents = new ObjectStorage(); $this->referencesEvents = new ObjectStorage();
} }
/** public function getGlobalId(): string
* Returns the globalId
*
* @return string $globalId
*/
public function getGlobalId()
{ {
return $this->globalId; return $this->globalId;
} }
/** public function setGlobalId(string $globalId): void
* @param string $globalId
* @return void
*/
public function setGlobalId($globalId)
{ {
$this->globalId = $globalId; $this->globalId = $globalId;
} }
/** public function getTitle(): string
* @return string $title
*/
public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** public function setTitle(string $title): void
* @param string $title
* @return void
*/
public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
} }
/** public function getSubtitle(): string
* @return string $subtitle
*/
public function getSubtitle()
{ {
return $this->subtitle; return $this->subtitle;
} }
/** public function setSubtitle(string $subtitle): void
* @param string $subtitle
* @return void
*/
public function setSubtitle($subtitle)
{ {
$this->subtitle = $subtitle; $this->subtitle = $subtitle;
} }
/** public function getTeaser(): string
* @return string $teaser
*/
public function getTeaser()
{ {
return $this->teaser; return $this->teaser;
} }
/** public function setTeaser(string $teaser): void
* @param string $teaser
* @return void
*/
public function setTeaser($teaser)
{ {
$this->teaser = $teaser; $this->teaser = $teaser;
} }
/** public function getDetails(): string
* @return string $details
*/
public function getDetails()
{ {
return $this->details; return $this->details;
} }
/** public function setDetails(string $details): void
* @param string $details
* @return void
*/
public function setDetails($details)
{ {
$this->details = $details; $this->details = $details;
} }
/** public function getPriceInfo(): string
* @return string $priceInfo
*/
public function getPriceInfo()
{ {
return $this->priceInfo; return $this->priceInfo;
} }
/** public function setPriceInfo(string $priceInfo): void
* @param string $priceInfo
* @return void
*/
public function setPriceInfo($priceInfo)
{ {
$this->priceInfo = $priceInfo; $this->priceInfo = $priceInfo;
} }
/** public function getName(): string
* @return string $name
*/
public function getName()
{ {
return $this->name; return $this->name;
} }
/** public function setName(string $name): void
* @param string $name
* @return void
*/
public function setName($name)
{ {
$this->name = $name; $this->name = $name;
} }
/** public function getStreet(): string
* @return string $street
*/
public function getStreet()
{ {
return $this->street; return $this->street;
} }
/** public function setStreet(string $street): void
* @param string $street
* @return void
*/
public function setStreet($street)
{ {
$this->street = $street; $this->street = $street;
} }
@ -402,184 +284,112 @@ class Event extends AbstractEntity
/** /**
* @return string $district * @return string $district
*/ */
public function getDistrict() public function getDistrict(): string
{ {
return $this->district; return $this->district;
} }
/** public function setDistrict(string $district): void
* @param string $district
* @return void
*/
public function setDistrict($district)
{ {
$this->district = $district; $this->district = $district;
} }
/** public function getCity(): string
* @return string $city
*/
public function getCity()
{ {
return $this->city; return $this->city;
} }
/** public function setCity(string $city): void
* @param string $city
* @return void
*/
public function setCity($city)
{ {
$this->city = $city; $this->city = $city;
} }
/** public function getZip(): string
* @return string $zip
*/
public function getZip()
{ {
return $this->zip; return $this->zip;
} }
/** public function setZip(string $zip): void
* @param string $zip
* @return void
*/
public function setZip($zip)
{ {
$this->zip = $zip; $this->zip = $zip;
} }
/** public function getPhone(): string
* @return string
*/
public function getPhone()
{ {
return $this->phone; return $this->phone;
} }
/** public function setPhone(string $phone): void
* @param string $phone
*/
public function setPhone($phone)
{ {
$this->phone = $phone; $this->phone = $phone;
} }
/** public function getWeb(): string
* @return string $web
*/
public function getWeb()
{ {
return $this->web; return $this->web;
} }
/** public function setWeb(string $web): void
* @param string $web
* @return void
*/
public function setWeb($web)
{ {
$this->web = $web; $this->web = $web;
} }
/** public function getTicket(): string
* @return string $ticket
*/
public function getTicket()
{ {
return $this->ticket; return $this->ticket;
} }
/** public function setTicket(string $ticket): void
* @param string $ticket
* @return void
*/
public function setTicket($ticket)
{ {
$this->ticket = $ticket; $this->ticket = $ticket;
} }
/** public function getFacebook(): string
* @return string $facebook
*/
public function getFacebook()
{ {
return $this->facebook; return $this->facebook;
} }
/** public function setFacebook(string $facebook): void
* @param string $facebook
* @return void
*/
public function setFacebook($facebook)
{ {
$this->facebook = $facebook; $this->facebook = $facebook;
} }
/** public function getYoutube(): string
* @return string $youtube
*/
public function getYoutube()
{ {
return $this->youtube; return $this->youtube;
} }
/** public function setYoutube(string $youtube): void
* @param string $youtube
* @return void
*/
public function setYoutube($youtube)
{ {
$this->youtube = $youtube; $this->youtube = $youtube;
} }
/** public function getInstagram(): string
* @return string $instagram
*/
public function getInstagram()
{ {
return $this->instagram; return $this->instagram;
} }
/** public function setInstagram(string $instagram): void
* @param string $instagram
*/
public function setInstagram(string $instagram)
{ {
$this->instagram = $instagram; $this->instagram = $instagram;
} }
/** public function getLatitude(): string
* @return string $latitude
*/
public function getLatitude()
{ {
return $this->latitude; return $this->latitude;
} }
/** public function setLatitude(string $latitude): void
* @param string $latitude
* @return void
*/
public function setLatitude($latitude)
{ {
$this->latitude = $latitude; $this->latitude = $latitude;
} }
/** public function getLongitude(): string
* @return string $longitude
*/
public function getLongitude()
{ {
return $this->longitude; return $this->longitude;
} }
/** public function setLongitude(string $longitude): void
* @param string $longitude
* @return void
*/
public function setLongitude($longitude)
{ {
$this->longitude = $longitude; $this->longitude = $longitude;
} }
@ -594,52 +404,34 @@ class Event extends AbstractEntity
/** /**
* @param ObjectStorage<FileReference> $images * @param ObjectStorage<FileReference> $images
* @return void
*/ */
public function setImages(FileReference $images) public function setImages(ObjectStorage $images): void
{ {
$this->images = $images; $this->images = $images;
} }
/** public function getSlug(): string
* @return string $slug
*/
public function getSlug()
{ {
return $this->slug; return $this->slug;
} }
/** public function setSlug(string $slug): void
* @param string $slug
* @return void
*/
public function setSlug($slug)
{ {
$this->slug = $slug; $this->slug = $slug;
} }
/** public function addDate(Date $date): void
* @param Date $date
* @return Event
*/
public function addDate(Date $date): self
{ {
$this->dates->attach($date); $this->dates->attach($date);
return $this;
} }
/** public function removeDate(Date $date): void
* @param Date $date
* @return Event
*/
public function removeDate(Date $date): self
{ {
$this->dates->detach($date); $this->dates->detach($date);
return $this;
} }
/** /**
* @return ObjectStorage * @return ObjectStorage<Date>
*/ */
public function getDates(): ObjectStorage public function getDates(): ObjectStorage
{ {
@ -647,33 +439,21 @@ class Event extends AbstractEntity
} }
/** /**
* @param ObjectStorage $dates * @param ObjectStorage<Date> $dates
*
* @return Event
*/ */
public function setDates($dates): self public function setDates(ObjectStorage $dates): void
{ {
$this->dates = $dates; $this->dates = $dates;
return $this;
} }
/** /**
* @param ObjectStorage $dates * @param ObjectStorage<Date> $dates
* @return void
*/ */
public function removeAllDates(ObjectStorage $dates) public function removeAllDates(ObjectStorage $dates): void
{ {
$this->dates->removeAll($dates); $this->dates->removeAll($dates);
} }
/**
* @return \Wrm\Events\Domain\Model\Organizer $organizer
*/
public function getOrganizer()
{
return $this->organizer;
}
/** /**
* @return ObjectStorage<Partner> * @return ObjectStorage<Partner>
*/ */
@ -690,70 +470,42 @@ class Event extends AbstractEntity
return $this->referencesEvents; return $this->referencesEvents;
} }
/** public function setOrganizer(Organizer $organizer): void
* @param \Wrm\Events\Domain\Model\Organizer $organizer
* @return void
*/
public function setOrganizer(Organizer $organizer)
{ {
$this->organizer = $organizer; $this->organizer = $organizer;
} }
/** public function getOrganizer(): ?Organizer
* @return \Wrm\Events\Domain\Model\Region $region {
*/ return $this->organizer;
public function getRegion() }
public function getRegion(): ?Region
{ {
return $this->region; return $this->region;
} }
/** public function setRegion(Region $region): void
* @param \Wrm\Events\Domain\Model\Region $region
* @return void
*/
public function setRegion(Region $region)
{ {
$this->region = $region; $this->region = $region;
} }
/** public function setHighlight(bool $highlight): void
* @return bool $highlight
*/
public function getHighlight()
{
return $this->highlight;
}
/**
* @param bool $highlight
* @return void
*/
public function setHighlight($highlight)
{ {
$this->highlight = $highlight; $this->highlight = $highlight;
} }
/** public function isHighlight(): bool
* @return bool
*/
public function isHighlight()
{ {
return $this->highlight; return $this->highlight;
} }
/** public function getCountry(): string
* @return string $country
*/
public function getCountry()
{ {
return $this->country; return $this->country;
} }
/** public function setCountry(string $country): void
* @param string $country
* @return void
*/
public function setCountry($country)
{ {
$this->country = $country; $this->country = $country;
} }
@ -770,10 +522,7 @@ class Event extends AbstractEntity
return $pages; return $pages;
} }
/** public function addCategory(Category $category): void
* @param \TYPO3\CMS\Extbase\Domain\Model\Category<\TYPO3\CMS\Extbase\Domain\Model\Category> $category
*/
public function addCategory(Category $category)
{ {
$this->categories->attach($category); $this->categories->attach($category);
} }
@ -790,34 +539,24 @@ class Event extends AbstractEntity
} }
/** /**
* @param TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> $categories * @param ObjectStorage<Category> $categories
*/ */
public function setCategories(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories) public function setCategories(ObjectStorage $categories): void
{ {
$this->categories = $categories; $this->categories = $categories;
} }
/** public function setLanguageUid(int $languageUid): void
* @param int $languageUid
* @return void
*/
public function setLanguageUid($languageUid)
{ {
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** public function getLanguageUid(): int
* @return int
*/
public function getLanguageUid()
{ {
return $this->_languageUid; return $this->_languageUid;
} }
/** public function getLocalizedUid(): int
* @return int
*/
public function getLocalizedUid()
{ {
return $this->_localizedUid; return $this->_localizedUid;
} }

View file

@ -15,63 +15,44 @@ namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* Organizer
*/
class Organizer extends AbstractEntity class Organizer extends AbstractEntity
{ {
/** /**
* name
*
* @var string * @var string
*/ */
protected $name = ''; protected $name = '';
/** /**
* street
*
* @var string * @var string
*/ */
protected $street = ''; protected $street = '';
/** /**
* district
*
* @var string * @var string
*/ */
protected $district = ''; protected $district = '';
/** /**
* city
*
* @var string * @var string
*/ */
protected $city = ''; protected $city = '';
/** /**
* zip
*
* @var string * @var string
*/ */
protected $zip = ''; protected $zip = '';
/** /**
* phone
*
* @var string * @var string
*/ */
protected $phone = ''; protected $phone = '';
/** /**
* web
*
* @var string * @var string
*/ */
protected $web = ''; protected $web = '';
/** /**
* email
*
* @var string * @var string
*/ */
protected $email = ''; protected $email = '';
@ -81,209 +62,92 @@ class Organizer extends AbstractEntity
*/ */
protected $_languageUid; protected $_languageUid;
/** public function getName(): string
* Returns the name
*
* @return string $name
*/
public function getName()
{ {
return $this->name; return $this->name;
} }
/** public function setName(string $name): void
* Sets the name
*
* @param string $name
* @return void
*/
public function setName($name)
{ {
$this->name = $name; $this->name = $name;
} }
/** public function getStreet(): string
* Returns the street
*
* @return string $street
*/
public function getStreet()
{ {
return $this->street; return $this->street;
} }
/** public function setStreet(string $street): void
* Sets the street
*
* @param string $street
* @return void
*/
public function setStreet($street)
{ {
$this->street = $street; $this->street = $street;
} }
/** public function getDistrict(): string
* Returns the district
*
* @return string $district
*/
public function getDistrict()
{ {
return $this->district; return $this->district;
} }
/** public function setDistrict(string $district): void
* Sets the district
*
* @param string $district
* @return void
*/
public function setDistrict($district)
{ {
$this->district = $district; $this->district = $district;
} }
/** public function getCity(): string
* Returns the city
*
* @return string $city
*/
public function getCity()
{ {
return $this->city; return $this->city;
} }
/** public function setCity(string $city): void
* Sets the city
*
* @param string $city
* @return void
*/
public function setCity($city)
{ {
$this->city = $city; $this->city = $city;
} }
/** public function getZip(): string
* Returns the zip
*
* @return string $zip
*/
public function getZip()
{ {
return $this->zip; return $this->zip;
} }
/** public function setZip(string $zip): void
* Sets the zip
*
* @param string $zip
* @return void
*/
public function setZip($zip)
{ {
$this->zip = $zip; $this->zip = $zip;
} }
/** public function getPhone(): string
* Returns the phone
*
* @return string $phone
*/
public function getPhone()
{ {
return $this->phone; return $this->phone;
} }
/** public function setPhone(string $phone): void
* Sets the phone
*
* @param string $phone
* @return void
*/
public function setPhone($phone)
{ {
$this->phone = $phone; $this->phone = $phone;
} }
/** public function getWeb(): string
* Returns the web
*
* @return string $web
*/
public function getWeb()
{ {
return $this->web; return $this->web;
} }
/** public function setWeb(string $web): void
* Sets the web
*
* @param string $web
* @return void
*/
public function setWeb($web)
{ {
$this->web = $web; $this->web = $web;
} }
/** public function getEmail(): string
* Returns the email
*
* @return string $email
*/
public function getEmail()
{ {
return $this->email; return $this->email;
} }
/** public function setEmail(string $email): void
* Sets the email
*
* @param string $email
* @return void
*/
public function setEmail($email)
{ {
$this->email = $email; $this->email = $email;
} }
/** public function setLanguageUid(int $languageUid): void
* __construct
*/
public function __construct()
{
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects()
{
}
/**
* @param int $languageUid
* @return void
*/
public function setLanguageUid($languageUid)
{ {
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** public function getLanguageUid(): int
* @return int
*/
public function getLanguageUid()
{ {
return $this->_languageUid; return $this->_languageUid;
} }

View file

@ -52,6 +52,9 @@ class Partner extends AbstractEntity
return $this->link; return $this->link;
} }
/**
* @return ObjectStorage<FileReference>
*/
public function getImages(): ObjectStorage public function getImages(): ObjectStorage
{ {
return $this->images; return $this->images;

View file

@ -15,14 +15,9 @@ namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* Region
*/
class Region extends AbstractEntity class Region extends AbstractEntity
{ {
/** /**
* title
*
* @var string * @var string
*/ */
protected $title = ''; protected $title = '';
@ -32,62 +27,22 @@ class Region extends AbstractEntity
*/ */
protected $_languageUid; protected $_languageUid;
/** public function getTitle(): string
* Returns the title
*
* @return string $title
*/
public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** public function setTitle(string $title): void
* Sets the title
*
* @param string $title
* @return void
*/
public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
} }
/** public function setLanguageUid(int $languageUid): void
* __construct
*/
public function __construct()
{
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects()
{
}
/**
* @param int $languageUid
* @return void
*/
public function setLanguageUid($languageUid)
{ {
$this->_languageUid = $languageUid; $this->_languageUid = $languageUid;
} }
/** public function getLanguageUid(): int
* @return int
*/
public function getLanguageUid()
{ {
return $this->_languageUid; return $this->_languageUid;
} }

View file

@ -41,17 +41,20 @@ class CategoryRepository extends Repository
*/ */
protected $dataMapper; protected $dataMapper;
public function injectConnectionPool(ConnectionPool $connectionPool) public function injectConnectionPool(ConnectionPool $connectionPool): void
{ {
$this->connectionPool = $connectionPool; $this->connectionPool = $connectionPool;
} }
public function injectDataMapper(DataMapper $dataMapper) public function injectDataMapper(DataMapper $dataMapper): void
{ {
$this->dataMapper = $dataMapper; $this->dataMapper = $dataMapper;
} }
public function findAllCurrentlyAssigned() /**
* @return array<Category>
*/
public function findAllCurrentlyAssigned(): array
{ {
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_event'); $qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_event');
$qb->select('category.*'); $qb->select('category.*');

View file

@ -5,6 +5,7 @@ namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
@ -13,12 +14,7 @@ use Wrm\Events\Service\CategoryService;
class DateRepository extends Repository class DateRepository extends Repository
{ {
/** public function findByUids(string $uids): QueryResult
* Find all dates based on selected uids
* @param string $uids
* @return array
*/
public function findByUids($uids)
{ {
$uids = explode(',', $uids); $uids = explode(',', $uids);
$query = $this->createQuery(); $query = $this->createQuery();
@ -28,26 +24,12 @@ class DateRepository extends Repository
return $query->execute(); return $query->execute();
} }
/** public function findByDemand(DateDemand $demand): QueryResult
* @param DateDemand $demand
* @return QueryResultInterface
* @throws InvalidQueryException
*/
public function findByDemand(DateDemand $demand)
{ {
$query = $this->createDemandQuery($demand); $query = $this->createDemandQuery($demand);
return $query->execute(); return $query->execute();
// For testing purposes
// $query = $this->createDemandQueryViaBuilder($demand);
// return $query->execute()->fetchAll();
} }
/**
* @param DateDemand $demand
* @return QueryInterface
* @throws InvalidQueryException
*/
protected function createDemandQuery(DateDemand $demand): QueryInterface protected function createDemandQuery(DateDemand $demand): QueryInterface
{ {
$query = $this->createQuery(); $query = $this->createQuery();
@ -86,7 +68,7 @@ class DateRepository extends Repository
$constraints['ends'] = $query->lessThanOrEqual('end', $demand->getEnd()); $constraints['ends'] = $query->lessThanOrEqual('end', $demand->getEnd());
} }
if ($demand->getStart() === '' && $demand->getEnd() === '') { if ($demand->getStart() !== null && $demand->getEnd() !== null) {
$now = new \DateTime('now', new \DateTimeZone('Europe/Berlin')); $now = new \DateTime('now', new \DateTimeZone('Europe/Berlin'));
$constraints['untilnow'] = $query->greaterThanOrEqual('start', $now); $constraints['untilnow'] = $query->greaterThanOrEqual('start', $now);
} }
@ -130,38 +112,23 @@ class DateRepository extends Repository
return $query->logicalOr($constraints); return $query->logicalOr($constraints);
} }
/** protected function createCategoryConstraint(QueryInterface $query, string $categories, bool $includeSubCategories = false): array
* @param QueryInterface $query
* @param string $categories
* @param bool $includeSubCategories
* @return array
* @throws InvalidQueryException
*/
protected function createCategoryConstraint(QueryInterface $query, $categories, bool $includeSubCategories = false): array
{ {
$constraints = []; $constraints = [];
if ($includeSubCategories) { if ($includeSubCategories) {
$categoryService = GeneralUtility::makeInstance(CategoryService::class); $categoryService = GeneralUtility::makeInstance(CategoryService::class);
$allCategories = $categoryService->getChildrenCategories($categories); $categories = $categoryService->getChildrenCategories($categories);
if (!\is_array($allCategories)) {
$allCategories = GeneralUtility::intExplode(',', $allCategories, true);
}
} else {
$allCategories = GeneralUtility::intExplode(',', $categories, true);
} }
foreach ($allCategories as $category) { $categories = GeneralUtility::intExplode(',', $categories, true);
foreach ($categories as $category) {
$constraints[] = $query->contains('event.categories', $category); $constraints[] = $query->contains('event.categories', $category);
} }
return $constraints; return $constraints;
} }
/** public function findSearchWord(string $search): array
* findSearchWord with Query Builder
* @param $search
*/
public function findSearchWord($search)
{ {
$connection = GeneralUtility::makeInstance(ConnectionPool::class) $connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_events_domain_model_date'); ->getConnectionForTable('tx_events_domain_model_date');

View file

@ -17,8 +17,8 @@ namespace Wrm\Events\Domain\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface; use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
use Wrm\Events\Domain\Model\Dto\EventDemand; use Wrm\Events\Domain\Model\Dto\EventDemand;
use Wrm\Events\Domain\Model\Event; use Wrm\Events\Domain\Model\Event;
@ -26,7 +26,7 @@ use Wrm\Events\Service\CategoryService;
class EventRepository extends Repository class EventRepository extends Repository
{ {
public function findByUids(string $uids): QueryResultInterface public function findByUids(string $uids): QueryResult
{ {
$query = $this->createQuery(); $query = $this->createQuery();
$query->matching($query->in('uid', GeneralUtility::intExplode(',', $uids))); $query->matching($query->in('uid', GeneralUtility::intExplode(',', $uids)));
@ -35,8 +35,7 @@ class EventRepository extends Repository
} }
/** /**
* @return QueryResultInterface|array * @return QueryResult|array
* @throws InvalidQueryException
*/ */
public function findByDemand(EventDemand $demand) public function findByDemand(EventDemand $demand)
{ {
@ -49,9 +48,6 @@ class EventRepository extends Repository
return $query->execute(); return $query->execute();
} }
/**
* @throws InvalidQueryException
*/
protected function createDemandQuery(EventDemand $demand): QueryInterface protected function createDemandQuery(EventDemand $demand): QueryInterface
{ {
$query = $this->createQuery(); $query = $this->createQuery();
@ -133,24 +129,18 @@ class EventRepository extends Repository
return $constraints; return $constraints;
} }
/**
* @throws InvalidQueryException
*/
protected function createCategoryConstraint(QueryInterface $query, EventDemand $demand): ConstraintInterface protected function createCategoryConstraint(QueryInterface $query, EventDemand $demand): ConstraintInterface
{ {
$constraints = []; $constraints = [];
$allCategories = GeneralUtility::intExplode(',', $demand->getCategories(), true); $categories = $demand->getCategories();
if ($demand->getIncludeSubCategories()) { if ($demand->getIncludeSubCategories()) {
$categoryService = GeneralUtility::makeInstance(CategoryService::class); $categoryService = GeneralUtility::makeInstance(CategoryService::class);
$allCategories = $categoryService->getChildrenCategories($demand->getCategories()); $categories = $categoryService->getChildrenCategories($categories);
if (!\is_array($allCategories)) {
$allCategories = GeneralUtility::intExplode(',', $allCategories, true);
}
} }
foreach ($allCategories as $category) { $categories = GeneralUtility::intExplode(',', $categories, true);
foreach ($categories as $category) {
$constraints[] = $query->contains('categories', $category); $constraints[] = $query->contains('categories', $category);
} }
@ -160,7 +150,7 @@ class EventRepository extends Repository
return $query->logicalAnd($constraints); return $query->logicalAnd($constraints);
} }
public function findSearchWord($search) public function findSearchWord(string $search): QueryResult
{ {
$query = $this->createQuery(); $query = $this->createQuery();
$query->matching($query->like('title', '%' . $search . '%')); $query->matching($query->like('title', '%' . $search . '%'));

View file

@ -94,7 +94,7 @@ class Database
}, $records); }, $records);
} }
public function deleteDates(int ...$uids) public function deleteDates(int ...$uids): void
{ {
/* @var QueryBuilder $queryBuilder */ /* @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)

View file

@ -25,21 +25,21 @@ class CleanupService
$this->files = $files; $this->files = $files;
} }
public function deleteAllData() public function deleteAllData(): void
{ {
$this->database->truncateTables(...[Database::DATE_TABLE, Database::ORGANIZER_TABLE]); $this->database->truncateTables(...[Database::DATE_TABLE, Database::ORGANIZER_TABLE]);
$this->removeViaDataHandler($this->database->getDeletionStructureForEvents()); $this->removeViaDataHandler($this->database->getDeletionStructureForEvents());
$this->files->deleteAll(); $this->files->deleteAll();
} }
public function deletePastData() public function deletePastData(): void
{ {
$this->database->deleteDates(...$this->database->getPastDates()); $this->database->deleteDates(...$this->database->getPastDates());
$this->removeViaDataHandler($this->database->getDeletionStructureForEventsWithoutDates()); $this->removeViaDataHandler($this->database->getDeletionStructureForEventsWithoutDates());
$this->files->deleteDangling(); $this->files->deleteDangling();
} }
private function removeViaDataHandler(array $structure) private function removeViaDataHandler(array $structure): void
{ {
/* @var DataHandler $dataHandler */ /* @var DataHandler $dataHandler */
$dataHandler = GeneralUtility::makeInstance(DataHandler::class); $dataHandler = GeneralUtility::makeInstance(DataHandler::class);

View file

@ -463,14 +463,14 @@ class DestinationDataImportService
} }
$tmpOrganizer = $this->objectManager->get(Organizer::class); $tmpOrganizer = $this->objectManager->get(Organizer::class);
$tmpOrganizer->setLanguageUid(-1); $tmpOrganizer->setLanguageUid(-1);
$tmpOrganizer->setName($address['name']); $tmpOrganizer->setName($address['name'] ?? '');
$tmpOrganizer->setCity($address['city']); $tmpOrganizer->setCity($address['city'] ?? '');
$tmpOrganizer->setZip($address['zip']); $tmpOrganizer->setZip($address['zip'] ?? '');
$tmpOrganizer->setStreet($address['street']); $tmpOrganizer->setStreet($address['street'] ?? '');
$tmpOrganizer->setPhone($address['phone']); $tmpOrganizer->setPhone($address['phone'] ?? '');
$tmpOrganizer->setWeb($address['web']); $tmpOrganizer->setWeb($address['web'] ?? '');
$tmpOrganizer->setEmail($address['email']); $tmpOrganizer->setEmail($address['email'] ?? '');
$tmpOrganizer->setDistrict($address['district']); $tmpOrganizer->setDistrict($address['district'] ?? '');
$this->organizerRepository->add($tmpOrganizer); $this->organizerRepository->add($tmpOrganizer);
$this->tmpCurrentEvent->setOrganizer($tmpOrganizer); $this->tmpCurrentEvent->setOrganizer($tmpOrganizer);
} }
@ -482,27 +482,13 @@ class DestinationDataImportService
*/ */
protected function setAddress(array $event) protected function setAddress(array $event)
{ {
if (!empty($event['name'])) { $this->tmpCurrentEvent->setName($event['name'] ?? '');
$this->tmpCurrentEvent->setName($event['name']); $this->tmpCurrentEvent->setStreet($event['street'] ?? '');
} $this->tmpCurrentEvent->setCity($event['city'] ?? '');
if (!empty($event['street'])) { $this->tmpCurrentEvent->setZip($event['zip'] ?? '');
$this->tmpCurrentEvent->setStreet($event['street']); $this->tmpCurrentEvent->setCountry($event['country'] ?? '');
} $this->tmpCurrentEvent->setPhone($event['phone'] ?? '');
if (!empty($event['city'])) { $this->tmpCurrentEvent->setWeb($event['web'] ?? '');
$this->tmpCurrentEvent->setCity($event['city']);
}
if (!empty($event['zip'])) {
$this->tmpCurrentEvent->setZip($event['zip']);
}
if (!empty($event['country'])) {
$this->tmpCurrentEvent->setCountry($event['country']);
}
if (!empty($event['phone'])) {
$this->tmpCurrentEvent->setPhone($event['phone']);
}
if (!empty($event['web'])) {
$this->tmpCurrentEvent->setWeb($event['web']);
}
} }
/** /**

View file

@ -12,7 +12,8 @@
"require": { "require": {
"typo3/cms-core": "^10.4", "typo3/cms-core": "^10.4",
"typo3/cms-extbase": "^10.4", "typo3/cms-extbase": "^10.4",
"typo3/cms-fluid": "^10.4" "typo3/cms-fluid": "^10.4",
"typo3/cms-frontend": "^10.4"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -33,6 +34,9 @@
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",
"symplify/easy-coding-standard": "^9.4" "symplify/easy-coding-standard": "^9.4",
"phpstan/phpstan": "^0.12.98",
"phpstan/extension-installer": "^1.1",
"saschaegerer/phpstan-typo3": "^0.13.3"
} }
} }

337
phpstan-baseline.neon Normal file
View file

@ -0,0 +1,337 @@
parameters:
ignoreErrors:
-
message: "#^Cannot call method fetchAll\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Domain/Repository/CategoryRepository.php
-
message: "#^Cannot call method fetchAll\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Domain/Repository/DateRepository.php
-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Extbase/AddSpecialProperties.php
-
message: "#^Cannot call method fetchColumn\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Extbase/AddSpecialProperties.php
-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Service/CategoryService.php
-
message: "#^Cannot call method fetchAll\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Service/CategoryService.php
-
message: "#^Cannot call method fetchAll\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 3
path: Classes/Service/Cleanup/Database.php
-
message: "#^Call to method deleteFile\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Storage\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Call to method getFile\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Storage\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Call to method hasFile\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Storage\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Cannot call method fetchAll\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\Cleanup\\\\Files\\:\\:delete\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\Cleanup\\\\Files\\:\\:deleteAll\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\Cleanup\\\\Files\\:\\:deleteDangling\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\Cleanup\\\\Files\\:\\:deleteFromDb\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\Cleanup\\\\Files\\:\\:deleteFromFal\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/Cleanup/Files.php
-
message: "#^Access to an undefined property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$sysCategoriesPid\\.$#"
count: 2
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface\\:\\:getUid\\(\\)\\.$#"
count: 2
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Cannot call method fetch\\(\\) on Doctrine\\\\DBAL\\\\Driver\\\\ResultStatement\\|int\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Cannot call method sanitizeFileName\\(\\) on TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\|null\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:getAttributeValue\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:getOrCreateEvent\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:import\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:import\\(\\) has parameter \\$filesFolder with no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:import\\(\\) has parameter \\$regionUid with no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:import\\(\\) has parameter \\$restExperience with no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:import\\(\\) has parameter \\$storagePid with no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:loadFile\\(\\) should return string but returns false\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:multi_array_key_exists\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:processData\\(\\) has parameter \\$data with no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setAddress\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setAssets\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setCategories\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setDates\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setLatLng\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setOrganizer\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setSocial\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setTexts\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:setTickets\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @param has invalid value \\(\\$data\\)\\: Unexpected token \"\\$data\", expected type at offset 18$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @param has invalid value \\(\\$filesFolder\\)\\: Unexpected token \"\\$filesFolder\", expected type at offset 99$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @param has invalid value \\(\\$regionUid\\)\\: Unexpected token \"\\$regionUid\", expected type at offset 74$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @param has invalid value \\(\\$restExperience\\)\\: Unexpected token \"\\$restExperience\", expected type at offset 18$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @param has invalid value \\(\\$storagePid\\)\\: Unexpected token \"\\$storagePid\", expected type at offset 48$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^PHPDoc tag @var has invalid value \\(\\)\\: Unexpected token \"\\\\n \", expected type at offset 15$#"
count: 15
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#1 \\$hour of method DateTime\\:\\:setTime\\(\\) expects int, string given\\.$#"
count: 4
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#1 \\$parent of method TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\Category\\:\\:setParent\\(\\) expects TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\Category, Wrm\\\\Events\\\\Domain\\\\Model\\\\Category\\|null given\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#1 \\$timestamp of method DateTime\\:\\:setTimestamp\\(\\) expects int, int\\|false given\\.$#"
count: 2
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#2 \\$minute of method DateTime\\:\\:setTime\\(\\) expects int, string given\\.$#"
count: 4
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Parameter \\#2 \\$now of function strtotime expects int, int\\|false given\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$categoriesPid has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$categoryParentUid has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$environment has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$filesFolder has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$logger has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$regionUid has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restExperience has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restLicenseKey has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restLimit has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restMode has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restTemplate has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restType has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$restUrl has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$storage has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$storagePid has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php
-
message: "#^Property Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:\\$tmpCurrentEvent has no typehint specified\\.$#"
count: 1
path: Classes/Service/DestinationDataImportService.php

9
phpstan.neon Normal file
View file

@ -0,0 +1,9 @@
includes:
- phpstan-baseline.neon
parameters:
level: max
paths:
- Classes
- Configuration
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false