diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ae814857e..3fc21129c 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - versions: [{php: '8.1', solr: '9.10.1'}, {php: '8.2', solr: '9.10.1'}, {php: '8.3', solr: '9.10.1'}, {php: '8.4', solr: '9.10.1'}] + versions: [{php: '8.1', solr: '9.10.1'}, {php: '8.2', solr: '9.10.1'}, {php: '8.3', solr: '9.10.1'}, {php: '8.4', solr: '9.10.1'}, {php: '8.5', solr: '9.10.1'}] fail-fast: false name: PHP ${{ matrix.versions.php }} Test diff --git a/library/Application/Controller/Action/Helper/DocumentTypes.php b/library/Application/Controller/Action/Helper/DocumentTypes.php index d39e163f7..5e6226fb4 100644 --- a/library/Application/Controller/Action/Helper/DocumentTypes.php +++ b/library/Application/Controller/Action/Helper/DocumentTypes.php @@ -124,7 +124,7 @@ public function getAllDocumentTypes() */ public function isValid($documentType) { - return array_key_exists($documentType, $this->getDocumentTypes()); + return null !== $documentType && array_key_exists($documentType, $this->getDocumentTypes()); } /** diff --git a/library/Application/Controller/Action/Helper/Version.php b/library/Application/Controller/Action/Helper/Version.php index 71b0567c7..1e2fafc15 100644 --- a/library/Application/Controller/Action/Helper/Version.php +++ b/library/Application/Controller/Action/Helper/Version.php @@ -85,7 +85,6 @@ public function getLatestReleaseFromServer() curl_setopt($ch, CURLOPT_USERAGENT, 'OPUS 4'); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $response = curl_exec($ch); - curl_close($ch); if (! $response) { // TODO no response diff --git a/library/Application/Form/Element/Language.php b/library/Application/Form/Element/Language.php index 7089bc0d7..726f6be06 100644 --- a/library/Application/Form/Element/Language.php +++ b/library/Application/Form/Element/Language.php @@ -61,7 +61,7 @@ public function init() */ public function setValue($value) { - if ($value !== null) { + if (null !== $value) { $language = Languages::getLanguage($value); if (null !== $language) { @@ -69,7 +69,7 @@ public function setValue($value) } } - if (! in_array($value, array_keys(self::getLanguageList()))) { + if (null !== $value && ! in_array($value, array_keys(self::getLanguageList()))) { $label = Locale::getDisplayName($value); if ($label !== $value) { $label .= " ({$value})"; diff --git a/library/Application/Form/Element/PublicationState.php b/library/Application/Form/Element/PublicationState.php index d6d4840a9..d204a716c 100644 --- a/library/Application/Form/Element/PublicationState.php +++ b/library/Application/Form/Element/PublicationState.php @@ -57,7 +57,7 @@ public function setValue($value) $publicationState = new PublicationState(); - if (! array_key_exists($value, $options) && in_array($value, $publicationState->getAllValues())) { + if (null !== $value && ! array_key_exists($value, $options) && in_array($value, $publicationState->getAllValues())) { $additionalOption[$value] = $this->translateValue($value); $options = array_merge( diff --git a/library/Application/Translate/TmxParser.php b/library/Application/Translate/TmxParser.php index 9e73155d4..9636b8103 100644 --- a/library/Application/Translate/TmxParser.php +++ b/library/Application/Translate/TmxParser.php @@ -63,7 +63,6 @@ public function __construct() public function __destruct() { - xml_parser_free($this->parser); unset($this->parser); } diff --git a/modules/admin/forms/Document/MultiSubForm.php b/modules/admin/forms/Document/MultiSubForm.php index 7f3714400..79a383b4c 100644 --- a/modules/admin/forms/Document/MultiSubForm.php +++ b/modules/admin/forms/Document/MultiSubForm.php @@ -582,9 +582,10 @@ public function isValid($data, $context = null) $result = true; if ($this->subformValidator !== null) { - if (array_key_exists($this->getName(), $data)) { - $this->subformValidator->prepareValidation($this, $data[$this->getName()], $context); - $result = $this->subformValidator->isValid($data[$this->getName()], $context); + $name = $this->getName(); + if (null !== $name && array_key_exists($name, $data)) { + $this->subformValidator->prepareValidation($this, $data[$name], $context); + $result = $this->subformValidator->isValid($data[$name], $context); } } diff --git a/modules/frontdoor/models/HtmlMetaTags.php b/modules/frontdoor/models/HtmlMetaTags.php index e669b68c3..316f84a8e 100644 --- a/modules/frontdoor/models/HtmlMetaTags.php +++ b/modules/frontdoor/models/HtmlMetaTags.php @@ -566,7 +566,7 @@ public function getMetatagsType($document) { $mappingConfig = $this->getMappingConfig(); $docType = $document->getType(); - if (isset($mappingConfig[$docType])) { + if (null !== $docType && isset($mappingConfig[$docType])) { return $mappingConfig[$docType]; } else { return 'other'; diff --git a/modules/oai/models/Set/PublicationStateSets.php b/modules/oai/models/Set/PublicationStateSets.php index 22e07b382..9aecec864 100644 --- a/modules/oai/models/Set/PublicationStateSets.php +++ b/modules/oai/models/Set/PublicationStateSets.php @@ -147,7 +147,7 @@ protected function getSubsetNames() */ public function getSubsetName($publicationState) { - if (array_key_exists($publicationState, $this->subsetMapping)) { + if (null !== $publicationState && array_key_exists($publicationState, $this->subsetMapping)) { return $this->subsetMapping[$publicationState]; } else { return null; diff --git a/tests/library/Application/Controller/Action/Helper/FilesTest.php b/tests/library/Application/Controller/Action/Helper/FilesTest.php index bdb2c1403..8ff43d56d 100644 --- a/tests/library/Application/Controller/Action/Helper/FilesTest.php +++ b/tests/library/Application/Controller/Action/Helper/FilesTest.php @@ -94,9 +94,7 @@ public function testListFilesAllFileTypes() public function testGetAllowedFileTypes() { - $method = new ReflectionMethod('Application_Controller_Action_Helper_Files', 'getAllowedFileTypes'); - $method->setAccessible(true); - + $method = new ReflectionMethod('Application_Controller_Action_Helper_Files', 'getAllowedFileTypes'); $fileTypes = $method->invoke($this->helper); $this->assertEquals(4, count($fileTypes)); diff --git a/tests/library/Application/Form/Model/AbstractTest.php b/tests/library/Application/Form/Model/AbstractTest.php index 015f3ddf8..a1f075bb4 100644 --- a/tests/library/Application/Form/Model/AbstractTest.php +++ b/tests/library/Application/Form/Model/AbstractTest.php @@ -183,16 +183,12 @@ public function testSetGetVerifyModelIdIsNumeric() public function testValidateModelIdValidMustBeNumeric() { $method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId'); - $method->setAccessible(true); - $this->assertNull($method->invoke($this->form, '123')); } public function testValidateModelIdValidNonNumeric() { $method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId'); - $method->setAccessible(true); - $this->form->setVerifyModelIdIsNumeric(false); $this->assertNull($method->invoke($this->form, 'enrichment')); } @@ -200,8 +196,6 @@ public function testValidateModelIdValidNonNumeric() public function testValidateModelIdNotValidNonNumeric() { $method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId'); - $method->setAccessible(true); - $this->expectException(ApplicationException::class); $this->expectExceptionMessage('Model-ID must be numeric.'); $method->invoke($this->form, 'enrichment'); @@ -210,8 +204,6 @@ public function testValidateModelIdNotValidNonNumeric() public function testValidateModelIdForNull() { $method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId'); - $method->setAccessible(true); - $this->assertNull($method->invoke($this->form, null)); $this->form->setVerifyModelIdIsNumeric(false); diff --git a/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php b/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php index 0d67324bb..fe0117133 100644 --- a/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php +++ b/tests/library/Application/Form/Validate/CollectionRoleOaiNameUniqueTest.php @@ -82,9 +82,7 @@ public function testGetModel() $collectionRole->store(); $method = new ReflectionMethod(Application_Form_Validate_CollectionRoleOaiNameUnique::class, 'getModel'); - $method->setAccessible(true); - - $model = $method->invoke($this->validator, ['NewTestColRoleOaiName']); + $model = $method->invoke($this->validator, ['NewTestColRoleOaiName']); $this->assertNotNull($model); $this->assertEquals('NewTestColRoleOaiName', $model->getOaiName()); diff --git a/tests/library/Application/Job/CheckWorkspaceFilesJobTest.php b/tests/library/Application/Job/CheckWorkspaceFilesJobTest.php index 034680ade..215edd889 100644 --- a/tests/library/Application/Job/CheckWorkspaceFilesJobTest.php +++ b/tests/library/Application/Job/CheckWorkspaceFilesJobTest.php @@ -71,8 +71,7 @@ public function testGetFilePath() $job = $this->job; $reflector = new ReflectionClass($job); $getPath = $reflector->getMethod('getFilesPath'); - $getPath->setAccessible(true); - $path = $getPath->invokeArgs($job, []); + $path = $getPath->invokeArgs($job, []); $expectedPath = realpath(Config::get()->workspacePath . DIRECTORY_SEPARATOR . "files"); @@ -84,8 +83,7 @@ public function testRunException() $job = $this->job; $reflector = new ReflectionClass($job); $getPath = $reflector->getMethod('getFilesPath'); - $getPath->setAccessible(true); - $path = $getPath->invokeArgs($job, []); + $path = $getPath->invokeArgs($job, []); $file = $this->createTestFile('/0909', null, $path); @@ -105,8 +103,7 @@ public function testSetFilesPath() $reflector = new ReflectionClass($job); $getPath = $reflector->getMethod('getFilesPath'); - $getPath->setAccessible(true); - $path = $getPath->invokeArgs($job, []); + $path = $getPath->invokeArgs($job, []); $this->assertSame($expectedPath, $path); } diff --git a/tests/library/Application/Job/CleanTemporariesJobTest.php b/tests/library/Application/Job/CleanTemporariesJobTest.php index c5169fd89..472e1822f 100644 --- a/tests/library/Application/Job/CleanTemporariesJobTest.php +++ b/tests/library/Application/Job/CleanTemporariesJobTest.php @@ -90,8 +90,7 @@ public function testGetPreviousDate() $job = $this->job; $reflector = new ReflectionClass($job); $getDate = $reflector->getMethod('getPreviousDate'); - $getDate->setAccessible(true); - $date = $getDate->invokeArgs($job, []); + $date = $getDate->invokeArgs($job, []); $dateTime = new DateTime(); $expected = $dateTime->sub(new DateInterval('P2D'))->format('Y-m-d'); diff --git a/tests/library/Application/Security/HttpAuthAdapterTest.php b/tests/library/Application/Security/HttpAuthAdapterTest.php index e6ebb5ab0..0fd25f26b 100644 --- a/tests/library/Application/Security/HttpAuthAdapterTest.php +++ b/tests/library/Application/Security/HttpAuthAdapterTest.php @@ -39,7 +39,6 @@ public function testSecureStringCompare() ]); $method = new ReflectionMethod('Application_Security_HttpAuthAdapter', '_secureStringCompare'); - $method->setAccessible(true); $this->assertFalse($method->invoke($adapter, 'password', 'password')); diff --git a/tests/library/Application/Translate/TranslationManagerTest.php b/tests/library/Application/Translate/TranslationManagerTest.php index f8eedcfac..b6d93ac9b 100644 --- a/tests/library/Application/Translate/TranslationManagerTest.php +++ b/tests/library/Application/Translate/TranslationManagerTest.php @@ -1216,7 +1216,6 @@ public function testGetLanguageOrderRef() $class = new ReflectionClass(get_class($manager)); $method = $class->getMethod('getLanguageOrderRef'); - $method->setAccessible(true); $order = $method->invoke($manager); @@ -1246,7 +1245,6 @@ public function testSortLanguages() $class = new ReflectionClass(get_class($manager)); $method = $class->getMethod('sortLanguages'); - $method->setAccessible(true); $sorted = $method->invoke($manager, [ 'en' => 'English', diff --git a/tests/library/Application/Util/NotificationTest.php b/tests/library/Application/Util/NotificationTest.php index 1ed37c5de..82781791a 100644 --- a/tests/library/Application/Util/NotificationTest.php +++ b/tests/library/Application/Util/NotificationTest.php @@ -283,10 +283,8 @@ public function testCreateWorkerJobIfAsyncEnabled() */ protected function getMethod($methodName) { - $class = new ReflectionClass('Application_Util_Notification'); - $method = $class->getMethod($methodName); - $method->setAccessible(true); - return $method; + $class = new ReflectionClass('Application_Util_Notification'); + return $class->getMethod($methodName); } public function testGetSubjectTemplate() diff --git a/tests/library/Application/Util/PublicationNotificationTest.php b/tests/library/Application/Util/PublicationNotificationTest.php index 79df516ff..437225e4e 100644 --- a/tests/library/Application/Util/PublicationNotificationTest.php +++ b/tests/library/Application/Util/PublicationNotificationTest.php @@ -245,10 +245,8 @@ public function testGetRecipientsForPublicationContextWithoutSubmitter() */ protected function getMethod($methodName) { - $class = new ReflectionClass('Application_Util_PublicationNotification'); - $method = $class->getMethod($methodName); - $method->setAccessible(true); - return $method; + $class = new ReflectionClass('Application_Util_PublicationNotification'); + return $class->getMethod($methodName); } public function testGetPublicationMailBodyWithEmptyAuthorsAndEmptyTitle() diff --git a/tests/modules/admin/forms/Document/DefaultMultiSubFormTest.php b/tests/modules/admin/forms/Document/DefaultMultiSubFormTest.php index 123a4fa77..a60223db9 100644 --- a/tests/modules/admin/forms/Document/DefaultMultiSubFormTest.php +++ b/tests/modules/admin/forms/Document/DefaultMultiSubFormTest.php @@ -447,7 +447,6 @@ public function testConstructWithTableHeader() public function testPrepareSubFormDecoratorsForTableRendering() { $method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'prepareSubFormDecorators'); - $method->setAccessible(true); $columns = [ [], @@ -494,7 +493,6 @@ public function testAddRemoveButtonForTableRendering() ]); $method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'addRemoveButton'); - $method->setAccessible(true); $subform = new Zend_Form_SubForm(); $subform->addElement('hidden', 'Id'); diff --git a/tests/modules/admin/forms/Document/FilesTest.php b/tests/modules/admin/forms/Document/FilesTest.php index fbb863e69..f4ccd7723 100644 --- a/tests/modules/admin/forms/Document/FilesTest.php +++ b/tests/modules/admin/forms/Document/FilesTest.php @@ -79,7 +79,6 @@ public function testColumnLabelTranslations() $form = new Admin_Form_Document_Files(); $property = new ReflectionProperty(Admin_Form_Document_Files::class, 'header'); - $property->setAccessible(true); $header = $property->getValue($form); diff --git a/tests/modules/admin/forms/Document/MultiSubFormTest.php b/tests/modules/admin/forms/Document/MultiSubFormTest.php index 90e318514..1417dc158 100644 --- a/tests/modules/admin/forms/Document/MultiSubFormTest.php +++ b/tests/modules/admin/forms/Document/MultiSubFormTest.php @@ -443,7 +443,6 @@ public function testConstructWithTableHeader() public function testPrepareSubFormDecoratorsForTableRendering() { $method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'prepareSubFormDecorators'); - $method->setAccessible(true); $columns = [ [], @@ -490,7 +489,6 @@ public function testAddRemoveButtonForTableRendering() ]); $method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'addRemoveButton'); - $method->setAccessible(true); $subform = new Zend_Form_SubForm(); $subform->addElement('hidden', 'Id'); diff --git a/tests/modules/admin/forms/Document/PersonRoleTest.php b/tests/modules/admin/forms/Document/PersonRoleTest.php index 447da9069..6ce7644f1 100644 --- a/tests/modules/admin/forms/Document/PersonRoleTest.php +++ b/tests/modules/admin/forms/Document/PersonRoleTest.php @@ -716,9 +716,7 @@ protected function getFormForSorting() */ private function getMethod($className, $methodName) { - $class = new ReflectionClass($className); - $method = $class->getMethod($methodName); - $method->setAccessible(true); - return $method; + $class = new ReflectionClass($className); + return $class->getMethod($methodName); } } diff --git a/tests/modules/export/controllers/IndexControllerTest.php b/tests/modules/export/controllers/IndexControllerTest.php index 5363f4f3f..a9397e0cd 100644 --- a/tests/modules/export/controllers/IndexControllerTest.php +++ b/tests/modules/export/controllers/IndexControllerTest.php @@ -263,7 +263,6 @@ public function testSolrIndexIsNotUpToDate() // add document to search index // TODO fix $methodSendSolrXmlToServer = $class->getMethod('sendSolrXmlToServer'); - // $methodSendSolrXmlToServer->setAccessible(true); // $methodSendSolrXmlToServer->invoke($indexer, $solrXml); // $indexer->commit(); diff --git a/tests/modules/solrsearch/models/CollectionRolesTest.php b/tests/modules/solrsearch/models/CollectionRolesTest.php index 4a4d392c3..c1b921752 100644 --- a/tests/modules/solrsearch/models/CollectionRolesTest.php +++ b/tests/modules/solrsearch/models/CollectionRolesTest.php @@ -47,9 +47,8 @@ public function testHasVisibleChildrenForEmptyCollectionRole() { $collectionRoles = new Solrsearch_Model_CollectionRoles(); - $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); - $method = $class->getMethod('hasVisibleChildren'); - $method->setAccessible(true); + $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); + $method = $class->getMethod('hasVisibleChildren'); $hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(17)]); $this->assertFalse($hasChildren); @@ -59,9 +58,8 @@ public function testHasVisibleChildrenForNonEmptyCollectionRole() { $collectionRoles = new Solrsearch_Model_CollectionRoles(); - $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); - $method = $class->getMethod('hasVisibleChildren'); - $method->setAccessible(true); + $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); + $method = $class->getMethod('hasVisibleChildren'); $hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(7)]); $this->assertTrue($hasChildren); @@ -71,9 +69,8 @@ public function testHasPublishedDocsForEmptyCollectionRole() { $collectionRoles = new Solrsearch_Model_CollectionRoles(); - $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); - $method = $class->getMethod('hasPublishedDocs'); - $method->setAccessible(true); + $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); + $method = $class->getMethod('hasPublishedDocs'); $hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(17)]); $this->assertFalse($hasChildren); @@ -83,9 +80,8 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithoutPublishedDoc { $collectionRoles = new Solrsearch_Model_CollectionRoles(); - $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); - $method = $class->getMethod('hasPublishedDocs'); - $method->setAccessible(true); + $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); + $method = $class->getMethod('hasPublishedDocs'); $hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(7)]); $this->assertFalse($hasChildren); @@ -95,9 +91,8 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithPublishedDocs() { $collectionRoles = new Solrsearch_Model_CollectionRoles(); - $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); - $method = $class->getMethod('hasPublishedDocs'); - $method->setAccessible(true); + $class = new ReflectionClass('Solrsearch_Model_CollectionRoles'); + $method = $class->getMethod('hasPublishedDocs'); $hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(5)]); $this->assertTrue($hasChildren);