From a60e5283d2c735e13498440b1c2adfb61df9e426 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 21 Nov 2017 10:41:45 -0500 Subject: [PATCH] Eliminate is_null() calls. --- module/VuFind/src/VuFind/Config/Locator.php | 2 +- module/VuFind/src/VuFind/Config/PluginFactory.php | 2 +- module/VuFind/src/VuFind/Connection/Oracle.php | 2 +- .../VuFind/src/VuFind/Connection/WorldCatUtils.php | 2 +- .../VuFind/src/VuFind/Controller/AbstractRecord.php | 2 +- .../VuFind/src/VuFind/Controller/CartController.php | 10 +++++----- .../src/VuFind/Controller/ILLRequestsTrait.php | 2 +- .../src/VuFind/Controller/MyResearchController.php | 4 ++-- .../Controller/StorageRetrievalRequestsTrait.php | 2 +- module/VuFind/src/VuFind/Db/AdapterFactory.php | 4 ++-- module/VuFind/src/VuFind/Db/Table/Resource.php | 4 ++-- module/VuFind/src/VuFind/Db/Table/UserList.php | 2 +- module/VuFind/src/VuFind/Db/Table/UserResource.php | 4 ++-- module/VuFind/src/VuFind/ILS/Driver/DAIA.php | 6 +++--- module/VuFind/src/VuFind/ILS/Driver/Symphony.php | 2 +- module/VuFind/src/VuFind/ILS/Driver/Virtua.php | 4 ++-- module/VuFind/src/VuFind/ILS/Driver/Voyager.php | 8 ++++---- module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php | 6 +++--- module/VuFind/src/VuFind/OAI/Server.php | 2 +- .../src/VuFind/Recommend/OpenLibrarySubjects.php | 2 +- module/VuFind/src/VuFind/Recommend/SwitchType.php | 2 +- .../VuFind/src/VuFind/RecordDriver/AbstractBase.php | 2 +- .../src/VuFind/Resolver/Driver/Threesixtylink.php | 2 +- module/VuFind/src/VuFind/Search/Base/Options.php | 2 +- module/VuFind/src/VuFind/Search/Base/Params.php | 4 ++-- module/VuFind/src/VuFind/Search/Base/Results.php | 12 ++++++------ .../VuFind/src/VuFind/Search/Favorites/Results.php | 12 ++++++------ module/VuFind/src/VuFind/Search/Solr/Results.php | 2 +- .../VuFind/src/VuFind/Search/SolrAuthor/Params.php | 2 +- .../src/VuFind/Search/SolrAuthorFacets/Params.php | 2 +- module/VuFind/src/VuFind/Search/Summon/Results.php | 2 +- .../VuFind/src/VuFind/View/Helper/Root/Context.php | 4 ++-- module/VuFind/src/VuFind/View/Helper/Root/Record.php | 2 +- .../src/VuFind/View/Helper/Root/ResultFeed.php | 2 +- .../src/VuFindTest/Mink/CallnumberBrowseTest.php | 4 ++-- .../src/VuFindAdmin/Controller/TagsController.php | 8 ++++---- .../src/VuFindSearch/Backend/SRU/Connector.php | 8 ++++---- .../src/VuFindSearch/Backend/Solr/SearchHandler.php | 4 ++-- .../src/VuFindTheme/View/Helper/ImageLink.php | 2 +- tests/vufind.php_cs | 1 + tests/vufind_templates.php_cs | 1 + .../RecordDriver/DefaultRecord/list-entry.phtml | 2 +- themes/bootstrap3/templates/admin/tags/list.phtml | 2 +- .../templates/myresearch/bulk-action-buttons.phtml | 4 ++-- themes/bootstrap3/templates/record/taglist.phtml | 2 +- 45 files changed, 82 insertions(+), 80 deletions(-) diff --git a/module/VuFind/src/VuFind/Config/Locator.php b/module/VuFind/src/VuFind/Config/Locator.php index 1f92f623de3..70ef3166048 100644 --- a/module/VuFind/src/VuFind/Config/Locator.php +++ b/module/VuFind/src/VuFind/Config/Locator.php @@ -52,7 +52,7 @@ class Locator public static function getLocalConfigPath($filename, $path = null, $force = false ) { - if (is_null($path)) { + if (null === $path) { $path = 'config/vufind'; } if (defined('LOCAL_OVERRIDE_DIR') && strlen(trim(LOCAL_OVERRIDE_DIR)) > 0) { diff --git a/module/VuFind/src/VuFind/Config/PluginFactory.php b/module/VuFind/src/VuFind/Config/PluginFactory.php index 0e90cc18d65..7d7f2a4f342 100644 --- a/module/VuFind/src/VuFind/Config/PluginFactory.php +++ b/module/VuFind/src/VuFind/Config/PluginFactory.php @@ -106,7 +106,7 @@ class PluginFactory implements AbstractFactoryInterface // Now we'll pull all the children down one at a time and override settings // as appropriate: - while (!is_null($child = array_pop($configs))) { + while (null !== ($child = array_pop($configs))) { $overrideSections = isset($child->Parent_Config->override_full_sections) ? explode( ',', str_replace( diff --git a/module/VuFind/src/VuFind/Connection/Oracle.php b/module/VuFind/src/VuFind/Connection/Oracle.php index aa73b4015ad..5da2af4a758 100644 --- a/module/VuFind/src/VuFind/Connection/Oracle.php +++ b/module/VuFind/src/VuFind/Connection/Oracle.php @@ -412,7 +412,7 @@ class Oracle // For building the sql $columns[] = $column; // Dates are special - if (count($tmp) > 0 && !is_null($datum)) { + if (count($tmp) > 0 && null !== $datum) { $values[] = "TO_DATE(:$column, '" . join(":", $tmp) . "')"; } else { $values[] = ":$column"; diff --git a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php index 9a1bf4b9161..8b378e1915d 100644 --- a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php +++ b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php @@ -207,7 +207,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface // Collect subjects for current name: $retVal = []; - if (!is_null($subjects) && count($subjects) > 0) { + if (null !== $subjects && count($subjects) > 0) { foreach ($subjects as $currentSubject) { if ($currentSubject['tag'] == '650') { $text = (string)$currentSubject; diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 9cb0eb451db..bb5287b7986 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -168,7 +168,7 @@ class AbstractRecord extends AbstractBase } $id = $this->params()->fromQuery('delete'); $table = $this->getTable('Comments'); - if (!is_null($id) && $table->deleteIfOwnedByUser($id, $user)) { + if (null !== $id && $table->deleteIfOwnedByUser($id, $user)) { $this->flashMessenger()->addMessage('delete_comment_success', 'success'); } else { $this->flashMessenger()->addMessage('delete_comment_failure', 'error'); diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index 9442cecc341..00d9726097e 100644 --- a/module/VuFind/src/VuFind/Controller/CartController.php +++ b/module/VuFind/src/VuFind/Controller/CartController.php @@ -149,7 +149,7 @@ class CartController extends AbstractBase $this->followup()->retrieveAndClear('cartAction'); $this->followup()->retrieveAndClear('cartIds'); - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); @@ -226,7 +226,7 @@ class CartController extends AbstractBase public function emailAction() { // Retrieve ID list: - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); @@ -291,7 +291,7 @@ class CartController extends AbstractBase */ public function printcartAction() { - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { @@ -323,7 +323,7 @@ class CartController extends AbstractBase public function exportAction() { // Get the desired ID list: - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { @@ -416,7 +416,7 @@ class CartController extends AbstractBase // Load record information first (no need to prompt for login if we just // need to display a "no records" error message): - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids', $this->params()->fromQuery('ids')) : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { diff --git a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php index 24d3ba082ca..290af4eedbd 100644 --- a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php @@ -92,7 +92,7 @@ trait ILLRequestsTrait ? explode(":", $checkRequests['extraFields']) : []; // Process form submissions if necessary: - if (!is_null($this->params()->fromPost('placeILLRequest'))) { + if (null !== $this->params()->fromPost('placeILLRequest')) { // If we made it this far, we're ready to place the hold; // if successful, we will redirect and can stop here. diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 9f2240f8bea..2a8e8a35769 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -496,7 +496,7 @@ class MyResearchController extends AbstractBase : $this->url()->fromRoute('userList', ['id' => $listID]); // Fail if we have nothing to delete: - $ids = is_null($this->params()->fromPost('selectAll')) + $ids = null === $this->params()->fromPost('selectAll') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { @@ -603,7 +603,7 @@ class MyResearchController extends AbstractBase } $this->flashMessenger()->addMessage('edit_list_success', 'success'); - $newUrl = is_null($listID) + $newUrl = null === $listID ? $this->url()->fromRoute('myresearch-favorites') : $this->url()->fromRoute('userList', ['id' => $listID]); return $this->redirect()->toUrl($newUrl); diff --git a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php index 272ff2af2ee..76fd180609f 100644 --- a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php @@ -93,7 +93,7 @@ trait StorageRetrievalRequestsTrait ? explode(":", $checkRequests['extraFields']) : []; // Process form submissions if necessary: - if (!is_null($this->params()->fromPost('placeStorageRetrievalRequest'))) { + if (null !== $this->params()->fromPost('placeStorageRetrievalRequest')) { // If we made it this far, we're ready to place the hold; // if successful, we will redirect and can stop here. diff --git a/module/VuFind/src/VuFind/Db/AdapterFactory.php b/module/VuFind/src/VuFind/Db/AdapterFactory.php index fa204b77172..e645eed3530 100644 --- a/module/VuFind/src/VuFind/Db/AdapterFactory.php +++ b/module/VuFind/src/VuFind/Db/AdapterFactory.php @@ -161,8 +161,8 @@ class AdapterFactory $username = $credentials; $password = null; } - $username = !is_null($overrideUser) ? $overrideUser : $username; - $password = !is_null($overridePass) ? $overridePass : $password; + $username = null !== $overrideUser ? $overrideUser : $username; + $password = null !== $overridePass ? $overridePass : $password; // Set up default options: $options = [ diff --git a/module/VuFind/src/VuFind/Db/Table/Resource.php b/module/VuFind/src/VuFind/Db/Table/Resource.php index 61fec5c041a..cc5a92f003a 100644 --- a/module/VuFind/src/VuFind/Db/Table/Resource.php +++ b/module/VuFind/src/VuFind/Db/Table/Resource.php @@ -174,14 +174,14 @@ class Resource extends Gateway $s->where->equalTo('ur.user_id', $user); // Adjust for list if necessary: - if (!is_null($list)) { + if (null !== $list) { $s->where->equalTo('ur.list_id', $list); } if ($offset > 0) { $s->offset($offset); } - if (!is_null($limit)) { + if (null !== $limit) { $s->limit($limit); } diff --git a/module/VuFind/src/VuFind/Db/Table/UserList.php b/module/VuFind/src/VuFind/Db/Table/UserList.php index 1de447d20c1..0bfd743326b 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserList.php +++ b/module/VuFind/src/VuFind/Db/Table/UserList.php @@ -142,7 +142,7 @@ class UserList extends Gateway ->equalTo('r.record_id', $resourceId); $select->order(['title']); - if (!is_null($userId)) { + if (null !== $userId) { $select->where->equalTo('ur.user_id', $userId); } }; diff --git a/module/VuFind/src/VuFind/Db/Table/UserResource.php b/module/VuFind/src/VuFind/Db/Table/UserResource.php index 88704ccc7dc..ed1ac007324 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserResource.php +++ b/module/VuFind/src/VuFind/Db/Table/UserResource.php @@ -93,10 +93,10 @@ class UserResource extends Gateway $select->where->equalTo('r.source', $source) ->equalTo('r.record_id', $resourceId); - if (!is_null($userId)) { + if (null !== $userId) { $select->where->equalTo('user_resource.user_id', $userId); } - if (!is_null($listId)) { + if (null !== $listId) { $select->where->equalTo('user_resource.list_id', $listId); } }; diff --git a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php index 178568d8b6f..f932d2306af 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php @@ -272,7 +272,7 @@ class DAIA extends AbstractBase implements // extract the DAIA document for the current id from the // HTTPRequest's result $doc = $this->extractDaiaDoc($id, $rawResult); - if (!is_null($doc)) { + if (null !== $doc) { // parse the extracted DAIA document and return the status info $data = $this->parseDaiaDoc($id, $doc); // cache the status information @@ -335,7 +335,7 @@ class DAIA extends AbstractBase implements // it is assumed that each DAIA document has a unique URI, // so get the document with the corresponding id $doc = $this->extractDaiaDoc($id, $rawResult); - if (!is_null($doc)) { + if (null !== $doc) { // a document with the corresponding id exists, which // means we got status information for that record $data = $this->parseDaiaDoc($id, $doc); @@ -355,7 +355,7 @@ class DAIA extends AbstractBase implements // extract the DAIA document for the current id from the // HTTPRequest's result $doc = $this->extractDaiaDoc($id, $rawResult); - if (!is_null($doc)) { + if (null !== $doc) { // parse the extracted DAIA document and save the status // info $data = $this->parseDaiaDoc($id, $doc); diff --git a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php index 6a22779cb11..62fcd46b008 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php @@ -207,7 +207,7 @@ class Symphony extends AbstractBase implements LoggerAwareInterface $reset = false ) { $data = ['clientID' => $this->config['WebServices']['clientID']]; - if (!is_null($login)) { + if (null !== $login) { $data['sessionToken'] = $this->getSessionToken($login, $password, $reset); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php index 6c1da3c18d1..a75a9c7c273 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php @@ -1874,14 +1874,14 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ protected function httpRequest($url, $postParams = null, $rawPost = null) { - $method = (is_null($postParams) && is_null($rawPost)) ? 'GET' : 'POST'; + $method = (null === $postParams && null === $rawPost) ? 'GET' : 'POST'; try { $client = $this->httpService->createClient($url); if (is_array($postParams)) { $client->setParameterPost($postParams); } - if (!is_null($rawPost)) { + if (null !== $rawPost) { $client->setRawBody($rawPost); $client->setEncType('application/x-www-form-urlencoded'); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php index 863684cef04..fcde568102c 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php @@ -1271,16 +1271,16 @@ EOT; // For some reason barcode is not unique, so evaluate all resulting // rows just to be safe while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $primary = !is_null($row['LOGIN']) + $primary = null !== $row['LOGIN'] ? mb_strtolower(utf8_encode($row['LOGIN']), 'UTF-8') : null; - $fallback = $fallback_login_field && is_null($row['LOGIN']) + $fallback = $fallback_login_field && null === $row['LOGIN'] ? mb_strtolower(utf8_encode($row['FALLBACK_LOGIN']), 'UTF-8') : null; - if ((!is_null($primary) && ($primary == $compareLogin + if ((null !== $primary && ($primary == $compareLogin || $primary == $this->sanitizePIN($compareLogin))) - || ($fallback_login_field && is_null($primary) + || ($fallback_login_field && null === $primary && $fallback == $compareLogin) ) { return [ diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php index 704ebf66c0b..826bb5339d0 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php @@ -348,7 +348,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $agencyList = []; - if (is_null($agency)) { + if (null === $agency) { $keys = array_keys($this->agency); $agencyList[] = $keys[0]; } @@ -504,7 +504,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $agencyList = []; $idList = []; - if (! is_null($ids)) { + if (null !== $ids) { foreach ($ids as $_id) { // Need to parse out the 035$a format, e.g., "(Agency) 123" if (preg_match('/\(([^\)]+)\)\s*([0-9]+)/', $_id, $matches)) { @@ -1750,7 +1750,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'xsd/ncip_v2_0.xsd">' . '<ns1:LookupUser>'; - if (!is_null($patron_agency_id)) { + if (null !== $patron_agency_id) { $ret .= '<ns1:InitiationHeader>' . '<ns1:FromAgencyId>' . diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index cc35396adaf..ca6a6928223 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -323,7 +323,7 @@ class Server // Check for sets: $fields = $record->getRawData(); - if (!is_null($this->setField) && !empty($fields[$this->setField])) { + if (null !== $this->setField && !empty($fields[$this->setField])) { $sets = $fields[$this->setField]; } else { $sets = []; diff --git a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php index e110f6fd7a8..a2bd344d6c0 100644 --- a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php +++ b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php @@ -202,7 +202,7 @@ class OpenLibrarySubjects implements RecommendInterface, // Try to extract range details from request parameters or SearchObject: $from = $request->get($field . 'from'); $to = $request->get($field . 'to'); - if (!is_null($from) && !is_null($to)) { + if (null !== $from && null !== $to) { $range = ['from' => $from, 'to' => $to]; } elseif (is_object($params)) { $currentFilters = $params->getFilters(); diff --git a/module/VuFind/src/VuFind/Recommend/SwitchType.php b/module/VuFind/src/VuFind/Recommend/SwitchType.php index b448d68db5c..632fb06d1e1 100644 --- a/module/VuFind/src/VuFind/Recommend/SwitchType.php +++ b/module/VuFind/src/VuFind/Recommend/SwitchType.php @@ -119,7 +119,7 @@ class SwitchType implements RecommendInterface // anything! We should only show recommendations if we know what handler is // being used and can determine that it is not the same as the new handler // that we want to recommend. - $this->active = (!is_null($handler) && $handler != $this->newHandler); + $this->active = (null !== $handler && $handler != $this->newHandler); } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index 575bbff6d11..4d3603b41ff 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -311,7 +311,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, */ public function getRelated(\VuFind\Related\PluginManager $factory, $types = null) { - if (is_null($types)) { + if (null === $types) { $types = isset($this->recordConfig->Record->related) ? $this->recordConfig->Record->related : []; } diff --git a/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php b/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php index fe55f6c3be0..6fb0e9f42f6 100644 --- a/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php +++ b/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php @@ -101,7 +101,7 @@ class Threesixtylink extends AbstractBase $xpath = new DOMXpath($xml); $linkGroups = $xpath->query("//ssopenurl:linkGroup[@type='holding']"); - if (!is_null($linkGroups)) { + if (null !== $linkGroups) { foreach ($linkGroups as $linkGroup) { $record = []; // select the deepest link returned diff --git a/module/VuFind/src/VuFind/Search/Base/Options.php b/module/VuFind/src/VuFind/Search/Base/Options.php index be76c77fd8d..670c7f43b21 100644 --- a/module/VuFind/src/VuFind/Search/Base/Options.php +++ b/module/VuFind/src/VuFind/Search/Base/Options.php @@ -636,7 +636,7 @@ abstract class Options implements TranslatorAwareInterface */ public function spellcheckEnabled($bool = null) { - if (!is_null($bool)) { + if (null !== $bool) { $this->spellcheck = $bool; } return $this->spellcheck; diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 0223bd7dbda..c1be8950e8b 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -384,7 +384,7 @@ class Params { // If no lookfor parameter was found, we have no search terms to // add to our array! - if (is_null($lookfor = $request->get('lookfor'))) { + if (null === ($lookfor = $request->get('lookfor'))) { return false; } @@ -668,7 +668,7 @@ class Params */ public function getView() { - return is_null($this->view) + return null === $this->view ? $this->getOptions()->getDefaultView() : $this->view; } diff --git a/module/VuFind/src/VuFind/Search/Base/Results.php b/module/VuFind/src/VuFind/Search/Base/Results.php index 13c3abb9764..c01c0976485 100644 --- a/module/VuFind/src/VuFind/Search/Base/Results.php +++ b/module/VuFind/src/VuFind/Search/Base/Results.php @@ -301,7 +301,7 @@ abstract class Results */ public function getResultTotal() { - if (is_null($this->resultTotal)) { + if (null === $this->resultTotal) { $this->performAndProcessSearch(); } return $this->resultTotal; @@ -369,7 +369,7 @@ abstract class Results */ public function getResults() { - if (is_null($this->results)) { + if (null === $this->results) { $this->performAndProcessSearch(); } return $this->results; @@ -395,7 +395,7 @@ abstract class Results // This data is not available until \VuFind\Db\Table\Search::saveSearch() // is called... blow up if somebody tries to get data that is not yet // available. - if (is_null($this->savedSearch)) { + if (null === $this->savedSearch) { throw new \Exception( 'Cannot retrieve save status before updateSaveStatus is called.' ); @@ -450,7 +450,7 @@ abstract class Results */ public function getQuerySpeed() { - if (is_null($this->queryTime)) { + if (null === $this->queryTime) { $this->performAndProcessSearch(); } return $this->queryTime; @@ -463,7 +463,7 @@ abstract class Results */ public function getStartTime() { - if (is_null($this->queryStartTime)) { + if (null === $this->queryStartTime) { $this->performAndProcessSearch(); } return $this->queryStartTime; @@ -500,7 +500,7 @@ abstract class Results */ public function getRawSuggestions() { - if (is_null($this->suggestions)) { + if (null === $this->suggestions) { $this->performAndProcessSearch(); } return $this->suggestions; diff --git a/module/VuFind/src/VuFind/Search/Favorites/Results.php b/module/VuFind/src/VuFind/Search/Favorites/Results.php index 185c90d792d..0b8ae6de3f5 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Results.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Results.php @@ -109,12 +109,12 @@ class Results extends BaseResults public function getFacetList($filter = null) { // Make sure we have processed the search before proceeding: - if (is_null($this->user)) { + if (null === $this->user) { $this->performAndProcessSearch(); } // If there is no filter, we'll use all facets as the filter: - if (is_null($filter)) { + if (null === $filter) { $filter = $this->getParams()->getFacetConfig(); } @@ -170,12 +170,12 @@ class Results extends BaseResults // Make sure the user and/or list objects make it possible to view // the current result set -- we need to check logged in status and // list permissions. - if (is_null($list) && !$this->user) { + if (null === $list && !$this->user) { throw new ListPermissionException( 'Cannot retrieve favorites without logged in user.' ); } - if (!is_null($list) && !$list->public + if (null !== $list && !$list->public && (!$this->user || $list->user_id != $this->user->id) ) { throw new ListPermissionException( @@ -184,8 +184,8 @@ class Results extends BaseResults } // How many results were there? - $userId = is_null($list) ? $this->user->id : $list->user_id; - $listId = is_null($list) ? null : $list->id; + $userId = null === $list ? $this->user->id : $list->user_id; + $listId = null === $list ? null : $list->id; $rawResults = $this->resourceTable->getFavorites( $userId, $listId, $this->getTagFilters(), $this->getParams()->getSort() ); diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index 5af51e0f2d8..ad13f42a148 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -232,7 +232,7 @@ class Results extends \VuFind\Search\Base\Results } // If there is no filter, we'll use all facets as the filter: - if (is_null($filter)) { + if (null === $filter) { $filter = $this->getParams()->getFacetConfig(); } diff --git a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php index 93475648ccc..d0c1c3abe9d 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php @@ -50,7 +50,7 @@ class Params extends \VuFind\Search\Solr\Params { // If no lookfor parameter was found, we have no search terms to // add to our array! - if (is_null($lookfor = $request->get('author'))) { + if (null === ($lookfor = $request->get('author'))) { return false; } diff --git a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php index 00b8ffd9152..525984c55a7 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php @@ -76,7 +76,7 @@ class Params extends \VuFind\Search\Solr\Params { // If no lookfor parameter was found, we have no search terms to // add to our array! - if (is_null($lookfor = $request->get('lookfor'))) { + if (null === ($lookfor = $request->get('lookfor'))) { return false; } diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php index 2fdaecd7ca2..4397b7b3b6a 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Results.php +++ b/module/VuFind/src/VuFind/Search/Summon/Results.php @@ -131,7 +131,7 @@ class Results extends \VuFind\Search\Base\Results } // If there is no filter, we'll use all facets as the filter: - $filter = is_null($filter) + $filter = null === $filter ? $this->getParams()->getFacetConfig() : $this->stripFilterParameters($filter); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Context.php b/module/VuFind/src/VuFind/View/Helper/Root/Context.php index 110d027b6fb..c32b528caac 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Context.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Context.php @@ -77,7 +77,7 @@ class Context extends AbstractHelper $view = $this->getView(); foreach ($vars as $k => $v) { - if (is_null($v)) { + if (null === $v) { unset($view->$k); } else { $view->$k = $v; @@ -113,7 +113,7 @@ class Context extends AbstractHelper */ public function __invoke(RendererInterface $view = null) { - if (!is_null($view)) { + if (null !== $view) { $this->setView($view); } return $this; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Record.php b/module/VuFind/src/VuFind/View/Helper/Root/Record.php index db7143eac4e..bb9cb38d76b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Record.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Record.php @@ -105,7 +105,7 @@ class Record extends AbstractHelper public function renderTemplate($name, $context = null) { // Set default context if none provided: - if (is_null($context)) { + if (null === $context) { $context = ['driver' => $this->driver]; } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php index a8665fa27f9..83a074f9fd2 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php @@ -107,7 +107,7 @@ class ResultFeed extends AbstractHelper implements TranslatorAwareInterface public function __invoke($results, $currentPath = null) { // Determine base URL if not already provided: - if (is_null($currentPath)) { + if (null === $currentPath) { $currentPath = $this->getView()->plugin('currentpath')->__invoke(); } $serverUrl = $this->getView()->plugin('serverurl'); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php index 2b5b034b30d..5ab7e0c7e8b 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CallnumberBrowseTest.php @@ -169,7 +169,7 @@ class CallnumberBrowseTest extends \VuFindTest\Unit\MinkTestCase // - test multiple // else } else { - $this->assertTrue(is_null($link)); + $this->assertTrue(null === $link); } } @@ -188,7 +188,7 @@ class CallnumberBrowseTest extends \VuFindTest\Unit\MinkTestCase $page = $this->performSearch('id:' . $this->id); // No link $link = $page->find('css', '.callnumber a,.groupCallnumber a,.fullCallnumber a'); - $this->assertTrue(is_null($link)); + $this->assertTrue(null === $link); // With dewey links $this->activateAndTestLinks('dewey', $page, $expectLinks); // With lcc links diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php index 447b0cef037..9ea1fd38bda 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php @@ -86,7 +86,7 @@ class TagsController extends AbstractAdmin $view = $this->createViewModel(); $view->setTemplate('admin/tags/manage'); - $view->type = !is_null($this->params()->fromPost('type', null)) + $view->type = null !== $this->params()->fromPost('type', null) ? $this->params()->fromPost('type') : $this->params()->fromQuery('type', null); $view->uniqueTags = $this->getUniqueTags()->toArray(); @@ -147,8 +147,8 @@ class TagsController extends AbstractAdmin // Delete All if ("manage" == $origin - || !is_null($this->getRequest()->getPost('deleteFilter')) - || !is_null($this->getRequest()->getQuery('deleteFilter')) + || null !== $this->getRequest()->getPost('deleteFilter') + || null !== $this->getRequest()->getQuery('deleteFilter') ) { if (false === $confirm) { return $this->confirmTagsDeleteByFilter($tags, $originUrl, $newUrl); @@ -157,7 +157,7 @@ class TagsController extends AbstractAdmin } else { // Delete by ID // Fail if we have nothing to delete: - $ids = is_null($this->getRequest()->getPost('deletePage')) + $ids = null === $this->getRequest()->getPost('deletePage') ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php index ac09fd37403..a151125fbb6 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php @@ -128,10 +128,10 @@ class Connector implements \Zend\Log\LoggerAwareInterface { $options = ['operation' => 'scan', 'scanClause' => $clause]; - if (!is_null($pos)) { + if (null !== $pos) { $options['responsePosition'] = $pos; } - if (!is_null($maxTerms)) { + if (null !== $maxTerms) { $options['maximumTerms'] = $maxTerms; } @@ -160,10 +160,10 @@ class Connector implements \Zend\Log\LoggerAwareInterface 'query' => $query, 'startRecord' => ($start) ? $start : 1, 'recordSchema' => $schema]; - if (!is_null($limit)) { + if (null !== $limit) { $options['maximumRecords'] = $limit; } - if (!is_null($sortBy)) { + if (null !== $sortBy) { $options['sortKeys'] = $sortBy; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php index 41b97b9eac8..c38383aee5b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php @@ -456,7 +456,7 @@ class SearchHandler ')'; // ...and add a weight if we have one $weight = $sw[1]; - if (!is_null($weight) && $weight && $weight > 0) { + if (null !== $weight && $weight && $weight > 0) { $sstring .= '^' . $weight; } // push it onto the stack of clauses @@ -470,7 +470,7 @@ class SearchHandler // Add the weight if we have one. Yes, I know, it's redundant // code. $weight = $spec[1]; - if (!is_null($weight) && $weight && $weight > 0) { + if (null !== $weight && $weight && $weight > 0) { $sstring .= '^' . $weight; } // ..and push it on the stack of clauses diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/ImageLink.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/ImageLink.php index 6d7c8004dcf..dd7027b3841 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/ImageLink.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/ImageLink.php @@ -68,7 +68,7 @@ class ImageLink extends \Zend\View\Helper\AbstractHelper $relPath = 'images/' . $image; $currentTheme = $this->themeInfo->findContainingTheme($relPath); - if (is_null($currentTheme)) { + if (null === $currentTheme) { return null; } diff --git a/tests/vufind.php_cs b/tests/vufind.php_cs index 0c17650db1c..aff0b9e402c 100644 --- a/tests/vufind.php_cs +++ b/tests/vufind.php_cs @@ -20,6 +20,7 @@ $rules = [ 'function_declaration' => true, 'function_typehint_space' => true, 'indentation_type' => true, + 'is_null' => true, 'line_ending' => true, 'linebreak_after_opening_tag' => true, 'lowercase_cast' => true, diff --git a/tests/vufind_templates.php_cs b/tests/vufind_templates.php_cs index 1fae1b0cea2..3e492046281 100644 --- a/tests/vufind_templates.php_cs +++ b/tests/vufind_templates.php_cs @@ -20,6 +20,7 @@ $rules = [ 'function_declaration' => true, 'function_typehint_space' => true, 'indentation_type' => true, + 'is_null' => true, 'line_ending' => true, 'lowercase_cast' => true, 'lowercase_constants' => true, diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml index 620faf92859..233050c58a1 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml @@ -167,7 +167,7 @@ </div> <div class="result-links hidden-print"> - <i class="fa fa-fw fa-edit" aria-hidden="true"></i> <a href="<?=$this->url('myresearch-edit')?>?id=<?=urlencode($id)?>&source=<?=urlencode($source)?><? if (!is_null($list_id)):?>&list_id=<?=urlencode($list_id)?><? endif; ?>" class="edit tool"><?=$this->transEsc('Edit')?></a><br/> + <i class="fa fa-fw fa-edit" aria-hidden="true"></i> <a href="<?=$this->url('myresearch-edit')?>?id=<?=urlencode($id)?>&source=<?=urlencode($source)?><? if (null !== $list_id):?>&list_id=<?=urlencode($list_id)?><? endif; ?>" class="edit tool"><?=$this->transEsc('Edit')?></a><br/> <? /* Use a different delete URL if we're removing from a specific list or the overall favorites: */ $deleteUrl = null === $list_id ? $this->url('myresearch-favorites') diff --git a/themes/bootstrap3/templates/admin/tags/list.phtml b/themes/bootstrap3/templates/admin/tags/list.phtml index 138bcb5c7e5..deab9563c27 100644 --- a/themes/bootstrap3/templates/admin/tags/list.phtml +++ b/themes/bootstrap3/templates/admin/tags/list.phtml @@ -49,7 +49,7 @@ </label> <label for="taglistsubmit"> <input type="submit" id="taglistsubmit" value="<?=$this->transEsc('Filter')?>" class="btn btn-primary"> - <? if((isset($this->params['user_id']) && !is_null($this->params['user_id'])) || (isset($this->params['tag_id']) && !is_null($this->params['tag_id'])) || (isset($this->params['resource_id']) && !is_null($this->params['resource_id']))):?> + <? if((isset($this->params['user_id']) && null !== $this->params['user_id']) || (isset($this->params['tag_id']) && null !== $this->params['tag_id']) || (isset($this->params['resource_id']) && null !== $this->params['resource_id'])):?> <a href="<?= $this->url('admin/tags', ['action' => 'List']); ?>"><?=$this->translate('clear_tag_filter')?></a> <? endif;?> </label> diff --git a/themes/bootstrap3/templates/myresearch/bulk-action-buttons.phtml b/themes/bootstrap3/templates/myresearch/bulk-action-buttons.phtml index 26a447a4cc6..22df8cfc089 100644 --- a/themes/bootstrap3/templates/myresearch/bulk-action-buttons.phtml +++ b/themes/bootstrap3/templates/myresearch/bulk-action-buttons.phtml @@ -10,8 +10,8 @@ </div> <div class="btn-group"> <input class="btn btn-default" type="submit" name="email" value="<?=$this->transEsc('Email')?>" title="<?=$this->transEsc('email_selected')?>"/> - <? if ((!is_null($this->list) && $this->list->editAllowed($user)) || is_null($this->list) && $user): ?> - <input class="btn btn-default" id="<?=$this->idPrefix?>delete_list_items_<?=!is_null($this->list) ? $this->escapeHtmlAttr($this->list->id) : ''?>" type="submit" name="delete" value="<?=$this->transEsc('Delete')?>" title="<?=$this->transEsc('delete_selected')?>"/> + <? if ((null !== $this->list && $this->list->editAllowed($user)) || null === $this->list && $user): ?> + <input class="btn btn-default" id="<?=$this->idPrefix?>delete_list_items_<?=null !== $this->list ? $this->escapeHtmlAttr($this->list->id) : ''?>" type="submit" name="delete" value="<?=$this->transEsc('Delete')?>" title="<?=$this->transEsc('delete_selected')?>"/> <? endif; ?> <? $exportOptions = $this->export()->getActiveFormats('bulk'); if (count($exportOptions) > 0): ?> <input class="btn btn-default" type="submit" name="export" value="<?=$this->transEsc('Export')?>" title="<?=$this->transEsc('export_selected')?>"/> diff --git a/themes/bootstrap3/templates/record/taglist.phtml b/themes/bootstrap3/templates/record/taglist.phtml index b0bb61475f9..d0fc1540437 100644 --- a/themes/bootstrap3/templates/record/taglist.phtml +++ b/themes/bootstrap3/templates/record/taglist.phtml @@ -1,7 +1,7 @@ <div class="tagList<?=$loggedin ? ' loggedin' : ''?>"> <? if (count($tagList) > 0): ?> <? foreach ($tagList as $tag): ?> - <? $is_me = isset($tag['is_me']) && !is_null($tag['is_me']) ? $tag['is_me'] : false; ?> + <? $is_me = isset($tag['is_me']) && null !== $tag['is_me'] ? $tag['is_me'] : false; ?> <div class="tag<?=$is_me ? ' selected' : ''?>"> <a href="<?=$this->url('tag-home')?>?lookfor=<?=urlencode($tag['tag'])?>"><?=$this->escapeHtml($tag['tag'])?></a> <? if($loggedin): ?> -- GitLab