Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jul 24, 2024
1 parent 920ab2a commit 4e0c352
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion classes/file/PublicFileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PublicFileManager extends PKPPublicFileManager
/**
* @copydoc PKPPublicFileManager::getContextFilesPath()
*/
public function getContextFilesPath($contextId)
public function getContextFilesPath(int $contextId)
{
return Config::getVar('files', 'public_files_dir') . '/contexts/' . (int) $contextId;
}
Expand Down
13 changes: 4 additions & 9 deletions classes/oai/ops/OAIDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@ public function __construct()
/**
* Cached function to get a server
*
* @param int $serverId
*
* @return object
*/
public function &getServer($serverId)
public function getServer(int $serverId)
{
if (!isset($this->serverCache[$serverId])) {
$this->serverCache[$serverId] = $this->serverDao->getById($serverId);
}
return $this->serverCache[$serverId];
return $this->serverCache[$serverId] ??= $this->serverDao->getById($serverId);
}

/**
Expand All @@ -92,14 +87,14 @@ public function &getSection($sectionId)
/**
* Return hierarchy of OAI sets (servers plus server sections).
*
* @param int $serverId
* @param int $offset
* @param int $total
*
* @return array OAISet
*
* @hook OAIDAO::getServerSets [[$this, $serverId, $offset, $limit, $total, &$sets]]
*/
public function &getServerSets($serverId, $offset, $limit, &$total)
public function &getServerSets(int $serverId, $offset, $limit, &$total)
{
if (isset($serverId)) {
$servers = [$this->serverDao->getById($serverId)];
Expand Down
6 changes: 4 additions & 2 deletions classes/oai/ops/ServerOAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class ServerOAI extends OAI
/** @var Server associated server object */
public $server;

/** @var int|null Server ID; null if no server */
public $serverId;
public ?int $serverId;

/** @var OAIDAO DAO for retrieving OAI records/tokens from database */
public $dao;
Expand Down Expand Up @@ -182,6 +181,7 @@ public function record($identifier)

/**
* @copydoc OAI::records()
*
* @hook ServerOAI::records [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]]
*/
public function records($metadataPrefix, $from, $until, $set, $offset, $limit, &$total)
Expand All @@ -201,6 +201,7 @@ public function records($metadataPrefix, $from, $until, $set, $offset, $limit, &

/**
* @copydoc OAI::identifiers()
*
* @hook ServerOAI::identifiers [[$this, $from, $until, $set, $offset, $limit, &$total, &$records]]
*/
public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limit, &$total)
Expand All @@ -220,6 +221,7 @@ public function identifiers($metadataPrefix, $from, $until, $set, $offset, $limi

/**
* @copydoc OAI::sets()
*
* @hook ServerOAI::sets [[$this, $offset, $limit, &$total, &$sets]]
*/
public function sets($offset, $limit, &$total)
Expand Down
4 changes: 1 addition & 3 deletions classes/publication/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ class Publication extends PKPPublication
/**
* Get the URL to a localized cover image
*
* @param int $contextId
*
* @return string
*/
public function getLocalizedCoverImageUrl($contextId)
public function getLocalizedCoverImageUrl(int $contextId)
{
$coverImage = $this->getLocalizedData('coverImage');

Expand Down
8 changes: 4 additions & 4 deletions classes/section/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getAbbrev(?string $locale): string|array|null
return $this->getData('abbrev', $locale);
}

public function setAbbrev(string|array $abbrev, string $locale = null): void
public function setAbbrev(string|array $abbrev, ?string $locale = null): void
{
$this->setData('abbrev', $abbrev, $locale);
}
Expand All @@ -51,7 +51,7 @@ public function getPolicy(?string $locale): string|array|null
return $this->getData('policy', $locale);
}

public function setPolicy(string|array $policy, string $locale = null): void
public function setPolicy(string|array $policy, ?string $locale = null): void
{
$this->setData('policy', $policy, $locale);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public function getIdentifyType(?string $locale): string|array|null
/**
* Set string identifying type of items in this section.
*/
public function setIdentifyType(string|array $identifyType, string $locale = null): void
public function setIdentifyType(string|array $identifyType, ?string $locale = null): void
{
$this->setData('identifyType', $identifyType, $locale);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public function getDescription(?string $locale): string|array|null
/**
* Set series description.
*/
public function setDescription(string|array $description, string $locale = null): void
public function setDescription(string|array $description, ?string $locale = null): void
{
$this->setData('description', $description, $locale);
}
Expand Down
6 changes: 2 additions & 4 deletions classes/server/ServerDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ public function getTitles($enabledOnly = false)
/**
* Delete the public IDs of all publishing objects in a server.
*
* @param int $serverId
* @param string $pubIdType One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
*/
public function deleteAllPubIds($serverId, $pubIdType)
public function deleteAllPubIds(int $serverId, $pubIdType)
{
Repo::galley()->dao->deleteAllPubIds($serverId, $pubIdType);
Repo::submissionFile()->dao->deleteAllPubIds($serverId, $pubIdType);
Expand All @@ -93,7 +92,6 @@ public function deleteAllPubIds($serverId, $pubIdType)
* Check whether the given public ID exists for any publishing
* object in a server.
*
* @param int $serverId
* @param string $pubIdType One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
Expand All @@ -106,7 +104,7 @@ public function deleteAllPubIds($serverId, $pubIdType)
* @return bool
*/
public function anyPubIdExists(
$serverId,
int $serverId,
$pubIdType,
$pubId,
$assocType = MetadataTypeDescription::ASSOC_TYPE_ANY,
Expand Down
2 changes: 1 addition & 1 deletion classes/submission/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function deleteById(int $id): int
*
* @return DAOResultFactory<Submission>
*/
public function getExportable($contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null)
public function getExportable(int $contextId, $pubIdType = null, $title = null, $author = null, $issueId = null, $pubIdSettingName = null, $pubIdSettingValue = null, $rangeInfo = null)
{
$q = DB::table('submissions', 's')
->leftJoin('publications AS p', 's.current_publication_id', '=', 'p.publication_id')
Expand Down

0 comments on commit 4e0c352

Please sign in to comment.