diff --git a/composer.json b/composer.json index f1457df63393d8606c6a6ba8c3bab36a74e18a12..aeeb53d564ab9af6f18fc73cd368e7f51f4ed312 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "phpmd/phpmd": "2.4.2", "phpunit/phpunit": "4.8.27", "sebastian/phpcpd": "2.0.0", - "squizlabs/php_codesniffer": "2.6.0" + "squizlabs/php_codesniffer": "2.7.1" }, "scripts": { "post-update-cmd": "phing installsolr installswaggerui" diff --git a/module/VuFind/src/VuFind/Connection/Oracle.php b/module/VuFind/src/VuFind/Connection/Oracle.php index 24054d5ad6666580220cd53fa6f27a0d666e414d..aa73b4015ad8447c607ec750f29d8cfd12a27654 100644 --- a/module/VuFind/src/VuFind/Connection/Oracle.php +++ b/module/VuFind/src/VuFind/Connection/Oracle.php @@ -201,10 +201,11 @@ class Oracle public function bindParam( $parsed, $place_holder, $data, $data_type = 'string', $length = -1 ) { - if (@oci_bind_by_name( + $success = @oci_bind_by_name( $parsed, $place_holder, $data, $length, $this->getDataTypeConstant($data_type) - )) { + ); + if ($success) { return true; } else { $this->handleError('binding', oci_error()); @@ -234,10 +235,11 @@ class Oracle public function returnParam( $parsed, $place_holder, &$data, $data_type = 'string', $length = -1 ) { - if (@oci_bind_by_name( + $success = @oci_bind_by_name( $parsed, $place_holder, $data, $length, $this->getDataTypeConstant($data_type) - )) { + ); + if ($success) { return true; } else { $this->handleError('binding', oci_error()); diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 643c49ab4e143eb1027e65a47018884b70a185e5..982097b995774f1d037cfacd3e61e0a752c06262 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -123,9 +123,9 @@ class AbstractBase extends AbstractActionController */ protected function createViewModel($params = null) { - if ('lightbox' === $this->params()->fromPost( - 'layout', $this->params()->fromQuery('layout', false) - )) { + $layout = $this->params() + ->fromPost('layout', $this->params()->fromQuery('layout', false)); + if ('lightbox' === $layout) { $this->layout()->setTemplate('layout/lightbox'); } return new ViewModel($params); diff --git a/module/VuFind/src/VuFind/Controller/ContentController.php b/module/VuFind/src/VuFind/Controller/ContentController.php index 276df0199507757ae9d77bde7f6c28ef497e0064..ac9464b86fc6a77ba04baec9a4f1166cb9c51282 100644 --- a/module/VuFind/src/VuFind/Controller/ContentController.php +++ b/module/VuFind/src/VuFind/Controller/ContentController.php @@ -59,13 +59,11 @@ class ContentController extends \VuFind\Controller\AbstractBase // 1.) Current language suffix // 2.) Default language suffix // 3.) No language suffix - if (null !== $themeInfo->findContainingTheme( - "templates/content/{$page}_$language.phtml" - )) { + $currentTpl = "templates/content/{$page}_$language.phtml"; + $defaultTpl = "templates/content/{$page}_$defaultLanguage.phtml"; + if (null !== $themeInfo->findContainingTheme($currentTpl)) { $page = "{$page}_$language"; - } elseif (null !== $themeInfo->findContainingTheme( - "templates/content/{$page}_$defaultLanguage.phtml" - )) { + } elseif (null !== $themeInfo->findContainingTheme($defaultTpl)) { $page = "{$page}_$defaultLanguage"; } diff --git a/module/VuFind/src/VuFind/Controller/HoldsTrait.php b/module/VuFind/src/VuFind/Controller/HoldsTrait.php index 41957b1173bbc0988c715ff89d1d429e01ac670a..1fb404e041881eee46b73233ceee031b05171005 100644 --- a/module/VuFind/src/VuFind/Controller/HoldsTrait.php +++ b/module/VuFind/src/VuFind/Controller/HoldsTrait.php @@ -84,9 +84,10 @@ trait HoldsTrait } // Block invalid requests: - if (!$catalog->checkRequestIsValid( + $validRequest = $catalog->checkRequestIsValid( $driver->getUniqueID(), $gatheredDetails, $patron - )) { + ); + if (!$validRequest) { return $this->blockedholdAction(); } @@ -116,18 +117,19 @@ trait HoldsTrait $pickup = $catalog->getPickUpLocations($patron, $pickupDetails); // Process form submissions if necessary: - if (!is_null($this->params()->fromPost('placeHold'))) { + if (null !== $this->params()->fromPost('placeHold')) { // If the form contained a pickup location or request group, make sure // they are valid: - $valid = $this->holds()->validateRequestGroupInput( + $validGroup = $this->holds()->validateRequestGroupInput( $gatheredDetails, $extraHoldFields, $requestGroups ); - if (!$valid) { + $validPickup = $validGroup && $this->holds()->validatePickUpInput( + $gatheredDetails['pickUpLocation'], $extraHoldFields, $pickup + ); + if (!$validGroup) { $this->flashMessenger() ->addMessage('hold_invalid_request_group', 'error'); - } elseif (!$this->holds()->validatePickUpInput( - $gatheredDetails['pickUpLocation'], $extraHoldFields, $pickup - )) { + } elseif (!$validPickup) { $this->flashMessenger()->addMessage('hold_invalid_pickup', 'error'); } else { // If we made it this far, we're ready to place the hold; diff --git a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php index eaa943d0416008bac083a0b7101617c59bbb7345..099d9517d155aba4c17bcc6eae79eef88c5c124a 100644 --- a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php @@ -86,9 +86,10 @@ trait ILLRequestsTrait } // Block invalid requests: - if (!$catalog->checkILLRequestIsValid( + $validRequest = $catalog->checkILLRequestIsValid( $driver->getUniqueID(), $gatheredDetails, $patron - )) { + ); + if (!$validRequest) { return $this->blockedILLRequestAction(); } diff --git a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php index e76997c3c392f95b7f9d99804079bd36471bcf0d..1119e39ccd04fd4d76ac5ff46cddb515923379f7 100644 --- a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php @@ -87,9 +87,10 @@ trait StorageRetrievalRequestsTrait } // Block invalid requests: - if (!$catalog->checkStorageRetrievalRequestIsValid( + $validRequest = $catalog->checkStorageRetrievalRequestIsValid( $driver->getUniqueID(), $gatheredDetails, $patron - )) { + ); + if (!$validRequest) { return $this->blockedStorageRetrievalRequestAction(); } diff --git a/module/VuFind/src/VuFind/ILS/Connection.php b/module/VuFind/src/VuFind/ILS/Connection.php index bfd4d300629cf733f02fa7a801b2dfdd8f1fb58d..31dc2b086695fc112b1c00ea2b511a7d799dda97 100644 --- a/module/VuFind/src/VuFind/ILS/Connection.php +++ b/module/VuFind/src/VuFind/ILS/Connection.php @@ -642,9 +642,8 @@ class Connection implements TranslatorAwareInterface, LoggerAwareInterface public function checkRequestIsValid($id, $data, $patron) { try { - if ($this->checkCapability( - 'checkRequestIsValid', [$id, $data, $patron] - )) { + $params = [$id, $data, $patron]; + if ($this->checkCapability('checkRequestIsValid', $params)) { return $this->getDriver()->checkRequestIsValid($id, $data, $patron); } } catch (\Exception $e) { @@ -674,9 +673,10 @@ class Connection implements TranslatorAwareInterface, LoggerAwareInterface public function checkStorageRetrievalRequestIsValid($id, $data, $patron) { try { - if ($this->checkCapability( + $check = $this->checkCapability( 'checkStorageRetrievalRequestIsValid', [$id, $data, $patron] - )) { + ); + if ($check) { return $this->getDriver()->checkStorageRetrievalRequestIsValid( $id, $data, $patron ); @@ -707,9 +707,8 @@ class Connection implements TranslatorAwareInterface, LoggerAwareInterface public function checkILLRequestIsValid($id, $data, $patron) { try { - if ($this->checkCapability( - 'checkILLRequestIsValid', [$id, $data, $patron] - )) { + $params = [$id, $data, $patron]; + if ($this->checkCapability('checkILLRequestIsValid', $params)) { return $this->getDriver()->checkILLRequestIsValid( $id, $data, $patron ); diff --git a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php index fe69cf8b4c78a0d8bae4b7e5693f82a38bffc225..4a251de393d6052b68b9934431c44f0b2384edbe 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php @@ -781,14 +781,12 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $addLink = ($hold_request[0] == 'Y'); } $matches = []; - if (preg_match( - "/([0-9]*\\/[a-zA-Z]*\\/[0-9]*);([a-zA-Z ]*)/", $status, $matches - )) { + $dueDateWithStatusRegEx = "/([0-9]*\\/[a-zA-Z]*\\/[0-9]*);([a-zA-Z ]*)/"; + $dueDateRegEx = "/([0-9]*\\/[a-zA-Z]*\\/[0-9]*)/"; + if (preg_match($dueDateWithStatusRegEx, $status, $matches)) { $duedate = $this->parseDate($matches[1]); $requested = (trim($matches[2]) == "Requested"); - } else if (preg_match( - "/([0-9]*\\/[a-zA-Z]*\\/[0-9]*)/", $status, $matches - )) { + } else if (preg_match($dueDateRegEx, $status, $matches)) { $duedate = $this->parseDate($matches[1]); } else { $duedate = null; diff --git a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php index 48e8ae6491ff1747ac07225423b532b5bbbdb91d..0a0b8287c88be94f2138f4eb3bf1e9462f5c8828 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php @@ -654,7 +654,8 @@ class DAIA extends AbstractBase implements || (in_array( $domNode->nodeName, ['storage', 'limitation', 'department', 'institution'] - ) && strlen($domNode->nodeValue))) { + ) && strlen($domNode->nodeValue)) + ) { if (trim($node->textContent)) { $domNode->setAttribute('content', $node->textContent); $node->nodeValue = ''; diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php index c053f579b096877dc12e3d12b29fbc84c3cc946d..fdebc09f46de8d3db1cbc5ee660a374a49fa3a9d 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php +++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php @@ -554,9 +554,10 @@ class MultiBackend extends AbstractBase $source = $this->getSource($patron['cat_username']); $driver = $this->getDriver($source); if ($driver) { - if (!$this->methodSupported( + $supported = $this->methodSupported( $driver, 'getMyStorageRetrievalRequests', compact('patron') - )) { + ); + if (!$supported) { // Return empty array if not supported by the driver return []; } @@ -1076,9 +1077,10 @@ class MultiBackend extends AbstractBase $source = $this->getSource($patron['cat_username']); $driver = $this->getDriver($source); if ($driver) { - if (!$this->methodSupported( + $supported = $this->methodSupported( $driver, 'getMyILLRequests', compact('patron') - )) { + ); + if (!$supported) { // Return empty array if not supported by the driver return []; } @@ -1187,9 +1189,10 @@ class MultiBackend extends AbstractBase $source = $this->getSource($patron['cat_username']); $driver = $this->getDriver($source); if ($driver) { - if (!$this->methodSupported( + $supported = $this->methodSupported( $driver, 'getRequestBlocks', compact('patron') - )) { + ); + if (!$supported) { return false; } return $driver->getRequestBlocks( @@ -1212,9 +1215,10 @@ class MultiBackend extends AbstractBase $source = $this->getSource($patron['cat_username']); $driver = $this->getDriver($source); if ($driver) { - if (!$this->methodSupported( + $supported = $this->methodSupported( $driver, 'getAccountBlocks', compact('patron') - )) { + ); + if (!$supported) { return false; } return $driver->getAccountBlocks( diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php index 2f56a89a8e20dda275f7fd397111c7f359fa40c6..602e6dc7ce1636e470939b32da1a3e4135b7d2b4 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php @@ -589,11 +589,9 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa ) { // ... can this user borrow on loan items at this // location? - if (in_array( + $can_req = in_array( $location, $unavailable_locs[$item_loc_code] - )) { - $can_req = true; - } + ); } } else { // The item is NOT on loan ... @@ -601,9 +599,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // ... and has a requestable status ... if (in_array($item_stat_code, $status_list)) { // ... can the user borrow status items at this location? - if (in_array($location, $status_locs[$item_loc_code])) { - $can_req = true; - } + $can_req = in_array($location, $status_locs[$item_loc_code]); } else { // ... and DOESN'T have a requestable status ... if ($item_stat_code !== null) { @@ -611,11 +607,9 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa } else { // ... can the user borrow available items at this // location? - if (in_array( + $can_req = in_array( $location, $available_locs[$item_loc_code] - )) { - $can_req = true; - } + ); } } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php index e9a4b9513094a8bb97f095b073cf4e23473378ec..2176bd7861b2cf9522526d7935998ab11e3e1819 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php @@ -474,9 +474,10 @@ class Voyager extends AbstractBase : PHP_INT_MAX ]; } else { - if (!in_array( + $statusFound = in_array( $row['STATUS'], $data[$row['ITEM_ID']]['status_array'] - )) { + ); + if (!$statusFound) { $data[$row['ITEM_ID']]['status_array'][] = $row['STATUS']; } } @@ -760,9 +761,7 @@ class Voyager extends AbstractBase } // If we've encountered a new status code, we should track it: - if (!in_array( - $row['STATUS'], $record['STATUS_ARRAY'] - )) { + if (!in_array($row['STATUS'], $record['STATUS_ARRAY'])) { $record['STATUS_ARRAY'][] = $row['STATUS']; } } else { diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index a161e5dceed85c6e3985be4a2fed78808150430d..539cec5baa1d223a99cebcdc97007aceba64e923 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -369,9 +369,10 @@ class Server // Retrieve the record from the index if ($record = $this->loadRecord($this->params['identifier'])) { - if (!$this->attachNonDeleted( + $success = $this->attachNonDeleted( $xml, $record, $this->params['metadataPrefix'] - )) { + ); + if (!$success) { return $this->showError('cannotDisseminateFormat', 'Unknown Format'); } } else { diff --git a/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php b/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php index a2a34cc42b9bb0d440c6744be2ed7d2f1f11428d..e0512d76f38551989b68f2df6bc146bf27876725 100644 --- a/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php @@ -346,11 +346,7 @@ class DeduplicationListener { $result = []; foreach ($params->get('fq') as $fq) { - if (preg_match_all( - '/\bbuilding:"([^"]+)"/', - $fq, - $matches - )) { + if (preg_match_all('/\bbuilding:"([^"]+)"/', $fq, $matches)) { $values = $matches[1]; foreach ($values as $value) { if (preg_match('/^\d+\/([^\/]+?)\//', $value, $matches)) { @@ -364,8 +360,7 @@ class DeduplicationListener } array_unshift($result, ''); - $result = array_flip($result); - return $result; + return array_flip($result); } }