Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Consistently use type declaration for parameters and return values - part 1 #1018

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Classes/Api/Orcid/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,31 @@ class Client
* @access protected
* @var Logger This holds the logger
*/
protected $logger;
protected Logger $logger;

/**
* @access private
* @var string The ORCID API endpoint
**/
private $endpoint = 'record';
private string $endpoint = 'record';

/**
* @access private
* @var string The ORCID API access level
**/
private $level = 'pub';
private string $level = 'pub';

/**
* @access private
* @var string The ORCID ID to search for
**/
private $orcid = null;
private string $orcid;

/**
* @access private
* @var RequestFactoryInterface The request object
**/
private $requestFactory = null;
private RequestFactoryInterface $requestFactory;

/**
* Constructs a new instance
Expand All @@ -78,7 +78,7 @@ class Client
*
* @return void
**/
public function __construct($orcid, RequestFactory $requestFactory)
public function __construct(string $orcid, RequestFactory $requestFactory)
{
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
$this->orcid = $orcid;
Expand All @@ -94,7 +94,7 @@ public function __construct($orcid, RequestFactory $requestFactory)
*
* @return void
*/
public function setEndpoint($endpoint) {
public function setEndpoint(string $endpoint): void {
$this->endpoint = $endpoint;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public function getData()
*
* @return string
**/
private function getApiEndpoint()
private function getApiEndpoint(): string
{
$url = 'https://' . $this->level . '.' . self::HOSTNAME;
$url .= '/v' . self::VERSION . '/';
Expand Down
10 changes: 5 additions & 5 deletions Classes/Api/Orcid/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ class Profile
* @access protected
* @var Logger This holds the logger
*/
protected $logger;
protected Logger $logger;

/**
* @access private
* @var Client This holds the client
*/
private $client;
private Client $client;

/**
* @access private
* @var \SimpleXmlElement|false The raw ORCID profile
**/
private $raw = null;
private $raw;

/**
* Constructs client instance
Expand All @@ -55,7 +55,7 @@ class Profile
*
* @return void
**/
public function __construct($orcid)
public function __construct(string $orcid)
{
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
$this->client = new Client($orcid, GeneralUtility::makeInstance(RequestFactory::class));
Expand Down Expand Up @@ -151,7 +151,7 @@ public function getFullName()
*
* @return void
**/
private function getRaw($endpoint)
private function getRaw(string $endpoint): void
{
$this->client->setEndpoint($endpoint);
$data = $this->client->getData();
Expand Down
14 changes: 7 additions & 7 deletions Classes/Api/Viaf/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ class Client
* @access protected
* @var Logger This holds the logger
*/
protected $logger;
protected Logger $logger;

/**
* The VIAF API endpoint
*
* @access private
* @var string The VIAF API endpoint
**/
private $endpoint = 'viaf.xml';
private string $endpoint = 'viaf.xml';

/**
* @access private
* @var string The VIAF URL for the profile
**/
private $viafUrl = null;
private string $viafUrl;

/**
* @access private
* @var RequestFactoryInterface The request object
**/
private $requestFactory = null;
private RequestFactoryInterface $requestFactory;

/**
* Constructs a new instance
Expand All @@ -64,7 +64,7 @@ class Client
*
* @return void
**/
public function __construct($viaf, RequestFactory $requestFactory)
public function __construct(string $viaf, RequestFactory $requestFactory)
{
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
$this->viafUrl = 'http://viaf.org/viaf/' . $viaf;
Expand All @@ -80,7 +80,7 @@ public function __construct($viaf, RequestFactory $requestFactory)
*
* @return void
*/
public function setEndpoint($endpoint) {
public function setEndpoint(string $endpoint): void {
$this->endpoint = $endpoint;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public function getData()
*
* @return string
**/
private function getApiEndpoint()
private function getApiEndpoint(): string
{
return $this->viafUrl . '/' . $this->endpoint;
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Api/Viaf/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Profile
* @access private
* @var \SimpleXmlElement|false The raw VIAF profile or false if not found
**/
private $raw = null;
private $raw;

/**
* Constructs client instance
Expand All @@ -55,7 +55,7 @@ class Profile
*
* @return void
**/
public function __construct($viaf)
public function __construct(string $viaf)
{
$this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
$this->client = new Client($viaf, GeneralUtility::makeInstance(RequestFactory::class));
Expand Down Expand Up @@ -128,7 +128,7 @@ public function getFullName()
*
* @return void
**/
private function getRaw()
private function getRaw(): void
{
$data = $this->client->getData();
if (!isset($this->raw) && $data != false) {
Expand Down
28 changes: 14 additions & 14 deletions Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,48 @@ class BaseCommand extends Command
* @access protected
* @var CollectionRepository
*/
protected $collectionRepository;
protected CollectionRepository $collectionRepository;

/**
* @access protected
* @var DocumentRepository
*/
protected $documentRepository;
protected DocumentRepository $documentRepository;

/**
* @access protected
* @var LibraryRepository
*/
protected $libraryRepository;
protected LibraryRepository $libraryRepository;

/**
* @access protected
* @var StructureRepository
*/
protected $structureRepository;
protected StructureRepository $structureRepository;

/**
* @access protected
* @var int
*/
protected $storagePid;
protected int $storagePid;

/**
* @access protected
* @var Library
* @var Library|null
*/
protected $owner;
protected ?Library $owner;

/**
* @access protected
* @var array
*/
protected $extConf;
protected array $extConf;

/**
* @var ConfigurationManager
*/
protected $configurationManager;
protected ConfigurationManager $configurationManager;

public function __construct(CollectionRepository $collectionRepository,
DocumentRepository $documentRepository,
Expand Down Expand Up @@ -115,7 +115,7 @@ public function __construct(CollectionRepository $collectionRepository,
*
* @return bool
*/
protected function initializeRepositories($storagePid)
protected function initializeRepositories(int $storagePid): bool
{
if (MathUtility::canBeInterpretedAsInteger($storagePid)) {
$frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
Expand Down Expand Up @@ -191,11 +191,11 @@ protected function getSolrCores(int $pageId): array
*
* @access protected
*
* @param int|string $doc The document uid from DB OR the location of a METS document.
* @param Document $doc The document instance
*
* @return bool true on success
* @return bool true on success, false otherwise
*/
protected function saveToDatabase(Document $document)
protected function saveToDatabase(Document $document): bool
{
$doc = $document->getCurrentDocument();
if ($doc === null) {
Expand Down Expand Up @@ -316,7 +316,7 @@ protected function saveToDatabase(Document $document)
*
* @return int The parent document's id.
*/
protected function getParentDocumentUidForSaving(Document $document)
protected function getParentDocumentUidForSaving(Document $document): int
{
$doc = $document->getCurrentDocument();

Expand Down
6 changes: 3 additions & 3 deletions Classes/Command/HarvestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HarvestCommand extends BaseCommand
*
* @return void
*/
public function configure()
public function configure(): void
{
$this
->setDescription('Harvest OAI-PMH contents into database and Solr.')
Expand Down Expand Up @@ -101,7 +101,7 @@ public function configure()
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dryRun = $input->getOption('dry-run') != false ? true : false;

Expand Down Expand Up @@ -268,7 +268,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
*
* @return void
*/
protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io)
protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io): void
{
$io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:' . "\n " . $exception->getMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class IndexCommand extends BaseCommand
*
* @return void
*/
public function configure()
public function configure(): void
{
$this
->setDescription('Index single document into database and Solr.')
Expand Down Expand Up @@ -88,7 +88,7 @@ public function configure()
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dryRun = $input->getOption('dry-run') != false ? true : false;

Expand Down
4 changes: 2 additions & 2 deletions Classes/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ReindexCommand extends BaseCommand
*
* @return void
*/
public function configure()
public function configure(): void
{
$this
->setDescription('Reindex a collection into database and Solr.')
Expand Down Expand Up @@ -92,7 +92,7 @@ public function configure()
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dryRun = $input->getOption('dry-run') != false ? true : false;

Expand Down
Loading