diff --git a/classes/file/PublicFileManager.php b/classes/file/PublicFileManager.php index f22c5a34dc7..f773fd96502 100644 --- a/classes/file/PublicFileManager.php +++ b/classes/file/PublicFileManager.php @@ -24,9 +24,9 @@ class PublicFileManager extends PKPPublicFileManager /** * @copydoc PKPPublicFileManager::getContextFilesPath() */ - public function getContextFilesPath($contextId) + public function getContextFilesPath(int $contextId) { - return Config::getVar('files', 'public_files_dir') . '/presses/' . (int) $contextId; + return Config::getVar('files', 'public_files_dir') . '/presses/' . $contextId; } } diff --git a/classes/monograph/ChapterDAO.php b/classes/monograph/ChapterDAO.php index 3f4871487b5..4c03f8eac9d 100644 --- a/classes/monograph/ChapterDAO.php +++ b/classes/monograph/ChapterDAO.php @@ -80,7 +80,7 @@ public function getByContextId(int $pressId): DAOResultFactory INNER JOIN publications p ON (spc.publication_id = p.publication_id) INNER JOIN submissions s ON (p.submission_id = s.submission_id) WHERE s.context_id = ?', - [(int) $pressId] + [$pressId] ), $this, '_fromRow' diff --git a/classes/oai/omp/OAIDAO.php b/classes/oai/omp/OAIDAO.php index 4c86ae6fc98..e2ba8fde805 100644 --- a/classes/oai/omp/OAIDAO.php +++ b/classes/oai/omp/OAIDAO.php @@ -60,16 +60,11 @@ public function __construct() /** * Cached function to get a press * - * @param int $pressId - * * @return Press */ - public function getPress($pressId) + public function getPress(int $pressId) { - if (!isset($this->_pressCache[$pressId])) { - $this->_pressCache[$pressId] = $this->_pressDao->getById($pressId); - } - return $this->_pressCache[$pressId]; + return $this->_pressCache[$pressId] ??= $this->_pressDao->getById($pressId); } /** @@ -94,7 +89,6 @@ public function getSeries($seriesId) /** * Return hierarchy of OAI sets (presses plus press series). * - * @param int|null $pressId * @param int $offset * @param int $total * @@ -102,7 +96,7 @@ public function getSeries($seriesId) * * @hook OAIDAO::getSets [[&$this, $pressId, $offset, $limit, $total, &$sets]] */ - public function getSets($pressId, $offset, $limit, &$total) + public function getSets(?int $pressId, $offset, $limit, &$total) { if (isset($pressId)) { $presses = [$this->getPress($pressId)]; diff --git a/classes/oai/omp/PressOAI.php b/classes/oai/omp/PressOAI.php index f4c655c06a3..4d4230f0dce 100644 --- a/classes/oai/omp/PressOAI.php +++ b/classes/oai/omp/PressOAI.php @@ -42,8 +42,7 @@ class PressOAI extends OAI /** @var Press $press associated press object */ public $press; - /** @var int $pressId null if no press */ - public $pressId; + public ?int $pressId; /** @var OAIDAO $dao DAO for retrieving OAI records/tokens from database */ public $dao; @@ -99,11 +98,10 @@ public function identifierToPublicationFormatId($identifier) * Get press ID and series ID corresponding to a set specifier. * * @param string $setSpec - * @param int $pressId * * @return array */ - public function setSpecToSeriesId($setSpec, $pressId = null) + public function setSpecToSeriesId($setSpec, ?int $pressId = null) { $tmpArray = preg_split('/:/', $setSpec); if (count($tmpArray) == 1) { diff --git a/classes/payment/omp/OMPCompletedPaymentDAO.php b/classes/payment/omp/OMPCompletedPaymentDAO.php index feb3269672c..4648623df87 100644 --- a/classes/payment/omp/OMPCompletedPaymentDAO.php +++ b/classes/payment/omp/OMPCompletedPaymentDAO.php @@ -31,11 +31,10 @@ class OMPCompletedPaymentDAO extends DAO * Retrieve a CompletedPayment by its ID. * * @param int $completedPaymentId - * @param int $contextId optional * * @return CompletedPayment|null */ - public function getById($completedPaymentId, $contextId = null) + public function getById($completedPaymentId, ?int $contextId = null) { $params = [(int) $completedPaymentId]; if ($contextId) { @@ -141,12 +140,11 @@ public function hasPaidPurchaseFile($userId, $submissionFileId) /** * Retrieve an array of payments for a particular context ID. * - * @param int $contextId * @param DBResultRange|null $rangeInfo * * @return DAOResultFactory containing matching payments */ - public function getByContextId($contextId, $rangeInfo = null) + public function getByContextId(int $contextId, $rangeInfo = null) { return new DAOResultFactory( $this->retrieveRange( diff --git a/classes/plugins/PubIdPlugin.php b/classes/plugins/PubIdPlugin.php index 80b02771690..f8b5188337e 100644 --- a/classes/plugins/PubIdPlugin.php +++ b/classes/plugins/PubIdPlugin.php @@ -221,7 +221,7 @@ public function getDAOs() /** * @copydoc PKPPubIdPlugin::checkDuplicate() */ - public function checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId) + public function checkDuplicate($pubId, $pubObjectType, $excludeId, int $contextId) { /** @var ChapterDAO */ $chapterDao = DAORegistry::getDAO('ChapterDAO'); diff --git a/classes/press/PressDAO.php b/classes/press/PressDAO.php index ec2714fb276..84cbd5feb90 100644 --- a/classes/press/PressDAO.php +++ b/classes/press/PressDAO.php @@ -64,12 +64,11 @@ public function newDataObject() /** * Delete the public IDs of all publishing objects in a press. * - * @param int $pressId * @param string $pubIdType One of the NLM pub-id-type values or * 'other::something' if not part of the official NLM list * (see ). */ - public function deleteAllPubIds($pressId, $pubIdType) + public function deleteAllPubIds(int $pressId, $pubIdType) { $pubObjectDaos = ['ChapterDAO', 'PublicationFormatDAO']; foreach ($pubObjectDaos as $daoName) { @@ -87,7 +86,6 @@ public function deleteAllPubIds($pressId, $pubIdType) * Check whether the given public ID exists for any publishing * object in a press. * - * @param int $pressId * @param string $pubIdType One of the NLM pub-id-type values or * 'other::something' if not part of the official NLM list * (see ). @@ -100,7 +98,7 @@ public function deleteAllPubIds($pressId, $pubIdType) * @return bool */ public function anyPubIdExists( - $pressId, + int $pressId, $pubIdType, $pubId, $assocType = MetadataTypeDescription::ASSOC_TYPE_ANY, diff --git a/classes/publication/Publication.php b/classes/publication/Publication.php index 390db4abc0a..12049ff31a0 100644 --- a/classes/publication/Publication.php +++ b/classes/publication/Publication.php @@ -48,12 +48,11 @@ public function getEditorString() /** * Get the URL to a localized cover image * - * @param int $contextId * @param string $preferredLocale Return the cover image in a specified locale. * * @return string */ - public function getLocalizedCoverImageUrl($contextId, $preferredLocale = null) + public function getLocalizedCoverImageUrl(int $contextId, $preferredLocale = null) { $coverImage = $this->getLocalizedData('coverImage', $preferredLocale); @@ -73,11 +72,9 @@ public function getLocalizedCoverImageUrl($contextId, $preferredLocale = null) /** * Get the URL to the thumbnail of a localized cover image * - * @param int $contextId - * * @return string */ - public function getLocalizedCoverImageThumbnailUrl($contextId) + public function getLocalizedCoverImageThumbnailUrl(int $contextId) { $url = $this->getLocalizedCoverImageUrl($contextId); $pathParts = pathinfo($url); diff --git a/classes/publicationFormat/PublicationFormatDAO.php b/classes/publicationFormat/PublicationFormatDAO.php index 98f266e8f4c..93e209c5d4a 100644 --- a/classes/publicationFormat/PublicationFormatDAO.php +++ b/classes/publicationFormat/PublicationFormatDAO.php @@ -29,9 +29,6 @@ class PublicationFormatDAO extends DAO implements RepresentationDAOInterface { /** * @copydoc RepresentationDAO::getById() - * - * @param null|mixed $publicationId - * @param null|mixed $contextId */ public function getById(int $representationId, ?int $publicationId = null, ?int $contextId = null): PublicationFormat { @@ -45,11 +42,11 @@ public function getById(int $representationId, ?int $publicationId = null, ?int $result = $this->retrieve( 'SELECT pf.* - FROM publication_formats pf - ' . ($contextId ? ' - JOIN publications p ON (p.publication_id = pf.publicationId) - JOIN submissions s ON (s.submission_id=p.submission_id)' : '') . ' - WHERE pf.publication_format_id=?' . + FROM publication_formats pf + ' . ($contextId ? ' + JOIN publications p ON (p.publication_id = pf.publicationId) + JOIN submissions s ON (s.submission_id=p.submission_id)' : '') . ' + WHERE pf.publication_format_id=?' . ($publicationId ? ' AND pf.publication_id = ?' : '') . ($contextId ? ' AND s.context_id = ?' : ''), $params @@ -63,27 +60,26 @@ public function getById(int $representationId, ?int $publicationId = null, ?int * * @param string $settingName * @param int $publicationId optional - * @param int $pressId optional * * @return array The publication formats identified by setting. */ - public function getBySetting($settingName, $settingValue, $publicationId = null, $pressId = null) + public function getBySetting($settingName, $settingValue, $publicationId = null, ?int $pressId = null) { $params = [$settingName]; $sql = 'SELECT pf.* - FROM publication_formats pf '; + FROM publication_formats pf '; if ($pressId) { $sql .= 'INNER JOIN publications p ON p.publication_id = pf.publication_id - INNER JOIN submissions s ON s.submission_id = p.submission_id '; + INNER JOIN submissions s ON s.submission_id = p.submission_id '; } if (is_null($settingValue)) { $sql .= 'LEFT JOIN publication_format_settings pfs ON pf.publication_format_id = pfs.publication_format_id AND pfs.setting_name = ? - WHERE (pfs.setting_value IS NULL OR pfs.setting_value = \'\')'; + WHERE (pfs.setting_value IS NULL OR pfs.setting_value = \'\')'; } else { $params[] = (string) $settingValue; $sql .= 'INNER JOIN publication_format_settings pfs ON pf.publication_format_id = pfs.publication_format_id - WHERE pfs.setting_name = ? AND pfs.setting_value = ?'; + WHERE pfs.setting_name = ? AND pfs.setting_value = ?'; } if ($publicationId) { @@ -115,11 +111,10 @@ public function getBySetting($settingName, $settingValue, $publicationId = null, * (see ). * @param string $pubId * @param int $publicationId optional - * @param int $pressId optional * * @return PublicationFormat|null */ - public function getByPubId($pubIdType, $pubId, $publicationId = null, $pressId = null) + public function getByPubId($pubIdType, $pubId, $publicationId = null, ?int $pressId = null) { if (empty($pubId)) { return null; @@ -160,9 +155,9 @@ public function getByBestId($representationId, $publicationId) { $result = $this->retrieve( 'SELECT pf.* - FROM publication_formats pf - WHERE pf.url_path = ? - AND pf.publication_id = ?', + FROM publication_formats pf + WHERE pf.url_path = ? + AND pf.publication_id = ?', [ $representationId, $publicationId, @@ -179,11 +174,9 @@ public function getByBestId($representationId, $publicationId) /** * @copydoc RepresentationDAO::getByPublicationId() * - * @param null|mixed $contextId - * * @return DAOResultFactory */ - public function getByPublicationId($publicationId, $contextId = null): array + public function getByPublicationId($publicationId, ?int $contextId = null): array { $params = [(int) $publicationId]; if ($contextId) { @@ -193,10 +186,10 @@ public function getByPublicationId($publicationId, $contextId = null): array $result = new DAOResultFactory( $this->retrieve( 'SELECT pf.* - FROM publication_formats pf ' . + FROM publication_formats pf ' . ($contextId ? 'INNER JOIN publications p ON (pf.publication_id=p.publication_id) - INNER JOIN submissions s ON (s.submission_id = p.submission_id) ' + INNER JOIN submissions s ON (s.submission_id = p.submission_id) ' : '') . 'WHERE pf.publication_id=? ' . ($contextId ? ' AND s.context_id = ? ' : '') @@ -213,21 +206,19 @@ public function getByPublicationId($publicationId, $contextId = null): array /** * Retrieves a list of publication formats for a press * - * @param int $pressId - * * @return DAOResultFactory */ - public function getByContextId($pressId) + public function getByContextId(int $pressId) { return new DAOResultFactory( $this->retrieve( 'SELECT pf.* - FROM publication_formats pf - JOIN publications p ON (p.publication_id = pf.publication_id) - JOIN submissions s ON (s.submission_id = p.submission_id) - WHERE s.context_id = ? - ORDER BY pf.seq', - [(int) $pressId] + FROM publication_formats pf + JOIN publications p ON (p.publication_id = pf.publication_id) + JOIN submissions s ON (s.submission_id = p.submission_id) + WHERE s.context_id = ? + ORDER BY pf.seq', + [$pressId] ), $this, '_fromRow' @@ -364,9 +355,9 @@ public function insertObject($publicationFormat) { $this->update( 'INSERT INTO publication_formats - (is_approved, entry_key, physical_format, publication_id, seq, file_size, front_matter, back_matter, height, height_unit_code, width, width_unit_code, thickness, thickness_unit_code, weight, weight_unit_code, product_composition_code, product_form_detail_code, country_manufacture_code, imprint, product_availability_code, technical_protection_code, returnable_indicator_code, remote_url, url_path, is_available, doi_id) - VALUES - (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + (is_approved, entry_key, physical_format, publication_id, seq, file_size, front_matter, back_matter, height, height_unit_code, width, width_unit_code, thickness, thickness_unit_code, weight, weight_unit_code, product_composition_code, product_form_detail_code, country_manufacture_code, imprint, product_availability_code, technical_protection_code, returnable_indicator_code, remote_url, url_path, is_available, doi_id) + VALUES + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ (int) $publicationFormat->getIsApproved(), $publicationFormat->getEntryKey(), @@ -413,33 +404,33 @@ public function updateObject(Representation $publicationFormat): void { $this->update( 'UPDATE publication_formats - SET is_approved = ?, - entry_key = ?, - physical_format = ?, - seq = ?, - file_size = ?, - front_matter = ?, - back_matter = ?, - height = ?, - height_unit_code = ?, - width = ?, - width_unit_code = ?, - thickness = ?, - thickness_unit_code = ?, - weight = ?, - weight_unit_code = ?, - product_composition_code = ?, - product_form_detail_code = ?, - country_manufacture_code = ?, - imprint = ?, - product_availability_code = ?, - technical_protection_code = ?, - returnable_indicator_code = ?, - remote_url = ?, - url_path = ?, - is_available = ?, - doi_id = ? - WHERE publication_format_id = ?', + SET is_approved = ?, + entry_key = ?, + physical_format = ?, + seq = ?, + file_size = ?, + front_matter = ?, + back_matter = ?, + height = ?, + height_unit_code = ?, + width = ?, + width_unit_code = ?, + thickness = ?, + thickness_unit_code = ?, + weight = ?, + weight_unit_code = ?, + product_composition_code = ?, + product_form_detail_code = ?, + country_manufacture_code = ?, + imprint = ?, + product_availability_code = ?, + technical_protection_code = ?, + returnable_indicator_code = ?, + remote_url = ?, + url_path = ?, + is_available = ?, + doi_id = ? + WHERE publication_format_id = ?', [ (int) $publicationFormat->getIsApproved(), $publicationFormat->getEntryKey(), diff --git a/classes/publicationFormat/PublicationFormatTombstoneManager.php b/classes/publicationFormat/PublicationFormatTombstoneManager.php index 6fd4e76c92c..22fbd63c2f8 100755 --- a/classes/publicationFormat/PublicationFormatTombstoneManager.php +++ b/classes/publicationFormat/PublicationFormatTombstoneManager.php @@ -134,10 +134,8 @@ public function deleteTombstonesByPublicationFormats($publicationFormats) /** * Delete tombstone for every publication format inside the passed press. - * - * @param int $pressId */ - public function deleteTombstonesByPressId($pressId) + public function deleteTombstonesByPressId(int $pressId) { $submissions = Repo::submission() ->getCollector() diff --git a/controllers/grid/settings/series/form/SeriesForm.php b/controllers/grid/settings/series/form/SeriesForm.php index 7cb9802fb2f..dc3251557eb 100644 --- a/controllers/grid/settings/series/form/SeriesForm.php +++ b/controllers/grid/settings/series/form/SeriesForm.php @@ -31,8 +31,7 @@ class SeriesForm extends PKPSectionForm { - /** @var int $_pressId */ - public $_pressId; + public int $_pressId; /** * Constructor. diff --git a/pages/information/InformationHandler.php b/pages/information/InformationHandler.php index 61dbd7e57fa..cba1b93fedb 100644 --- a/pages/information/InformationHandler.php +++ b/pages/information/InformationHandler.php @@ -33,7 +33,7 @@ public function index($args, $request) $this->validate(null, $request); $press = $request->getPress(); if ($press == null) { - $request->redirect('index'); + $request->redirect(Application::SITE_CONTEXT_PATH); } $this->setupTemplate($request); diff --git a/plugins/blocks/browse/BrowseBlockSettingsForm.php b/plugins/blocks/browse/BrowseBlockSettingsForm.php index a59f4d8bf5f..e484270473a 100644 --- a/plugins/blocks/browse/BrowseBlockSettingsForm.php +++ b/plugins/blocks/browse/BrowseBlockSettingsForm.php @@ -20,9 +20,6 @@ class BrowseBlockSettingsForm extends Form { - // - // Private properties - // /** @var int press ID */ public $_pressId; @@ -30,16 +27,12 @@ class BrowseBlockSettingsForm extends Form public $_plugin; - // - // Constructor - // /** * Constructor * * @param BrowseBlockPlugin $plugin - * @param int $pressId */ - public function __construct($plugin, $pressId) + public function __construct($plugin, int $pressId) { $this->setPressId($pressId); $this->setPlugin($plugin); @@ -53,25 +46,18 @@ public function __construct($plugin, $pressId) $this->setData('pluginJavaScriptPath', $plugin->getPluginPath()); } - // - // Getters and Setters - // /** * Get the Press ID. - * - * @return int */ - public function getPressId() + public function getPressId(): int { return $this->_pressId; } /** * Set the Press ID. - * - * @param int $pressId */ - public function setPressId($pressId) + public function setPressId(int $pressId) { $this->_pressId = $pressId; } @@ -96,9 +82,6 @@ public function setPlugin($plugin) $this->_plugin = $plugin; } - // - // Implement template methods from Form - // /** * @see Form::initData() */ @@ -132,9 +115,6 @@ public function execute(...$functionArgs) parent::execute(...$functionArgs); } - // - // Private helper methods - // public function _getFormFields() { return [ diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index 637a6ef1c07..6135d54106b 100644 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -79,7 +79,7 @@ public function getDescription() /** * @copydoc PKPPubIdPlugin::constructPubId() */ - public function constructPubId($pubIdPrefix, $pubIdSuffix, $contextId) + public function constructPubId($pubIdPrefix, $pubIdSuffix, int $contextId) { $urn = $pubIdPrefix . $pubIdSuffix; $suffixFieldName = $this->getSuffixFieldName(); @@ -118,7 +118,7 @@ public function getPubIdFullName() /** * @copydoc PKPPubIdPlugin::getResolvingURL() */ - public function getResolvingURL($contextId, $pubId) + public function getResolvingURL(int $contextId, $pubId) { $resolverURL = $this->getSetting($contextId, 'urnResolver'); return $resolverURL . $pubId; @@ -158,7 +158,7 @@ public function getPubIdAssignFile() /** * @copydoc PKPPubIdPlugin::instantiateSettingsForm() */ - public function instantiateSettingsForm($contextId) + public function instantiateSettingsForm(int $contextId) { return new URNSettingsForm($this, $contextId); } @@ -246,7 +246,7 @@ public function getDAOFieldNames() /** * @copydoc PKPPubIdPlugin::isObjectTypeEnabled() */ - public function isObjectTypeEnabled($pubObjectType, $contextId) + public function isObjectTypeEnabled($pubObjectType, int $contextId) { return (bool) $this->getSetting($contextId, "enable{$pubObjectType}URN"); } @@ -264,9 +264,9 @@ public function getNotUniqueErrorMsg() */ public function validatePublicationUrn(string $hookName, array $args): void { - $errors = & $args[0]; + $errors = &$args[0]; $object = $args[1]; - $props = & $args[2]; + $props = &$args[2]; if (empty($props['pub-id::other::urn'])) { return; @@ -351,8 +351,8 @@ public function addPublicationFormFields(string $hookName, FormComponent $form): } $form->addField(new FieldPubIdUrn('pub-id::other::urn', $fieldData)); - // Otherwise add a field for manual entry that includes a button to generate - // the check number + // Otherwise add a field for manual entry that includes a button to generate + // the check number } else { $form->addField(new FieldTextUrn('pub-id::other::urn', [ 'label' => __('plugins.pubIds.urn.displayName'), @@ -383,7 +383,7 @@ public function addPublishFormNotice(string $hookName, FormComponent $form): voi if (!$publicationUrnEnabled && !$chapterUrnEnabled && !$publicationFormatUrnEnabled && !$submissionFileUrnEnabled) { return; - // Use a simplified view when only assigning to the publication + // Use a simplified view when only assigning to the publication } elseif ($publicationFormatUrnEnabled && !$chapterUrnEnabled && !$publicationFormatUrnEnabled && !$submissionFileUrnEnabled) { if ($form->publication->getData('pub-id::other::urn')) { $msg = __('plugins.pubIds.urn.editor.preview.publication', ['urn' => $form->publication->getData('pub-id::other::urn')]); @@ -396,7 +396,7 @@ public function addPublishFormNotice(string $hookName, FormComponent $form): voi ])); return; - // Show a table if probably more than one URN is going to be created + // Show a table if probably more than one URN is going to be created } else { $urnTableRows = []; if ($publicationUrnEnabled) { diff --git a/plugins/pubIds/urn/classes/form/URNSettingsForm.php b/plugins/pubIds/urn/classes/form/URNSettingsForm.php index c8995bf13fc..0e9b3b92b2a 100644 --- a/plugins/pubIds/urn/classes/form/URNSettingsForm.php +++ b/plugins/pubIds/urn/classes/form/URNSettingsForm.php @@ -58,9 +58,8 @@ public function _getPlugin() * Constructor * * @param \APP\plugins\pubIds\urn\URNPubIdPlugin $plugin - * @param int $contextId */ - public function __construct($plugin, $contextId) + public function __construct($plugin, int $contextId) { $this->_contextId = $contextId; $this->_plugin = $plugin;