From e6a362a2de80debfb8bedbde63982c69bea142c8 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 18 Feb 2015 14:50:05 -0500 Subject: [PATCH] Updated array formatting to short syntax. --- module/VuDL/Module.php | 12 +- module/VuDL/config/module.config.php | 124 +-- .../VuDL/src/VuDL/Connection/AbstractBase.php | 32 +- module/VuDL/src/VuDL/Connection/Fedora.php | 50 +- module/VuDL/src/VuDL/Connection/Manager.php | 4 +- module/VuDL/src/VuDL/Connection/Solr.php | 58 +- .../VuDL/src/VuDL/Controller/AbstractVuDL.php | 4 +- .../src/VuDL/Controller/VudlController.php | 42 +- module/VuDL/src/VuDL/Factory.php | 2 +- module/VuDL/src/VuDL/OutlineGenerator.php | 28 +- .../VuDL/src/VuDL/RecordDriver/SolrVudl.php | 26 +- .../src/VuDL/View/Helper/Bootstrap3/VuDL.php | 8 +- .../VuDLTest/Connection/AbstractBaseTest.php | 8 +- .../src/VuDLTest/Connection/FedoraTest.php | 20 +- .../src/VuDLTest/Connection/ManagerTest.php | 2 +- .../src/VuDLTest/Connection/SolrTest.php | 46 +- module/VuFind/Module.php | 20 +- module/VuFind/config/module.config.php | 652 ++++++------- .../VuFind/src/VuFind/Auth/AbstractBase.php | 6 +- module/VuFind/src/VuFind/Auth/CAS.php | 6 +- module/VuFind/src/VuFind/Auth/ChoiceAuth.php | 6 +- module/VuFind/src/VuFind/Auth/Database.php | 12 +- module/VuFind/src/VuFind/Auth/ILS.php | 12 +- .../src/VuFind/Auth/ILSAuthenticator.php | 2 +- module/VuFind/src/VuFind/Auth/LDAP.php | 8 +- module/VuFind/src/VuFind/Auth/Manager.php | 20 +- module/VuFind/src/VuFind/Auth/MultiAuth.php | 4 +- module/VuFind/src/VuFind/Auth/Shibboleth.php | 6 +- .../VuFind/src/VuFind/Autocomplete/None.php | 2 +- .../VuFind/Autocomplete/OCLCIdentities.php | 2 +- .../src/VuFind/Autocomplete/PluginManager.php | 4 +- .../VuFind/src/VuFind/Autocomplete/Solr.php | 8 +- .../VuFind/src/VuFind/Autocomplete/SolrCN.php | 6 +- module/VuFind/src/VuFind/Autocomplete/Tag.php | 2 +- module/VuFind/src/VuFind/Bootstrapper.php | 14 +- module/VuFind/src/VuFind/Cache/Manager.php | 22 +- module/VuFind/src/VuFind/Cart.php | 16 +- .../src/VuFind/Config/PluginFactory.php | 6 +- .../src/VuFind/Config/SearchSpecsReader.php | 4 +- module/VuFind/src/VuFind/Config/Upgrade.php | 76 +- module/VuFind/src/VuFind/Config/Writer.php | 6 +- .../src/VuFind/Connection/OpenLibrary.php | 6 +- .../VuFind/src/VuFind/Connection/Oracle.php | 22 +- .../src/VuFind/Connection/Wikipedia.php | 26 +- .../src/VuFind/Connection/WorldCatUtils.php | 32 +- .../src/VuFind/Content/AbstractSyndetics.php | 2 +- .../VuFind/Content/AuthorNotes/Syndetics.php | 10 +- .../src/VuFind/Content/Covers/Amazon.php | 4 +- .../src/VuFind/Content/Covers/Factory.php | 2 +- .../src/VuFind/Content/Covers/Google.php | 4 +- .../src/VuFind/Content/Excerpts/Syndetics.php | 10 +- module/VuFind/src/VuFind/Content/Loader.php | 2 +- .../src/VuFind/Content/Reviews/Amazon.php | 14 +- .../Content/Reviews/AmazonEditorial.php | 8 +- .../src/VuFind/Content/Reviews/Booksite.php | 2 +- .../src/VuFind/Content/Reviews/Guardian.php | 4 +- .../src/VuFind/Content/Reviews/Syndetics.php | 50 +- .../src/VuFind/Controller/AbstractBase.php | 38 +- .../src/VuFind/Controller/AbstractRecord.php | 20 +- .../src/VuFind/Controller/AbstractSearch.php | 34 +- .../src/VuFind/Controller/AjaxController.php | 160 ++-- .../Controller/AlphabrowseController.php | 14 +- .../VuFind/Controller/AuthorityController.php | 2 +- .../VuFind/Controller/BrowseController.php | 104 +-- .../src/VuFind/Controller/CartController.php | 24 +- .../Controller/CollectionsController.php | 16 +- .../VuFind/Controller/CombinedController.php | 16 +- .../VuFind/Controller/ConfirmController.php | 4 +- .../src/VuFind/Controller/EdsController.php | 4 +- .../src/VuFind/Controller/HelpController.php | 2 +- .../VuFind/Controller/HierarchyController.php | 10 +- .../VuFind/Controller/InstallController.php | 56 +- .../Controller/MyResearchController.php | 80 +- .../Controller/Plugin/AbstractRequestBase.php | 12 +- .../VuFind/Controller/Plugin/DbUpgrade.php | 34 +- .../src/VuFind/Controller/Plugin/Factory.php | 2 +- .../VuFind/Controller/Plugin/Favorites.php | 6 +- .../src/VuFind/Controller/Plugin/Followup.php | 2 +- .../src/VuFind/Controller/Plugin/Holds.php | 16 +- .../VuFind/Controller/Plugin/ILLRequests.php | 16 +- .../src/VuFind/Controller/Plugin/NewItems.php | 16 +- .../VuFind/Controller/Plugin/Recaptcha.php | 4 +- .../src/VuFind/Controller/Plugin/Renewals.php | 6 +- .../src/VuFind/Controller/Plugin/Reserves.php | 6 +- .../Controller/Plugin/ResultScroller.php | 6 +- .../Plugin/StorageRetrievalRequests.php | 16 +- .../VuFind/Controller/QRCodeController.php | 4 +- .../VuFind/Controller/RecordController.php | 48 +- .../VuFind/Controller/RecordsController.php | 2 +- .../VuFind/Controller/SearchController.php | 42 +- .../VuFind/Controller/SummonController.php | 8 +- .../Controller/SummonrecordController.php | 2 +- .../VuFind/Controller/UpgradeController.php | 22 +- module/VuFind/src/VuFind/Cookie/Container.php | 2 +- module/VuFind/src/VuFind/Cover/Generator.php | 10 +- module/VuFind/src/VuFind/Cover/Loader.php | 8 +- module/VuFind/src/VuFind/Crypt/RC4.php | 2 +- module/VuFind/src/VuFind/Date/Converter.php | 10 +- .../VuFind/src/VuFind/Db/AdapterFactory.php | 6 +- .../src/VuFind/Db/Row/ChangeTracker.php | 2 +- .../src/VuFind/Db/Row/OaiResumption.php | 4 +- module/VuFind/src/VuFind/Db/Row/Tags.php | 12 +- module/VuFind/src/VuFind/Db/Row/User.php | 46 +- module/VuFind/src/VuFind/Db/Row/UserList.php | 6 +- .../src/VuFind/Db/Table/ChangeTracker.php | 2 +- .../VuFind/src/VuFind/Db/Table/Comments.php | 22 +- .../src/VuFind/Db/Table/OaiResumption.php | 2 +- .../VuFind/src/VuFind/Db/Table/Resource.php | 26 +- .../src/VuFind/Db/Table/ResourceTags.php | 70 +- module/VuFind/src/VuFind/Db/Table/Search.php | 10 +- module/VuFind/src/VuFind/Db/Table/Session.php | 2 +- module/VuFind/src/VuFind/Db/Table/Tags.php | 62 +- module/VuFind/src/VuFind/Db/Table/User.php | 6 +- .../VuFind/src/VuFind/Db/Table/UserList.php | 18 +- .../src/VuFind/Db/Table/UserResource.php | 38 +- .../VuFind/src/VuFind/Db/Table/UserStats.php | 22 +- .../src/VuFind/Db/Table/UserStatsFields.php | 14 +- module/VuFind/src/VuFind/Export.php | 18 +- .../Writer/Extension/DublinCore/Entry.php | 2 +- module/VuFind/src/VuFind/Harvester/OAI.php | 36 +- .../VuFind/Hierarchy/Driver/AbstractBase.php | 2 +- .../Hierarchy/Driver/ConfigurationBased.php | 2 +- .../src/VuFind/Hierarchy/Driver/Factory.php | 4 +- .../Hierarchy/TreeDataSource/AbstractBase.php | 2 +- .../Hierarchy/TreeDataSource/Factory.php | 2 +- .../VuFind/Hierarchy/TreeDataSource/Solr.php | 30 +- .../Hierarchy/TreeDataSource/XMLFile.php | 2 +- .../VuFind/Hierarchy/TreeRenderer/JSTree.php | 36 +- .../I18n/Translator/Loader/ExtendedIni.php | 8 +- .../I18n/Translator/TranslatorAwareTrait.php | 4 +- module/VuFind/src/VuFind/ILS/Connection.php | 86 +- .../src/VuFind/ILS/Driver/AbstractBase.php | 2 +- module/VuFind/src/VuFind/ILS/Driver/Aleph.php | 200 ++-- .../VuFind/src/VuFind/ILS/Driver/Amicus.php | 78 +- .../src/VuFind/ILS/Driver/ClaviusSQL.php | 68 +- module/VuFind/src/VuFind/ILS/Driver/DAIA.php | 28 +- module/VuFind/src/VuFind/ILS/Driver/Demo.php | 284 +++--- .../src/VuFind/ILS/Driver/Evergreen.php | 54 +- .../VuFind/src/VuFind/ILS/Driver/Horizon.php | 156 ++-- .../src/VuFind/ILS/Driver/HorizonXMLAPI.php | 146 +-- .../src/VuFind/ILS/Driver/Innovative.php | 16 +- module/VuFind/src/VuFind/ILS/Driver/Koha.php | 58 +- module/VuFind/src/VuFind/ILS/Driver/LBS4.php | 54 +- .../src/VuFind/ILS/Driver/MultiBackend.php | 70 +- .../src/VuFind/ILS/Driver/NewGenLib.php | 50 +- module/VuFind/src/VuFind/ILS/Driver/NoILS.php | 40 +- module/VuFind/src/VuFind/ILS/Driver/PICA.php | 72 +- .../VuFind/src/VuFind/ILS/Driver/Polaris.php | 42 +- .../VuFind/src/VuFind/ILS/Driver/Sample.php | 16 +- .../VuFind/src/VuFind/ILS/Driver/Sierra.php | 44 +- .../VuFind/src/VuFind/ILS/Driver/Symphony.php | 274 +++--- .../VuFind/src/VuFind/ILS/Driver/Unicorn.php | 196 ++-- .../VuFind/src/VuFind/ILS/Driver/Virtua.php | 216 ++--- .../VuFind/src/VuFind/ILS/Driver/Voyager.php | 294 +++--- .../src/VuFind/ILS/Driver/VoyagerRestful.php | 378 ++++---- .../VuFind/src/VuFind/ILS/Driver/XCNCIP2.php | 164 ++-- module/VuFind/src/VuFind/ILS/Logic/Holds.php | 34 +- .../src/VuFind/ILS/Logic/TitleHolds.php | 16 +- module/VuFind/src/VuFind/ImageLoader.php | 8 +- module/VuFind/src/VuFind/Log/Logger.php | 18 +- module/VuFind/src/VuFind/Mailer/Factory.php | 8 +- module/VuFind/src/VuFind/Mailer/Mailer.php | 8 +- module/VuFind/src/VuFind/OAI/Server.php | 24 +- module/VuFind/src/VuFind/QRCode/Loader.php | 6 +- .../src/VuFind/Recommend/AbstractFacets.php | 4 +- .../src/VuFind/Recommend/AuthorFacets.php | 10 +- .../VuFind/Recommend/AuthorityRecommend.php | 24 +- .../VuFind/src/VuFind/Recommend/DPLATerms.php | 22 +- .../src/VuFind/Recommend/EuropeanaResults.php | 12 +- .../src/VuFind/Recommend/ExpandFacets.php | 2 +- .../src/VuFind/Recommend/FacetCloud.php | 4 +- .../src/VuFind/Recommend/FavoriteFacets.php | 2 +- .../VuFind/Recommend/OpenLibrarySubjects.php | 10 +- .../Recommend/OpenLibrarySubjectsDeferred.php | 2 +- .../src/VuFind/Recommend/PubDateVisAjax.php | 10 +- .../src/VuFind/Recommend/RandomRecommend.php | 6 +- .../src/VuFind/Recommend/SideFacets.php | 40 +- .../src/VuFind/Recommend/SwitchQuery.php | 14 +- .../VuFind/src/VuFind/Recommend/TopFacets.php | 6 +- .../src/VuFind/Recommend/VisualFacets.php | 4 +- .../src/VuFind/Recommend/WorldCatTerms.php | 2 +- module/VuFind/src/VuFind/Record/Loader.php | 12 +- module/VuFind/src/VuFind/Record/Router.php | 10 +- .../src/VuFind/RecordDriver/AbstractBase.php | 22 +- module/VuFind/src/VuFind/RecordDriver/EDS.php | 24 +- module/VuFind/src/VuFind/RecordDriver/EIT.php | 36 +- .../src/VuFind/RecordDriver/Pazpar2.php | 28 +- .../src/VuFind/RecordDriver/PluginManager.php | 4 +- .../VuFind/src/VuFind/RecordDriver/Primo.php | 24 +- .../Response/PublicationDetails.php | 2 +- .../src/VuFind/RecordDriver/SolrAuth.php | 6 +- .../src/VuFind/RecordDriver/SolrDefault.php | 128 +-- .../src/VuFind/RecordDriver/SolrMarc.php | 114 +-- .../src/VuFind/RecordDriver/SolrReserves.php | 2 +- .../src/VuFind/RecordDriver/SolrWeb.php | 2 +- .../VuFind/src/VuFind/RecordDriver/Summon.php | 70 +- .../src/VuFind/RecordDriver/WorldCat.php | 32 +- .../src/VuFind/RecordTab/AbstractContent.php | 2 +- .../src/VuFind/RecordTab/HierarchyTree.php | 2 +- .../src/VuFind/RecordTab/HoldingsILS.php | 2 +- module/VuFind/src/VuFind/RecordTab/Map.php | 10 +- .../src/VuFind/RecordTab/PluginManager.php | 4 +- .../VuFind/RecordTab/SimilarItemsCarousel.php | 2 +- module/VuFind/src/VuFind/Related/Editions.php | 4 +- .../src/VuFind/Related/WorldCatEditions.php | 2 +- .../src/VuFind/Related/WorldCatSimilar.php | 2 +- .../VuFind/src/VuFind/Reserves/CsvReader.php | 14 +- .../VuFind/src/VuFind/Resolver/Connection.php | 2 +- .../VuFind/src/VuFind/Resolver/Driver/Ezb.php | 10 +- .../VuFind/src/VuFind/Resolver/Driver/Sfx.php | 4 +- .../VuFind/Resolver/Driver/Threesixtylink.php | 4 +- .../src/VuFind/Role/DynamicRoleProvider.php | 4 +- .../Role/PermissionProvider/IpRange.php | 2 +- module/VuFind/src/VuFind/SMS/AbstractBase.php | 2 +- module/VuFind/src/VuFind/SMS/Clickatell.php | 8 +- module/VuFind/src/VuFind/SMS/Factory.php | 4 +- module/VuFind/src/VuFind/SMS/Mailer.php | 26 +- .../src/VuFind/Search/BackendManager.php | 2 +- .../VuFind/src/VuFind/Search/Base/Options.php | 22 +- .../VuFind/src/VuFind/Search/Base/Params.php | 104 +-- .../VuFind/src/VuFind/Search/Base/Results.php | 8 +- .../src/VuFind/Search/Combined/Params.php | 4 +- .../src/VuFind/Search/Combined/Results.php | 2 +- .../VuFind/src/VuFind/Search/EDS/Options.php | 64 +- .../VuFind/src/VuFind/Search/EDS/Params.php | 20 +- .../src/VuFind/Search/EDS/QueryAdapter.php | 2 +- .../VuFind/src/VuFind/Search/EDS/Results.php | 12 +- .../VuFind/src/VuFind/Search/EIT/Results.php | 2 +- .../src/VuFind/Search/EmptySet/Results.php | 2 +- .../Factory/AbstractSolrBackendFactory.php | 24 +- .../Search/Factory/EdsBackendFactory.php | 4 +- .../Factory/LibGuidesBackendFactory.php | 2 +- .../Search/Factory/PrimoBackendFactory.php | 6 +- .../Factory/SolrDefaultBackendFactory.php | 2 +- .../Search/Factory/SummonBackendFactory.php | 4 +- .../src/VuFind/Search/Favorites/Options.php | 4 +- .../src/VuFind/Search/Favorites/Params.php | 2 +- .../src/VuFind/Search/Favorites/Results.php | 26 +- .../src/VuFind/Search/LibGuides/Results.php | 2 +- module/VuFind/src/VuFind/Search/Minified.php | 4 +- .../src/VuFind/Search/MixedList/Params.php | 4 +- .../src/VuFind/Search/MixedList/Results.php | 2 +- .../src/VuFind/Search/Pazpar2/Options.php | 4 +- .../src/VuFind/Search/Pazpar2/Results.php | 2 +- .../src/VuFind/Search/Primo/Options.php | 2 +- .../src/VuFind/Search/Primo/Results.php | 12 +- .../VuFind/src/VuFind/Search/QueryAdapter.php | 30 +- .../Search/Solr/AbstractErrorListener.php | 2 +- .../Search/Solr/DeduplicationListener.php | 14 +- .../Search/Solr/HierarchicalFacetHelper.php | 10 +- .../Search/Solr/HierarchicalFacetListener.php | 12 +- .../Solr/InjectHighlightingListener.php | 4 +- .../Search/Solr/InjectSpellingListener.php | 4 +- .../VuFind/Search/Solr/MultiIndexListener.php | 18 +- .../VuFind/src/VuFind/Search/Solr/Options.php | 16 +- .../VuFind/src/VuFind/Search/Solr/Params.php | 26 +- .../VuFind/src/VuFind/Search/Solr/Results.php | 12 +- .../VuFind/Search/Solr/SpellingProcessor.php | 20 +- .../VuFind/Search/Solr/V4/ErrorListener.php | 2 +- .../src/VuFind/Search/SolrAuthor/Params.php | 6 +- .../Search/SolrAuthorFacets/Options.php | 4 +- .../VuFind/Search/SolrAuthorFacets/Params.php | 4 +- .../Search/SolrAuthorFacets/Results.php | 2 +- .../VuFind/Search/SolrCollection/Options.php | 6 +- .../VuFind/Search/SolrCollection/Params.php | 2 +- .../src/VuFind/Search/Summon/Options.php | 4 +- .../src/VuFind/Search/Summon/Params.php | 10 +- .../src/VuFind/Search/Summon/Results.php | 26 +- .../VuFind/src/VuFind/Search/Tags/Options.php | 6 +- .../VuFind/src/VuFind/Search/Tags/Params.php | 2 +- .../VuFind/src/VuFind/Search/Tags/Results.php | 8 +- .../src/VuFind/Search/UrlQueryHelper.php | 18 +- .../src/VuFind/Search/WorldCat/Results.php | 2 +- module/VuFind/src/VuFind/Service/Factory.php | 14 +- .../ServiceManager/AbstractPluginManager.php | 2 +- .../src/VuFind/Sitemap/AbstractFile.php | 2 +- .../VuFind/src/VuFind/Sitemap/Generator.php | 16 +- module/VuFind/src/VuFind/Solr/Utils.php | 8 +- .../src/VuFind/Statistics/AbstractBase.php | 6 +- .../VuFind/Statistics/Driver/AbstractBase.php | 6 +- .../src/VuFind/Statistics/Driver/Db.php | 2 +- .../src/VuFind/Statistics/Driver/Solr.php | 16 +- .../VuFind/src/VuFind/Statistics/Record.php | 22 +- .../VuFind/src/VuFind/Statistics/Search.php | 24 +- module/VuFind/src/VuFind/Tags.php | 2 +- .../VuFind/View/Helper/Root/AddEllipsis.php | 2 +- .../src/VuFind/View/Helper/Root/Auth.php | 14 +- .../src/VuFind/View/Helper/Root/Citation.php | 38 +- .../src/VuFind/View/Helper/Root/Context.php | 2 +- .../src/VuFind/View/Helper/Root/DateTime.php | 8 +- .../src/VuFind/View/Helper/Root/Factory.php | 6 +- .../VuFind/View/Helper/Root/Flashmessages.php | 4 +- .../src/VuFind/View/Helper/Root/HelpText.php | 6 +- .../src/VuFind/View/Helper/Root/Highlight.php | 8 +- .../View/Helper/Root/JqueryValidation.php | 8 +- .../View/Helper/Root/JsTranslations.php | 4 +- .../View/Helper/Root/LocalizedNumber.php | 4 +- .../src/VuFind/View/Helper/Root/OpenUrl.php | 4 +- .../src/VuFind/View/Helper/Root/Piwik.php | 16 +- .../src/VuFind/View/Helper/Root/Recaptcha.php | 4 +- .../src/VuFind/View/Helper/Root/Recommend.php | 2 +- .../src/VuFind/View/Helper/Root/Record.php | 42 +- .../src/VuFind/View/Helper/Root/Related.php | 2 +- .../VuFind/View/Helper/Root/RenderArray.php | 4 +- .../VuFind/View/Helper/Root/ResultFeed.php | 2 +- .../src/VuFind/View/Helper/Root/SearchBox.php | 30 +- .../VuFind/View/Helper/Root/SearchTabs.php | 18 +- .../VuFind/View/Helper/Root/SortFacetList.php | 2 +- .../src/VuFind/View/Helper/Root/TransEsc.php | 2 +- .../src/VuFind/View/Helper/Root/Translate.php | 2 +- .../View/Helper/jQueryMobile/MobileMenu.php | 4 +- .../VuFind/src/VuFind/XSLT/Import/VuFind.php | 24 +- .../src/VuFind/XSLT/Import/VuFindSitemap.php | 24 +- module/VuFind/src/VuFind/XSLT/Importer.php | 4 +- module/VuFind/src/VuFind/XSLT/Processor.php | 2 +- .../VuFindTest/RecordDriver/TestHarness.php | 4 +- .../VuFindTest/Search/TestHarness/Results.php | 8 +- .../VuFind/src/VuFindTest/Unit/DbTestCase.php | 42 +- .../src/VuFindTest/Unit/MinkTestCase.php | 2 +- .../Unit/RecommendDeferredTestCase.php | 2 +- .../VuFind/src/VuFindTest/Unit/TestCase.php | 52 +- .../VuFindTest/Unit/ViewHelperTestCase.php | 6 +- module/VuFind/tests/bootstrap.php | 2 +- .../src/VuFindTest/Auth/DatabaseTest.php | 32 +- .../src/VuFindTest/Auth/ILSTest.php | 20 +- .../src/VuFindTest/Auth/ShibbolethTest.php | 16 +- .../VuFindTest/Db/Table/ChangeTrackerTest.php | 2 +- .../VuFindTest/Mink/AdvancedSearchTest.php | 2 +- .../src/VuFindTest/Mink/CartTest.php | 2 +- .../View/Helper/Root/ResultFeedTest.php | 14 +- .../src/VuFindTest/Auth/ChoiceAuthTest.php | 6 +- .../src/VuFindTest/Auth/DatabaseUnitTest.php | 16 +- .../VuFindTest/Auth/ILSAuthenticatorTest.php | 36 +- .../src/VuFindTest/Auth/LDAPTest.php | 20 +- .../src/VuFindTest/Auth/ManagerTest.php | 58 +- .../src/VuFindTest/Auth/MultiAuthTest.php | 22 +- .../src/VuFindTest/Auth/SIP2Test.php | 16 +- .../src/VuFindTest/Autocomplete/TagTest.php | 14 +- .../unit-tests/src/VuFindTest/CartTest.php | 34 +- .../VuFindTest/Config/PluginFactoryTest.php | 4 +- .../Config/Reader/CacheDecoratorTest.php | 14 +- .../Config/SearchSpecsReaderTest.php | 2 +- .../src/VuFindTest/Config/UpgradeTest.php | 20 +- .../src/VuFindTest/Config/WriterTest.php | 32 +- .../VuFindTest/Content/Covers/AmazonTest.php | 16 +- .../Content/Covers/BooksiteTest.php | 4 +- .../Content/Covers/ContentCafeTest.php | 8 +- .../Content/Covers/LibraryThingTest.php | 4 +- .../Content/Covers/OpenLibraryTest.php | 4 +- .../VuFindTest/Content/Covers/SummonTest.php | 4 +- .../Controller/Plugin/FollowupTest.php | 2 +- .../Controller/Plugin/NewItemsTest.php | 52 +- .../Controller/Plugin/ResultScrollerTest.php | 30 +- .../src/VuFindTest/Cookie/ContainerTest.php | 2 +- .../src/VuFindTest/Cover/LoaderTest.php | 18 +- .../src/VuFindTest/Crypt/HMACTest.php | 2 +- .../src/VuFindTest/Date/ConverterTest.php | 4 +- .../unit-tests/src/VuFindTest/ExportTest.php | 100 +- .../src/VuFindTest/Harvester/OAITest.php | 34 +- .../Loader/ExtendedIniReaderTest.php | 6 +- .../Translator/Loader/ExtendedIniTest.php | 40 +- .../ILS/Driver/MultiBackendTest.php | 882 +++++++++--------- .../src/VuFindTest/ILS/Driver/NoILSTest.php | 12 +- .../VuFindTest/ILS/Driver/SymphonyTest.php | 2 +- .../src/VuFindTest/Log/LoggerTest.php | 6 +- .../src/VuFindTest/Mailer/MailerTest.php | 4 +- .../src/VuFindTest/OAI/ServerTest.php | 4 +- .../src/VuFindTest/QRCode/LoaderTest.php | 10 +- .../Recommend/CollectionSideFacetsTest.php | 4 +- .../VuFindTest/Recommend/ExpandFacetsTest.php | 16 +- .../VuFindTest/Recommend/FacetCloudTest.php | 6 +- .../Recommend/FavoriteFacetsTest.php | 6 +- .../Recommend/RandomRecommendTest.php | 6 +- .../VuFindTest/Recommend/SideFacetsTest.php | 178 ++-- .../VuFindTest/Recommend/SwitchQueryTest.php | 26 +- .../Recommend/WorldCatTermsTest.php | 8 +- .../src/VuFindTest/Record/LoaderTest.php | 26 +- .../src/VuFindTest/Record/RouterTest.php | 30 +- .../RecordDriver/SolrDefaultTest.php | 22 +- .../VuFindTest/RecordDriver/SolrMarcTest.php | 12 +- .../src/VuFindTest/Related/SimilarTest.php | 8 +- .../Related/WorldCatSimilarTest.php | 12 +- .../src/VuFindTest/Reserves/CsvReaderTest.php | 28 +- .../src/VuFindTest/SMS/ClickatellTest.php | 16 +- .../VuFindTest/Search/QueryAdapterTest.php | 8 +- .../Solr/HierarchicalFacetHelperTest.php | 32 +- .../Search/Solr/MultiIndexListenerTest.php | 130 +-- .../Search/Solr/SpellingProcessorTest.php | 272 +++--- .../Search/Solr/V3/ErrorListenerTest.php | 4 +- .../Search/Solr/V4/ErrorListenerTest.php | 4 +- .../src/VuFindTest/Solr/UtilsTest.php | 4 +- .../src/VuFindTest/Solr/WriterTest.php | 6 +- .../unit-tests/src/VuFindTest/TagsTest.php | 8 +- .../VuFindTest/View/Helper/Root/CartTest.php | 8 +- .../View/Helper/Root/CitationTest.php | 252 ++--- .../View/Helper/Root/RecordTest.php | 128 +-- .../Helper/jQueryMobile/MobileMenuTest.php | 4 +- module/VuFindAdmin/Module.php | 12 +- module/VuFindAdmin/config/module.config.php | 108 +-- .../Controller/MaintenanceController.php | 2 +- .../Controller/StatisticsController.php | 2 +- .../VuFindAdmin/Controller/TagsController.php | 62 +- .../Controller/SocialstatsControllerTest.php | 8 +- module/VuFindConsole/Module.php | 16 +- module/VuFindConsole/config/module.config.php | 24 +- .../VuFindConsole/Controller/AbstractBase.php | 2 +- .../Controller/GenerateController.php | 2 +- .../Controller/HarvestController.php | 4 +- .../Controller/ImportController.php | 6 +- .../Controller/UtilController.php | 28 +- .../Mvc/Router/ConsoleRouter.php | 4 +- .../tests/unit-tests/bootstrap.php | 12 +- .../Mvc/Router/ConsoleRouterTest.php | 2 +- module/VuFindDevTools/Module.php | 12 +- .../VuFindDevTools/config/module.config.php | 12 +- .../Controller/DevtoolsController.php | 18 +- .../Controller/DevtoolsControllerTest.php | 18 +- module/VuFindLocalTemplate/Module.php | 12 +- .../config/module.config.php | 4 +- module/VuFindSearch/Module.php | 12 +- .../src/VuFindSearch/Backend/EDS/Backend.php | 16 +- .../src/VuFindSearch/Backend/EDS/Base.php | 18 +- .../VuFindSearch/Backend/EDS/Exception.php | 2 +- .../VuFindSearch/Backend/EDS/QueryBuilder.php | 6 +- .../Backend/EDS/Response/RecordCollection.php | 12 +- .../EDS/Response/RecordCollectionFactory.php | 2 +- .../Backend/EDS/SearchRequestModel.php | 16 +- .../src/VuFindSearch/Backend/EDS/Zend2.php | 12 +- .../VuFindSearch/Backend/EIT/Connector.php | 16 +- .../VuFindSearch/Backend/EIT/QueryBuilder.php | 6 +- .../EIT/Response/XML/RecordCollection.php | 2 +- .../Backend/Exception/BackendException.php | 2 +- .../Backend/LibGuides/Backend.php | 4 +- .../Backend/LibGuides/Connector.php | 24 +- .../Backend/LibGuides/QueryBuilder.php | 2 +- .../LibGuides/Response/RecordCollection.php | 2 +- .../VuFindSearch/Backend/Pazpar2/Backend.php | 6 +- .../Backend/Pazpar2/Connector.php | 6 +- .../Pazpar2/Response/RecordCollection.php | 2 +- .../VuFindSearch/Backend/Primo/Backend.php | 6 +- .../VuFindSearch/Backend/Primo/Connector.php | 28 +- .../Backend/Primo/QueryBuilder.php | 4 +- .../Primo/Response/RecordCollection.php | 2 +- .../VuFindSearch/Backend/SRU/Connector.php | 14 +- .../src/VuFindSearch/Backend/Solr/Backend.php | 16 +- .../VuFindSearch/Backend/Solr/Connector.php | 6 +- .../Backend/Solr/Document/DeleteDocument.php | 4 +- .../Backend/Solr/Document/UpdateDocument.php | 4 +- .../VuFindSearch/Backend/Solr/HandlerMap.php | 8 +- .../Backend/Solr/LuceneSyntaxHelper.php | 32 +- .../Backend/Solr/QueryBuilder.php | 8 +- .../Backend/Solr/Response/Json/NamedList.php | 2 +- .../Solr/Response/Json/RecordCollection.php | 20 +- .../Backend/Solr/Response/Json/Spellcheck.php | 2 +- .../Backend/Solr/Response/Json/Terms.php | 2 +- .../Backend/Solr/SearchHandler.php | 30 +- .../VuFindSearch/Backend/Summon/Backend.php | 10 +- .../Backend/Summon/QueryBuilder.php | 4 +- .../Summon/Response/RecordCollection.php | 4 +- .../Backend/WorldCat/Connector.php | 14 +- .../Backend/WorldCat/QueryBuilder.php | 6 +- .../Response/XML/RecordCollection.php | 2 +- .../src/VuFindSearch/ParamBag.php | 12 +- .../src/VuFindSearch/Query/QueryGroup.php | 10 +- .../Response/AbstractRecordCollection.php | 2 +- .../VuFindSearch/src/VuFindSearch/Service.php | 6 +- .../tests/unit-tests/bootstrap.php | 12 +- .../Backend/AbstractHandlerMapTest.php | 14 +- .../VuFindTest/Backend/EDS/BackendTest.php | 30 +- .../Backend/EDS/QueryBuilderTest.php | 6 +- .../EDS/Response/RecordCollectionTest.php | 6 +- .../VuFindTest/Backend/EIT/BackendTest.php | 8 +- .../Backend/EIT/QueryBuilderTest.php | 6 +- .../EIT/Response/XML/RecordCollectionTest.php | 6 +- .../Backend/LibGuides/BackendTest.php | 24 +- .../Backend/LibGuides/QueryBuilderTest.php | 4 +- .../Response/RecordCollectionFactoryTest.php | 2 +- .../Response/RecordCollectionTest.php | 6 +- .../Backend/Pazpar2/BackendTest.php | 10 +- .../VuFindTest/Backend/Primo/BackendTest.php | 20 +- .../Backend/Primo/ConnectorTest.php | 30 +- .../Backend/Primo/QueryBuilderTest.php | 14 +- .../Primo/Response/RecordCollectionTest.php | 4 +- .../VuFindTest/Backend/Solr/BackendTest.php | 30 +- .../VuFindTest/Backend/Solr/ConnectorTest.php | 4 +- .../Solr/Document/DeleteDocumentTest.php | 2 +- .../Solr/Document/UpdateDocumentTest.php | 4 +- .../Backend/Solr/HandlerMapTest.php | 80 +- .../Backend/Solr/LuceneSyntaxHelperTest.php | 92 +- .../Backend/Solr/QueryBuilderTest.php | 188 ++-- .../Solr/Record/SerializableRecordTest.php | 2 +- .../Backend/Solr/Response/Json/FacetsTest.php | 12 +- .../Solr/Response/Json/NamedListTest.php | 12 +- .../Json/RecordCollectionFactoryTest.php | 2 +- .../Response/Json/RecordCollectionTest.php | 76 +- .../Solr/Response/Json/SpellcheckTest.php | 32 +- .../Backend/Solr/Response/Json/TermsTest.php | 10 +- .../Backend/Solr/SearchHandlerTest.php | 58 +- .../VuFindTest/Backend/Summon/BackendTest.php | 28 +- .../Backend/Summon/QueryBuilderTest.php | 8 +- .../Summon/Response/RecordCollectionTest.php | 6 +- .../Backend/WorldCat/BackendTest.php | 8 +- .../Backend/WorldCat/ConnectorTest.php | 4 +- .../Backend/WorldCat/QueryBuilderTest.php | 8 +- .../src/VuFindTest/ParamBagTest.php | 12 +- .../src/VuFindTest/Query/QueryGroupTest.php | 2 +- .../src/VuFindTest/SearchServiceTest.php | 44 +- module/VuFindTheme/Module.php | 32 +- .../src/VuFindTheme/Initializer.php | 10 +- .../src/VuFindTheme/LessCompiler.php | 16 +- .../src/VuFindTheme/ResourceContainer.php | 12 +- .../VuFindTheme/src/VuFindTheme/ThemeInfo.php | 6 +- .../src/VuFindTheme/View/Helper/HeadLink.php | 10 +- .../View/Helper/HeadThemeResources.php | 6 +- .../VuFindTheme/View/Helper/InlineScript.php | 2 +- .../src/VuFindTheme/View/Helper/MobileUrl.php | 2 +- .../tests/unit-tests/bootstrap.php | 12 +- .../fixtures/themes/child/theme.config.php | 4 +- .../fixtures/themes/parent/theme.config.php | 4 +- .../src/VuFindTest/LessCompilerTest.php | 6 +- .../src/VuFindTest/ThemeInfoTest.php | 4 +- .../ThemeInjectTemplateListenerTest.php | 4 +- .../src/VuFindTest/ThemeMobileTest.php | 2 +- .../VuFindTest/ThemeResourceContainerTest.php | 16 +- .../View/Helper/HeadThemeResourcesTest.php | 2 +- 525 files changed, 6458 insertions(+), 6458 deletions(-) diff --git a/module/VuDL/Module.php b/module/VuDL/Module.php index d6d52738d2c..dd97d68c147 100644 --- a/module/VuDL/Module.php +++ b/module/VuDL/Module.php @@ -55,12 +55,12 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } } diff --git a/module/VuDL/config/module.config.php b/module/VuDL/config/module.config.php index ddb4338b66a..fc41092e9d9 100644 --- a/module/VuDL/config/module.config.php +++ b/module/VuDL/config/module.config.php @@ -1,98 +1,98 @@ <?php namespace VuDL\Module\Configuration; -$config = array( - 'controllers' => array( - 'invokables' => array( +$config = [ + 'controllers' => [ + 'invokables' => [ 'vudl' => 'VuDL\Controller\VudlController' - ), - ), - 'service_manager' => array( - 'factories' => array( + ], + ], + 'service_manager' => [ + 'factories' => [ 'VuDL\Connection\Manager' => 'VuDL\Factory::getConnectionManager', 'VuDL\Connection\Fedora' => 'VuDL\Factory::getConnectionFedora', 'VuDL\Connection\Solr' => 'VuDL\Factory::getConnectionSolr', - ), - ), - 'vufind' => array( - 'plugin_managers' => array( - 'recorddriver' => array( - 'factories' => array( + ], + ], + 'vufind' => [ + 'plugin_managers' => [ + 'recorddriver' => [ + 'factories' => [ 'solrvudl' => 'VuDL\Factory::getRecordDriver', - ), - ), - ), - ), - 'router' => array( - 'routes' => array( - 'files' => array( + ], + ], + ], + ], + 'router' => [ + 'routes' => [ + 'files' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/files/:id/:type' - ) - ), - 'vudl-about' => array( + ] + ], + 'vudl-about' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/VuDL/About', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'About', - ) - ) - ), - 'vudl-default-collection' => array( + ] + ] + ], + 'vudl-default-collection' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Collection[/]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'Collections' - ) - ) - ), - 'vudl-grid' => array( + ] + ] + ], + 'vudl-grid' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Grid/:id', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'Grid' - ) - ) - ), - 'vudl-home' => array( + ] + ] + ], + 'vudl-home' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/VuDL/Home[/]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'Home', - ) - ) - ), - 'vudl-record' => array( + ] + ] + ], + 'vudl-record' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Item/:id', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'Record' - ) - ) - ), - 'vudl-sibling' => array( + ] + ] + ], + 'vudl-sibling' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Vudl/Sibling/', - 'defaults' => array( + 'defaults' => [ 'controller' => 'VuDL', 'action' => 'Sibling' - ) - ) - ), - ) - ), -); + ] + ] + ], + ] + ], +]; return $config; diff --git a/module/VuDL/src/VuDL/Connection/AbstractBase.php b/module/VuDL/src/VuDL/Connection/AbstractBase.php index 068da109ee6..7c6b96e2007 100644 --- a/module/VuDL/src/VuDL/Connection/AbstractBase.php +++ b/module/VuDL/src/VuDL/Connection/AbstractBase.php @@ -54,7 +54,7 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface * * @var array */ - protected $parentLists = array(); + protected $parentLists = []; /** * Constructor @@ -87,7 +87,7 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface { return isset($this->config->Details) ? $this->config->Details->toArray() - : array(); + : []; } /** @@ -117,7 +117,7 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface if (empty($detailsList)) { throw new \Exception('Missing [Details] in VuDL.ini'); } - $details = array(); + $details = []; foreach ($detailsList as $key => $title) { $keys = explode(',', $key); $field = false; @@ -132,13 +132,13 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface } if (count($keys) == 1) { if (isset($record[$keys[0]])) { - $details[$field] = array( + $details[$field] = [ 'title' => $title, 'value' => $record[$keys[0]] - ); + ]; } } else { - $value = array(); + $value = []; foreach ($keys as $k) { if (isset($record[$k])) { if (is_array($record[$k])) { @@ -148,10 +148,10 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface } } } - $details[$field] = array( + $details[$field] = [ 'title' => $title, 'value' => $value - ); + ]; } } return $details; @@ -169,13 +169,13 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface protected function traceParents($tree, $id) { // BFS from top (root id) to target $id - $queue = array( - array( + $queue = [ + [ 'id' => $this->getRootId(), - 'path' => array() - ) - ); - $ret = array(); + 'path' => [] + ] + ]; + $ret = []; while (!empty($queue)) { $current = array_shift($queue); $record = $tree[$current['id']]; @@ -190,10 +190,10 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface } else { // Add to queue for more array_push( $queue, - array( + [ 'id' => $cid, 'path' => $path - ) + ] ); } } diff --git a/module/VuDL/src/VuDL/Connection/Fedora.php b/module/VuDL/src/VuDL/Connection/Fedora.php index c3ea24557ce..d3dbc6f2bdd 100644 --- a/module/VuDL/src/VuDL/Connection/Fedora.php +++ b/module/VuDL/src/VuDL/Connection/Fedora.php @@ -45,7 +45,7 @@ class Fedora extends AbstractBase * * @var array */ - protected $datastreams = array(); + protected $datastreams = []; /** * Get Fedora Base URL. @@ -69,7 +69,7 @@ class Fedora extends AbstractBase public function getClasses($id) { $data = $this->getDatastreamContent($id, 'RELS-EXT'); - $matches = array(); + $matches = []; preg_match_all( '/rdf:resource="info:fedora\/vudl-system:([^"]+)/', $data, @@ -146,13 +146,13 @@ class Fedora extends AbstractBase */ public function getDetails($id, $format = false) { - $dc = array(); + $dc = []; preg_match_all( '/<[^\/]*dc:([^ >]+)>([^<]+)/', $this->getDatastreamContent($id, 'DC'), $dc ); - $details = array(); + $details = []; foreach ($dc[2] as $i => $detail) { $details[$dc[1][$i]] = $detail; } @@ -210,7 +210,7 @@ class Fedora extends AbstractBase . 'and $member <dc:identifier> $memberPID'; $response = $this->query($query); $list = explode("\n", $response->getBody()); - $items = array(); + $items = []; for ($i = 1;$i<count($list);$i++) { if (empty($list[$i])) { continue; @@ -259,7 +259,7 @@ class Fedora extends AbstractBase $response = $this->query($query); $list = explode("\n", $response->getBody()); if (count($list) > 2) { - $items = array(); + $items = []; $sequenced = true; for ($i = 1;$i<count($list);$i++) { if (empty($list[$i])) { @@ -271,10 +271,10 @@ class Fedora extends AbstractBase $sequenced = false; break; } - $items[] = array( + $items[] = [ 'seq' => $seq, 'id' => $id - ); + ]; } if ($sequenced) { usort( @@ -300,7 +300,7 @@ class Fedora extends AbstractBase . 'order by $memberTitle'; $response = $this->query($query); $list = explode("\n", $response->getBody()); - $items = array(); + $items = []; for ($i = 1;$i<count($list);$i++) { if (empty($list[$i])) { continue; @@ -334,15 +334,15 @@ class Fedora extends AbstractBase // Parse out relationships $response = $this->query($query); $list = explode("\n", trim($response->getBody(), "\n")); - $tree = array(); + $tree = []; for ($i = 1;$i<count($list);$i++) { list($child, $parent, $title) = explode(',', substr($list[$i], 12), 3); $parent = substr($parent, 12); if (!isset($tree[$parent])) { - $tree[$parent] = array( - 'children' => array(), + $tree[$parent] = [ + 'children' => [], 'title' => $title - ); + ]; } $tree[$parent]['children'][] = $child; } @@ -377,7 +377,7 @@ class Fedora extends AbstractBase if ($record == null) { return false; } - $ret = array(); + $ret = []; // OCR if (isset($record['ocr-dirty'])) { $record['ocr-dirty'] = htmlentities( @@ -399,7 +399,7 @@ class Fedora extends AbstractBase } if ($renderer != null) { $ret['div'] = $renderer - ->render('vudl/techinfo.phtml', array('record' => $record)); + ->render('vudl/techinfo.phtml', ['record' => $record]); } return $ret; } @@ -413,23 +413,23 @@ class Fedora extends AbstractBase */ protected function getSizeAndTypeInfo($techInfo) { - $data = $type = array(); + $data = $type = []; preg_match('/<size[^>]*>([^<]*)/', $techInfo, $data); preg_match('/mimetype="([^"]*)/', $techInfo, $type); $size_index = 0; if (count($data) > 1) { $bytes = intval($data[1]); - $sizes = array('bytes','KB','MB'); + $sizes = ['bytes','KB','MB']; while ($size_index < count($sizes)-1 && $bytes > 1024) { $bytes /= 1024; $size_index++; } - return array( + return [ 'size' => round($bytes, 1) . ' ' . $sizes[$size_index], 'type' => $type[1] - ); + ]; } - return array(); + return []; } /** @@ -450,10 +450,10 @@ class Fedora extends AbstractBase $license = $license[1]; foreach ($setLicenses as $tell => $value) { if (strpos($license, $tell)) { - return array($license, $value); + return [$license, $value]; } } - return array($license, false); + return [$license, false]; } return null; } @@ -466,15 +466,15 @@ class Fedora extends AbstractBase * * @return Response */ - protected function query($query, $options = array()) + protected function query($query, $options = []) { - $data = array( + $data = [ 'type' => 'tuples', 'flush' => false, 'lang' => 'itql', 'format' => 'CSV', 'query' => $query - ); + ]; foreach ($options as $key => $value) { $data[$key] = $value; } diff --git a/module/VuDL/src/VuDL/Connection/Manager.php b/module/VuDL/src/VuDL/Connection/Manager.php index 4c475524570..7652e1610a1 100644 --- a/module/VuDL/src/VuDL/Connection/Manager.php +++ b/module/VuDL/src/VuDL/Connection/Manager.php @@ -62,7 +62,7 @@ class Manager public function __construct($priority, $sm) { $this->priority = $priority; - $this->connections = array(); + $this->connections = []; $this->serviceLocator = $sm; } @@ -97,7 +97,7 @@ class Manager while ($index < count($this->priority)) { $object = $this->get($this->priority[$index]); if (method_exists($object, $methodName)) { - $ret = call_user_func_array(array($object, $methodName), $params); + $ret = call_user_func_array([$object, $methodName], $params); if (!is_null($ret)) { //var_dump($methodName.' - '.$this->priority[$index]); return $ret; diff --git a/module/VuDL/src/VuDL/Connection/Solr.php b/module/VuDL/src/VuDL/Connection/Solr.php index 5ac83817db8..6a6d545aa2e 100644 --- a/module/VuDL/src/VuDL/Connection/Solr.php +++ b/module/VuDL/src/VuDL/Connection/Solr.php @@ -70,10 +70,10 @@ class Solr extends AbstractBase // Get record $response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $id . '"', 'fl' => 'modeltype_str_mv', - ) + ] ) ); $record = json_decode($response); @@ -101,9 +101,9 @@ class Solr extends AbstractBase { if ($response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $id . '"' - ) + ] ) )) { $record = json_decode($response); @@ -127,10 +127,10 @@ class Solr extends AbstractBase $labelField = 'dc_title_str'; $response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $id . '"', 'fl' => $labelField, - ) + ] ) ); $details = json_decode($response); @@ -153,11 +153,11 @@ class Solr extends AbstractBase // Get members $response = $this->search( new ParamBag( - array( + [ 'q' => 'relsext.isMemberOf:"' . $root . '"', 'fl' => 'id,hierarchy_top_title', 'rows' => 100, - ) + ] ) ); $children = json_decode($response); @@ -165,15 +165,15 @@ class Solr extends AbstractBase if ($children->response->numFound > 0) { return array_map( function ($n) { - return array( + return [ 'id' => $n->id, 'title' => $n->hierarchy_top_title, - ); + ]; }, $children->response->docs ); } - return array(); + return []; } /** @@ -189,10 +189,10 @@ class Solr extends AbstractBase $modfield = 'fgs.lastModifiedDate'; if ($response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $id . '"', 'fl' => $modfield, - ) + ] ) )) { $record = json_decode($response); @@ -210,22 +210,22 @@ class Solr extends AbstractBase * * @return string $id */ - public function getOrderedMembers($id, $extra_sort = array()) + public function getOrderedMembers($id, $extra_sort = []) { // Try to find members in order $seqField = 'sequence_' . str_replace(':', '_', $id) . '_str'; - $sort = array($seqField . ' asc'); + $sort = [$seqField . ' asc']; foreach ($extra_sort as $sf) { $sort[] = $sf; } $response = $this->search( new ParamBag( - array( + [ 'q' => 'relsext.isMemberOf:"' . $id . '"', 'sort' => implode(',', $sort), 'fl' => 'id', 'rows' => 99999, - ) + ] ) ); $data = json_decode($response); @@ -255,8 +255,8 @@ class Solr extends AbstractBase if (isset($this->parentLists[$id])) { return $this->parentLists[$id]; } - $queue = array($id); - $tree = array(); + $queue = [$id]; + $tree = []; while (!empty($queue)) { $current = array_shift($queue); if ($current == $this->getRootId()) { @@ -264,10 +264,10 @@ class Solr extends AbstractBase } $response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $current . '"', 'fl' => 'hierarchy_parent_id,hierarchy_parent_title', - ) + ] ) ); $data = json_decode($response); @@ -279,10 +279,10 @@ class Solr extends AbstractBase foreach ($parents->hierarchy_parent_id as $i => $cid) { array_push($queue, $cid); if (!isset($tree[$cid])) { - $tree[$cid] = array( - 'children' => array(), + $tree[$cid] = [ + 'children' => [], 'title' => $parents->hierarchy_parent_title[$i] - ); + ]; } if (!in_array($current, $tree[$cid]['children'])) { $tree[$cid]['children'][] = $current; @@ -309,10 +309,10 @@ class Solr extends AbstractBase $licenseField = 'license.mdRef'; $response = $this->search( new ParamBag( - array( + [ 'q' => 'id:"' . $id . '"', 'fl' => $licenseField - ) + ] ) ); $data = json_decode($response); @@ -324,10 +324,10 @@ class Solr extends AbstractBase $license = $license[0]; foreach ($setLicenses as $tell => $value) { if (strpos($license, $tell)) { - return array($license, $value); + return [$license, $value]; } } - return array($license, false); + return [$license, false]; } /** @@ -342,7 +342,7 @@ class Solr extends AbstractBase // Remove global filters from the Solr connector $map = $this->solr->getMap(); $params = $map->getParameters('select', 'appends'); - $map->setParameters('select', 'appends', array()); + $map->setParameters('select', 'appends', []); // Turn off grouping $paramBag->set('group', 'false'); $paramBag->add('wt', 'json'); diff --git a/module/VuDL/src/VuDL/Controller/AbstractVuDL.php b/module/VuDL/src/VuDL/Controller/AbstractVuDL.php index d51573df67b..e11ae4a7b46 100644 --- a/module/VuDL/src/VuDL/Controller/AbstractVuDL.php +++ b/module/VuDL/src/VuDL/Controller/AbstractVuDL.php @@ -93,7 +93,7 @@ class AbstractVuDL extends \VuFind\Controller\AbstractBase protected function getLicenses() { $cfg = $this->getVuDLConfig(); - return isset($cfg->Licenses) ? $cfg->Licenses->toArray() : array(); + return isset($cfg->Licenses) ? $cfg->Licenses->toArray() : []; } /** @@ -104,6 +104,6 @@ class AbstractVuDL extends \VuFind\Controller\AbstractBase protected function getVuDLRoutes() { $cfg = $this->getVuDLConfig(); - return isset($cfg->Routes) ? $cfg->Routes->toArray() : array(); + return isset($cfg->Routes) ? $cfg->Routes->toArray() : []; } } diff --git a/module/VuDL/src/VuDL/Controller/VudlController.php b/module/VuDL/src/VuDL/Controller/VudlController.php index deddfdf635b..1216a281c03 100644 --- a/module/VuDL/src/VuDL/Controller/VudlController.php +++ b/module/VuDL/src/VuDL/Controller/VudlController.php @@ -91,7 +91,7 @@ class VudlController extends AbstractVuDL $items = $this->getConnector()->getOrderedMembers($list_data); foreach ($items as $i => $id) { if ($id == $child) { - return array($list, $i); + return [$list, $i]; } } } @@ -151,7 +151,7 @@ class VudlController extends AbstractVuDL */ protected function jsonReturn($data) { - $output = array('data' => $data, 'status' => 'OK'); + $output = ['data' => $data, 'status' => 'OK']; $response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine( @@ -177,10 +177,10 @@ class VudlController extends AbstractVuDL $id = $this->params()->fromQuery('record'); $start = $this->params()->fromQuery('start'); $end = $this->params()->fromQuery('end'); - $data = array( + $data = [ 'outline' => $this->getOutline($id, $start, $end-$start), 'start' => (int)$start - ); + ]; $data['outline'] = current($data['outline']['lists']); if (isset($data['outline'])) { $data['length'] = count($data['outline']); @@ -201,7 +201,7 @@ class VudlController extends AbstractVuDL $data = $this->params()->fromPost(); if ($data == null) { $id = $this->params()->fromQuery('id'); - $list = array(); + $list = []; preg_match_all( '/dsid="([^"]+)"/', strtolower($this->getConnector()->getDatastreams($id)), @@ -240,7 +240,7 @@ class VudlController extends AbstractVuDL $classes = $this->getConnector()->getClasses($id); if (in_array('FolderCollection', $classes)) { - return $this->forwardTo('Collection', 'Home', array('id' => $id)); + return $this->forwardTo('Collection', 'Home', ['id' => $id]); } $view = $this->createViewModel(); @@ -256,7 +256,7 @@ class VudlController extends AbstractVuDL } catch(\Exception $e) { } if (isset($driver) && $driver->isProtected()) { - return $this->forwardTo('VuDL', 'Denied', array('id' => $id)); + return $this->forwardTo('VuDL', 'Denied', ['id' => $id]); } // File information / description @@ -300,17 +300,17 @@ class VudlController extends AbstractVuDL $config = $this->getConfig('vudl'); $children = $this->getConnector()->getMemberList($config->General->root_id); foreach ($children as $item) { - $outline[] = array( + $outline[] = [ 'id' => $item['id'], 'img' => $this->url()->fromRoute( 'files', - array( + [ 'id' => $item['id'], 'type' => 'THUMBNAIL' - ) + ] ), 'label' => $item['title'][0] - ); + ]; } $view->thumbnails = $outline; return $view; @@ -359,27 +359,27 @@ class VudlController extends AbstractVuDL $view = $this->createViewModel(); $connector = $this->getServiceLocator()->get('VuFind\Search\BackendManager') ->get('Solr')->getConnector(); - $queries = array( + $queries = [ 'modeltype_str_mv:"vudl-system:FolderCollection"', 'modeltype_str_mv:"vudl-system:ResourceCollection"', // TODO: make these work: //'modeltype_str_mv:"vudl-system:ImageData"', //'modeltype_str_mv:"vudl-system:PDFData"', - ); + ]; $response = ''; foreach ($queries as $q) { - $params = new \VuFindSearch\ParamBag(array('q' => $q)); + $params = new \VuFindSearch\ParamBag(['q' => $q]); $response .= $connector->search($params); } - $result = array(); + $result = []; preg_match_all('/"ngroups">([^<]*)/', $response, $result); - $view->totals = array( + $view->totals = [ 'folders' => intval($result[1][0]), 'resources' => intval($result[1][1]), // TODO: make these work: //'images'=>intval($result[1][2]), //'pdfs'=>intval($result[1][3]) - ); + ]; return $view; } @@ -428,14 +428,14 @@ class VudlController extends AbstractVuDL } if ($index == -1) { return $this->redirect() - ->toRoute('collection', array('id' => $params['trail'])); + ->toRoute('collection', ['id' => $params['trail']]); } elseif (isset($params['prev'])) { return $this->redirect()->toRoute( - 'vudl-record', array('id' => $members[($index-1)%count($members)]) + 'vudl-record', ['id' => $members[($index-1)%count($members)]] ); } else { return $this->redirect()->toRoute( - 'vudl-record', array('id' => $members[($index+1)%count($members)]) + 'vudl-record', ['id' => $members[($index+1)%count($members)]] ); } } @@ -448,6 +448,6 @@ class VudlController extends AbstractVuDL protected function collectionsAction() { return $this - ->forwardTo('Collection', 'Home', array('id' => $this->getRootId())); + ->forwardTo('Collection', 'Home', ['id' => $this->getRootId()]); } } diff --git a/module/VuDL/src/VuDL/Factory.php b/module/VuDL/src/VuDL/Factory.php index 1505cc6545d..d06b3c37d9e 100644 --- a/module/VuDL/src/VuDL/Factory.php +++ b/module/VuDL/src/VuDL/Factory.php @@ -51,7 +51,7 @@ class Factory public static function getConnectionManager(ServiceManager $sm) { return new \VuDL\Connection\Manager( - array('Solr', 'Fedora'), $sm + ['Solr', 'Fedora'], $sm ); } diff --git a/module/VuDL/src/VuDL/OutlineGenerator.php b/module/VuDL/src/VuDL/OutlineGenerator.php index d52012d5233..0e8b24c3a01 100644 --- a/module/VuDL/src/VuDL/OutlineGenerator.php +++ b/module/VuDL/src/VuDL/OutlineGenerator.php @@ -97,7 +97,7 @@ class OutlineGenerator * @param object|bool $cache Cache object (or false to disable caching) */ public function __construct(Connection\Manager $connector, UrlHelper $url, - $routes = array(), $cache = false + $routes = [], $cache = false ) { $this->connector = $connector; $this->url = $url; @@ -139,10 +139,10 @@ class OutlineGenerator if ($this->cache) { $this->cache->setItem( $key, - array( + [ 'moddate' => date(DATE_ATOM), 'outline' => $data - ) + ] ); return $data; } @@ -159,12 +159,12 @@ class OutlineGenerator protected function loadLists($root) { // Reset the state of the class: - $this->queue = $this->moddate = array(); - $this->outline = array( - 'counts' => array(), - 'names' => array(), - 'lists' => array() - ); + $this->queue = $this->moddate = []; + $this->outline = [ + 'counts' => [], + 'names' => [], + 'lists' => [] + ]; // Get lists $lists = $this->connector->getOrderedMembers($root); // Get list items @@ -187,7 +187,7 @@ class OutlineGenerator protected function buildItem($id) { // Else, get all the data and save it to the cache - $list = array(); + $list = []; // Get the file type $file = $this->connector->getDatastreams($id); preg_match_all( @@ -206,7 +206,7 @@ class OutlineGenerator ); } $details = $this->connector->getDetails($id, false); - return array( + return [ 'id' => $id, 'fulltype' => $type, 'mimetype' => $mimetype, @@ -218,7 +218,7 @@ class OutlineGenerator : $id, 'datastreams' => $list[1], 'mimetypes' => $list[2] - ); + ]; } /** @@ -242,7 +242,7 @@ class OutlineGenerator if (count($items) < $start) { continue; } - $this->outline['lists'][$parent] = array(); + $this->outline['lists'][$parent] = []; for ($i = $start;$i < $start + $pageLength;$i++) { if ($i >= count($items)) { break; @@ -269,7 +269,7 @@ class OutlineGenerator foreach ($this->outline['lists'] as $key => $list) { foreach ($list as $id => $item) { foreach ($item['datastreams'] as $ds) { - $routeParams = array('id' => $item['id'], 'type' => $ds); + $routeParams = ['id' => $item['id'], 'type' => $ds]; $this->outline['lists'][$key][$id][strtolower($ds)] = $this->url->fromRoute('files', $routeParams); } diff --git a/module/VuDL/src/VuDL/RecordDriver/SolrVudl.php b/module/VuDL/src/VuDL/RecordDriver/SolrVudl.php index 728036ce3b0..a133cc30806 100644 --- a/module/VuDL/src/VuDL/RecordDriver/SolrVudl.php +++ b/module/VuDL/src/VuDL/RecordDriver/SolrVudl.php @@ -91,13 +91,13 @@ class SolrVudl extends \VuFind\RecordDriver\SolrDefault */ public function getThumbnail($size = 'small') { - return array( + return [ 'route' => 'files', - 'routeParams' => array( + 'routeParams' => [ 'id' => $this->getUniqueID(), 'type' => 'THUMBNAIL' - ) - ); + ] + ]; // We are currently storing only one size of thumbnail; we'll use this for // small and medium sizes in the interface, flagging "large" as unavailable // for now. @@ -126,16 +126,16 @@ class SolrVudl extends \VuFind\RecordDriver\SolrDefault public function getURLs() { if ($this->isCollection()) { - return array(); + return []; } else { - $retval = array( - array( + $retval = [ + [ 'route' => 'vudl-record', - 'routeParams' => array( + 'routeParams' => [ 'id' => $this->getUniqueID() - ) - ) - ); + ] + ] + ]; if ($this->isProtected()) { $retval[0]['prefix'] = $this->getProxyUrl(); } @@ -157,7 +157,7 @@ class SolrVudl extends \VuFind\RecordDriver\SolrDefault // Check IP range $userIP = $_SERVER['REMOTE_ADDR']; $range = isset($this->vuDLConfig->Access->ip_range) - ? $this->vuDLConfig->Access->ip_range->toArray() : array(); + ? $this->vuDLConfig->Access->ip_range->toArray() : []; foreach ($range as $ip) { if (strpos($userIP, $ip) === 0) { return false; @@ -186,7 +186,7 @@ class SolrVudl extends \VuFind\RecordDriver\SolrDefault */ public function getAllSubjectHeadings() { - $retVal = array(); + $retVal = []; if (isset($this->fields['topic'])) { foreach ($this->fields['topic'] as $current) { $retVal[] = explode(' -- ', $current); diff --git a/module/VuDL/src/VuDL/View/Helper/Bootstrap3/VuDL.php b/module/VuDL/src/VuDL/View/Helper/Bootstrap3/VuDL.php index 7d3fbd99fb1..bc111f2992a 100644 --- a/module/VuDL/src/VuDL/View/Helper/Bootstrap3/VuDL.php +++ b/module/VuDL/src/VuDL/View/Helper/Bootstrap3/VuDL.php @@ -47,7 +47,7 @@ class VuDL extends \Zend\View\Helper\AbstractHelper */ public function formatTechInfo($techInfo) { - $old = array( + $old = [ '/<(\/[^>]+)>/', '/<([^>]+)>/', '/\/>/', @@ -55,8 +55,8 @@ class VuDL extends \Zend\View\Helper\AbstractHelper '/<div>\s*<\/div>/', '/(?<=<div>)([^<]+)<div>/', '/<div>/' - ); - $new = array( + ]; + $new = [ '<\1></div>', '<div><\1>', '/></div>', @@ -69,7 +69,7 @@ class VuDL extends \Zend\View\Helper\AbstractHelper . " : 'xml'" . '">\1</a><div>', '<div class="xml">' - ); + ]; return preg_replace($old, $new, $techInfo); } } \ No newline at end of file diff --git a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/AbstractBaseTest.php b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/AbstractBaseTest.php index 60f6a79cb82..ae5dd3e2e01 100644 --- a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/AbstractBaseTest.php +++ b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/AbstractBaseTest.php @@ -40,16 +40,16 @@ class AbstractBaseTest extends \VuFindTest\Unit\TestCase { public function testConstructorAndSet() { - $subject = new \VuDL\Connection\AbstractBase(array()); + $subject = new \VuDL\Connection\AbstractBase([]); $subject->setHttpService(new FakeInterface()); } } class FakeInterface implements \VuFindHttp\HttpServiceInterface { - public function proxify(\Zend\Http\Client $client, array $options = array()) {} - public function get($url, array $params = array(), $timeout = null) {} + public function proxify(\Zend\Http\Client $client, array $options = []) {} + public function get($url, array $params = [], $timeout = null) {} public function post($url, $body = null, $type = 'application/octet-stream', $timeout = null) {} - public function postForm($url, array $params = array(), $timeout = null) {} + public function postForm($url, array $params = [], $timeout = null) {} public function createClient($url, $method = \Zend\Http\Request::METHOD_GET, $timeout = null) {} } \ No newline at end of file diff --git a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/FedoraTest.php b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/FedoraTest.php index 8db6305d498..fbc4873e0e8 100644 --- a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/FedoraTest.php +++ b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/FedoraTest.php @@ -42,15 +42,15 @@ class FedoraTest extends \VuFindTest\Unit\TestCase { $subject = $this->getMock( '\VuDL\Connection\Fedora', - array('getDatastreamContent', 'getDatastreamHeaders'), - array((object) array( - 'Fedora' => (object) array( + ['getDatastreamContent', 'getDatastreamHeaders'], + [(object) [ + 'Fedora' => (object) [ 'url_base' => 'http://jsontest.com/', 'query_url' => 'QUERY', 'adminUser' => 'ADMIN', 'adminPass' => 'ADMINPASS' - ) - )) + ] + ]] ); $subject->method('getDatastreamContent')->will( $this->onConsecutiveCalls( @@ -62,21 +62,21 @@ class FedoraTest extends \VuFindTest\Unit\TestCase ); $subject->method('getDatastreamHeaders')->will( $this->onConsecutiveCalls( - array('HTTP/1.1 200 OK'), - array('HTTP/1.1 404 EVERYTHING IS WRONG') + ['HTTP/1.1 200 OK'], + ['HTTP/1.1 404 EVERYTHING IS WRONG'] ) ); $this->assertEquals('http://jsontest.com/', $subject->getBase()); - $this->assertEquals(array('CLASS1','CLASS2'), $subject->getClasses('id')); + $this->assertEquals(['CLASS1','CLASS2'], $subject->getClasses('id')); $this->assertEquals('<xml><a><b id="c"></b></a></xml>', $subject->getDatastreams('id')); $this->assertEquals('SimpleXMLElement', get_class($subject->getDatastreams('id', true))); - $this->assertEquals(array('test_passed', 'fake'), $subject->getCopyright('id', array('passed' => 'fake'))); + $this->assertEquals(['test_passed', 'fake'], $subject->getCopyright('id', ['passed' => 'fake'])); - $this->assertEquals(array('title' => 'T','id' => 'ID'), $subject->getDetails('id')); + $this->assertEquals(['title' => 'T','id' => 'ID'], $subject->getDetails('id')); // Detail formatting tested in Solr $this->assertEquals('Zend\Http\Client', get_class($subject->getHttpClient('url'))); diff --git a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/ManagerTest.php b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/ManagerTest.php index ac0843fef5b..471731009a5 100644 --- a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/ManagerTest.php +++ b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/ManagerTest.php @@ -41,7 +41,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase { protected function getTestSubject() { - return new \VuDL\Connection\Manager(array('First', 'Second'), new FakeServiceLocator()); + return new \VuDL\Connection\Manager(['First', 'Second'], new FakeServiceLocator()); } public function testManager() diff --git a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/SolrTest.php b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/SolrTest.php index ebd0d619079..24797285952 100644 --- a/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/SolrTest.php +++ b/module/VuDL/tests/unit-tests/src/VuDLTest/Connection/SolrTest.php @@ -41,8 +41,8 @@ class SolrTest extends \VuFindTest\Unit\TestCase public function testMissingDetails() { $subject = new \VuDL\Connection\Solr( - (object) array('General' => (object) array('page_length' => 8)), - new FakeBackend(array('{"response":{"docs":[{"author":"1,2"}]}}')) + (object) ['General' => (object) ['page_length' => 8]], + new FakeBackend(['{"response":{"docs":[{"author":"1,2"}]}}']) ); $this->assertEquals(8, $subject->getPageLength()); @@ -63,12 +63,12 @@ class SolrTest extends \VuFindTest\Unit\TestCase public function testAllWithMock() { $subject = new \VuDL\Connection\Solr( - (object) array( - 'General' => (object) array('root_id' => 'ROOT'), - 'Details' => new FakeConfig(array('author,author2' => 'Author','series' => 'Series','bacon,eggs' => 'Yum','unused' => ':(')) - ), + (object) [ + 'General' => (object) ['root_id' => 'ROOT'], + 'Details' => new FakeConfig(['author,author2' => 'Author','series' => 'Series','bacon,eggs' => 'Yum','unused' => ':(']) + ], new FakeBackend( - array( + [ '{"response":{"numFound":0}}', '{"response":{"numFound":1,"docs":[{"modeltype_str_mv":["123456789012CLASS_ONE","123456789012CLASS_TWO"]}]}}', @@ -97,41 +97,41 @@ class SolrTest extends \VuFindTest\Unit\TestCase '{"response":{"numFound":0,"docs":[0]}}', '{"response":{"numFound":1,"docs":[{"license.mdRef":["vuABC"]}]}}', '{"response":{"numFound":1,"docs":[{"license.mdRef":["vuABC"]}]}}' - ) + ] ) ); $this->assertEquals(null, $subject->getClasses('id')); - $this->assertEquals(array("CLASS_ONE", "CLASS_TWO"), $subject->getClasses('id')); + $this->assertEquals(["CLASS_ONE", "CLASS_TWO"], $subject->getClasses('id')); $this->assertEquals(null, $subject->getDetails('id', false)); - $this->assertEquals(array("author" => array("A1","A2"),"series" => "S1"), $subject->getDetails('id', false)); - $this->assertEquals(array( - "author" => array("title" => "Author", "value" => array("A1","A2")), - "bacon" => array("title" => "Yum", "value" => array("MORE")), - "series" => array("title" => "Series", "value" => "S1"), - ), $subject->getDetails('id', true)); + $this->assertEquals(["author" => ["A1","A2"],"series" => "S1"], $subject->getDetails('id', false)); + $this->assertEquals([ + "author" => ["title" => "Author", "value" => ["A1","A2"]], + "bacon" => ["title" => "Yum", "value" => ["MORE"]], + "series" => ["title" => "Series", "value" => "S1"], + ], $subject->getDetails('id', true)); $this->assertEquals(null, $subject->getLabel('id')); $this->assertEquals("LABEL", $subject->getLabel('id')); - $this->assertEquals(array(), $subject->getMemberList('root')); - $this->assertEquals(array(array('id' => 'ID','title' => 'TOP')), $subject->getMemberList('root')); + $this->assertEquals([], $subject->getMemberList('root')); + $this->assertEquals([['id' => 'ID','title' => 'TOP']], $subject->getMemberList('root')); $this->assertEquals(null, $subject->getModDate('id')); $this->assertEquals("DATE", $subject->getModDate('id')); $this->assertEquals(null, $subject->getOrderedMembers('id')); - $this->assertEquals(array("ID1", "ID2"), $subject->getOrderedMembers('id', array('fake_filter'))); + $this->assertEquals(["ID1", "ID2"], $subject->getOrderedMembers('id', ['fake_filter'])); $this->assertEquals(null, $subject->getParentList('id1')); - $this->assertEquals(array(array('id4' => 'title4'), array('id3' => 'title3','id2' => 'title2')), $subject->getParentList('id1')); + $this->assertEquals([['id4' => 'title4'], ['id3' => 'title3','id2' => 'title2']], $subject->getParentList('id1')); // Cache test - $this->assertEquals(array(array('id4' => 'title4'), array('id3' => 'title3','id2' => 'title2')), $subject->getParentList('id1')); + $this->assertEquals([['id4' => 'title4'], ['id3' => 'title3','id2' => 'title2']], $subject->getParentList('id1')); - $this->assertEquals(null, $subject->getCopyright('id', array())); - $this->assertEquals(array("vuABC", "WTFPL"), $subject->getCopyright('id', array('A' => 'WTFPL'))); - $this->assertEquals(array("vuABC", false), $subject->getCopyright('id', array('X' => 'WTFPL'))); + $this->assertEquals(null, $subject->getCopyright('id', [])); + $this->assertEquals(["vuABC", "WTFPL"], $subject->getCopyright('id', ['A' => 'WTFPL'])); + $this->assertEquals(["vuABC", false], $subject->getCopyright('id', ['X' => 'WTFPL'])); $this->assertEquals(16, $subject->getPageLength()); } diff --git a/module/VuFind/Module.php b/module/VuFind/Module.php index a3353bc3584..93cdccd1990 100644 --- a/module/VuFind/Module.php +++ b/module/VuFind/Module.php @@ -56,18 +56,18 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\ClassMapAutoloader' => array( - 'classes' => array( + return [ + 'Zend\Loader\ClassMapAutoloader' => [ + 'classes' => [ 'minSO' => __DIR__ . '/src/VuFind/Search/minSO.php' - ) - ), - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + ] + ], + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } /** diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index cca8b9a7783..ff53d0003f7 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -1,73 +1,73 @@ <?php namespace VuFind\Module\Config; -$config = array( - 'router' => array( - 'routes' => array( - 'default' => array( +$config = [ + 'router' => [ + 'routes' => [ + 'default' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/[:controller[/[:action]]]', - 'constraints' => array( + 'constraints' => [ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( + ], + 'defaults' => [ 'controller' => 'index', 'action' => 'Home', - ), - ), - ), - 'legacy-alphabrowse-results' => array( + ], + ], + ], + 'legacy-alphabrowse-results' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/AlphaBrowse/Results', - 'defaults' => array( + 'defaults' => [ 'controller' => 'Alphabrowse', 'action' => 'Home', - ) - ) - ), - 'legacy-bookcover' => array( + ] + ] + ], + 'legacy-bookcover' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/bookcover.php', - 'defaults' => array( + 'defaults' => [ 'controller' => 'cover', 'action' => 'Show', - ) - ) - ), - 'legacy-summonrecord' => array( + ] + ] + ], + 'legacy-summonrecord' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/Summon/Record', - 'defaults' => array( + 'defaults' => [ 'controller' => 'SummonRecord', 'action' => 'Home', - ) - ) - ), - 'legacy-worldcatrecord' => array( + ] + ] + ], + 'legacy-worldcatrecord' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/WorldCat/Record', - 'defaults' => array( + 'defaults' => [ 'controller' => 'WorldcatRecord', 'action' => 'Home', - ) - ) - ) - ), - ), - 'controllers' => array( - 'factories' => array( + ] + ] + ] + ], + ], + 'controllers' => [ + 'factories' => [ 'browse' => 'VuFind\Controller\Factory::getBrowseController', 'collection' => 'VuFind\Controller\Factory::getCollectionController', 'collections' => 'VuFind\Controller\Factory::getCollectionsController', 'record' => 'VuFind\Controller\Factory::getRecordController', - ), - 'invokables' => array( + ], + 'invokables' => [ 'ajax' => 'VuFind\Controller\AjaxController', 'alphabrowse' => 'VuFind\Controller\AlphabrowseController', 'author' => 'VuFind\Controller\AuthorController', @@ -103,31 +103,31 @@ $config = array( 'web' => 'VuFind\Controller\WebController', 'worldcat' => 'VuFind\Controller\WorldcatController', 'worldcatrecord' => 'VuFind\Controller\WorldcatrecordController', - ), - 'initializers' => array( + ], + 'initializers' => [ 'ZfcRbac\Initializer\AuthorizationServiceInitializer' - ), - ), - 'controller_plugins' => array( - 'factories' => array( + ], + ], + 'controller_plugins' => [ + 'factories' => [ 'holds' => 'VuFind\Controller\Plugin\Factory::getHolds', 'newitems' => 'VuFind\Controller\Plugin\Factory::getNewItems', 'ILLRequests' => 'VuFind\Controller\Plugin\Factory::getILLRequests', 'recaptcha' => 'VuFind\Controller\Plugin\Factory::getRecaptcha', 'reserves' => 'VuFind\Controller\Plugin\Factory::getReserves', 'storageRetrievalRequests' => 'VuFind\Controller\Plugin\Factory::getStorageRetrievalRequests', - ), - 'invokables' => array( + ], + 'invokables' => [ 'db-upgrade' => 'VuFind\Controller\Plugin\DbUpgrade', 'favorites' => 'VuFind\Controller\Plugin\Favorites', 'followup' => 'VuFind\Controller\Plugin\Followup', 'renewals' => 'VuFind\Controller\Plugin\Renewals', 'result-scroller' => 'VuFind\Controller\Plugin\ResultScroller', - ) - ), - 'service_manager' => array( + ] + ], + 'service_manager' => [ 'allow_override' => true, - 'factories' => array( + 'factories' => [ 'VuFind\AuthManager' => 'VuFind\Auth\Factory::getManager', 'VuFind\AuthPluginManager' => 'VuFind\Service\Factory::getAuthPluginManager', 'VuFind\AutocompletePluginManager' => 'VuFind\Service\Factory::getAutocompletePluginManager', @@ -179,64 +179,64 @@ $config = array( 'VuFind\Tags' => 'VuFind\Service\Factory::getTags', 'VuFind\Translator' => 'VuFind\Service\Factory::getTranslator', 'VuFind\WorldCatUtils' => 'VuFind\Service\Factory::getWorldCatUtils', - ), - 'invokables' => array( + ], + 'invokables' => [ 'VuFind\SessionManager' => 'Zend\Session\SessionManager', 'VuFind\Search' => 'VuFindSearch\Service', 'VuFind\Search\Memory' => 'VuFind\Search\Memory', 'VuFind\HierarchicalFacetHelper' => 'VuFind\Search\Solr\HierarchicalFacetHelper' - ), - 'initializers' => array( + ], + 'initializers' => [ 'VuFind\ServiceManager\Initializer::initInstance', - ), - 'aliases' => array( + ], + 'aliases' => [ 'mvctranslator' => 'VuFind\Translator', 'translator' => 'VuFind\Translator', - ), - ), - 'translator' => array(), - 'view_helpers' => array( - 'initializers' => array( + ], + ], + 'translator' => [], + 'view_helpers' => [ + 'initializers' => [ 'VuFind\ServiceManager\Initializer::initZendPlugin', - ), - ), - 'view_manager' => array( + ], + ], + 'view_manager' => [ 'display_not_found_reason' => APPLICATION_ENV == 'development', 'display_exceptions' => APPLICATION_ENV == 'development', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', - 'template_path_stack' => array(), - ), + 'template_path_stack' => [], + ], // This section contains all VuFind-specific settings (i.e. configurations // unrelated to specific Zend Framework 2 components). - 'vufind' => array( + 'vufind' => [ // The config reader is a special service manager for loading .ini files: - 'config_reader' => array( - 'abstract_factories' => array('VuFind\Config\PluginFactory'), - ), + 'config_reader' => [ + 'abstract_factories' => ['VuFind\Config\PluginFactory'], + ], // PostgreSQL sequence mapping - 'pgsql_seq_mapping' => array( - 'comments' => array('id', 'comments_id_seq'), - 'oai_resumption' => array('id', 'oai_resumption_id_seq'), - 'resource' => array('id', 'resource_id_seq'), - 'resource_tags' => array('id', 'resource_tags_id_seq'), - 'search' => array('id', 'search_id_seq'), - 'session' => array('id', 'session_id_seq'), - 'tags' => array('id', 'tags_id_seq'), - 'user' => array('id', 'user_id_seq'), - 'user_list' => array('id', 'user_list_id_seq'), - 'user_resource' => array('id', 'user_resource_id_seq') - ), + 'pgsql_seq_mapping' => [ + 'comments' => ['id', 'comments_id_seq'], + 'oai_resumption' => ['id', 'oai_resumption_id_seq'], + 'resource' => ['id', 'resource_id_seq'], + 'resource_tags' => ['id', 'resource_tags_id_seq'], + 'search' => ['id', 'search_id_seq'], + 'session' => ['id', 'session_id_seq'], + 'tags' => ['id', 'tags_id_seq'], + 'user' => ['id', 'user_id_seq'], + 'user_list' => ['id', 'user_list_id_seq'], + 'user_resource' => ['id', 'user_resource_id_seq'] + ], // This section contains service manager configurations for all VuFind // pluggable components: - 'plugin_managers' => array( - 'auth' => array( - 'abstract_factories' => array('VuFind\Auth\PluginFactory'), - 'factories' => array( + 'plugin_managers' => [ + 'auth' => [ + 'abstract_factories' => ['VuFind\Auth\PluginFactory'], + 'factories' => [ 'ils' => 'VuFind\Auth\Factory::getILS', 'multiils' => 'VuFind\Auth\Factory::getMultiILS', - ), - 'invokables' => array( + ], + 'invokables' => [ 'cas' => 'VuFind\Auth\CAS', 'choiceauth' => 'VuFind\Auth\ChoiceAuth', 'database' => 'VuFind\Auth\Database', @@ -245,27 +245,27 @@ $config = array( 'multiauth' => 'VuFind\Auth\MultiAuth', 'shibboleth' => 'VuFind\Auth\Shibboleth', 'sip2' => 'VuFind\Auth\SIP2', - ), - 'aliases' => array( + ], + 'aliases' => [ // for legacy 1.x compatibility 'db' => 'Database', 'sip' => 'Sip2', - ), - ), - 'autocomplete' => array( - 'abstract_factories' => array('VuFind\Autocomplete\PluginFactory'), - 'factories' => array( + ], + ], + 'autocomplete' => [ + 'abstract_factories' => ['VuFind\Autocomplete\PluginFactory'], + 'factories' => [ 'solr' => 'VuFind\Autocomplete\Factory::getSolr', 'solrauth' => 'VuFind\Autocomplete\Factory::getSolrAuth', 'solrcn' => 'VuFind\Autocomplete\Factory::getSolrCN', 'solrreserves' => 'VuFind\Autocomplete\Factory::getSolrReserves', - ), - 'invokables' => array( + ], + 'invokables' => [ 'none' => 'VuFind\Autocomplete\None', 'oclcidentities' => 'VuFind\Autocomplete\OCLCIdentities', 'tag' => 'VuFind\Autocomplete\Tag', - ), - 'aliases' => array( + ], + 'aliases' => [ // for legacy 1.x compatibility 'noautocomplete' => 'None', 'oclcidentitiesautocomplete' => 'OCLCIdentities', @@ -274,60 +274,60 @@ $config = array( 'solrcnautocomplete' => 'SolrCN', 'solrreservesautocomplete' => 'SolrReserves', 'tagautocomplete' => 'Tag', - ), - ), - 'content' => array( - 'factories' => array( + ], + ], + 'content' => [ + 'factories' => [ 'authornotes' => 'VuFind\Content\Factory::getAuthorNotes', 'excerpts' => 'VuFind\Content\Factory::getExcerpts', 'reviews' => 'VuFind\Content\Factory::getReviews', - ), - ), - 'content_authornotes' => array( - 'factories' => array( + ], + ], + 'content_authornotes' => [ + 'factories' => [ 'syndetics' => 'VuFind\Content\AuthorNotes\Factory::getSyndetics', 'syndeticsplus' => 'VuFind\Content\AuthorNotes\Factory::getSyndeticsPlus', - ), - ), - 'content_excerpts' => array( - 'factories' => array( + ], + ], + 'content_excerpts' => [ + 'factories' => [ 'syndetics' => 'VuFind\Content\Excerpts\Factory::getSyndetics', 'syndeticsplus' => 'VuFind\Content\Excerpts\Factory::getSyndeticsPlus', - ), - ), - 'content_covers' => array( - 'factories' => array( + ], + ], + 'content_covers' => [ + 'factories' => [ 'amazon' => 'VuFind\Content\Covers\Factory::getAmazon', 'booksite' => 'VuFind\Content\Covers\Factory::getBooksite', 'contentcafe' => 'VuFind\Content\Covers\Factory::getContentCafe', 'syndetics' => 'VuFind\Content\Covers\Factory::getSyndetics', - ), - 'invokables' => array( + ], + 'invokables' => [ 'google' => 'VuFind\Content\Covers\Google', 'librarything' => 'VuFind\Content\Covers\LibraryThing', 'openlibrary' => 'VuFind\Content\Covers\OpenLibrary', 'summon' => 'VuFind\Content\Covers\Summon', - ), - ), - 'content_reviews' => array( - 'factories' => array( + ], + ], + 'content_reviews' => [ + 'factories' => [ 'amazon' => 'VuFind\Content\Reviews\Factory::getAmazon', 'amazoneditorial' => 'VuFind\Content\Reviews\Factory::getAmazonEditorial', 'booksite' => 'VuFind\Content\Reviews\Factory::getBooksite', 'syndetics' => 'VuFind\Content\Reviews\Factory::getSyndetics', 'syndeticsplus' => 'VuFind\Content\Reviews\Factory::getSyndeticsPlus', - ), - 'invokables' => array( + ], + 'invokables' => [ 'guardian' => 'VuFind\Content\Reviews\Guardian', - ), - ), - 'db_table' => array( - 'abstract_factories' => array('VuFind\Db\Table\PluginFactory'), - 'factories' => array( + ], + ], + 'db_table' => [ + 'abstract_factories' => ['VuFind\Db\Table\PluginFactory'], + 'factories' => [ 'resource' => 'VuFind\Db\Table\Factory::getResource', 'user' => 'VuFind\Db\Table\Factory::getUser', - ), - 'invokables' => array( + ], + 'invokables' => [ 'changetracker' => 'VuFind\Db\Table\ChangeTracker', 'comments' => 'VuFind\Db\Table\Comments', 'oairesumption' => 'VuFind\Db\Table\OaiResumption', @@ -339,30 +339,30 @@ $config = array( 'userresource' => 'VuFind\Db\Table\UserResource', 'userstats' => 'VuFind\Db\Table\UserStats', 'userstatsfields' => 'VuFind\Db\Table\UserStatsFields', - ), - ), - 'hierarchy_driver' => array( - 'factories' => array( + ], + ], + 'hierarchy_driver' => [ + 'factories' => [ 'default' => 'VuFind\Hierarchy\Driver\Factory::getHierarchyDefault', 'flat' => 'VuFind\Hierarchy\Driver\Factory::getHierarchyFlat', - ), - ), - 'hierarchy_treedatasource' => array( - 'factories' => array( + ], + ], + 'hierarchy_treedatasource' => [ + 'factories' => [ 'solr' => 'VuFind\Hierarchy\TreeDataSource\Factory::getSolr', - ), - 'invokables' => array( + ], + 'invokables' => [ 'xmlfile' => 'VuFind\Hierarchy\TreeDataSource\XMLFile', - ), - ), - 'hierarchy_treerenderer' => array( - 'factories' => array( + ], + ], + 'hierarchy_treerenderer' => [ + 'factories' => [ 'jstree' => 'VuFind\Hierarchy\TreeRenderer\Factory::getJSTree' - ), - ), - 'ils_driver' => array( - 'abstract_factories' => array('VuFind\ILS\Driver\PluginFactory'), - 'factories' => array( + ], + ], + 'ils_driver' => [ + 'abstract_factories' => ['VuFind\ILS\Driver\PluginFactory'], + 'factories' => [ 'aleph' => 'VuFind\ILS\Driver\Factory::getAleph', 'demo' => 'VuFind\ILS\Driver\Factory::getDemo', 'horizon' => 'VuFind\ILS\Driver\Factory::getHorizon', @@ -372,8 +372,8 @@ $config = array( 'unicorn' => 'VuFind\ILS\Driver\Factory::getUnicorn', 'voyager' => 'VuFind\ILS\Driver\Factory::getVoyager', 'voyagerrestful' => 'VuFind\ILS\Driver\Factory::getVoyagerRestful', - ), - 'invokables' => array( + ], + 'invokables' => [ 'amicus' => 'VuFind\ILS\Driver\Amicus', 'claviussql' => 'VuFind\ILS\Driver\ClaviusSQL', 'daia' => 'VuFind\ILS\Driver\DAIA', @@ -389,11 +389,11 @@ $config = array( 'symphony' => 'VuFind\ILS\Driver\Symphony', 'virtua' => 'VuFind\ILS\Driver\Virtua', 'xcncip2' => 'VuFind\ILS\Driver\XCNCIP2', - ), - ), - 'recommend' => array( - 'abstract_factories' => array('VuFind\Recommend\PluginFactory'), - 'factories' => array( + ], + ], + 'recommend' => [ + 'abstract_factories' => ['VuFind\Recommend\PluginFactory'], + 'factories' => [ 'authorfacets' => 'VuFind\Recommend\Factory::getAuthorFacets', 'authorinfo' => 'VuFind\Recommend\Factory::getAuthorInfo', 'authorityrecommend' => 'VuFind\Recommend\Factory::getAuthorityRecommend', @@ -415,8 +415,8 @@ $config = array( 'webresults' => 'VuFind\Recommend\Factory::getWebResults', 'worldcatidentities' => 'VuFind\Recommend\Factory::getWorldCatIdentities', 'worldcatterms' => 'VuFind\Recommend\Factory::getWorldCatTerms', - ), - 'invokables' => array( + ], + 'invokables' => [ 'europeanaresultsdeferred' => 'VuFind\Recommend\EuropeanaResultsDeferred', 'facetcloud' => 'VuFind\Recommend\FacetCloud', 'openlibrarysubjects' => 'VuFind\Recommend\OpenLibrarySubjects', @@ -428,11 +428,11 @@ $config = array( 'summondatabasesdeferred' => 'VuFind\Recommend\SummonDatabasesDeferred', 'summonresultsdeferred' => 'VuFind\Recommend\SummonResultsDeferred', 'switchtype' => 'VuFind\Recommend\SwitchType', - ), - ), - 'recorddriver' => array( - 'abstract_factories' => array('VuFind\RecordDriver\PluginFactory'), - 'factories' => array( + ], + ], + 'recorddriver' => [ + 'abstract_factories' => ['VuFind\RecordDriver\PluginFactory'], + 'factories' => [ 'eds' => 'VuFind\RecordDriver\Factory::getEDS', 'eit' => 'VuFind\RecordDriver\Factory::getEIT', 'missing' => 'VuFind\RecordDriver\Factory::getMissing', @@ -445,14 +445,14 @@ $config = array( 'solrweb' => 'VuFind\RecordDriver\Factory::getSolrWeb', 'summon' => 'VuFind\RecordDriver\Factory::getSummon', 'worldcat' => 'VuFind\RecordDriver\Factory::getWorldCat', - ), - 'invokables' => array( + ], + 'invokables' => [ 'libguides' => 'VuFind\RecordDriver\LibGuides', - ), - ), - 'recordtab' => array( - 'abstract_factories' => array('VuFind\RecordTab\PluginFactory'), - 'factories' => array( + ], + ], + 'recordtab' => [ + 'abstract_factories' => ['VuFind\RecordTab\PluginFactory'], + 'factories' => [ 'collectionhierarchytree' => 'VuFind\RecordTab\Factory::getCollectionHierarchyTree', 'collectionlist' => 'VuFind\RecordTab\Factory::getCollectionList', 'excerpt' => 'VuFind\RecordTab\Factory::getExcerpt', @@ -464,36 +464,36 @@ $config = array( 'reviews' => 'VuFind\RecordTab\Factory::getReviews', 'similaritemscarousel' => 'VuFind\RecordTab\Factory::getSimilarItemsCarousel', 'usercomments' => 'VuFind\RecordTab\Factory::getUserComments', - ), - 'invokables' => array( + ], + 'invokables' => [ 'description' => 'VuFind\RecordTab\Description', 'staffviewarray' => 'VuFind\RecordTab\StaffViewArray', 'staffviewmarc' => 'VuFind\RecordTab\StaffViewMARC', 'toc' => 'VuFind\RecordTab\TOC', - ), - ), - 'related' => array( - 'abstract_factories' => array('VuFind\Related\PluginFactory'), - 'factories' => array( + ], + ], + 'related' => [ + 'abstract_factories' => ['VuFind\Related\PluginFactory'], + 'factories' => [ 'editions' => 'VuFind\Related\Factory::getEditions', 'similar' => 'VuFind\Related\Factory::getSimilar', 'worldcateditions' => 'VuFind\Related\Factory::getWorldCatEditions', 'worldcatsimilar' => 'VuFind\Related\Factory::getWorldCatSimilar', - ), - ), - 'resolver_driver' => array( - 'abstract_factories' => array('VuFind\Resolver\Driver\PluginFactory'), - 'factories' => array( + ], + ], + 'resolver_driver' => [ + 'abstract_factories' => ['VuFind\Resolver\Driver\PluginFactory'], + 'factories' => [ '360link' => 'VuFind\Resolver\Driver\Factory::getThreesixtylink', 'ezb' => 'VuFind\Resolver\Driver\Factory::getEzb', 'sfx' => 'VuFind\Resolver\Driver\Factory::getSfx', - ), - 'aliases' => array( + ], + 'aliases' => [ 'threesixtylink' => '360link', - ), - ), - 'search_backend' => array( - 'factories' => array( + ], + ], + 'search_backend' => [ + 'factories' => [ 'EDS' => 'VuFind\Search\Factory\EdsBackendFactory', 'EIT' => 'VuFind\Search\Factory\EITBackendFactory', 'LibGuides' => 'VuFind\Search\Factory\LibGuidesBackendFactory', @@ -506,8 +506,8 @@ $config = array( 'SolrWeb' => 'VuFind\Search\Factory\SolrWebBackendFactory', 'Summon' => 'VuFind\Search\Factory\SummonBackendFactory', 'WorldCat' => 'VuFind\Search\Factory\WorldCatBackendFactory', - ), - 'aliases' => array( + ], + 'aliases' => [ // Allow Solr core names to be used as aliases for services: 'authority' => 'SolrAuth', 'biblio' => 'Solr', @@ -515,103 +515,103 @@ $config = array( 'stats' => 'SolrStats', // Legacy: 'VuFind' => 'Solr', - ) - ), - 'search_options' => array( - 'abstract_factories' => array('VuFind\Search\Options\PluginFactory'), - 'factories' => array( + ] + ], + 'search_options' => [ + 'abstract_factories' => ['VuFind\Search\Options\PluginFactory'], + 'factories' => [ 'eds' => 'VuFind\Search\Options\Factory::getEDS', - ), - ), - 'search_params' => array( - 'abstract_factories' => array('VuFind\Search\Params\PluginFactory'), - ), - 'search_results' => array( - 'abstract_factories' => array('VuFind\Search\Results\PluginFactory'), - 'factories' => array( + ], + ], + 'search_params' => [ + 'abstract_factories' => ['VuFind\Search\Params\PluginFactory'], + ], + 'search_results' => [ + 'abstract_factories' => ['VuFind\Search\Results\PluginFactory'], + 'factories' => [ 'solr' => 'VuFind\Search\Results\Factory::getSolr', - ), - ), - 'session' => array( - 'abstract_factories' => array('VuFind\Session\PluginFactory'), - 'invokables' => array( + ], + ], + 'session' => [ + 'abstract_factories' => ['VuFind\Session\PluginFactory'], + 'invokables' => [ 'database' => 'VuFind\Session\Database', 'file' => 'VuFind\Session\File', 'memcache' => 'VuFind\Session\Memcache', - ), - 'aliases' => array( + ], + 'aliases' => [ // for legacy 1.x compatibility 'filesession' => 'File', 'memcachesession' => 'Memcache', 'mysqlsession' => 'Database', - ), - ), - 'statistics_driver' => array( - 'abstract_factories' => array('VuFind\Statistics\Driver\PluginFactory'), - 'factories' => array( + ], + ], + 'statistics_driver' => [ + 'abstract_factories' => ['VuFind\Statistics\Driver\PluginFactory'], + 'factories' => [ 'file' => 'VuFind\Statistics\Driver\Factory::getFile', 'solr' => 'VuFind\Statistics\Driver\Factory::getSolr', - ), - 'invokables' => array( + ], + 'invokables' => [ 'db' => 'VuFind\Statistics\Driver\Db', - ), - 'aliases' => array( + ], + 'aliases' => [ 'database' => 'db', - ), - ), - ), + ], + ], + ], // This section behaves just like recorddriver_tabs below, but is used for // the collection module instead of the standard record view. - 'recorddriver_collection_tabs' => array( - 'VuFind\RecordDriver\AbstractBase' => array( - 'tabs' => array( + 'recorddriver_collection_tabs' => [ + 'VuFind\RecordDriver\AbstractBase' => [ + 'tabs' => [ 'CollectionList' => 'CollectionList', 'HierarchyTree' => 'CollectionHierarchyTree', - ), + ], 'defaultTab' => null, - ), - ), + ], + ], // This section controls which tabs are used for which record driver classes. // Each sub-array is a map from a tab name (as used in a record URL) to a tab // service (found in recordtab_plugin_manager, below). If a particular record // driver is not defined here, it will inherit configuration from a configured // parent class. The defaultTab setting may be used to specify the default // active tab; if null, the value from the relevant .ini file will be used. - 'recorddriver_tabs' => array( - 'VuFind\RecordDriver\EDS' => array( - 'tabs' => array( + 'recorddriver_tabs' => [ + 'VuFind\RecordDriver\EDS' => [ + 'tabs' => [ 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', 'Preview' => 'preview', 'Details' => 'StaffViewArray', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\Pazpar2' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\Pazpar2' => [ + 'tabs' => [ 'Details' => 'StaffViewMARC', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\Primo' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\Primo' => [ + 'tabs' => [ 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', 'Preview' => 'preview', 'Details' => 'StaffViewArray', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\SolrAuth' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\SolrAuth' => [ + 'tabs' => [ 'Details' => 'StaffViewMARC', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\SolrDefault' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\SolrDefault' => [ + 'tabs' => [ 'Holdings' => 'HoldingsILS', 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', @@ -619,11 +619,11 @@ $config = array( 'HierarchyTree' => 'HierarchyTree', 'Map' => 'Map', 'Similar' => 'SimilarItemsCarousel', 'Details' => 'StaffViewArray', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\SolrMarc' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\SolrMarc' => [ + 'tabs' => [ 'Holdings' => 'HoldingsILS', 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', @@ -631,59 +631,59 @@ $config = array( 'HierarchyTree' => 'HierarchyTree', 'Map' => 'Map', 'Similar' => 'SimilarItemsCarousel', 'Details' => 'StaffViewMARC', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\Summon' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\Summon' => [ + 'tabs' => [ 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', 'Preview' => 'preview', 'Details' => 'StaffViewArray', - ), + ], 'defaultTab' => null, - ), - 'VuFind\RecordDriver\WorldCat' => array( - 'tabs' => array( + ], + 'VuFind\RecordDriver\WorldCat' => [ + 'tabs' => [ 'Holdings' => 'HoldingsWorldCat', 'Description' => 'Description', 'TOC' => 'TOC', 'UserComments' => 'UserComments', 'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt', 'Details' => 'StaffViewMARC', - ), + ], 'defaultTab' => null, - ), - ), - ), + ], + ], + ], // Authorization configuration: - 'zfc_rbac' => array( + 'zfc_rbac' => [ 'identity_provider' => 'VuFind\AuthManager', 'guest_role' => 'guest', - 'role_provider' => array( - 'VuFind\Role\DynamicRoleProvider' => array( + 'role_provider' => [ + 'VuFind\Role\DynamicRoleProvider' => [ 'map_legacy_settings' => true, - ), - ), - 'role_provider_manager' => array( - 'factories' => array( + ], + ], + 'role_provider_manager' => [ + 'factories' => [ 'VuFind\Role\DynamicRoleProvider' => 'VuFind\Role\DynamicRoleProviderFactory', - ), - ), - 'vufind_permission_provider_manager' => array( - 'factories' => array( + ], + ], + 'vufind_permission_provider_manager' => [ + 'factories' => [ 'ipRange' => 'VuFind\Role\PermissionProvider\Factory::getIpRange', 'ipRegEx' => 'VuFind\Role\PermissionProvider\Factory::getIpRegEx', 'username' => 'VuFind\Role\PermissionProvider\Factory::getUsername', - ), - 'invokables' => array( + ], + 'invokables' => [ 'role' => 'VuFind\Role\PermissionProvider\Role', - ), - ), - ), -); + ], + ], + ], +]; // Define record view routes -- route name => controller -$recordRoutes = array( +$recordRoutes = [ 'record' => 'Record', 'collection' => 'Collection', 'edsrecord' => 'EdsRecord', @@ -693,20 +693,20 @@ $recordRoutes = array( 'solrauthrecord' => 'Authority', 'summonrecord' => 'SummonRecord', 'worldcatrecord' => 'WorldcatRecord' -); +]; // Record sub-routes are generally used to access tab plug-ins, but a few // URLs are hard-coded to specific actions; this array lists those actions. -$nonTabRecordActions = array( +$nonTabRecordActions = [ 'AddComment', 'DeleteComment', 'AddTag', 'Save', 'Email', 'SMS', 'Cite', 'Export', 'RDF', 'Hold', 'BlockedHold', 'Home', 'StorageRetrievalRequest', 'AjaxTab', 'BlockedStorageRetrievalRequest', 'ILLRequest', 'BlockedILLRequest', 'PDF', -); +]; // Define list-related routes -- route name => MyResearch action -$listRoutes = array('userList' => 'MyList', 'editList' => 'EditList'); +$listRoutes = ['userList' => 'MyList', 'editList' => 'EditList']; // Define static routes -- Controller/Action strings -$staticRoutes = array( +$staticRoutes = [ 'Alphabrowse/Home', 'Author/Home', 'Author/Search', 'Authority/Home', 'Authority/Record', 'Authority/Search', 'Browse/Author', 'Browse/Dewey', 'Browse/Era', 'Browse/Genre', 'Browse/Home', @@ -747,88 +747,88 @@ $staticRoutes = array( 'Upgrade/ShowSQL', 'Web/Home', 'Web/Results', 'Worldcat/Advanced', 'Worldcat/Home', 'Worldcat/Search' -); +]; // Build record routes foreach ($recordRoutes as $routeBase => $controller) { // catch-all "tab" route: - $config['router']['routes'][$routeBase] = array( + $config['router']['routes'][$routeBase] = [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/' . $controller . '/[:id[/:tab]]', - 'constraints' => array( + 'constraints' => [ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( + ], + 'defaults' => [ 'controller' => $controller, 'action' => 'Home', - ) - ) - ); + ] + ] + ]; // special non-tab actions that each need their own route: foreach ($nonTabRecordActions as $action) { - $config['router']['routes'][$routeBase . '-' . strtolower($action)] = array( + $config['router']['routes'][$routeBase . '-' . strtolower($action)] = [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/' . $controller . '/[:id]/' . $action, - 'constraints' => array( + 'constraints' => [ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( + ], + 'defaults' => [ 'controller' => $controller, 'action' => $action, - ) - ) - ); + ] + ] + ]; } } // Build list routes foreach ($listRoutes as $routeName => $action) { - $config['router']['routes'][$routeName] = array( + $config['router']['routes'][$routeName] = [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/MyResearch/' . $action . '/[:id]', - 'constraints' => array( + 'constraints' => [ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( + ], + 'defaults' => [ 'controller' => 'MyResearch', 'action' => $action, - ) - ) - ); + ] + ] + ]; } // Build static routes foreach ($staticRoutes as $route) { list($controller, $action) = explode('/', $route); $routeName = str_replace('/', '-', strtolower($route)); - $config['router']['routes'][$routeName] = array( + $config['router']['routes'][$routeName] = [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/' . $route, - 'defaults' => array( + 'defaults' => [ 'controller' => $controller, 'action' => $action, - ) - ) - ); + ] + ] + ]; } // Add the home route last -$config['router']['routes']['home'] = array( +$config['router']['routes']['home'] = [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/', - 'defaults' => array( + 'defaults' => [ 'controller' => 'index', 'action' => 'Home', - ) - ) -); + ] + ] +]; return $config; diff --git a/module/VuFind/src/VuFind/Auth/AbstractBase.php b/module/VuFind/src/VuFind/Auth/AbstractBase.php index 81f0a6ceb44..a32e0846e25 100644 --- a/module/VuFind/src/VuFind/Auth/AbstractBase.php +++ b/module/VuFind/src/VuFind/Auth/AbstractBase.php @@ -253,7 +253,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, */ public function getPasswordPolicy() { - $policy = array(); + $policy = []; $config = $this->getConfig(); if (isset($config->Authentication->minimum_password_length)) { $policy['minLength'] @@ -294,7 +294,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, throw new AuthException( $this->translate( 'password_minimum_length', - array('%%minlength%%' => $policy['minLength']) + ['%%minlength%%' => $policy['minLength']] ) ); } @@ -304,7 +304,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, throw new AuthException( $this->translate( 'password_maximum_length', - array('%%maxlength%%' => $policy['maxLength']) + ['%%maxlength%%' => $policy['maxLength']] ) ); } diff --git a/module/VuFind/src/VuFind/Auth/CAS.php b/module/VuFind/src/VuFind/Auth/CAS.php index e3b121d70ef..cc3d2da81b8 100644 --- a/module/VuFind/src/VuFind/Auth/CAS.php +++ b/module/VuFind/src/VuFind/Auth/CAS.php @@ -136,10 +136,10 @@ class CAS extends AbstractBase $user = $this->getUserTable()->getByUsername($username); // Has the user configured attributes to use for populating the user table? - $attribsToCheck = array( + $attribsToCheck = [ "cat_username", "cat_password", "email", "lastname", "firstname", "college", "major", "home_library" - ); + ]; foreach ($attribsToCheck as $attribute) { if (isset($cas->$attribute)) { $value = $casauth->getAttribute($cas->$attribute); @@ -235,7 +235,7 @@ class CAS extends AbstractBase protected function getRequiredAttributes() { // Special case -- store username as-is to establish return array: - $sortedUserAttributes = array(); + $sortedUserAttributes = []; // Now extract user attribute values: $cas = $this->getConfig()->CAS; diff --git a/module/VuFind/src/VuFind/Auth/ChoiceAuth.php b/module/VuFind/src/VuFind/Auth/ChoiceAuth.php index 7b935dac2fd..f0b08a37c75 100644 --- a/module/VuFind/src/VuFind/Auth/ChoiceAuth.php +++ b/module/VuFind/src/VuFind/Auth/ChoiceAuth.php @@ -50,7 +50,7 @@ class ChoiceAuth extends AbstractBase * * @var array */ - protected $strategies = array(); + protected $strategies = []; /** * Auth strategy selected by user @@ -306,10 +306,10 @@ class ChoiceAuth extends AbstractBase } $authenticator = $this->getPluginManager()->get($this->strategy); $authenticator->setConfig($this->getConfig()); - if (!is_callable(array($authenticator, $method))) { + if (!is_callable([$authenticator, $method])) { throw new AuthException($this->strategy . "has no method $method"); } - return call_user_func_array(array($authenticator, $method), $params); + return call_user_func_array([$authenticator, $method], $params); } /** diff --git a/module/VuFind/src/VuFind/Auth/Database.php b/module/VuFind/src/VuFind/Auth/Database.php index 7a33fc378e8..8d930d16eba 100644 --- a/module/VuFind/src/VuFind/Auth/Database.php +++ b/module/VuFind/src/VuFind/Auth/Database.php @@ -110,10 +110,10 @@ class Database extends AbstractBase { // Ensure that all expected parameters are populated to avoid notices // in the code below. - $params = array( + $params = [ 'firstname' => '', 'lastname' => '', 'username' => '', 'password' => '', 'password2' => '', 'email' => '' - ); + ]; foreach ($params as $param => $default) { $params[$param] = $request->getPost()->get($param, $default); } @@ -141,13 +141,13 @@ class Database extends AbstractBase } // If we got this far, we're ready to create the account: - $data = array( + $data = [ 'username' => $params['username'], 'firstname' => $params['firstname'], 'lastname' => $params['lastname'], 'email' => $params['email'], 'created' => date('Y-m-d H:i:s') - ); + ]; if ($this->passwordHashingEnabled()) { $bcrypt = new Bcrypt(); @@ -173,9 +173,9 @@ class Database extends AbstractBase { // Ensure that all expected parameters are populated to avoid notices // in the code below. - $params = array( + $params = [ 'username' => '', 'password' => '', 'password2' => '' - ); + ]; foreach ($params as $param => $default) { $params[$param] = $request->getPost()->get($param, $default); } diff --git a/module/VuFind/src/VuFind/Auth/ILS.php b/module/VuFind/src/VuFind/Auth/ILS.php index a01e02605fe..c8a69c509a2 100644 --- a/module/VuFind/src/VuFind/Auth/ILS.php +++ b/module/VuFind/src/VuFind/Auth/ILS.php @@ -135,7 +135,7 @@ class ILS extends AbstractBase { return false !== $this->getCatalog()->checkFunction( 'changePassword', - array('patron' => $this->getLoggedInPatron()) + ['patron' => $this->getLoggedInPatron()] ); } @@ -163,8 +163,8 @@ class ILS extends AbstractBase { // Ensure that all expected parameters are populated to avoid notices // in the code below. - $params = array(); - foreach (array('oldpwd', 'password', 'password2') as $param) { + $params = []; + foreach (['oldpwd', 'password', 'password2'] as $param) { $params[$param] = $request->getPost()->get($param, ''); } @@ -177,11 +177,11 @@ class ILS extends AbstractBase $this->validatePasswordUpdate($params); $result = $this->getCatalog()->changePassword( - array( + [ 'patron' => $patron, 'oldPassword' => $params['oldpwd'], 'newPassword' => $params['password'] - ) + ] ); if (!$result['success']) { throw new AuthException($result['status']); @@ -219,7 +219,7 @@ class ILS extends AbstractBase $user->password = ''; // Update user information based on ILS data: - $fields = array('firstname', 'lastname', 'email', 'major', 'college'); + $fields = ['firstname', 'lastname', 'email', 'major', 'college']; foreach ($fields as $field) { $user->$field = isset($info[$field]) ? $info[$field] : ' '; } diff --git a/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php b/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php index df4c20718e0..5d24cb8582b 100644 --- a/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php +++ b/module/VuFind/src/VuFind/Auth/ILSAuthenticator.php @@ -58,7 +58,7 @@ class ILSAuthenticator * * @var array */ - protected $ilsAccount = array(); + protected $ilsAccount = []; /** * Constructor diff --git a/module/VuFind/src/VuFind/Auth/LDAP.php b/module/VuFind/src/VuFind/Auth/LDAP.php index 451cf553685..c80c4fced3e 100644 --- a/module/VuFind/src/VuFind/Auth/LDAP.php +++ b/module/VuFind/src/VuFind/Auth/LDAP.php @@ -52,7 +52,7 @@ class LDAP extends AbstractBase protected function validateConfig() { // Check for missing parameters: - $requiredParams = array('host', 'port', 'basedn', 'username'); + $requiredParams = ['host', 'port', 'basedn', 'username']; foreach ($requiredParams as $param) { if (!isset($this->config->LDAP->$param) || empty($this->config->LDAP->$param) @@ -78,7 +78,7 @@ class LDAP extends AbstractBase // Normalize all values to lowercase except for potentially case-sensitive // bind and basedn credentials. - $doNotLower = array('bind_username', 'bind_password', 'basedn'); + $doNotLower = ['bind_username', 'bind_password', 'basedn']; return (in_array($name, $doNotLower)) ? $value : strtolower($value); } @@ -258,10 +258,10 @@ class LDAP extends AbstractBase protected function processLDAPUser($username, $data) { // Database fields that we may be able to load from LDAP: - $fields = array( + $fields = [ 'firstname', 'lastname', 'email', 'cat_username', 'cat_password', 'college', 'major' - ); + ]; // User object to populate from LDAP: $user = $this->getUserTable()->getByUsername($username); diff --git a/module/VuFind/src/VuFind/Auth/Manager.php b/module/VuFind/src/VuFind/Auth/Manager.php index 6901de079dc..8da987b076b 100644 --- a/module/VuFind/src/VuFind/Auth/Manager.php +++ b/module/VuFind/src/VuFind/Auth/Manager.php @@ -46,7 +46,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface * * @var \VuFind\Auth\AbstractBase[] */ - protected $auth = array(); + protected $auth = []; /** * Currently selected authentication module @@ -128,7 +128,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface // if no setting passed in): $method = isset($config->Authentication->method) ? $config->Authentication->method : 'Database'; - $this->legalAuthOptions = array($method); // mark it as legal + $this->legalAuthOptions = [$method]; // mark it as legal $this->setAuthMethod($method); // load it } @@ -251,7 +251,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface public function getAuthClassForTemplateRendering() { $auth = $this->getAuth(); - if (is_callable(array($auth, 'getSelectedAuthOption'))) { + if (is_callable([$auth, 'getSelectedAuthOption'])) { $selected = $auth->getSelectedAuthOption(); if ($selected) { $auth = $this->getAuth($selected); @@ -270,12 +270,12 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface public function getSelectableAuthOptions() { $auth = $this->getAuth(); - if (is_callable(array($auth, 'getSelectableAuthOptions'))) { + if (is_callable([$auth, 'getSelectableAuthOptions'])) { if ($methods = $auth->getSelectableAuthOptions()) { return $methods; } } - return array($this->getAuthMethod()); + return [$this->getAuthMethod()]; } /** @@ -288,8 +288,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface public function getLoginTargets() { $auth = $this->getAuth(); - return is_callable(array($auth, 'getLoginTargets')) - ? $auth->getLoginTargets() : array(); + return is_callable([$auth, 'getLoginTargets']) + ? $auth->getLoginTargets() : []; } /** @@ -302,7 +302,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface public function getDefaultLoginTarget() { $auth = $this->getAuth(); - return is_callable(array($auth, 'getDefaultLoginTarget')) + return is_callable([$auth, 'getDefaultLoginTarget']) ? $auth->getDefaultLoginTarget() : null; } @@ -357,7 +357,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface // If we don't want to destroy the session, we still need to empty it. // There should be a way to do this through Zend\Session, but there // apparently isn't (TODO -- do this better): - $_SESSION = array(); + $_SESSION = []; } return $url; @@ -384,7 +384,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface // load the object from the database: if (!$this->currentUser && isset($this->session->userId)) { $results = $this->userTable - ->select(array('id' => $this->session->userId)); + ->select(['id' => $this->session->userId]); $this->currentUser = count($results) < 1 ? false : $results->current(); } diff --git a/module/VuFind/src/VuFind/Auth/MultiAuth.php b/module/VuFind/src/VuFind/Auth/MultiAuth.php index 055ed057843..f72ef18ed0c 100644 --- a/module/VuFind/src/VuFind/Auth/MultiAuth.php +++ b/module/VuFind/src/VuFind/Auth/MultiAuth.php @@ -68,14 +68,14 @@ class MultiAuth extends AbstractBase * * @var array */ - protected $filters = array(); + protected $filters = []; /** * Authentication methods to try * * @var array */ - protected $methods = array(); + protected $methods = []; /** * Username input diff --git a/module/VuFind/src/VuFind/Auth/Shibboleth.php b/module/VuFind/src/VuFind/Auth/Shibboleth.php index ec072621953..d8308b14016 100644 --- a/module/VuFind/src/VuFind/Auth/Shibboleth.php +++ b/module/VuFind/src/VuFind/Auth/Shibboleth.php @@ -99,10 +99,10 @@ class Shibboleth extends AbstractBase $catPassword = null; // Has the user configured attributes to use for populating the user table? - $attribsToCheck = array( + $attribsToCheck = [ 'cat_username', 'cat_password', 'email', 'lastname', 'firstname', 'college', 'major', 'home_library' - ); + ]; foreach ($attribsToCheck as $attribute) { if (isset($shib->$attribute)) { $value = $request->getServer()->get($shib->$attribute); @@ -209,7 +209,7 @@ class Shibboleth extends AbstractBase protected function getRequiredAttributes() { // Special case -- store username as-is to establish return array: - $sortedUserAttributes = array(); + $sortedUserAttributes = []; // Now extract user attribute values: $shib = $this->getConfig()->Shibboleth; diff --git a/module/VuFind/src/VuFind/Autocomplete/None.php b/module/VuFind/src/VuFind/Autocomplete/None.php index d4f1fc99159..3e3c47d6365 100644 --- a/module/VuFind/src/VuFind/Autocomplete/None.php +++ b/module/VuFind/src/VuFind/Autocomplete/None.php @@ -52,7 +52,7 @@ class None implements AutocompleteInterface public function getSuggestions($query) { // No suggestions - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/Autocomplete/OCLCIdentities.php b/module/VuFind/src/VuFind/Autocomplete/OCLCIdentities.php index ffeea422f58..1b3332c3a69 100644 --- a/module/VuFind/src/VuFind/Autocomplete/OCLCIdentities.php +++ b/module/VuFind/src/VuFind/Autocomplete/OCLCIdentities.php @@ -59,7 +59,7 @@ class OCLCIdentities implements AutocompleteInterface public function getSuggestions($query) { // Initialize return array: - $results = array(); + $results = []; // Build target URL: $target = $this->url . '?query=' . urlencode($query); diff --git a/module/VuFind/src/VuFind/Autocomplete/PluginManager.php b/module/VuFind/src/VuFind/Autocomplete/PluginManager.php index c6d7bc5f035..db097babda1 100644 --- a/module/VuFind/src/VuFind/Autocomplete/PluginManager.php +++ b/module/VuFind/src/VuFind/Autocomplete/PluginManager.php @@ -82,7 +82,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager $config = $this->getServiceLocator()->get('VuFind\Config') ->get($options->getSearchIni()); $types = isset($config->Autocomplete_Types) ? - $config->Autocomplete_Types->toArray() : array(); + $config->Autocomplete_Types->toArray() : []; // Figure out which handler to use: if (!empty($type) && isset($types[$type])) { @@ -104,6 +104,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager } return (isset($handler) && is_object($handler)) - ? array_values($handler->getSuggestions($query)) : array(); + ? array_values($handler->getSuggestions($query)) : []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Autocomplete/Solr.php b/module/VuFind/src/VuFind/Autocomplete/Solr.php index a6f19cca5e9..de819dfeb6d 100644 --- a/module/VuFind/src/VuFind/Autocomplete/Solr.php +++ b/module/VuFind/src/VuFind/Autocomplete/Solr.php @@ -122,10 +122,10 @@ class Solr implements AutocompleteInterface $this->handler = (isset($params[0]) && !empty($params[0])) ? $params[0] : null; $this->displayField = (isset($params[1]) && !empty($params[1])) ? - explode(',', $params[1]) : array($this->defaultDisplayField); + explode(',', $params[1]) : [$this->defaultDisplayField]; $this->sortField = (isset($params[2]) && !empty($params[2])) ? $params[2] : null; - $this->filters = array(); + $this->filters = []; if (count($params > 3)) { for ($x = 3; $x < count($params); $x += 2) { if (isset($params[$x + 1])) { @@ -161,7 +161,7 @@ class Solr implements AutocompleteInterface protected function mungeQuery($query) { // Modify the query so it makes a nice, truncated autocomplete query: - $forbidden = array(':', '(', ')', '*', '+', '"'); + $forbidden = [':', '(', ')', '*', '+', '"']; $query = str_replace($forbidden, " ", $query); if (substr($query, -1) != " ") { $query .= "*"; @@ -221,7 +221,7 @@ class Solr implements AutocompleteInterface */ protected function getSuggestionsFromSearch($searchResults, $query, $exact) { - $results = array(); + $results = []; foreach ($searchResults as $object) { $current = $object->getRawData(); foreach ($this->displayField as $field) { diff --git a/module/VuFind/src/VuFind/Autocomplete/SolrCN.php b/module/VuFind/src/VuFind/Autocomplete/SolrCN.php index 8b0f96fe2fd..c56fa796b8d 100644 --- a/module/VuFind/src/VuFind/Autocomplete/SolrCN.php +++ b/module/VuFind/src/VuFind/Autocomplete/SolrCN.php @@ -65,17 +65,17 @@ class SolrCN extends Solr protected function mungeQuery($query) { // Modify the query so it makes a nice, truncated autocomplete query: - $forbidden = array(':', '(', ')', '*', '+', '"'); + $forbidden = [':', '(', ')', '*', '+', '"']; $query = str_replace($forbidden, " ", $query); // Assign display fields and sort order based on the query -- if the // first character is a number, give Dewey priority; otherwise, give // LC priority: if (is_numeric(substr(trim($query), 0, 1))) { - $this->setDisplayField(array('dewey-full', 'callnumber-a')); + $this->setDisplayField(['dewey-full', 'callnumber-a']); $this->setSortField("dewey-sort,callnumber"); } else { - $this->setDisplayField(array('callnumber-a', 'dewey-full')); + $this->setDisplayField(['callnumber-a', 'dewey-full']); $this->setSortField("callnumber,dewey-sort"); } diff --git a/module/VuFind/src/VuFind/Autocomplete/Tag.php b/module/VuFind/src/VuFind/Autocomplete/Tag.php index a22e8e8cfa7..9e9d215564d 100644 --- a/module/VuFind/src/VuFind/Autocomplete/Tag.php +++ b/module/VuFind/src/VuFind/Autocomplete/Tag.php @@ -52,7 +52,7 @@ class Tag implements AutocompleteInterface, \VuFind\Db\Table\DbTableAwareInterfa */ public function getSuggestions($query) { - $tagList = array(); + $tagList = []; $tagTable = $this->getTagsTable(); $tags = $tagTable->matchText($query); if ($tags) { diff --git a/module/VuFind/src/VuFind/Bootstrapper.php b/module/VuFind/src/VuFind/Bootstrapper.php index f43f8fe6fb3..a0357003d15 100644 --- a/module/VuFind/src/VuFind/Bootstrapper.php +++ b/module/VuFind/src/VuFind/Bootstrapper.php @@ -159,7 +159,7 @@ class Bootstrapper ) { $callback = function ($e) { $routeMatch = new RouteMatch( - array('controller' => 'Error', 'action' => 'Unavailable'), 1 + ['controller' => 'Error', 'action' => 'Unavailable'], 1 ); $routeMatch->setMatchedRouteName('error-unavailable'); $e->setRouteMatch($routeMatch); @@ -180,7 +180,7 @@ class Bootstrapper // their behavior here. setlocale( LC_MONETARY, - array("{$this->config->Site->locale}.UTF-8", $this->config->Site->locale) + ["{$this->config->Site->locale}.UTF-8", $this->config->Site->locale] ); date_default_timezone_set($this->config->Site->timezone); } @@ -299,7 +299,7 @@ class Bootstrapper } $config = & $this->config; - $browserCallback = array($this, 'detectBrowserLanguage'); + $browserCallback = [$this, 'detectBrowserLanguage']; $callback = function ($event) use ($config, $browserCallback) { $validBrowserLanguage = call_user_func($browserCallback); @@ -357,7 +357,7 @@ class Bootstrapper // Attach template injection configuration to the route event: $this->events->attach( - 'route', array('VuFindTheme\Initializer', 'configureTemplateInjection') + 'route', ['VuFindTheme\Initializer', 'configureTemplateInjection'] ); // Attach remaining theme configuration to the dispatch event at high @@ -411,7 +411,7 @@ class Bootstrapper $sm = $this->event->getApplication()->getServiceManager(); $bm = $sm->get('VuFind\Search\BackendManager'); $events = $sm->get('SharedEventManager'); - $events->attach('VuFindSearch', 'resolve', array($bm, 'onResolve')); + $events->attach('VuFindSearch', 'resolve', [$bm, 'onResolve']); } /** @@ -425,12 +425,12 @@ class Bootstrapper $sm = $event->getApplication()->getServiceManager(); if ($sm->has('VuFind\Logger')) { $log = $sm->get('VuFind\Logger'); - if (is_callable(array($log, 'logException'))) { + if (is_callable([$log, 'logException'])) { $exception = $event->getParam('exception'); // Console request does not include server, // so use a dummy in that case. $server = Console::isConsole() - ? new \Zend\Stdlib\Parameters(array('env' => 'console')) + ? new \Zend\Stdlib\Parameters(['env' => 'console']) : $event->getRequest()->getServer(); if (!empty($exception)) { $log->logException($exception, $server); diff --git a/module/VuFind/src/VuFind/Cache/Manager.php b/module/VuFind/src/VuFind/Cache/Manager.php index 6e2f344b9b4..bcbccde404a 100644 --- a/module/VuFind/src/VuFind/Cache/Manager.php +++ b/module/VuFind/src/VuFind/Cache/Manager.php @@ -60,14 +60,14 @@ class Manager * * @var array */ - protected $cacheSettings = array(); + protected $cacheSettings = []; /** * Actual cache objects generated from settings. * * @var array */ - protected $caches = array(); + protected $caches = []; /** * Constructor @@ -89,7 +89,7 @@ class Manager $cacheBase = $this->getCacheDir(); // Set up standard file-based caches: - foreach (array('config', 'cover', 'language', 'object') as $cache) { + foreach (['config', 'cover', 'language', 'object'] as $cache) { $this->createFileCache($cache, $cacheBase . $cache . 's'); } @@ -239,7 +239,7 @@ class Manager } } if (empty($opts)) { - $opts = array('cache_dir' => $dirName); + $opts = ['cache_dir' => $dirName]; } elseif (is_array($opts)) { // If cache_dir was set in config.ini, the cache-specific name should // have been appended to the path to create the value $dirName. @@ -248,10 +248,10 @@ class Manager // Dryrot throw new \Exception('$opts is neither array nor false'); } - $this->cacheSettings[$cacheName] = array( - 'adapter' => array('name' => 'filesystem', 'options' => $opts), - 'plugins' => array('serializer') - ); + $this->cacheSettings[$cacheName] = [ + 'adapter' => ['name' => 'filesystem', 'options' => $opts], + 'plugins' => ['serializer'] + ]; } /** @@ -263,9 +263,9 @@ class Manager */ protected function createAPCCache($cacheName) { - $this->cacheSettings[$cacheName] = array( + $this->cacheSettings[$cacheName] = [ 'adapter' => 'APC', - 'plugins' => array('serializer') - ); + 'plugins' => ['serializer'] + ]; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Cart.php b/module/VuFind/src/VuFind/Cart.php index b7606b3e335..3385de5a128 100644 --- a/module/VuFind/src/VuFind/Cart.php +++ b/module/VuFind/src/VuFind/Cart.php @@ -131,7 +131,7 @@ class Cart */ public function emptyCart() { - $this->items = array(); + $this->items = []; $this->save(); } @@ -145,7 +145,7 @@ class Cart */ public function addItem($item) { - return $this->addItems(array($item)); + return $this->addItems([$item]); } /** @@ -165,9 +165,9 @@ class Cart $this->save(); if ($total > $this->maxSize) { $notAdded = $total-$this->maxSize; - return array('success' => false, 'notAdded' => $notAdded); + return ['success' => false, 'notAdded' => $notAdded]; } - return array('success' => true); + return ['success' => true]; } /** @@ -179,7 +179,7 @@ class Cart */ public function removeItems($items) { - $results = array(); + $results = []; foreach ($this->items as $id) { if (!in_array($id, $items)) { $results[] = $id; @@ -261,7 +261,7 @@ class Cart } } } - $this->items = $items ? $items : array(); + $this->items = $items ? $items : []; } /** @@ -272,8 +272,8 @@ class Cart */ protected function save() { - $sources = array(); - $ids = array(); + $sources = []; + $ids = []; foreach ($this->items as $item) { // Break apart the source and the ID: diff --git a/module/VuFind/src/VuFind/Config/PluginFactory.php b/module/VuFind/src/VuFind/Config/PluginFactory.php index 193c8d6e2c8..876b9bcc27d 100644 --- a/module/VuFind/src/VuFind/Config/PluginFactory.php +++ b/module/VuFind/src/VuFind/Config/PluginFactory.php @@ -71,13 +71,13 @@ class PluginFactory implements AbstractFactoryInterface */ protected function loadConfigFile($filename, $path = 'config/vufind') { - $configs = array(); + $configs = []; $fullpath = Locator::getConfigPath($filename, $path); // Return empty configuration if file does not exist: if (!file_exists($fullpath)) { - return new Config(array()); + return new Config([]); } // Retrieve and parse at least one configuration file, and possibly a whole @@ -111,7 +111,7 @@ class PluginFactory implements AbstractFactoryInterface ' ', '', $child->Parent_Config->override_full_sections ) ) - : array(); + : []; foreach ($child as $section => $contents) { if (in_array($section, $overrideSections) || !isset($config->$section) diff --git a/module/VuFind/src/VuFind/Config/SearchSpecsReader.php b/module/VuFind/src/VuFind/Config/SearchSpecsReader.php index f65a280a402..b2172e98209 100644 --- a/module/VuFind/src/VuFind/Config/SearchSpecsReader.php +++ b/module/VuFind/src/VuFind/Config/SearchSpecsReader.php @@ -51,7 +51,7 @@ class SearchSpecsReader * * @var array */ - protected $searchSpecs = array(); + protected $searchSpecs = []; /** * Constructor @@ -92,7 +92,7 @@ class SearchSpecsReader // Generate data if not found in cache: if ($cache === false || !($results = $cache->getItem($cacheKey))) { - $results = file_exists($fullpath) ? Yaml::parse($fullpath) : array(); + $results = file_exists($fullpath) ? Yaml::parse($fullpath) : []; if (!empty($local)) { $localResults = Yaml::parse($local); foreach ($localResults as $key => $value) { diff --git a/module/VuFind/src/VuFind/Config/Upgrade.php b/module/VuFind/src/VuFind/Config/Upgrade.php index 801bd23a98d..dfeee51de88 100644 --- a/module/VuFind/src/VuFind/Config/Upgrade.php +++ b/module/VuFind/src/VuFind/Config/Upgrade.php @@ -80,28 +80,28 @@ class Upgrade * * @var array */ - protected $oldConfigs = array(); + protected $oldConfigs = []; /** * Processed new configurations * * @var array */ - protected $newConfigs = array(); + protected $newConfigs = []; /** * Comments parsed from configuration files * * @var array */ - protected $comments = array(); + protected $comments = []; /** * Warnings generated during upgrade process * * @var array */ - protected $warnings = array(); + protected $warnings = []; /** * Are we upgrading files in place rather than creating them? @@ -289,11 +289,11 @@ class Upgrade { // Configuration files to load. Note that config.ini must always be loaded // first so that getOldConfigPath can work properly! - $configs = array( + $configs = [ 'config.ini', 'authority.ini', 'facets.ini', 'reserves.ini', 'searches.ini', 'Summon.ini', 'WorldCat.ini', 'sms.ini', 'permissions.ini' - ); + ]; foreach ($configs as $config) { // Special case for config.ini, since we may need to overlay extra // settings: @@ -302,7 +302,7 @@ class Upgrade } else { $path = $this->getOldConfigPath($config); $this->oldConfigs[$config] = file_exists($path) - ? parse_ini_file($path, true) : array(); + ? parse_ini_file($path, true) : []; } $this->newConfigs[$config] = parse_ini_file($this->rawDir . '/' . $config, true); @@ -320,7 +320,7 @@ class Upgrade * * @return void */ - protected function applyOldSettings($filename, $fullSections = array()) + protected function applyOldSettings($filename, $fullSections = []) { // First override all individual settings: foreach ($this->oldConfigs[$filename] as $section => $subsection) { @@ -333,7 +333,7 @@ class Upgrade foreach ($fullSections as $section) { $this->newConfigs[$filename][$section] = isset($this->oldConfigs[$filename][$section]) - ? $this->oldConfigs[$filename][$section] : array(); + ? $this->oldConfigs[$filename][$section] : []; } } @@ -568,7 +568,7 @@ class Upgrade && !is_array($newConfig['Content']['GoogleOptions']) ) { $newConfig['Content']['GoogleOptions'] - = array('link' => $newConfig['Content']['GoogleOptions']); + = ['link' => $newConfig['Content']['GoogleOptions']]; } // Disable unused, obsolete setting: @@ -596,7 +596,7 @@ class Upgrade // Eliminate obsolete database settings: $newConfig['Database'] - = array('database' => $newConfig['Database']['database']); + = ['database' => $newConfig['Database']['database']]; // Eliminate obsolete config override settings: unset($newConfig['Extra_Config']); @@ -605,7 +605,7 @@ class Upgrade if (isset($newConfig['Statistics']['enabled'])) { // If "enabled" is on, this equates to the new system being in Solr mode: if ($newConfig['Statistics']['enabled']) { - $newConfig['Statistics']['mode'] = array('Solr'); + $newConfig['Statistics']['mode'] = ['Solr']; } // Whether or not "enabled" is on, remove the deprecated setting: @@ -680,10 +680,10 @@ class Upgrade { // we want to retain the old installation's various facet groups // exactly as-is - $facetGroups = array( + $facetGroups = [ 'Results', 'ResultsTop', 'Advanced', 'Author', 'CheckboxFacets', 'HomePage' - ); + ]; $this->applyOldSettings('facets.ini', $facetGroups); // fill in home page facets with advanced facets if missing: @@ -721,9 +721,9 @@ class Upgrade { // we want to retain the old installation's Basic/Advanced search settings // and sort settings exactly as-is - $groups = array( + $groups = [ 'Basic_Searches', 'Advanced_Searches', 'Sorting', 'DefaultSortingByType' - ); + ]; $this->applyOldSettings('searches.ini', $groups); // Fix autocomplete settings in case they use the old style: @@ -742,7 +742,7 @@ class Upgrade } } - $this->upgradeSpellingSettings('searches.ini', array('CallNumber')); + $this->upgradeSpellingSettings('searches.ini', ['CallNumber']); // save the file $this->saveModifiedConfig('searches.ini'); @@ -757,17 +757,17 @@ class Upgrade * * @return void */ - protected function upgradeSpellingSettings($ini, $skip = array()) + protected function upgradeSpellingSettings($ini, $skip = []) { // Turn on the spelling recommendations if we're upgrading from a version // prior to 2.4. if ((float)$this->from < 2.4) { // Fix defaults in general section: $cfg = & $this->newConfigs[$ini]['General']; - $keys = array('default_top_recommend', 'default_noresults_recommend'); + $keys = ['default_top_recommend', 'default_noresults_recommend']; foreach ($keys as $key) { if (!isset($cfg[$key])) { - $cfg[$key] = array(); + $cfg[$key] = []; } if (!in_array('SpellingSuggestions', $cfg[$key])) { $cfg[$key][] = 'SpellingSuggestions'; @@ -790,7 +790,7 @@ class Upgrade if (!isset($cfg[$key])) { $cfg[$key] = array_diff( $this->newConfigs[$ini]['General']['default_top_recommend'], - array('SpellingSuggestions') + ['SpellingSuggestions'] ); } } @@ -827,7 +827,7 @@ class Upgrade */ protected function upgradeSms() { - $this->applyOldSettings('sms.ini', array('Carriers')); + $this->applyOldSettings('sms.ini', ['Carriers']); $this->saveModifiedConfig('sms.ini'); } @@ -841,9 +841,9 @@ class Upgrade { // we want to retain the old installation's search and facet settings // exactly as-is - $groups = array( + $groups = [ 'Facets', 'Basic_Searches', 'Advanced_Searches', 'Sorting' - ); + ]; $this->applyOldSettings('authority.ini', $groups); // save the file @@ -867,9 +867,9 @@ class Upgrade // we want to retain the old installation's search and facet settings // exactly as-is - $groups = array( + $groups = [ 'Facets', 'Basic_Searches', 'Advanced_Searches', 'Sorting' - ); + ]; $this->applyOldSettings('reserves.ini', $groups); // save the file @@ -892,9 +892,9 @@ class Upgrade // we want to retain the old installation's search and facet settings // exactly as-is - $groups = array( + $groups = [ 'Facets', 'FacetsTop', 'Basic_Searches', 'Advanced_Searches', 'Sorting' - ); + ]; $this->applyOldSettings('Summon.ini', $groups); // Turn on advanced checkbox facets if we're upgrading from a version @@ -966,14 +966,14 @@ class Upgrade } // we want to retain the old installation's search settings exactly as-is - $groups = array( + $groups = [ 'Basic_Searches', 'Advanced_Searches', 'Sorting' - ); + ]; $this->applyOldSettings('WorldCat.ini', $groups); // we need to fix an obsolete search setting for authors - foreach (array('Basic_Searches', 'Advanced_Searches') as $section) { - $new = array(); + foreach (['Basic_Searches', 'Advanced_Searches'] as $section) { + $new = []; foreach ($this->newConfigs['WorldCat.ini'][$section] as $k => $v) { if ($k == 'srw.au:srw.pn:srw.cn') { $k = 'srw.au'; @@ -1052,7 +1052,7 @@ class Upgrade // VuFind 1.x uses *_local.yaml files as overrides; VuFind 2.x uses files // with the same filename in the local directory. Copy any old override // files into the new expected location: - $files = array('searchspecs', 'authsearchspecs', 'reservessearchspecs'); + $files = ['searchspecs', 'authsearchspecs', 'reservessearchspecs']; foreach ($files as $file) { $old = $this->oldDir . '/' . $file . '_local.yaml'; $new = $this->newDir . '/' . $file . '.yaml'; @@ -1132,7 +1132,7 @@ class Upgrade // setting with StripFields setting): if (isset($this->oldConfigs['facets.ini']['StripFacets'])) { if (!isset($this->oldConfigs['searches.ini']['StripFields'])) { - $this->oldConfigs['searches.ini']['StripFields'] = array(); + $this->oldConfigs['searches.ini']['StripFields'] = []; } foreach ($this->oldConfigs['facets.ini']['StripFacets'] as $k => $v) { // If we already have values for the current key, merge and dedupe: @@ -1179,7 +1179,7 @@ class Upgrade $lines = file($filename); // Initialize our return value: - $retVal = array('sections' => array(), 'after' => ''); + $retVal = ['sections' => [], 'after' => '']; // Initialize variables for tracking status during parsing: $section = $comments = ''; @@ -1206,10 +1206,10 @@ class Upgrade } else { $inline = ''; } - $retVal['sections'][$section] = array( + $retVal['sections'][$section] = [ 'before' => $comments, 'inline' => $inline, - 'settings' => array()); + 'settings' => []]; $comments = ''; } } else if (($equals = strpos($trimmed, '=')) !== false) { @@ -1231,7 +1231,7 @@ class Upgrade // concern, but we should improve it if we ever need to. if (!isset($retVal['sections'][$section]['settings'][$set])) { $retVal['sections'][$section]['settings'][$set] - = array('before' => $comments, 'inline' => $inline); + = ['before' => $comments, 'inline' => $inline]; } else { $retVal['sections'][$section]['settings'][$set]['before'] .= $comments; diff --git a/module/VuFind/src/VuFind/Config/Writer.php b/module/VuFind/src/VuFind/Config/Writer.php index cc54657ee27..ea14c831886 100644 --- a/module/VuFind/src/VuFind/Config/Writer.php +++ b/module/VuFind/src/VuFind/Config/Writer.php @@ -64,7 +64,7 @@ class Writer * * @throws \Exception */ - public function __construct($filename, $content = null, $comments = array()) + public function __construct($filename, $content = null, $comments = []) { $this->filename = $filename; if (null === $content) { @@ -158,7 +158,7 @@ class Writer public function save() { // Create parent directory structure if necessary: - $stack = array(); + $stack = []; $dirname = dirname($this->filename); while (!empty($dirname) && !is_dir($dirname)) { $stack[] = $dirname; @@ -267,7 +267,7 @@ class Writer = $comments['sections'][$key]['settings'][$key2]; $content .= $settingComments['before']; } else { - $settingComments = array(); + $settingComments = []; } if (is_array($elem2)) { $content .= $this->buildContentArrayLines($key2, $elem2); diff --git a/module/VuFind/src/VuFind/Connection/OpenLibrary.php b/module/VuFind/src/VuFind/Connection/OpenLibrary.php index 5533ce01507..d5996ea0e7c 100644 --- a/module/VuFind/src/VuFind/Connection/OpenLibrary.php +++ b/module/VuFind/src/VuFind/Connection/OpenLibrary.php @@ -79,7 +79,7 @@ class OpenLibrary $limit = 5, $offset = null, $publicFullText = true ) { // empty array to hold the result - $result = array(); + $result = []; // normalise subject term $subject = $this->normaliseSubjectString($subject); @@ -125,7 +125,7 @@ class OpenLibrary protected function processSubjectsApi($url, $limit, $publicFullText) { // empty array to hold the result - $result = array(); + $result = []; // find out if there are any reviews $response = $this->client->setUri($url)->setMethod('GET')->send(); @@ -174,7 +174,7 @@ class OpenLibrary protected function normaliseSubjectString($subject) { // Normalise search term - $subject = str_replace(array('"', ',', '/'), '', $subject); + $subject = str_replace(['"', ',', '/'], '', $subject); $subject = trim(strtolower($subject)); $subject = preg_replace("/\s+/", "_", $subject); return $subject; diff --git a/module/VuFind/src/VuFind/Connection/Oracle.php b/module/VuFind/src/VuFind/Connection/Oracle.php index 3aa91d6d7e7..7da996b535e 100644 --- a/module/VuFind/src/VuFind/Connection/Oracle.php +++ b/module/VuFind/src/VuFind/Connection/Oracle.php @@ -318,7 +318,7 @@ class Oracle * * @return array|bool Results on success, false on error. */ - public function simpleSelect($sql, $fields = array()) + public function simpleSelect($sql, $fields = []) { $stmt = $this->prepare($sql); foreach ($fields as $field => $datum) { @@ -345,11 +345,11 @@ class Oracle * * @return bool */ - public function simpleDelete($table, $fields = array()) + public function simpleDelete($table, $fields = []) { - $types = array(); - $data = array(); - $clauses = array(); + $types = []; + $data = []; + $clauses = []; // Split all the fields up into arrays foreach ($fields as $field => $datum) { @@ -391,12 +391,12 @@ class Oracle * * @return bool */ - public function simpleInsert($table, $fields = array()) + public function simpleInsert($table, $fields = []) { - $types = array(); - $data = array(); - $columns = array(); - $values = array(); + $types = []; + $data = []; + $columns = []; + $values = []; // Split all the fields up into arrays foreach ($fields as $field => $datum) { @@ -448,7 +448,7 @@ class Oracle * * @return bool */ - public function simpleSql($sql, $fields = array()) + public function simpleSql($sql, $fields = []) { $stmt = $this->prepare($sql); foreach ($fields as $field => $datum) { diff --git a/module/VuFind/src/VuFind/Connection/Wikipedia.php b/module/VuFind/src/VuFind/Connection/Wikipedia.php index 75326b7e1f2..164aac14a4a 100644 --- a/module/VuFind/src/VuFind/Connection/Wikipedia.php +++ b/module/VuFind/src/VuFind/Connection/Wikipedia.php @@ -61,7 +61,7 @@ class Wikipedia implements TranslatorAwareInterface * * @var array */ - protected $pagesRetrieved = array(); + protected $pagesRetrieved = []; /** * Constructor @@ -98,7 +98,7 @@ class Wikipedia implements TranslatorAwareInterface // Don't retrieve the same page multiple times; this indicates a loop // that needs to be broken! if ($this->alreadyRetrieved($author)) { - return array(); + return []; } // Get information from Wikipedia API @@ -176,7 +176,7 @@ class Wikipedia implements TranslatorAwareInterface } } - return array($imageName, $imageCaption); + return [$imageName, $imageCaption]; } /** @@ -194,9 +194,9 @@ class Wikipedia implements TranslatorAwareInterface foreach ($matches[1] as $m) { // Check if this is the Infobox; name may vary by language - $infoboxTags = array( + $infoboxTags = [ 'Bio', 'Ficha de escritor', 'Infobox', 'Info/Biografia' - ); + ]; foreach ($infoboxTags as $tag) { if (substr($m, 0, strlen($tag) + 1) == '{' . $tag) { // We found an infobox!! @@ -219,9 +219,9 @@ class Wikipedia implements TranslatorAwareInterface { $imageName = $imageCaption = null; // The tag marking image files will vary depending on API language: - $tags = array( + $tags = [ 'Archivo', 'Bestand', 'Datei', 'Ficheiro', 'Fichier', 'File', 'Image' - ); + ]; $pattern = '/(\x5b\x5b)(' . implode('|', $tags) . '):([^\x5d]*\.jpg[^\x5d]*)(\x5d\x5d)/U'; @@ -235,7 +235,7 @@ class Wikipedia implements TranslatorAwareInterface ); } } - return array($imageName, $imageCaption); + return [$imageName, $imageCaption]; } /** @@ -293,8 +293,8 @@ class Wikipedia implements TranslatorAwareInterface $body = $this->stripImageAndFileLinks($body); // Initialize arrays of processing instructions - $pattern = array(); - $replacement = array(); + $pattern = []; + $replacement = []; // Convert wikipedia links $pattern[] = '/(\x5b\x5b)([^\x5d|]*)(\x5d\x5d)/Us'; @@ -371,7 +371,7 @@ class Wikipedia implements TranslatorAwareInterface } } - return array($name, $redirectTo, $page); + return [$name, $redirectTo, $page]; } /** @@ -427,11 +427,11 @@ class Wikipedia implements TranslatorAwareInterface /* Body */ $bodyStr = $this->extractBodyText($bodyArr, $infoboxStr); - $info = array( + $info = [ 'name' => $name, 'description' => $this->sanitizeWikipediaBody($bodyStr), 'wiki_lang' => $this->lang, - ); + ]; /* Image */ diff --git a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php index 15e886ce1c8..cc31e0f886f 100644 --- a/module/VuFind/src/VuFind/Connection/WorldCatUtils.php +++ b/module/VuFind/src/VuFind/Connection/WorldCatUtils.php @@ -86,7 +86,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface ) { // Legacy compatibility -- prior to VuFind 2.4, this parameter was a string. if (!($config instanceof Config)) { - $config = new Config(array('id' => $config)); + $config = new Config(['id' => $config]); } $this->config = $config; $this->client = $client; @@ -174,7 +174,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface $response = json_decode($this->retrieve($url)); // Fetch results - $isbns = array(); + $isbns = []; if (isset($response->list)) { foreach ($response->list as $line) { // Filter out non-ISBN characters and validate the length of @@ -210,10 +210,10 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface $response = json_decode($this->retrieve($url)); // Fetch results - $results = array(); + $results = []; if (isset($response->list)) { foreach ($response->list as $line) { - $values = isset($line->oclcnum) ? $line->oclcnum : array(); + $values = isset($line->oclcnum) ? $line->oclcnum : []; foreach ($values as $data) { // Filter out non-numeric characters and validate the length of // whatever is left behind; this will prevent us from treating @@ -247,7 +247,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface $this->debug("XISSN: $url"); // Fetch results - $issns = array(); + $issns = []; $xml = $this->retrieve($url); if (!empty($xml)) { $data = simplexml_load_string($xml); @@ -275,8 +275,8 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface { // Some common prefixes and suffixes that we do not want to treat as first // or last names: - static $badChunks = array('jr', 'sr', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', - 'viii', 'ix', 'x', 'junior', 'senior', 'esq', 'mr', 'mrs', 'miss', 'dr'); + static $badChunks = ['jr', 'sr', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', + 'viii', 'ix', 'x', 'junior', 'senior', 'esq', 'mr', 'mrs', 'miss', 'dr']; // Clean up the input string: $current = str_replace('.', '', strtolower($current)); @@ -301,7 +301,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface protected function getIdentitiesQuery($name) { // Clean up user query and try to find name components within it: - $name = trim(str_replace(array('"', ',', '-'), ' ', $name)); + $name = trim(str_replace(['"', ',', '-'], ' ', $name)); $parts = explode(' ', $name); $first = $last = ''; foreach ($parts as $current) { @@ -346,11 +346,11 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface $subjects = isset($current->fastHeadings->fast) ? $current->fastHeadings->fast : null; if (isset($subjects->tag)) { - $subjects = array($subjects); + $subjects = [$subjects]; } // Collect subjects for current name: - $retVal = array(); + $retVal = []; if (!is_null($subjects) && count($subjects) > 0) { foreach ($subjects as $currentSubject) { if ($currentSubject['tag'] == '650') { @@ -419,7 +419,7 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface } // Loop through data and collect names and related subjects: - $output = array(); + $output = []; foreach ($data->records->record as $current) { // Build current name string: $current = isset($current->recordData->Identity->nameInfo) ? @@ -497,9 +497,9 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface } // Initialize arrays: - $exact = array(); - $broader = array(); - $narrower = array(); + $exact = []; + $broader = []; + $narrower = []; while ($record = $marc->next()) { // Get exact terms; only save it if it is not a subset of the requested @@ -540,11 +540,11 @@ class WorldCatUtils implements \Zend\Log\LoggerAwareInterface natcasesort($broader); natcasesort($narrower); } - return array( + return [ 'exact' => array_unique($exact), 'broader' => array_unique($broader), 'narrower' => array_unique($narrower) - ); + ]; } /** diff --git a/module/VuFind/src/VuFind/Content/AbstractSyndetics.php b/module/VuFind/src/VuFind/Content/AbstractSyndetics.php index e1d4a8b85a9..53be91c71b8 100644 --- a/module/VuFind/src/VuFind/Content/AbstractSyndetics.php +++ b/module/VuFind/src/VuFind/Content/AbstractSyndetics.php @@ -85,7 +85,7 @@ abstract class AbstractSyndetics extends AbstractBase protected function getHttpClient($url) { $client = parent::getHttpClient($url); - $client->setOptions(array('timeout' => $this->timeout)); + $client->setOptions(['timeout' => $this->timeout]); return $client; } diff --git a/module/VuFind/src/VuFind/Content/AuthorNotes/Syndetics.php b/module/VuFind/src/VuFind/Content/AuthorNotes/Syndetics.php index 8af37237d68..6fc1fe4f690 100644 --- a/module/VuFind/src/VuFind/Content/AuthorNotes/Syndetics.php +++ b/module/VuFind/src/VuFind/Content/AuthorNotes/Syndetics.php @@ -43,13 +43,13 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics * * @var array */ - protected $sourceList = array( - 'ANOTES' => array( + protected $sourceList = [ + 'ANOTES' => [ 'title' => 'Author Notes', 'file' => 'ANOTES.XML', 'div' => '<div id="syn_anotes"></div>' - ) - ); + ] + ]; /** * This method is responsible for connecting to Syndetics and abstracting @@ -73,7 +73,7 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics public function loadByIsbn($key, \VuFindCode\ISBN $isbnObj) { // Initialize return value - $anotes = array(); + $anotes = []; // Find out if there are any notes $isbn = $this->getIsbn10($isbnObj); diff --git a/module/VuFind/src/VuFind/Content/Covers/Amazon.php b/module/VuFind/src/VuFind/Content/Covers/Amazon.php index 1a000682c20..732282123da 100644 --- a/module/VuFind/src/VuFind/Content/Covers/Amazon.php +++ b/module/VuFind/src/VuFind/Content/Covers/Amazon.php @@ -97,9 +97,9 @@ class Amazon extends \VuFind\Content\AbstractCover public function getUrl($key, $size, $ids) { try { - $params = array( + $params = [ 'ResponseGroup' => 'Images', 'AssociateTag' => $this->associate - ); + ]; // TODO: add support for 13-digit ISBNs (requires extra lookup) $isbn = isset($ids['isbn']) ? $ids['isbn']->get10() : false; if (!$isbn) { diff --git a/module/VuFind/src/VuFind/Content/Covers/Factory.php b/module/VuFind/src/VuFind/Content/Covers/Factory.php index 2c228883bf6..3f387d3bb11 100644 --- a/module/VuFind/src/VuFind/Content/Covers/Factory.php +++ b/module/VuFind/src/VuFind/Content/Covers/Factory.php @@ -87,7 +87,7 @@ class Factory { $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); $finalConfig = isset($config->Contentcafe) - ? $config->Contentcafe : new \Zend\Config\Config(array()); + ? $config->Contentcafe : new \Zend\Config\Config([]); return new ContentCafe($finalConfig); } diff --git a/module/VuFind/src/VuFind/Content/Covers/Google.php b/module/VuFind/src/VuFind/Content/Covers/Google.php index bafc794198a..16503111322 100644 --- a/module/VuFind/src/VuFind/Content/Covers/Google.php +++ b/module/VuFind/src/VuFind/Content/Covers/Google.php @@ -107,7 +107,7 @@ class Google extends \VuFind\Content\AbstractCover $json = $matches[1]; // convert \x26 or \u0026 to & - $json = str_replace(array("\\x26", "\\u0026"), "&", $json); + $json = str_replace(["\\x26", "\\u0026"], "&", $json); // decode the object: $json = json_decode($json, true); @@ -115,7 +115,7 @@ class Google extends \VuFind\Content\AbstractCover // convert a flat object to an array -- probably unnecessary, but // retained just in case the response format changes: if (isset($json['thumbnail_url'])) { - $json = array($json); + $json = [$json]; } // find the first thumbnail URL and process it: diff --git a/module/VuFind/src/VuFind/Content/Excerpts/Syndetics.php b/module/VuFind/src/VuFind/Content/Excerpts/Syndetics.php index ac533c3888f..83b4d7dbd8c 100644 --- a/module/VuFind/src/VuFind/Content/Excerpts/Syndetics.php +++ b/module/VuFind/src/VuFind/Content/Excerpts/Syndetics.php @@ -43,13 +43,13 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics * * @var array */ - protected $sourceList = array( - 'DBCHAPTER' => array( + protected $sourceList = [ + 'DBCHAPTER' => [ 'title' => 'First Chapter or Excerpt', 'file' => 'DBCHAPTER.XML', 'div' => '<div id="syn_dbchapter"></div>' - ) - ); + ] + ]; /** * This method is responsible for connecting to Syndetics and abstracting @@ -73,7 +73,7 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics public function loadByIsbn($key, \VuFindCode\ISBN $isbnObj) { // Initialize return value: - $excerpt = array(); + $excerpt = []; // Find out if there are any excerpts $isbn = $this->getIsbn10($isbnObj); diff --git a/module/VuFind/src/VuFind/Content/Loader.php b/module/VuFind/src/VuFind/Content/Loader.php index 63dd38738a3..f14bb275aff 100644 --- a/module/VuFind/src/VuFind/Content/Loader.php +++ b/module/VuFind/src/VuFind/Content/Loader.php @@ -88,7 +88,7 @@ class Loader */ public function loadByIsbn($isbn) { - $results = array(); + $results = []; if (!($isbnObj = $this->getIsbnObject($isbn))) { return $results; } diff --git a/module/VuFind/src/VuFind/Content/Reviews/Amazon.php b/module/VuFind/src/VuFind/Content/Reviews/Amazon.php index 2d83066aa82..63b31ea75d1 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/Amazon.php +++ b/module/VuFind/src/VuFind/Content/Reviews/Amazon.php @@ -59,7 +59,7 @@ class Amazon extends \VuFind\Content\AbstractAmazon $endpoint = 'webservices.amazon.com'; $requestURI = '/onca/xml'; $isbn = $this->getIsbn10($isbnObj); - $params = array( + $params = [ 'AWSAccessKeyId' => $key, 'ItemId' => $isbn, 'Service' => 'AWSECommerceService', @@ -68,13 +68,13 @@ class Amazon extends \VuFind\Content\AbstractAmazon 'Version' => '2010-10-10', 'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'), 'AssociateTag' => $this->associate - ); + ]; // Alphabetize the parameters: ksort($params); // URL encode and assemble the parameters: - $encodedParams = array(); + $encodedParams = []; foreach ($params as $key => $value) { $encodedParams[] = rawurlencode($key) . '=' . rawurlencode($value); } @@ -93,10 +93,10 @@ class Amazon extends \VuFind\Content\AbstractAmazon $data = !$result->isSuccess() ? false : simplexml_load_string($result->getBody()); if (!$data) { - return array(); + return []; } - $result = array(); + $result = []; $reviews = isset($data->Items->Item->CustomerReviews->Review) ? $data->Items->Item->CustomerReviews->Review : null; if (!empty($reviews)) { @@ -120,13 +120,13 @@ class Amazon extends \VuFind\Content\AbstractAmazon // CSS for iframe (explicit dimensions needed for IE // compatibility -- using 100% has bad results there): $css = "width: 700px; height: 500px;"; - $result[] = array( + $result[] = [ 'Rating' => '', 'Summary' => '', 'Copyright' => $this->getCopyright($isbn), 'Content' => "<iframe style=\"{$css}\" src=\"{$iframe}\"></iframe>" - ); + ]; } } diff --git a/module/VuFind/src/VuFind/Content/Reviews/AmazonEditorial.php b/module/VuFind/src/VuFind/Content/Reviews/AmazonEditorial.php index 88cbb5d95f5..b42b1f25f2c 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/AmazonEditorial.php +++ b/module/VuFind/src/VuFind/Content/Reviews/AmazonEditorial.php @@ -57,20 +57,20 @@ class AmazonEditorial extends \VuFind\Content\AbstractAmazon try { $amazon = new Amazon($key, 'US', $this->secret); $amazon->getRestClient()->setHttpClient($this->getHttpClient()); - $params = array( + $params = [ 'ResponseGroup' => 'EditorialReview', 'AssociateTag' => $this->associate - ); + ]; $isbn = $this->getIsbn10($isbnObj); $data = $amazon->itemLookup($isbn, $params); } catch (\Exception $e) { // Something went wrong? Just return empty list. - return array(); + return []; } if ($data) { $i = 0; - $result = array(); + $result = []; $reviews = isset($data->EditorialReviews) ? $data->EditorialReviews : null; if (!empty($reviews)) { diff --git a/module/VuFind/src/VuFind/Content/Reviews/Booksite.php b/module/VuFind/src/VuFind/Content/Reviews/Booksite.php index ce4baa8eb7e..9947ae59f45 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/Booksite.php +++ b/module/VuFind/src/VuFind/Content/Reviews/Booksite.php @@ -80,7 +80,7 @@ class BookSite extends \VuFind\Content\AbstractBase */ public function loadByIsbn($key, \VuFindCode\ISBN $isbnObj) { - $reviews = array(); // Initialize return value + $reviews = []; // Initialize return value $isn = $this->getIsbn10($isbnObj); $url = $this->url . '/poca/book/tradereviews?apikey=' . $this->apiKey diff --git a/module/VuFind/src/VuFind/Content/Reviews/Guardian.php b/module/VuFind/src/VuFind/Content/Reviews/Guardian.php index 3bc112b7861..efda7908cd3 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/Guardian.php +++ b/module/VuFind/src/VuFind/Content/Reviews/Guardian.php @@ -76,7 +76,7 @@ class Guardian extends \VuFind\Content\AbstractBase // parse json from response $data = json_decode($result->getBody(), true); if ($data) { - $result = array(); + $result = []; $i = 0; foreach ($data['response']['results'] as $review) { $result[$i]['Date'] = $review['webPublicationDate']; @@ -114,7 +114,7 @@ class Guardian extends \VuFind\Content\AbstractBase throw new \Exception('Could not parse Guardian response.'); } } else { - return array(); + return []; } } } diff --git a/module/VuFind/src/VuFind/Content/Reviews/Syndetics.php b/module/VuFind/src/VuFind/Content/Reviews/Syndetics.php index 2acb9cef3aa..1714272b55c 100644 --- a/module/VuFind/src/VuFind/Content/Reviews/Syndetics.php +++ b/module/VuFind/src/VuFind/Content/Reviews/Syndetics.php @@ -43,41 +43,41 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics * * @var array */ - protected $sourceList = array( - 'CHREVIEW' => array('title' => 'Choice Review', + protected $sourceList = [ + 'CHREVIEW' => ['title' => 'Choice Review', 'file' => 'CHREVIEW.XML', - 'div' => '<div id="syn_chreview"></div>'), - 'NYREVIEW' => array('title' => 'New York Times Review', + 'div' => '<div id="syn_chreview"></div>'], + 'NYREVIEW' => ['title' => 'New York Times Review', 'file' => 'NYREVIEW.XML', - 'div' => '<div id="syn_nyreview"></div>'), - 'BLREVIEW' => array('title' => 'Booklist Review', + 'div' => '<div id="syn_nyreview"></div>'], + 'BLREVIEW' => ['title' => 'Booklist Review', 'file' => 'BLREVIEW.XML', - 'div' => '<div id="syn_blreview"></div>'), - 'PWREVIEW' => array('title' => "Publisher's Weekly Review", + 'div' => '<div id="syn_blreview"></div>'], + 'PWREVIEW' => ['title' => "Publisher's Weekly Review", 'file' => 'PWREVIEW.XML', - 'div' => '<div id="syn_pwreview"></div>'), - 'LJREVIEW' => array('title' => 'Library Journal Review', + 'div' => '<div id="syn_pwreview"></div>'], + 'LJREVIEW' => ['title' => 'Library Journal Review', 'file' => 'LJREVIEW.XML', - 'div' => '<div id="syn_ljreview"></div>'), - 'SLJREVIEW' => array('title' => 'School Library Journal Review', + 'div' => '<div id="syn_ljreview"></div>'], + 'SLJREVIEW' => ['title' => 'School Library Journal Review', 'file' => 'SLJREVIEW.XML', - 'div' => '<div id="syn_sljreview"></div>'), - 'HBREVIEW' => array('title' => 'Horn Book Review', + 'div' => '<div id="syn_sljreview"></div>'], + 'HBREVIEW' => ['title' => 'Horn Book Review', 'file' => 'HBREVIEW.XML', - 'div' => '<div id="syn_hbreview"></div>'), - 'KIRKREVIEW' => array('title' => 'Kirkus Book Review', + 'div' => '<div id="syn_hbreview"></div>'], + 'KIRKREVIEW' => ['title' => 'Kirkus Book Review', 'file' => 'KIRKREVIEW.XML', - 'div' => '<div id="syn_kireview"></div>'), - 'CRITICASREVIEW' => array('title' => 'Criticas Review', + 'div' => '<div id="syn_kireview"></div>'], + 'CRITICASREVIEW' => ['title' => 'Criticas Review', 'file' => 'CRITICASREVIEW.XML', - 'div' => '<div id="syn_criticasreview"></div>'), + 'div' => '<div id="syn_criticasreview"></div>'], // These last two entries are probably typos -- retained for legacy // compatibility just in case they're actually used for something! - 'KIREVIEW' => array('title' => 'Kirkus Book Review', - 'file' => 'KIREVIEW.XML'), - 'CRITICASEREVIEW' => array('title' => 'Criti Case Review', - 'file' => 'CRITICASEREVIEW.XML') - ); + 'KIREVIEW' => ['title' => 'Kirkus Book Review', + 'file' => 'KIREVIEW.XML'], + 'CRITICASEREVIEW' => ['title' => 'Criti Case Review', + 'file' => 'CRITICASEREVIEW.XML'] + ]; /** * This method is responsible for connecting to Syndetics and abstracting @@ -104,7 +104,7 @@ class Syndetics extends \VuFind\Content\AbstractSyndetics public function loadByIsbn($key, \VuFindCode\ISBN $isbnObj) { // Initialize return value - $review = array(); + $review = []; // Find out if there are any reviews $isbn = $this->getIsbn10($isbnObj); diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index c3f8637486f..e79136759de 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -74,7 +74,7 @@ class AbstractBase extends AbstractActionController && !$this->getAuthorizationService()->isGranted($this->accessPermission) ) { if (!$this->getUser()) { - $e->setResponse($this->forceLogin(null, array(), false)); + $e->setResponse($this->forceLogin(null, [], false)); return; } throw new ForbiddenException('Access denied.'); @@ -93,7 +93,7 @@ class AbstractBase extends AbstractActionController if ($this->accessPermission) { $events = $this->getEventManager(); $events->attach( - MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 1000 + MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000 ); } } @@ -251,14 +251,14 @@ class AbstractBase extends AbstractActionController * * @return string */ - public function getLightboxAwareUrl($route, $params = array(), - $options = array(), $reuseMatchedParams = false + public function getLightboxAwareUrl($route, $params = [], + $options = [], $reuseMatchedParams = false ) { // Rearrange the parameters if we're in a lightbox: if ($this->inLightbox()) { // Make sure we have a query: $options['query'] = isset($options['query']) - ? $options['query'] : array(); + ? $options['query'] : []; // Map ID route parameter into a GET parameter if necessary: if (isset($params['id'])) { @@ -294,8 +294,8 @@ class AbstractBase extends AbstractActionController * * @return \Zend\Http\Response */ - public function lightboxAwareRedirect($route, $params = array(), - $options = array(), $reuseMatchedParams = false + public function lightboxAwareRedirect($route, $params = [], + $options = [], $reuseMatchedParams = false ) { return $this->redirect()->toUrl( $this->getLightboxAwareUrl( @@ -338,7 +338,7 @@ class AbstractBase extends AbstractActionController $request->setUri($url); $router = $this->getEvent()->getRouter(); $matched = $router->match($request)->getParams(); - $getParams = $routeParams = array(); + $getParams = $routeParams = []; foreach ($query as $current => $val) { if (isset($matched[$current])) { $routeParams[$current] = $val; @@ -349,7 +349,7 @@ class AbstractBase extends AbstractActionController // Now build the final URL: return $this->url() - ->fromRoute($routeName, $routeParams, array('query' => $getParams)); + ->fromRoute($routeName, $routeParams, ['query' => $getParams]); } /** @@ -361,7 +361,7 @@ class AbstractBase extends AbstractActionController * * @return mixed */ - protected function forceLogin($msg = null, $extras = array(), $forward = true) + protected function forceLogin($msg = null, $extras = [], $forward = true) { // Set default message if necessary. if (is_null($msg)) { @@ -519,7 +519,7 @@ class AbstractBase extends AbstractActionController * * @return string */ - public function translate($msg, $tokens = array(), $default = null) + public function translate($msg, $tokens = [], $default = null) { return $this->getViewRenderer()->plugin('translate') ->__invoke($msg, $tokens, $default); @@ -535,7 +535,7 @@ class AbstractBase extends AbstractActionController * * @return mixed */ - public function forwardTo($controller, $action, $params = array()) + public function forwardTo($controller, $action, $params = []) { // Inject action into the RouteMatch parameters $params['action'] = $action; @@ -573,20 +573,20 @@ class AbstractBase extends AbstractActionController * * @return mixed */ - public function confirm($title, $yesTarget, $noTarget, $messages = array(), - $extras = array() + public function confirm($title, $yesTarget, $noTarget, $messages = [], + $extras = [] ) { return $this->forwardTo( 'Confirm', 'Confirm', - array( - 'data' => array( + [ + 'data' => [ 'title' => $title, 'confirm' => $yesTarget, 'cancel' => $noTarget, 'messages' => (array)$messages, 'extras' => $extras - ) - ) + ] + ] ); } @@ -673,7 +673,7 @@ class AbstractBase extends AbstractActionController } // If we got this far, we want to store the referer: - $this->followup()->store(array(), $referer); + $this->followup()->store([], $referer); } /** diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index a8a14d301ac..74a2e1049d7 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -109,7 +109,7 @@ class AbstractRecord extends AbstractBase if (!($user = $this->getUser())) { // Remember comment since POST data will be lost: return $this->forceLogin( - null, array('comment' => $this->params()->fromPost('comment')) + null, ['comment' => $this->params()->fromPost('comment')] ); } @@ -305,7 +305,7 @@ class AbstractRecord extends AbstractBase $driver = $this->loadRecord(); // Find out if the item is already part of any lists; save list info/IDs - $listIds = array(); + $listIds = []; $resources = $user->getSavedData( $driver->getUniqueId(), null, $driver->getResourceSource() ); @@ -314,26 +314,26 @@ class AbstractRecord extends AbstractBase } // Loop through all user lists and sort out containing/non-containing lists - $containingLists = $nonContainingLists = array(); + $containingLists = $nonContainingLists = []; foreach ($user->getLists() as $list) { // Assign list to appropriate array based on whether or not we found // it earlier in the list of lists containing the selected record. if (in_array($list->id, $listIds)) { - $containingLists[] = array( + $containingLists[] = [ 'id' => $list->id, 'title' => $list->title - ); + ]; } else { - $nonContainingLists[] = array( + $nonContainingLists[] = [ 'id' => $list->id, 'title' => $list->title - ); + ]; } } $view = $this->createViewModel( - array( + [ 'containingLists' => $containingLists, 'nonContainingLists' => $nonContainingLists - ) + ] ); $view->setTemplate('record/save'); return $view; @@ -417,7 +417,7 @@ class AbstractRecord extends AbstractBase try { $body = $this->getViewRenderer()->partial( 'Email/record-sms.phtml', - array('driver' => $driver, 'to' => $view->to) + ['driver' => $driver, 'to' => $view->to] ); $sms->text($view->provider, $view->to, null, $body); $this->flashMessenger()->setNamespace('info') diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index ec5086544af..d945ec6cbda 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -119,7 +119,7 @@ class AbstractSearch extends AbstractBase ->get('VuFind\SearchResultsPluginManager') ->get($this->searchClassId); $view->saved->getParams()->initFromRequest( - new \Zend\StdLib\Parameters(array()) + new \Zend\StdLib\Parameters([]) ); } @@ -201,12 +201,12 @@ class AbstractSearch extends AbstractBase protected function getActiveRecommendationSettings() { // Enable recommendations unless explicitly told to disable them: - $all = array('top', 'side', 'noresults'); + $all = ['top', 'side', 'noresults']; $noRecommend = $this->params()->fromQuery('noRecommend', false); if ($noRecommend === 1 || $noRecommend === '1' || $noRecommend === 'true' || $noRecommend === true ) { - return array(); + return []; } else if ($noRecommend === 0 || $noRecommend === '0' || $noRecommend === 'false' || $noRecommend === false ) { @@ -364,7 +364,7 @@ class AbstractSearch extends AbstractBase { // Look up search in database and fail if it is not found: $searchTable = $this->getTable('Search'); - $search = $searchTable->select(array('id' => $searchId))->current(); + $search = $searchTable->select(['id' => $searchId])->current(); if (empty($search)) { $this->flashMessenger()->setNamespace('error') ->addMessage('advSearchError_notFound'); @@ -419,7 +419,7 @@ class AbstractSearch extends AbstractBase */ protected function getRangeSettings($fields, $type, $savedSearch = false) { - $parts = array(); + $parts = []; foreach ($fields as $field) { // Default to blank strings: @@ -442,11 +442,11 @@ class AbstractSearch extends AbstractBase } // Send back the settings: - $parts[] = array( + $parts[] = [ 'field' => $field, 'type' => $type, - 'values' => array($from, $to) - ); + 'values' => [$from, $to] + ]; } return $parts; @@ -467,7 +467,7 @@ class AbstractSearch extends AbstractBase { $config = $this->getServiceLocator()->get('VuFind\Config')->get($config); $fields = isset($config->SpecialFacets->$section) - ? $config->SpecialFacets->$section->toArray() : array(); + ? $config->SpecialFacets->$section->toArray() : []; if (!empty($filter)) { $fields = array_intersect($fields, $filter); @@ -487,7 +487,7 @@ class AbstractSearch extends AbstractBase * @return array */ protected function getDateRangeSettings($savedSearch = false, $config = 'facets', - $filter = array() + $filter = [] ) { $fields = $this->getRangeFieldList($config, 'dateRange', $filter); return $this->getRangeSettings($fields, 'date', $savedSearch); @@ -504,7 +504,7 @@ class AbstractSearch extends AbstractBase * @return array */ protected function getFullDateRangeSettings($savedSearch = false, - $config = 'facets', $filter = array() + $config = 'facets', $filter = [] ) { $fields = $this->getRangeFieldList($config, 'fullDateRange', $filter); return $this->getRangeSettings($fields, 'fulldate', $savedSearch); @@ -521,7 +521,7 @@ class AbstractSearch extends AbstractBase * @return array */ protected function getGenericRangeSettings($savedSearch = false, - $config = 'facets', $filter = array() + $config = 'facets', $filter = [] ) { $fields = $this->getRangeFieldList($config, 'genericRange', $filter); return $this->getRangeSettings($fields, 'generic', $savedSearch); @@ -538,7 +538,7 @@ class AbstractSearch extends AbstractBase * @return array */ protected function getNumericRangeSettings($savedSearch = false, - $config = 'facets', $filter = array() + $config = 'facets', $filter = [] ) { $fields = $this->getRangeFieldList($config, 'numericRange', $filter); return $this->getRangeSettings($fields, 'numeric', $savedSearch); @@ -556,7 +556,7 @@ class AbstractSearch extends AbstractBase protected function getAllRangeSettings($specialFacets, $savedSearch = false, $config = 'facets' ) { - $result = array(); + $result = []; if (isset($specialFacets['daterange'])) { $dates = $this->getDateRangeSettings( $savedSearch, $config, $specialFacets['daterange'] @@ -594,7 +594,7 @@ class AbstractSearch extends AbstractBase protected function parseSpecialFacetsSetting($specialFacets) { // Parse the special facets into a more useful format: - $parsed = array(); + $parsed = []; foreach (explode(',', $specialFacets) as $current) { $parts = explode(':', $current); $key = array_shift($parts); @@ -626,13 +626,13 @@ class AbstractSearch extends AbstractBase $flipCheckboxes = true; } $checkboxFacets = ($section && isset($config->$section)) - ? $config->$section->toArray() : array(); + ? $config->$section->toArray() : []; if (isset($flipCheckboxes) && $flipCheckboxes) { $checkboxFacets = array_flip($checkboxFacets); } // Reformat for convenience: - $formatted = array(); + $formatted = []; foreach ($checkboxFacets as $filter => $desc) { $current = compact('desc', 'filter'); $current['selected'] diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 26ea3da4a82..b2895952962 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -56,7 +56,7 @@ class AjaxController extends AbstractBase * * @var array */ - protected static $php_errors = array(); + protected static $php_errors = []; /** * Constructor @@ -64,7 +64,7 @@ class AjaxController extends AbstractBase public function __construct() { // Add notices to a key in the output - set_error_handler(array('VuFind\Controller\AjaxController', "storeError")); + set_error_handler(['VuFind\Controller\AjaxController', "storeError"]); } /** @@ -79,7 +79,7 @@ class AjaxController extends AbstractBase // Call the method specified by the 'method' parameter; append Ajax to // the end to avoid access to arbitrary inappropriate methods. - $callback = array($this, $this->params()->fromQuery('method') . 'Ajax'); + $callback = [$this, $this->params()->fromQuery('method') . 'Ajax']; if (is_callable($callback)) { try { return call_user_func($callback); @@ -165,7 +165,7 @@ class AjaxController extends AbstractBase $hideHoldings = $logic->getSuppressedLocations(); } - $filtered = array(); + $filtered = []; foreach ($record as $current) { if (!in_array($current['location'], $hideHoldings)) { $filtered[] = $current; @@ -194,7 +194,7 @@ class AjaxController extends AbstractBase if (!is_array($results)) { // If getStatuses returned garbage, let's turn it into an empty array // to avoid triggering a notice in the foreach loop below. - $results = array(); + $results = []; } // In order to detect IDs missing from the status response, create an @@ -207,11 +207,11 @@ class AjaxController extends AbstractBase $renderer = $this->getViewRenderer(); // Load messages for response: - $messages = array( + $messages = [ 'available' => $renderer->render('ajax/status-available.phtml'), 'unavailable' => $renderer->render('ajax/status-unavailable.phtml'), 'unknown' => $renderer->render('ajax/status-unknown.phtml') - ); + ]; // Load callnumber and location settings: $config = $this->getConfig(); @@ -223,7 +223,7 @@ class AjaxController extends AbstractBase ? $config->Item_Status->show_full_status : false; // Loop through all the status information that came back - $statuses = array(); + $statuses = []; foreach ($results as $recordNumber => $record) { // Filter out suppressed locations: $record = $this->filterSuppressedLocations($record); @@ -242,7 +242,7 @@ class AjaxController extends AbstractBase // If a full status display has been requested, append the HTML: if ($showFullStatus) { $current['full_status'] = $renderer->render( - 'ajax/status-full.phtml', array('statusItems' => $record) + 'ajax/status-full.phtml', ['statusItems' => $record] ); } $current['record_number'] = array_search($current['id'], $ids); @@ -255,7 +255,7 @@ class AjaxController extends AbstractBase // If any IDs were missing, send back appropriate dummy data foreach ($missingIds as $missingId => $recordNumber) { - $statuses[] = array( + $statuses[] = [ 'id' => $missingId, 'availability' => 'false', 'availability_message' => $messages['unavailable'], @@ -266,7 +266,7 @@ class AjaxController extends AbstractBase 'callnumber' => '', 'missing_data' => true, 'record_number' => $recordNumber - ); + ]; } // Done @@ -296,7 +296,7 @@ class AjaxController extends AbstractBase if (!$transPrefix) { return $list[0]; } else { - return $this->translate($transPrefix . $list[0], array(), $list[0]); + return $this->translate($transPrefix . $list[0], [], $list[0]); } } else if (count($list) == 0) { // Empty list? Return a blank string: @@ -304,10 +304,10 @@ class AjaxController extends AbstractBase } else if ($mode == 'all') { // Translate values if necessary: if ($transPrefix) { - $transList = array(); + $transList = []; foreach ($list as $current) { $transList[] = $this->translate( - $transPrefix . $current, array(), $current + $transPrefix . $current, [], $current ); } $list = $transList; @@ -340,7 +340,7 @@ class AjaxController extends AbstractBase $callnumberSetting ) { // Summarize call number, location and availability info across all items: - $callNumbers = $locations = array(); + $callNumbers = $locations = []; $use_unknown_status = $available = false; foreach ($record as $info) { // Find an available copy @@ -373,7 +373,7 @@ class AjaxController extends AbstractBase : $messages[$available ? 'available' : 'unavailable']; // Send back the collected details: - return array( + return [ 'id' => $record[0]['id'], 'availability' => ($available ? 'true' : 'false'), 'availability_message' => $availability_message, @@ -385,7 +385,7 @@ class AjaxController extends AbstractBase ? $this->translate('on_reserve') : $this->translate('Not On Reserve'), 'callnumber' => htmlentities($callNumber, ENT_COMPAT, 'UTF-8') - ); + ]; } /** @@ -404,7 +404,7 @@ class AjaxController extends AbstractBase protected function getItemStatusGroup($record, $messages, $callnumberSetting) { // Summarize call number, location and availability info across all items: - $locations = array(); + $locations = []; $use_unknown_status = $available = false; foreach ($record as $info) { // Find an available copy @@ -429,16 +429,16 @@ class AjaxController extends AbstractBase $locationCallnumbers = $this->pickValue( $locationCallnumbers, $callnumberSetting, 'Multiple Call Numbers' ); - $locationInfo = array( + $locationInfo = [ 'availability' => isset($details['available']) ? $details['available'] : false, 'location' => htmlentities( - $this->translate('location_' . $location, array(), $location), + $this->translate('location_' . $location, [], $location), ENT_COMPAT, 'UTF-8' ), 'callnumbers' => htmlentities($locationCallnumbers, ENT_COMPAT, 'UTF-8') - ); + ]; $locationList[] = $locationInfo; } @@ -447,7 +447,7 @@ class AjaxController extends AbstractBase : $messages[$available ? 'available' : 'unavailable']; // Send back the collected details: - return array( + return [ 'id' => $record[0]['id'], 'availability' => ($available ? 'true' : 'false'), 'availability_message' => $availability_message, @@ -459,7 +459,7 @@ class AjaxController extends AbstractBase ? $this->translate('on_reserve') : $this->translate('Not On Reserve'), 'callnumber' => false - ); + ]; } /** @@ -480,9 +480,9 @@ class AjaxController extends AbstractBase } // loop through each ID check if it is saved to any of the user's lists - $result = array(); - $ids = $this->params()->fromQuery('id', array()); - $sources = $this->params()->fromQuery('source', array()); + $result = []; + $ids = $this->params()->fromQuery('id', []); + $sources = $this->params()->fromQuery('source', []); if (!is_array($ids) || !is_array($sources)) { return $this->output( $this->translate('Argument must be array.'), @@ -495,14 +495,14 @@ class AjaxController extends AbstractBase if ($data) { // if this item was saved, add it to the list of saved items. foreach ($data as $list) { - $result[] = array( + $result[] = [ 'record_id' => $id, 'record_source' => $source, 'resource_id' => $list->id, 'list_id' => $list->list_id, 'list_title' => $list->list_title, 'record_number' => $i - ); + ]; } } } @@ -531,7 +531,7 @@ class AjaxController extends AbstractBase $headers->addHeaderLine( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT' ); - $output = array('data' => $data,'status' => $status); + $output = ['data' => $data,'status' => $status]; if ('development' == APPLICATION_ENV && count(self::$php_errors) > 0) { $output['php_errors'] = self::$php_errors; } @@ -663,9 +663,9 @@ class AjaxController extends AbstractBase ); // Build data structure for return: - $tagList = array(); + $tagList = []; foreach ($tags as $tag) { - $tagList[] = array('tag' => $tag->tag, 'cnt' => $tag->cnt); + $tagList[] = ['tag' => $tag->tag, 'cnt' => $tag->cnt]; } // If we don't have any tags, provide a user-appropriate message: @@ -688,7 +688,7 @@ class AjaxController extends AbstractBase * * @return \Zend\Http\Response */ - protected function getMapDataAjax($fields = array('long_lat')) + protected function getMapDataAjax($fields = ['long_lat']) { $this->writeSession(); // avoid session write timing bug $results = $this->getResultsManager()->get('Solr'); @@ -697,19 +697,19 @@ class AjaxController extends AbstractBase $facets = $results->getFullFieldFacets($fields, false); - $markers = array(); + $markers = []; $i = 0; $list = isset($facets['long_lat']['data']['list']) - ? $facets['long_lat']['data']['list'] : array(); + ? $facets['long_lat']['data']['list'] : []; foreach ($list as $location) { $longLat = explode(',', $location['value']); - $markers[$i] = array( + $markers[$i] = [ 'title' => (string)$location['count'], //needs to be a string 'location_facet' => $location['value'], //needed to load in the location 'lon' => $longLat[0], 'lat' => $longLat[1] - ); + ]; $i++; } return $this->output($markers, self::STATUS_OK); @@ -734,12 +734,12 @@ class AjaxController extends AbstractBase $params->initFromRequest($this->getRequest()->getQuery()); return $this->createViewModel( - array( + [ 'results' => $results, 'recordSet' => $results->getResults(), 'recordCount' => $results->getResultTotal(), 'completeListUrl' => $results->getUrlQuery()->getParams() - ) + ] ); } @@ -753,20 +753,20 @@ class AjaxController extends AbstractBase * * @return \Zend\Http\Response */ - protected function getVisDataAjax($fields = array('publishDate')) + protected function getVisDataAjax($fields = ['publishDate']) { $this->writeSession(); // avoid session write timing bug $results = $this->getResultsManager()->get('Solr'); $params = $results->getParams(); $params->initFromRequest($this->getRequest()->getQuery()); - foreach ($this->params()->fromQuery('hf', array()) as $hf) { + foreach ($this->params()->fromQuery('hf', []) as $hf) { $params->getOptions()->addHiddenFilter($hf); } $params->getOptions()->disableHighlighting(); $params->getOptions()->spellcheckEnabled(false); $filters = $params->getFilters(); $dateFacets = $this->params()->fromQuery('facetFields'); - $dateFacets = empty($dateFacets) ? array() : explode(':', $dateFacets); + $dateFacets = empty($dateFacets) ? [] : explode(':', $dateFacets); $fields = $this->processDateFacets($filters, $dateFacets, $results); $facets = $this->processFacetValues($fields, $results); foreach ($fields as $field => $val) { @@ -794,7 +794,7 @@ class AjaxController extends AbstractBase */ protected function processDateFacets($filters, $dateFacets, $results) { - $result = array(); + $result = []; foreach ($dateFacets as $current) { $from = $to = ''; if (isset($filters[$current])) { @@ -807,7 +807,7 @@ class AjaxController extends AbstractBase } } } - $result[$current] = array($from, $to); + $result[$current] = [$from, $to]; $result[$current]['label'] = $results->getParams()->getFacetLabel($current); } @@ -826,14 +826,14 @@ class AjaxController extends AbstractBase protected function processFacetValues($fields, $results) { $facets = $results->getFullFieldFacets(array_keys($fields)); - $retVal = array(); + $retVal = []; foreach ($facets as $field => $values) { - $newValues = array('data' => array()); + $newValues = ['data' => []]; foreach ($values['data']['list'] as $current) { // Only retain numeric values! if (preg_match("/^[0-9]+$/", $current['value'])) { $newValues['data'][] - = array($current['value'], $current['count']); + = [$current['value'], $current['count']]; } } $retVal[$field] = $newValues; @@ -875,10 +875,10 @@ class AjaxController extends AbstractBase protected function bulkSaveAjax() { // Without IDs, we can't continue - $ids = $this->params()->fromPost('ids', array()); + $ids = $this->params()->fromPost('ids', []); if (empty($ids)) { return $this->output( - array('result' => $this->translate('bulk_error_missing')), + ['result' => $this->translate('bulk_error_missing')], self::STATUS_ERROR ); } @@ -896,14 +896,14 @@ class AjaxController extends AbstractBase $this->getRequest()->getPost()->toArray(), $user ); return $this->output( - array( - 'result' => array('list' => $this->params()->fromPost('list')), + [ + 'result' => ['list' => $this->params()->fromPost('list')], 'info' => $this->translate("bulk_save_success") - ), self::STATUS_OK + ], self::STATUS_OK ); } catch (\Exception $e) { return $this->output( - array('info' => $this->translate('bulk_save_error')), + ['info' => $this->translate('bulk_save_error')], self::STATUS_ERROR ); } @@ -940,7 +940,7 @@ class AjaxController extends AbstractBase } } - return $this->output(array('id' => $id), self::STATUS_OK); + return $this->output(['id' => $id], self::STATUS_OK); } /** @@ -982,7 +982,7 @@ class AjaxController extends AbstractBase ); $to = $this->params()->fromPost('to'); $body = $this->getViewRenderer()->partial( - 'Email/record-sms.phtml', array('driver' => $record, 'to' => $to) + 'Email/record-sms.phtml', ['driver' => $record, 'to' => $to] ); $this->getServiceLocator()->get('VuFind\SMS')->text( $this->params()->fromPost('provider'), $to, null, $body @@ -1128,10 +1128,10 @@ class AjaxController extends AbstractBase $user = $this->getUser(); if (!$user) { return $this->output( - array( + [ 'status' => false, 'msg' => $this->translate('You must be logged in first') - ), + ], self::STATUS_NEED_AUTH ); } @@ -1178,7 +1178,7 @@ class AjaxController extends AbstractBase break; } return $this->output( - array('status' => $results, 'msg' => $msg), self::STATUS_OK + ['status' => $results, 'msg' => $msg], self::STATUS_OK ); } } catch (\Exception $e) { @@ -1261,7 +1261,7 @@ class AjaxController extends AbstractBase $this->params()->fromQuery('source', 'VuFind') ); $html = $this->getViewRenderer() - ->render('record/comments-list.phtml', array('driver' => $driver)); + ->render('record/comments-list.phtml', ['driver' => $driver]); return $this->output($html, self::STATUS_OK); } @@ -1292,7 +1292,7 @@ class AjaxController extends AbstractBase $this->favorites()->delete($ids, $listID, $user); return $this->output( - array('result' => $this->translate('fav_delete_success')), + ['result' => $this->translate('fav_delete_success')], self::STATUS_OK ); } @@ -1308,12 +1308,12 @@ class AjaxController extends AbstractBase $ids = $this->params()->fromPost('ids'); if (empty($ids)) { return $this->output( - array('result' => $this->translate('bulk_error_missing')), + ['result' => $this->translate('bulk_error_missing')], self::STATUS_ERROR ); } $this->getServiceLocator()->get('VuFind\Cart')->removeItems($ids); - return $this->output(array('delete' => true), self::STATUS_OK); + return $this->output(['delete' => true], self::STATUS_OK); } /** @@ -1327,19 +1327,19 @@ class AjaxController extends AbstractBase $export = $this->getServiceLocator()->get('VuFind\Export'); $url = $export->getBulkUrl( $this->getViewRenderer(), $format, - $this->params()->fromPost('ids', array()) + $this->params()->fromPost('ids', []) ); $html = $this->getViewRenderer()->render( 'ajax/export-favorites.phtml', - array('url' => $url, 'format' => $format) + ['url' => $url, 'format' => $format] ); return $this->output( - array( + [ 'result' => $this->translate('Done'), 'result_additional' => $html, 'needs_redirect' => $export->needsRedirect($format), 'result_url' => $url - ), self::STATUS_OK + ], self::STATUS_OK ); } @@ -1375,7 +1375,7 @@ class AjaxController extends AbstractBase $result = $resolver->fetchLinks($openUrl); // Sort the returned links into categories based on service type: - $electronic = $print = $services = array(); + $electronic = $print = $services = []; foreach ($result as $link) { switch (isset($link['service_type']) ? $link['service_type'] : '') { case 'getHolding': @@ -1405,10 +1405,10 @@ class AjaxController extends AbstractBase } // Render the links using the view: - $view = array( + $view = [ 'openUrlBase' => $base, 'openUrl' => $openUrl, 'print' => $print, 'electronic' => $electronic, 'services' => $services - ); + ]; $html = $this->getViewRenderer()->render('ajax/resolverLinks.phtml', $view); // output HTML encoded in JSON object @@ -1443,10 +1443,10 @@ class AjaxController extends AbstractBase $user = $this->getUser(); if (!$user) { return $this->output( - array( + [ 'status' => false, 'msg' => $this->translate('You must be logged in first') - ), + ], self::STATUS_NEED_AUTH ); } @@ -1462,13 +1462,13 @@ class AjaxController extends AbstractBase if (isset($result['name'])) { $result['name'] = $this->translate( 'location_' . $result['name'], - array(), + [], $result['name'] ); } } return $this->output( - array('locations' => $results), self::STATUS_OK + ['locations' => $results], self::STATUS_OK ); } } catch (\Exception $e) { @@ -1496,10 +1496,10 @@ class AjaxController extends AbstractBase $user = $this->getUser(); if (!$user) { return $this->output( - array( + [ 'status' => false, 'msg' => $this->translate('You must be logged in first') - ), + ], self::STATUS_NEED_AUTH ); } @@ -1508,10 +1508,10 @@ class AjaxController extends AbstractBase $catalog = $this->getILS(); $patron = $this->getILSAuthenticator()->storedCatalogLogin(); if ($patron) { - $details = array( + $details = [ 'id' => $id, 'requestGroupId' => $requestGroupId - ); + ]; $results = $catalog->getPickupLocations( $patron, $details ); @@ -1519,13 +1519,13 @@ class AjaxController extends AbstractBase if (isset($result['locationDisplay'])) { $result['locationDisplay'] = $this->translate( 'location_' . $result['locationDisplay'], - array(), + [], $result['locationDisplay'] ); } } return $this->output( - array('locations' => $results), self::STATUS_OK + ['locations' => $results], self::STATUS_OK ); } } catch (\Exception $e) { @@ -1563,9 +1563,9 @@ class AjaxController extends AbstractBase $params->addFacet($facet, null, $operator === 'OR'); $params->initFromRequest($this->getRequest()->getQuery()); - $facets = $results->getFullFieldFacets(array($facet), false, -1, 'count'); + $facets = $results->getFullFieldFacets([$facet], false, -1, 'count'); if (empty($facets[$facet]['data']['list'])) { - return $this->output(array(), self::STATUS_OK); + return $this->output([], self::STATUS_OK); } $facetList = $facets[$facet]['data']['list']; diff --git a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php index 94a6dcb4bd9..0c89dc9db1d 100644 --- a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php +++ b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php @@ -56,31 +56,31 @@ class AlphabrowseController extends AbstractBase if (isset($config->AlphaBrowse_Types) && !empty($config->AlphaBrowse_Types) ) { - $types = array(); + $types = []; foreach ($config->AlphaBrowse_Types as $key => $value) { $types[$key] = $value; } } else { - $types = array( + $types = [ 'topic' => 'By Topic', 'author' => 'By Author', 'title' => 'By Title', 'lcc' => 'By Call Number' - ); + ]; } // Load any extras from config file - $extras = array(); + $extras = []; if (isset($config->AlphaBrowse_Extras)) { foreach ($config->AlphaBrowse_Extras as $key => $value) { $extras[$key] = $value; } } else { - $extras = array( + $extras = [ 'title' => 'author:format:publishDate', 'lcc' => 'title', 'dewey' => 'title' - ); + ]; } // Load remaining config parameters @@ -171,7 +171,7 @@ class AlphabrowseController extends AbstractBase // Pass information about extra columns on to theme $view->extras = isset($extras[$source]) - ? explode(':', $extras[$source]) : array(); + ? explode(':', $extras[$source]) : []; return $view; } diff --git a/module/VuFind/src/VuFind/Controller/AuthorityController.php b/module/VuFind/src/VuFind/Controller/AuthorityController.php index b44a3956237..d0ee6e9d9d4 100644 --- a/module/VuFind/src/VuFind/Controller/AuthorityController.php +++ b/module/VuFind/src/VuFind/Controller/AuthorityController.php @@ -80,7 +80,7 @@ class AuthorityController extends AbstractSearch $tabs = $this->getServiceLocator() ->get('VuFind\RecordTabPluginManager') ->getTabsForRecord($driver, $tabConfig, $request); - return $this->createViewModel(array('driver' => $driver, 'tabs' => $tabs)); + return $this->createViewModel(['driver' => $driver, 'tabs' => $tabs]); } /** diff --git a/module/VuFind/src/VuFind/Controller/BrowseController.php b/module/VuFind/src/VuFind/Controller/BrowseController.php index d532d978067..540eb226366 100644 --- a/module/VuFind/src/VuFind/Controller/BrowseController.php +++ b/module/VuFind/src/VuFind/Controller/BrowseController.php @@ -70,7 +70,7 @@ class BrowseController extends AbstractBase { $this->config = $config; - $this->disabledFacets = array(); + $this->disabledFacets = []; foreach ($this->config->Browse as $key => $setting) { if ($setting == false) { $this->disabledFacets[] = $key; @@ -118,7 +118,7 @@ class BrowseController extends AbstractBase } // Initialize the array of top-level browse options. - $browseOptions = array(); + $browseOptions = []; // First option: tags -- is it enabled in config.ini? If no setting is // found, assume it is active. Note that this setting is disabled if tags @@ -161,9 +161,9 @@ class BrowseController extends AbstractBase // Loop through remaining browse options. All may be individually disabled // in config.ini, but if no settings are found, they are assumed to be on. - $remainingOptions = array( + $remainingOptions = [ 'Author', 'Topic', 'Genre', 'Region', 'Era' - ); + ]; foreach ($remainingOptions as $current) { $option = strToLower($current); if (!isset($this->config->Browse->$option) @@ -200,7 +200,7 @@ class BrowseController extends AbstractBase */ protected function buildBrowseOption($action, $description) { - return array('action' => $action, 'description' => $description); + return ['action' => $action, 'description' => $description]; } /** @@ -239,12 +239,12 @@ class BrowseController extends AbstractBase $this->params()->fromQuery('query_field'), 'count', $this->params()->fromQuery('query') ); - $resultList = array(); + $resultList = []; foreach ($results as $result) { - $resultList[] = array( + $resultList[] = [ 'result' => $result['displayText'], 'count' => $result['count'] - ); + ]; } // Don't make a second filter if it would be the same facet $view->paramTitle @@ -288,11 +288,11 @@ class BrowseController extends AbstractBase $this->setCurrentAction('Tag'); $view = $this->createViewModel(); - $view->categoryList = array( + $view->categoryList = [ 'alphabetical' => 'By Alphabetical', 'popularity' => 'By Popularity', 'recent' => 'By Recent' - ); + ]; if ($this->params()->fromQuery('findby')) { $params = $this->getRequest()->getQuery()->toArray(); @@ -307,13 +307,13 @@ class BrowseController extends AbstractBase // $params['query'] has already been validated against // the getAlphabetList() method below! $tags = $tagTable->matchText($params['query']); - $tagList = array(); + $tagList = []; foreach ($tags as $tag) { if ($tag['cnt'] > 0) { - $tagList[] = array( + $tagList[] = [ 'result' => $tag['tag'], 'count' => $tag['cnt'] - ); + ]; } } $view->resultList = array_slice( @@ -326,17 +326,17 @@ class BrowseController extends AbstractBase $params['findby'], $this->config->Browse->result_limit ); - $resultList = array(); + $resultList = []; foreach ($tagList as $i => $tag) { - $resultList[$i] = array( + $resultList[$i] = [ 'result' => $tag['tag'], 'count' => $tag['cnt'] - ); + ]; } $view->resultList = $resultList; } $view->paramTitle = 'lookfor='; - $view->searchParams = array(); + $view->searchParams = []; } return $this->performSearch($view); @@ -352,11 +352,11 @@ class BrowseController extends AbstractBase $this->setCurrentAction('LCC'); $view = $this->createViewModel(); list($view->filter, $view->secondaryList) = $this->getSecondaryList('lcc'); - $view->secondaryParams = array( + $view->secondaryParams = [ 'query_field' => 'callnumber-first', 'facet_field' => 'callnumber-subject' - ); - $view->searchParams = array(); + ]; + $view->searchParams = []; return $this->performSearch($view); } @@ -370,12 +370,12 @@ class BrowseController extends AbstractBase $this->setCurrentAction('Dewey'); $view = $this->createViewModel(); list($view->filter, $hundredsList) = $this->getSecondaryList('dewey'); - $categoryList = array(); + $categoryList = []; foreach ($hundredsList as $dewey) { - $categoryList[$dewey['value']] = array( + $categoryList[$dewey['value']] = [ 'text' => $dewey['displayText'], 'count' => $dewey['count'] - ); + ]; } $view->categoryList = $categoryList; if ($this->params()->fromQuery('findby')) { @@ -393,10 +393,10 @@ class BrowseController extends AbstractBase . $this->params()->fromQuery('findby'); } $view->secondaryList = $secondaryList; - $view->secondaryParams = array( + $view->secondaryParams = [ 'query_field' => 'dewey-tens', 'facet_field' => 'dewey-ones' - ); + ]; } return $this->performSearch($view); } @@ -419,10 +419,10 @@ class BrowseController extends AbstractBase $findby = $this->params()->fromQuery('findby'); if ($findby) { - $view->secondaryParams = array( + $view->secondaryParams = [ 'query_field' => $this->getCategory($findby), 'facet_field' => $this->getCategory($currentAction) - ); + ]; $view->facetPrefix = $facetPrefix && $findby == 'alphabetical'; list($view->filter, $view->secondaryList) = $this->getSecondaryList($findby); @@ -438,14 +438,14 @@ class BrowseController extends AbstractBase */ public function authorAction() { - $categoryList = array( + $categoryList = [ 'alphabetical' => 'By Alphabetical', 'lcc' => 'By Call Number', 'topic' => 'By Topic', 'genre' => 'By Genre', 'region' => 'By Region', 'era' => 'By Era' - ); + ]; return $this->performBrowse('Author', $categoryList, false); } @@ -457,12 +457,12 @@ class BrowseController extends AbstractBase */ public function topicAction() { - $categoryList = array( + $categoryList = [ 'alphabetical' => 'By Alphabetical', 'genre' => 'By Genre', 'region' => 'By Region', 'era' => 'By Era' - ); + ]; return $this->performBrowse('Topic', $categoryList, true); } @@ -474,12 +474,12 @@ class BrowseController extends AbstractBase */ public function genreAction() { - $categoryList = array( + $categoryList = [ 'alphabetical' => 'By Alphabetical', 'topic' => 'By Topic', 'region' => 'By Region', 'era' => 'By Era' - ); + ]; return $this->performBrowse('Genre', $categoryList, true); } @@ -491,12 +491,12 @@ class BrowseController extends AbstractBase */ public function regionAction() { - $categoryList = array( + $categoryList = [ 'alphabetical' => 'By Alphabetical', 'topic' => 'By Topic', 'genre' => 'By Genre', 'era' => 'By Era' - ); + ]; return $this->performBrowse('Region', $categoryList, true); } @@ -508,12 +508,12 @@ class BrowseController extends AbstractBase */ public function eraAction() { - $categoryList = array( + $categoryList = [ 'alphabetical' => 'By Alphabetical', 'topic' => 'By Topic', 'genre' => 'By Genre', 'region' => 'By Region' - ); + ]; return $this->performBrowse('Era', $categoryList, true); } @@ -530,43 +530,43 @@ class BrowseController extends AbstractBase $category = $this->getCategory(); switch($facet) { case 'alphabetical': - return array('', $this->getAlphabetList()); + return ['', $this->getAlphabetList()]; case 'dewey': - return array( + return [ 'dewey-tens', $this->quoteValues( $this->getFacetList('dewey-hundreds', $category, 'index') ) - ); + ]; case 'lcc': - return array( + return [ 'callnumber-first', $this->quoteValues( $this->getFacetList('callnumber-first', $category, 'index') ) - ); + ]; case 'topic': - return array( + return [ 'topic_facet', $this->quoteValues( $this->getFacetList('topic_facet', $category) ) - ); + ]; case 'genre': - return array( + return [ 'genre_facet', $this->quoteValues( $this->getFacetList('genre_facet', $category) ) - ); + ]; case 'region': - return array( + return [ 'geographic_facet', $this->quoteValues( $this->getFacetList('geographic_facet', $category) ) - ); + ]; case 'era': - return array( + return [ 'era_facet', $this->quoteValues( $this->getFacetList('era_facet', $category) ) - ); + ]; } } @@ -621,7 +621,7 @@ class BrowseController extends AbstractBase } return $result[$facet]['list']; } else { - return array(); + return []; } } @@ -697,7 +697,7 @@ class BrowseController extends AbstractBase // (value has asterix appended for Solr, but is unmodified for tags) $suffix = $this->getCurrentAction() == 'Tag' ? '' : '*'; $callback = function ($letter) use ($suffix) { - return array('value' => $letter . $suffix, 'displayText' => $letter); + return ['value' => $letter . $suffix, 'displayText' => $letter]; }; preg_match_all('/(.)/u', $chars, $matches); return array_map($callback, $matches[1]); diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index 1194d8e2909..f957259695b 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 $listID = $this->params()->fromPost('listID'); $this->session->url = empty($listID) ? $this->url()->fromRoute('myresearch-favorites') - : $this->url()->fromRoute('userList', array('id' => $listID)); + : $this->url()->fromRoute('userList', ['id' => $listID]); // Now forward to the requested controller/action: $controller = 'Cart'; // assume Cart unless overridden below. @@ -196,7 +196,7 @@ class CartController extends AbstractBase && !$this->getUser() ) { return $this->forceLogin( - null, array('cartIds' => $ids, 'cartAction' => 'Email') + null, ['cartIds' => $ids, 'cartAction' => 'Email'] ); } @@ -210,7 +210,7 @@ class CartController extends AbstractBase // Process form submission: if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { // Build the URL to share: - $params = array(); + $params = []; foreach ($ids as $current) { $params[] = urlencode('id[]') . '=' . urlencode($current); } @@ -293,12 +293,12 @@ class CartController extends AbstractBase if ($export->needsRedirect($format)) { return $this->redirect()->toUrl($url); } - $msg = array( + $msg = [ 'translate' => false, 'html' => true, 'msg' => $this->getViewRenderer()->render( - 'cart/export-success.phtml', array('url' => $url) + 'cart/export-success.phtml', ['url' => $url] ) - ); + ]; return $this->redirectToSource('info', $msg); } @@ -327,7 +327,7 @@ class CartController extends AbstractBase { // We use abbreviated parameters here to keep the URL short (there may // be a long list of IDs, and we don't want to run out of room): - $ids = $this->params()->fromQuery('i', array()); + $ids = $this->params()->fromQuery('i', []); $format = $this->params()->fromQuery('f'); // Make sure we have IDs to export: @@ -342,7 +342,7 @@ class CartController extends AbstractBase // Actually export the records $records = $this->getRecordLoader()->loadBatch($ids); $recordHelper = $this->getViewRenderer()->plugin('record'); - $parts = array(); + $parts = []; foreach ($records as $record) { $parts[] = $recordHelper($record)->getExport($format); } @@ -379,7 +379,7 @@ class CartController extends AbstractBase // Make sure user is logged in: if (!($user = $this->getUser())) { return $this->forceLogin( - null, array('cartIds' => $ids, 'cartAction' => 'Save') + null, ['cartIds' => $ids, 'cartAction' => 'Save'] ); } @@ -391,7 +391,7 @@ class CartController extends AbstractBase ->addMessage('bulk_save_success'); $list = $this->params()->fromPost('list'); if (!empty($list)) { - return $this->redirect()->toRoute('userList', array('id' => $list)); + return $this->redirect()->toRoute('userList', ['id' => $list]); } else { return $this->redirectToSource(); } @@ -399,10 +399,10 @@ class CartController extends AbstractBase // Pass record and list information to view: return $this->createViewModel( - array( + [ 'records' => $this->getRecordLoader()->loadBatch($ids), 'lists' => $user->getLists() - ) + ] ); } diff --git a/module/VuFind/src/VuFind/Controller/CollectionsController.php b/module/VuFind/src/VuFind/Controller/CollectionsController.php index db55532d1ae..34ad4f60962 100644 --- a/module/VuFind/src/VuFind/Controller/CollectionsController.php +++ b/module/VuFind/src/VuFind/Controller/CollectionsController.php @@ -67,10 +67,10 @@ class CollectionsController extends AbstractBase $this->params()->fromQuery('title') ); if (count($collections) != 1) { - return $this->createViewModel(array('collections' => $collections)); + return $this->createViewModel(['collections' => $collections]); } return $this->redirect() - ->toRoute('collection', array('id' => $collections[0]->getUniqueId())); + ->toRoute('collection', ['id' => $collections[0]->getUniqueId()]); } /** @@ -138,7 +138,7 @@ class CollectionsController extends AbstractBase $view->letters = $this->getAlphabetList(); // Format the results for proper display: - $finalresult = array(); + $finalresult = []; $delimiter = $this->getBrowseDelimiter(); foreach ($result['Browse']['items'] as $rkey => $collection) { $collectionIdNamePair @@ -163,7 +163,7 @@ class CollectionsController extends AbstractBase // Process incoming parameters: $from = $this->params()->fromQuery('from', ''); $page = $this->params()->fromQuery('page', 0); - $appliedFilters = $this->params()->fromQuery('filter', array()); + $appliedFilters = $this->params()->fromQuery('filter', []); $limit = $this->getBrowseLimit(); $browseField = "hierarchy_browse"; @@ -176,7 +176,7 @@ class CollectionsController extends AbstractBase // Only grab 150,000 facet values to avoid out-of-memory errors: $result = $searchObject->getFullFieldFacets( - array($browseField), false, 150000, 'index' + [$browseField], false, 150000, 'index' ); $result = $result[$browseField]['data']['list']; @@ -242,10 +242,10 @@ class CollectionsController extends AbstractBase $from = $this->normalizeForBrowse($from); // Push the from value into the array so we can find the matching position: - array_push($result, array('displayText' => $from, 'placeholder' => true)); + array_push($result, ['displayText' => $from, 'placeholder' => true]); // Declare array to hold the $result array in the right sort order - $sorted = array(); + $sorted = []; foreach (array_keys($this->normalizeAndSortFacets($result)) as $i) { // If this is the placeholder we added earlier, we have found the // array position we want to use as our start; otherwise, it is an @@ -273,7 +273,7 @@ class CollectionsController extends AbstractBase */ protected function normalizeAndSortFacets(&$result) { - $valuesSorted = array(); + $valuesSorted = []; foreach ($result as $resKey => $resVal) { $valuesSorted[$resKey] = $this->normalizeForBrowse($resVal['displayText']); diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index 976985acd27..44d68f918ff 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -105,7 +105,7 @@ class CombinedController extends AbstractSearch $cart = $this->getServiceLocator()->get('VuFind\Cart'); $general = $this->getServiceLocator()->get('VuFind\Config') ->get('config'); - $viewParams = array( + $viewParams = [ 'searchClassId' => $searchClassId, 'currentSearch' => $settings, 'showCartControls' => $currentOptions->supportsCart() @@ -113,7 +113,7 @@ class CombinedController extends AbstractSearch 'showBulkOptions' => $currentOptions->supportsCart() && isset($general->Site->showBulkOptions) && $general->Site->showBulkOptions - ); + ]; $html = $this->getViewRenderer()->render( 'combined/results-list.phtml', $viewParams @@ -147,13 +147,13 @@ class CombinedController extends AbstractSearch $this->getSearchMemory()->disable(); // Gather combined results: - $combinedResults = array(); + $combinedResults = []; $options = $this->getServiceLocator() ->get('VuFind\SearchOptionsPluginManager'); $config = $this->getServiceLocator()->get('VuFind\Config')->get('combined') ->toArray(); $supportsCart = false; - $supportsCartOptions = array(); + $supportsCartOptions = []; foreach ($config as $current => $settings) { // Special case -- ignore recommendation config: if ($current == 'Layout' || $current == 'RecommendationModules') { @@ -171,7 +171,7 @@ class CombinedController extends AbstractSearch $combinedResults[$current]['view'] = (!isset($settings['ajax']) || !$settings['ajax']) ? $this->forwardTo($controller, $action) - : $this->createViewModel(array('results' => $results)); + : $this->createViewModel(['results' => $results]); // Special case: include appropriate "powered by" message: if (strtolower($current) == 'summon') { @@ -190,7 +190,7 @@ class CombinedController extends AbstractSearch $placement = isset($config['Layout']['stack_placement']) ? $config['Layout']['stack_placement'] : 'distributed'; - if (!in_array($placement, array('distributed', 'left', 'right'))) { + if (!in_array($placement, ['distributed', 'left', 'right'])) { $placement = 'distributed'; } @@ -199,7 +199,7 @@ class CombinedController extends AbstractSearch // Build view model: return $this->createViewModel( - array( + [ 'columns' => $columns, 'combinedResults' => $combinedResults, 'config' => $config, @@ -210,7 +210,7 @@ class CombinedController extends AbstractSearch 'supportsCartOptions' => $supportsCartOptions, 'showBulkOptions' => isset($settings->Site->showBulkOptions) && $settings->Site->showBulkOptions - ) + ] ); } diff --git a/module/VuFind/src/VuFind/Controller/ConfirmController.php b/module/VuFind/src/VuFind/Controller/ConfirmController.php index 06581ba1e68..c6b09e0c27a 100644 --- a/module/VuFind/src/VuFind/Controller/ConfirmController.php +++ b/module/VuFind/src/VuFind/Controller/ConfirmController.php @@ -57,10 +57,10 @@ class ConfirmController extends AbstractBase foreach ($data['messages'] as $message) { $flash = (true === is_array($message)) - ? array( + ? [ 'msg' => $message['msg'], 'tokens' => $message['tokens'] - ) + ] : $message; $this->flashMessenger()->addMessage($flash); } diff --git a/module/VuFind/src/VuFind/Controller/EdsController.php b/module/VuFind/src/VuFind/Controller/EdsController.php index 3c192410d23..2ba06606843 100644 --- a/module/VuFind/src/VuFind/Controller/EdsController.php +++ b/module/VuFind/src/VuFind/Controller/EdsController.php @@ -88,7 +88,7 @@ class EdsController extends AbstractSearch { $this->setUp(); return $this->createViewModel( - array('results' => $this->getHomePageFacets()) + ['results' => $this->getHomePageFacets()] ); } @@ -242,7 +242,7 @@ class EdsController extends AbstractSearch } } } - return array($from, $to); + return [$from, $to]; } /** diff --git a/module/VuFind/src/VuFind/Controller/HelpController.php b/module/VuFind/src/VuFind/Controller/HelpController.php index 9f593daf2ad..9aff485ec1c 100644 --- a/module/VuFind/src/VuFind/Controller/HelpController.php +++ b/module/VuFind/src/VuFind/Controller/HelpController.php @@ -52,7 +52,7 @@ class HelpController extends AbstractBase { $this->layout()->setTemplate('layout/help'); return $this->createViewModel( - array('topic' => $this->params()->fromQuery('topic')) + ['topic' => $this->params()->fromQuery('topic')] ); } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Controller/HierarchyController.php b/module/VuFind/src/VuFind/Controller/HierarchyController.php index 5ed0422806a..ccf167ad5e9 100644 --- a/module/VuFind/src/VuFind/Controller/HierarchyController.php +++ b/module/VuFind/src/VuFind/Controller/HierarchyController.php @@ -84,7 +84,7 @@ class HierarchyController extends AbstractBase $config = $this->getConfig(); $limit = isset($config->Hierarchy->treeSearchLimit) ? $config->Hierarchy->treeSearchLimit : -1; - $resultIDs = array(); + $resultIDs = []; $hierarchyID = $this->params()->fromQuery('hierarchyID'); $lookfor = $this->params()->fromQuery('lookfor', ''); $searchType = $this->params()->fromQuery('type', 'AllFields'); @@ -93,20 +93,20 @@ class HierarchyController extends AbstractBase ->get('VuFind\SearchResultsPluginManager')->get('Solr'); $results->getParams()->setBasicSearch($lookfor, $searchType); $results->getParams()->addFilter('hierarchy_top_id:' . $hierarchyID); - $facets = $results->getFullFieldFacets(array('id'), false, $limit+1); + $facets = $results->getFullFieldFacets(['id'], false, $limit+1); $callback = function ($data) { return $data['value']; }; $resultIDs = isset($facets['id']['data']['list']) - ? array_map($callback, $facets['id']['data']['list']) : array(); + ? array_map($callback, $facets['id']['data']['list']) : []; $limitReached = ($limit > 0 && count($resultIDs) > $limit); - $returnArray = array( + $returnArray = [ "limitReached" => $limitReached, "results" => array_slice($resultIDs, 0, $limit) - ); + ]; return $this->outputJSON(json_encode($returnArray)); } diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index aa944b6fdfc..05fedd3a748 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -71,7 +71,7 @@ class InstallController extends AbstractBase { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 1000); + $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); } /** @@ -118,10 +118,10 @@ class InstallController extends AbstractBase } } - return array( + return [ 'title' => 'Basic Configuration', 'status' => $status, 'fix' => 'fixbasicconfig' - ); + ]; } /** @@ -164,11 +164,11 @@ class InstallController extends AbstractBase protected function checkCache() { $cache = $this->getServiceLocator()->get('VuFind\CacheManager'); - return array( + return [ 'title' => 'Cache', 'status' => !$cache->hasDirectoryCreationError(), 'fix' => 'fixcache' - ); + ]; } /** @@ -203,9 +203,9 @@ class InstallController extends AbstractBase } catch (\Exception $e) { $status = false; } - return array( + return [ 'title' => 'Database', 'status' => $status, 'fix' => 'fixdatabase' - ); + ]; } /** @@ -238,11 +238,11 @@ class InstallController extends AbstractBase && function_exists('mcrypt_module_open') && class_exists('XSLTProcessor'); - return array( + return [ 'title' => 'Dependencies', 'status' => $requiredFunctionsExist && $this->phpVersionIsNewEnough(), 'fix' => 'fixdependencies' - ); + ]; } /** @@ -309,7 +309,7 @@ class InstallController extends AbstractBase $problems++; } - return $this->createViewModel(array('problems' => $problems)); + return $this->createViewModel(['problems' => $problems]); } /** @@ -448,14 +448,14 @@ class InstallController extends AbstractBase . " WITH PASSWORD {$escapedPass}"; $grant = "GRANT ALL PRIVILEGES ON DATABASE " . "{$view->dbname} TO {$view->dbuser} "; - return array($create, $escape, $cuser, $grant); + return [$create, $escape, $cuser, $grant]; } // Default: MySQL: $grant = "GRANT SELECT,INSERT,UPDATE,DELETE ON " . $view->dbname . ".* TO '{$view->dbuser}'@'{$view->vufindhost}' " . "IDENTIFIED BY {$escapedPass} WITH GRANT OPTION"; - return array($create, $grant, 'FLUSH PRIVILEGES'); + return [$create, $grant, 'FLUSH PRIVILEGES']; } /** @@ -474,10 +474,10 @@ class InstallController extends AbstractBase . "SCHEMA public TO {$view->dbuser} "; $grantSequences = "GRANT ALL PRIVILEGES ON ALL SEQUENCES" . " IN SCHEMA public TO {$view->dbuser} "; - return array($grantTables, $grantSequences); + return [$grantTables, $grantSequences]; } // Default: MySQL: - return array(); + return []; } /** @@ -493,7 +493,7 @@ class InstallController extends AbstractBase } return $this->createViewModel( - array('sql' => $this->params()->fromQuery('sql')) + ['sql' => $this->params()->fromQuery('sql')] ); } @@ -505,7 +505,7 @@ class InstallController extends AbstractBase protected function checkILS() { $config = $this->getConfig(); - if (in_array($config->Catalog->driver, array('Sample', 'Demo'))) { + if (in_array($config->Catalog->driver, ['Sample', 'Demo'])) { $status = false; } else { try { @@ -516,7 +516,7 @@ class InstallController extends AbstractBase $status = false; } } - return array('title' => 'ILS', 'status' => $status, 'fix' => 'fixils'); + return ['title' => 'ILS', 'status' => $status, 'fix' => 'fixils']; } /** @@ -552,16 +552,16 @@ class InstallController extends AbstractBase // or if we need to warn the user that they have selected a fake driver: $config = $this->getConfig(); $view = $this->createViewModel(); - if (in_array($config->Catalog->driver, array('Sample', 'Demo'))) { + if (in_array($config->Catalog->driver, ['Sample', 'Demo'])) { $view->demo = true; // Get a list of available drivers: $dir = opendir(APPLICATION_PATH . '/module/VuFind/src/VuFind/ILS/Driver'); - $drivers = array(); - $blacklist = array( + $drivers = []; + $blacklist = [ 'Sample.php', 'Demo.php', 'DriverInterface.php', 'AbstractBase.php', 'PluginManager.php', 'PluginFactory.php' - ); + ]; while ($line = readdir($dir)) { if (stristr($line, '.php') && !in_array($line, $blacklist)) { $drivers[] = str_replace('.php', '', $line); @@ -604,7 +604,7 @@ class InstallController extends AbstractBase } catch (\Exception $e) { $status = false; } - return array('title' => 'Solr', 'status' => $status, 'fix' => 'fixsolr'); + return ['title' => 'Solr', 'status' => $status, 'fix' => 'fixsolr']; } /** @@ -639,7 +639,7 @@ class InstallController extends AbstractBase $view = $this->createViewModel(); $view->rawUrl = $config->Index->url; $view->userUrl = str_replace( - array('localhost', '127.0.0.1'), + ['localhost', '127.0.0.1'], $this->getRequest()->getServer()->get('HTTP_HOST'), $config->Index->url ); @@ -679,9 +679,9 @@ class InstallController extends AbstractBase } } - return array( + return [ 'title' => 'Security', 'status' => $status, 'fix' => 'fixsecurity' - ); + ]; } /** @@ -806,7 +806,7 @@ class InstallController extends AbstractBase if (!$writer->save()) { return $this->forwardTo('Install', 'fixbasicconfig'); } - return $this->createViewModel(array('configDir' => dirname($config))); + return $this->createViewModel(['configDir' => dirname($config)]); } /** @@ -818,13 +818,13 @@ class InstallController extends AbstractBase { // Perform all checks (based on naming convention): $methods = get_class_methods($this); - $checks = array(); + $checks = []; foreach ($methods as $method) { if (substr($method, 0, 5) == 'check') { $checks[] = $this->$method(); } } - return $this->createViewModel(array('checks' => $checks)); + return $this->createViewModel(['checks' => $checks]); } } diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index d2715cfac75..30ba1c8a564 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -389,7 +389,7 @@ class MyResearchController extends AbstractBase $listID = $this->params()->fromPost('listID'); $newUrl = empty($listID) ? $this->url()->fromRoute('myresearch-favorites') - : $this->url()->fromRoute('userList', array('id' => $listID)); + : $this->url()->fromRoute('userList', ['id' => $listID]); // Fail if we have nothing to delete: $ids = is_null($this->params()->fromPost('selectAll')) @@ -418,10 +418,10 @@ class MyResearchController extends AbstractBase $list = $table->getExisting($listID); } return $this->createViewModel( - array( + [ 'list' => $list, 'deleteIDS' => $ids, 'records' => $this->getRecordLoader()->loadBatch($ids) - ) + ] ); } @@ -454,12 +454,12 @@ class MyResearchController extends AbstractBase // ...Specific List $table = $this->getTable('UserList'); $list = $table->getExisting($listID); - $list->removeResourcesById($user, array($id), $source); + $list->removeResourcesById($user, [$id], $source); $this->flashMessenger()->setNamespace('info') ->addMessage('Item removed from list'); } else { // ...My Favorites - $user->removeResourcesById(array($id), $source); + $user->removeResourcesById([$id], $source); $this->flashMessenger()->setNamespace('info') ->addMessage('Item removed from favorites'); } @@ -485,25 +485,25 @@ class MyResearchController extends AbstractBase foreach ($lists as $list) { $tags = $this->params()->fromPost('tags' . $list); $driver->saveToFavorites( - array( + [ 'list' => $list, 'mytags' => $tagParser->parse($tags), 'notes' => $this->params()->fromPost('notes' . $list) - ), + ], $user ); } // add to a new list? $addToList = $this->params()->fromPost('addToList'); if ($addToList > -1) { - $driver->saveToFavorites(array('list' => $addToList), $user); + $driver->saveToFavorites(['list' => $addToList], $user); } $this->flashMessenger()->setNamespace('info') ->addMessage('edit_list_success'); $newUrl = is_null($listID) ? $this->url()->fromRoute('myresearch-favorites') - : $this->url()->fromRoute('userList', array('id' => $listID)); + : $this->url()->fromRoute('userList', ['id' => $listID]); return $this->redirect()->toUrl($newUrl); } @@ -537,20 +537,20 @@ class MyResearchController extends AbstractBase // Get saved favorites for selected list (or all lists if $listID is null) $userResources = $user->getSavedData($id, $listID, $source); - $savedData = array(); + $savedData = []; foreach ($userResources as $current) { - $savedData[] = array( + $savedData[] = [ 'listId' => $current->list_id, 'listTitle' => $current->list_title, 'notes' => $current->notes, 'tags' => $user->getTagString($id, $current->list_id, $source) - ); + ]; } // In order to determine which lists contain the requested item, we may // need to do an extra database lookup if the previous lookup was limited // to a particular list ID: - $containingLists = array(); + $containingLists = []; if (!empty($listID)) { $userResources = $user->getSavedData($id, null, $source); } @@ -560,7 +560,7 @@ class MyResearchController extends AbstractBase // Send non-containing lists to the view for user selection: $userLists = $user->getLists(); - $lists = array(); + $lists = []; foreach ($userLists as $userList) { if (!in_array($userList->id, $containingLists)) { $lists[$userList->id] = $userList->title; @@ -568,9 +568,9 @@ class MyResearchController extends AbstractBase } return $this->createViewModel( - array( + [ 'driver' => $driver, 'lists' => $lists, 'savedData' => $savedData - ) + ] ); } @@ -590,11 +590,11 @@ class MyResearchController extends AbstractBase if (empty($listID)) { $url = $this->url()->fromRoute('myresearch-favorites'); } else { - $url = $this->url()->fromRoute('userList', array('id' => $listID)); + $url = $this->url()->fromRoute('userList', ['id' => $listID]); } return $this->confirm( 'confirm_delete_brief', $url, $url, 'confirm_delete', - array('delete' => $id, 'source' => $source) + ['delete' => $id, 'source' => $source] ); } @@ -647,13 +647,13 @@ class MyResearchController extends AbstractBase new Parameters( $this->getRequest()->getQuery()->toArray() + $this->getRequest()->getPost()->toArray() - + array('id' => $this->params()->fromRoute('id')) + + ['id' => $this->params()->fromRoute('id')] ) ); $results->performAndProcessSearch(); return $this->createViewModel( - array('params' => $params, 'results' => $results) + ['params' => $params, 'results' => $results] ); } catch (ListPermissionException $e) { if (!$this->getUser()) { @@ -695,10 +695,10 @@ class MyResearchController extends AbstractBase // Similarly, if the user is in the process of bulk-saving records, // send them back to the appropriate place in the cart. $bulkIds = $this->params()->fromPost( - 'ids', $this->params()->fromQuery('ids', array()) + 'ids', $this->params()->fromQuery('ids', []) ); if (!empty($bulkIds)) { - $params = array(); + $params = []; foreach ($bulkIds as $id) { $params[] = urlencode('ids[]') . '=' . urlencode($id); } @@ -708,7 +708,7 @@ class MyResearchController extends AbstractBase ->toUrl($saveUrl . implode('&', $params)); } - return $this->lightboxAwareRedirect('userList', array('id' => $finalId)); + return $this->lightboxAwareRedirect('userList', ['id' => $finalId]); } catch (\Exception $e) { switch(get_class($e)) { case 'VuFind\Exception\ListPermission': @@ -757,7 +757,7 @@ class MyResearchController extends AbstractBase } // Send the list to the view: - return $this->createViewModel(array('list' => $list, 'newList' => $newList)); + return $this->createViewModel(['list' => $list, 'newList' => $newList]); } /** @@ -810,8 +810,8 @@ class MyResearchController extends AbstractBase return $this->confirm( 'confirm_delete_list_brief', $this->url()->fromRoute('myresearch-deletelist'), - $this->url()->fromRoute('userList', array('id' => $listID)), - 'confirm_delete_list_text', array('listID' => $listID) + $this->url()->fromRoute('userList', ['id' => $listID]), + 'confirm_delete_list_text', ['listID' => $listID] ); } @@ -852,7 +852,7 @@ class MyResearchController extends AbstractBase $cancelStatus = $catalog->checkFunction('cancelHolds', compact('patron')); $view = $this->createViewModel(); $view->cancelResults = $cancelStatus - ? $this->holds()->cancelHolds($catalog, $patron) : array(); + ? $this->holds()->cancelHolds($catalog, $patron) : []; // If we need to confirm if (!is_array($view->cancelResults)) { return $view->cancelResults; @@ -863,7 +863,7 @@ class MyResearchController extends AbstractBase // Get held item details: $result = $catalog->getMyHolds($patron); - $recordList = array(); + $recordList = []; $this->holds()->resetValidation(); foreach ($result as $current) { // Add cancel details if appropriate: @@ -916,7 +916,7 @@ class MyResearchController extends AbstractBase ? $this->storageRetrievalRequests()->cancelStorageRetrievalRequests( $catalog, $patron ) - : array(); + : []; // If we need to confirm if (!is_array($view->cancelResults)) { return $view->cancelResults; @@ -927,7 +927,7 @@ class MyResearchController extends AbstractBase // Get request details: $result = $catalog->getMyStorageRetrievalRequests($patron); - $recordList = array(); + $recordList = []; $this->storageRetrievalRequests()->resetValidation(); foreach ($result as $current) { // Add cancel details if appropriate: @@ -981,7 +981,7 @@ class MyResearchController extends AbstractBase ? $this->ILLRequests()->cancelILLRequests( $catalog, $patron ) - : array(); + : []; // If we need to confirm if (!is_array($view->cancelResults)) { return $view->cancelResults; @@ -992,7 +992,7 @@ class MyResearchController extends AbstractBase // Get request details: $result = $catalog->getMyILLRequests($patron); - $recordList = array(); + $recordList = []; $this->ILLRequests()->resetValidation(); foreach ($result as $current) { // Add cancel details if appropriate: @@ -1036,14 +1036,14 @@ class MyResearchController extends AbstractBase ? $this->renewals()->processRenewals( $this->getRequest()->getPost(), $catalog, $patron ) - : array(); + : []; // By default, assume we will not need to display a renewal form: $renewForm = false; // Get checked out item details: $result = $catalog->getMyTransactions($patron); - $transactions = array(); + $transactions = []; foreach ($result as $current) { // Add renewal details if appropriate: $current = $this->renewals()->addRenewDetails( @@ -1061,10 +1061,10 @@ class MyResearchController extends AbstractBase } return $this->createViewModel( - array( + [ 'transactions' => $transactions, 'renewForm' => $renewForm, 'renewResult' => $renewResult - ) + ] ); } @@ -1085,7 +1085,7 @@ class MyResearchController extends AbstractBase // Get fine details: $result = $catalog->getMyFines($patron); - $fines = array(); + $fines = []; foreach ($result as $row) { // Attempt to look up and inject title: try { @@ -1104,7 +1104,7 @@ class MyResearchController extends AbstractBase $fines[] = $row; } - return $this->createViewModel(array('fines' => $fines)); + return $this->createViewModel(['fines' => $fines]); } /** @@ -1194,12 +1194,12 @@ class MyResearchController extends AbstractBase // Custom template for emails (text-only) $message = $renderer->render( 'Email/recover-password.phtml', - array( + [ 'library' => $config->Site->title, 'url' => $this->getServerUrl('myresearch-verify') . '?hash=' . $user->verify_hash . '&auth_method=' . $method - ) + ] ); $this->getServiceLocator()->get('VuFind\Mailer')->send( $user->email, diff --git a/module/VuFind/src/VuFind/Controller/Plugin/AbstractRequestBase.php b/module/VuFind/src/VuFind/Controller/Plugin/AbstractRequestBase.php index 03edf858400..d85f53f100e 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/AbstractRequestBase.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/AbstractRequestBase.php @@ -86,7 +86,7 @@ abstract class AbstractRequestBase extends AbstractPlugin */ public function resetValidation() { - $this->getSession()->validIds = array(); + $this->getSession()->validIds = []; } /** @@ -118,7 +118,7 @@ abstract class AbstractRequestBase extends AbstractPlugin $controller = $this->getController(); $params = $controller->params(); - $keyValueArray = array(); + $keyValueArray = []; foreach ($linkData as $details) { // We expect most parameters to come via query, but some (mainly ID) may // be in the route: @@ -137,7 +137,7 @@ abstract class AbstractRequestBase extends AbstractPlugin // FIRST and then override it with GET values in order to ensure that // the user doesn't bypass the hashkey verification by manipulating POST // values. - $gatheredDetails = $params->fromPost('gatheredDetails', array()); + $gatheredDetails = $params->fromPost('gatheredDetails', []); // Make sure the bib ID is included, even if it's not loaded as part of // the validation loop below. @@ -255,7 +255,7 @@ abstract class AbstractRequestBase extends AbstractPlugin // Load config: $dateArray = isset($checkHolds['defaultRequiredDate']) ? explode(":", $checkHolds['defaultRequiredDate']) - : array(0, 1, 0); + : [0, 1, 0]; // Process special "driver" prefix and adjust default date // settings accordingly: @@ -263,7 +263,7 @@ abstract class AbstractRequestBase extends AbstractPlugin $useDriver = true; array_shift($dateArray); if (count($dateArray) < 3) { - $dateArray = array(0, 1, 0); + $dateArray = [0, 1, 0]; } } else { $useDriver = false; @@ -272,7 +272,7 @@ abstract class AbstractRequestBase extends AbstractPlugin // If the driver setting is active, try it out: if ($useDriver && $catalog) { $check = $catalog->checkCapability( - 'getHoldDefaultRequiredDate', array($patron, $holdInfo) + 'getHoldDefaultRequiredDate', [$patron, $holdInfo] ); if ($check) { $result = $catalog->getHoldDefaultRequiredDate($patron, $holdInfo); diff --git a/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php b/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php index b810c286421..e417ac51e91 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/DbUpgrade.php @@ -45,7 +45,7 @@ class DbUpgrade extends AbstractPlugin * * @var array */ - protected $dbCommands = array(); + protected $dbCommands = []; /** * Database adapter @@ -83,7 +83,7 @@ class DbUpgrade extends AbstractPlugin if (isset($matches[2])) { $table = str_replace('`', '', $matches[2]); if (!isset($this->dbCommands[$table])) { - $this->dbCommands[$table] = array(); + $this->dbCommands[$table] = []; } $this->dbCommands[$table][] = $statement; } @@ -147,7 +147,7 @@ class DbUpgrade extends AbstractPlugin if ($reload || !$this->tableInfo) { $metadata = new DbMetadata($this->getAdapter()); $tables = $metadata->getTables(); - $this->tableInfo = array(); + $this->tableInfo = []; foreach ($tables as $current) { $this->tableInfo[$current->getName()] = $current; } @@ -181,7 +181,7 @@ class DbUpgrade extends AbstractPlugin $results = $this->getAdapter()->query($sql, DbAdapter::QUERY_MODE_EXECUTE); // Load details: - $retVal = array(); + $retVal = []; foreach ($results as $current) { if (strtolower(substr($current->Collation, 0, 6)) == 'latin1') { $retVal[$current->Field] = (array)$current; @@ -203,7 +203,7 @@ class DbUpgrade extends AbstractPlugin $results = $this->getAdapter()->query($sql, DbAdapter::QUERY_MODE_EXECUTE); // Load details: - $retVal = array(); + $retVal = []; foreach ($results as $current) { if (strtolower(substr($current->Collation, 0, 6)) == 'latin1') { $retVal[$current->Name] @@ -291,8 +291,8 @@ class DbUpgrade extends AbstractPlugin protected function getTableColumns($table) { $info = $this->getTableInfo(true); - $columns = isset($info[$table]) ? $info[$table]->getColumns() : array(); - $retVal = array(); + $columns = isset($info[$table]) ? $info[$table]->getColumns() : []; + $retVal = []; foreach ($columns as $current) { $retVal[strtolower($current->getName())] = $current; } @@ -308,7 +308,7 @@ class DbUpgrade extends AbstractPlugin public function getMissingTables() { $tables = $this->getAllTables(); - $missing = array(); + $missing = []; foreach (array_keys($this->dbCommands) as $table) { if (!in_array(trim(strtolower($table)), $tables)) { $missing[] = $table; @@ -347,9 +347,9 @@ class DbUpgrade extends AbstractPlugin * @throws \Exception * @return array */ - public function getMissingColumns($missingTables = array()) + public function getMissingColumns($missingTables = []) { - $missing = array(); + $missing = []; foreach ($this->dbCommands as $table => $sql) { // Skip missing tables if we're logging if (in_array($table, $missingTables)) { @@ -363,7 +363,7 @@ class DbUpgrade extends AbstractPlugin $expectedColumns = $matches[1]; // Create associative array of column name => SQL defining that column - $columnDefinitions = array(); + $columnDefinitions = []; foreach ($expectedColumns as $i => $name) { // Strip off any comments: $parts = explode('--', $matches[0][$i]); @@ -377,7 +377,7 @@ class DbUpgrade extends AbstractPlugin foreach ($expectedColumns as $column) { if (!in_array(strtolower($column), $actualColumns)) { if (!isset($missing[$table])) { - $missing[$table] = array(); + $missing[$table] = []; } $missing[$table][] = $columnDefinitions[$column]; } @@ -454,10 +454,10 @@ class DbUpgrade extends AbstractPlugin * @throws \Exception * @return array */ - public function getModifiedColumns($missingTables = array(), - $missingColumns = array() + public function getModifiedColumns($missingTables = [], + $missingColumns = [] ) { - $missing = array(); + $missing = []; foreach ($this->dbCommands as $table => $sql) { // Skip missing tables if we're logging if (in_array($table, $missingTables)) { @@ -475,7 +475,7 @@ class DbUpgrade extends AbstractPlugin $expectedTypes = $matches[2]; // Create associative array of column name => SQL defining that column - $columnDefinitions = array(); + $columnDefinitions = []; foreach ($expectedColumns as $i => $name) { // Strip off any comments: $parts = explode('--', $matches[0][$i]); @@ -496,7 +496,7 @@ class DbUpgrade extends AbstractPlugin $currentColumn = $actualColumns[$column]; if (!$this->typeMatches($currentColumn, $expectedTypes[$i])) { if (!isset($missing[$table])) { - $missing[$table] = array(); + $missing[$table] = []; } $missing[$table][] = $columnDefinitions[$column]; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Factory.php b/module/VuFind/src/VuFind/Controller/Plugin/Factory.php index 5edc8060813..405d3af07db 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Factory.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Factory.php @@ -64,7 +64,7 @@ class Factory { $search = $sm->getServiceLocator()->get('VuFind\Config')->get('searches'); $config = isset($search->NewItem) - ? $search->NewItem : new \Zend\Config\Config(array()); + ? $search->NewItem : new \Zend\Config\Config([]); return new NewItems($config); } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Favorites.php b/module/VuFind/src/VuFind/Controller/Plugin/Favorites.php index 6226e828c65..8f0de1345de 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Favorites.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Favorites.php @@ -84,7 +84,7 @@ class Favorites extends AbstractPlugin // Add the information to the user's account: $tags = isset($params['mytags']) - ? $tagParser->parse($params['mytags']) : array(); + ? $tagParser->parse($params['mytags']) : []; $user->saveResource($resource, $list, $tags, '', false); } } @@ -102,11 +102,11 @@ class Favorites extends AbstractPlugin public function delete($ids, $listID, $user) { // Sort $ids into useful array: - $sorted = array(); + $sorted = []; foreach ($ids as $current) { list($source, $id) = explode('|', $current, 2); if (!isset($sorted[$source])) { - $sorted[$source] = array(); + $sorted[$source] = []; } $sorted[$source][] = $id; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Followup.php b/module/VuFind/src/VuFind/Controller/Plugin/Followup.php index 27a95209af0..1d82b5c17b5 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Followup.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Followup.php @@ -116,7 +116,7 @@ class Followup extends AbstractPlugin * * @return void */ - public function store($extras = array(), $overrideUrl = null) + public function store($extras = [], $overrideUrl = null) { // Store the current URL: $this->session->url = !empty($overrideUrl) diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php index ee7feb10c99..5ea4e300747 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php @@ -93,7 +93,7 @@ class Holds extends AbstractRequestBase $details = $params->fromPost('cancelSelectedIDS'); } else { // No button pushed -- no action needed - return array(); + return []; } if (!empty($details)) { @@ -105,10 +105,10 @@ class Holds extends AbstractRequestBase $this->getController()->url()->fromRoute('myresearch-holds'), $this->getController()->url()->fromRoute('myresearch-holds'), 'confirm_hold_cancel_all_text', - array( + [ 'cancelAll' => 1, 'cancelAllIDS' => $params->fromPost('cancelAllIDS') - ) + ] ); } else { return $this->getController()->confirm( @@ -116,11 +116,11 @@ class Holds extends AbstractRequestBase $this->getController()->url()->fromRoute('myresearch-holds'), $this->getController()->url()->fromRoute('myresearch-holds'), 'confirm_hold_cancel_selected_text', - array( + [ 'cancelSelected' => 1, 'cancelSelectedIDS' => $params->fromPost('cancelSelectedIDS') - ) + ] ); } } @@ -131,13 +131,13 @@ class Holds extends AbstractRequestBase if (!in_array($info, $this->getSession()->validIds)) { $flashMsg->setNamespace('error') ->addMessage('error_inconsistent_parameters'); - return array(); + return []; } } // Add Patron Data to Submitted Data $cancelResults = $catalog->cancelHolds( - array('details' => $details, 'patron' => $patron) + ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { $flashMsg->setNamespace('error')->addMessage('hold_cancel_fail'); @@ -156,6 +156,6 @@ class Holds extends AbstractRequestBase } else { $flashMsg->setNamespace('error')->addMessage('hold_empty_selection'); } - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php index 0f01ae62902..3df17289303 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php @@ -105,7 +105,7 @@ class ILLRequests extends AbstractRequestBase $details = $params->fromPost('cancelSelectedIDS'); } else { // No button pushed -- no action needed - return array(); + return []; } if (!empty($details)) { @@ -119,10 +119,10 @@ class ILLRequests extends AbstractRequestBase $url, $url, 'confirm_ill_request_cancel_all_text', - array( + [ 'cancelAll' => 1, 'cancelAllIDS' => $params->fromPost('cancelAllIDS') - ) + ] ); } else { return $this->getController()->confirm( @@ -130,11 +130,11 @@ class ILLRequests extends AbstractRequestBase $url, $url, 'confirm_ill_request_cancel_selected_text', - array( + [ 'cancelSelected' => 1, 'cancelSelectedIDS' => $params->fromPost('cancelSelectedIDS') - ) + ] ); } } @@ -145,13 +145,13 @@ class ILLRequests extends AbstractRequestBase if (!in_array($info, $this->getSession()->validIds)) { $flashMsg->setNamespace('error') ->addMessage('error_inconsistent_parameters'); - return array(); + return []; } } // Add Patron Data to Submitted Data $cancelResults = $catalog->cancelILLRequests( - array('details' => $details, 'patron' => $patron) + ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { $flashMsg->setNamespace('error')->addMessage( @@ -175,6 +175,6 @@ class ILLRequests extends AbstractRequestBase 'ill_request_empty_selection' ); } - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php index dc55b98acb2..8620b4193b8 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php @@ -77,7 +77,7 @@ class NewItems extends AbstractPlugin $newItems = $catalog->getNewItems(1, $perPage * $resultPages, $range, $dept); // Build a list of unique IDs - $bibIDs = array(); + $bibIDs = []; for ($i = 0; $i<count($newItems['results']); $i++) { $bibIDs[] = $newItems['results'][$i]['id']; } @@ -102,9 +102,9 @@ class NewItems extends AbstractPlugin if ($this->getMethod() == 'ils') { $catalog = $this->getController()->getILS(); return $catalog->checkCapability('getFunds') - ? $catalog->getFunds() : array(); + ? $catalog->getFunds() : []; } - return array(); + return []; } /** @@ -115,12 +115,12 @@ class NewItems extends AbstractPlugin public function getHiddenFilters() { if (!isset($this->config->filter)) { - return array(); + return []; } if (is_string($this->config->filter)) { - return array($this->config->filter); + return [$this->config->filter]; } - $hiddenFilters = array(); + $hiddenFilters = []; foreach ($this->config->filter as $current) { $hiddenFilters[] = $current; } @@ -156,7 +156,7 @@ class NewItems extends AbstractPlugin { // Find out if there are user configured range options; if not, // default to the standard 1/5/30 days: - $ranges = array(); + $ranges = []; if (isset($this->config->ranges)) { $tmp = explode(',', $this->config->ranges); foreach ($tmp as $range) { @@ -167,7 +167,7 @@ class NewItems extends AbstractPlugin } } if (empty($ranges)) { - $ranges = array(1, 5, 30); + $ranges = [1, 5, 30]; } return $ranges; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php b/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php index 62e1c91a896..6302c03f152 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php @@ -47,7 +47,7 @@ class Recaptcha extends AbstractPlugin /** * String array of forms where ReCaptcha is active */ - protected $domains = array(); + protected $domains = []; /** * Captcha activated in config @@ -90,7 +90,7 @@ class Recaptcha extends AbstractPlugin */ public function setErrorMode($mode) { - if (in_array($mode, array('flash', 'throw'))) { + if (in_array($mode, ['flash', 'throw'])) { $this->errorMode = $mode; return true; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php b/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php index 20c006454f2..d3ac6d9e6a4 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php @@ -88,7 +88,7 @@ class Renewals extends AbstractPlugin } else if (!empty($selected)) { $ids = $request->get('renewSelectedIDS'); } else { - $ids = array(); + $ids = []; } // Retrieve the flashMessenger helper: @@ -97,7 +97,7 @@ class Renewals extends AbstractPlugin // If there is actually something to renew, attempt the renewal action: if (is_array($ids) && !empty($ids)) { $renewResult = $catalog->renewMyItems( - array('details' => $ids, 'patron' => $patron) + ['details' => $ids, 'patron' => $patron] ); if ($renewResult !== false) { // Assign Blocks to the Template @@ -120,6 +120,6 @@ class Renewals extends AbstractPlugin $flashMsg->setNamespace('error')->addMessage('renew_empty_selection'); } - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Reserves.php b/module/VuFind/src/VuFind/Controller/Plugin/Reserves.php index 1c62e8c1e44..f21c944e155 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Reserves.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Reserves.php @@ -87,7 +87,7 @@ class Reserves extends AbstractPlugin $result = $this->getController()->getServiceLocator() ->get('VuFind\Search') ->retrieve('SolrReserves', $course . '|' . $inst . '|' . $dept); - $bibs = array(); + $bibs = []; if ($result->getTotal() < 1) { return $bibs; } @@ -95,12 +95,12 @@ class Reserves extends AbstractPlugin $instructor = $record->getInstructor(); $course = $record->getCourse(); foreach ($record->getItemIds() as $bib_id) { - $bibs[] = array( + $bibs[] = [ 'BIB_ID' => $bib_id, 'bib_id' => $bib_id, 'course' => $course, 'instructor' => $instructor - ); + ]; } return $bibs; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php index 59c6920b1fe..d9f9d23681e 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php @@ -299,10 +299,10 @@ class ResultScroller extends AbstractPlugin */ public function getScrollData($driver) { - $retVal = array( + $retVal = [ 'previousRecord' => null, 'nextRecord' => null, 'currentPosition' => null, 'resultTotal' => null - ); + ]; // Do nothing if disabled or data missing: if ($this->enabled @@ -391,7 +391,7 @@ class ResultScroller extends AbstractPlugin $searchObject->performAndProcessSearch(); } - $retVal = array(); + $retVal = []; foreach ($searchObject->getResults() as $record) { $retVal[] = $record->getResourceSource() . '|' . $record->getUniqueId(); } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php index 463557a7a14..a7b7c09b4ab 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php @@ -105,7 +105,7 @@ class StorageRetrievalRequests extends AbstractRequestBase $details = $params->fromPost('cancelSelectedIDS'); } else { // No button pushed -- no action needed - return array(); + return []; } if (!empty($details)) { @@ -119,10 +119,10 @@ class StorageRetrievalRequests extends AbstractRequestBase $url, $url, 'confirm_storage_retrieval_request_cancel_all_text', - array( + [ 'cancelAll' => 1, 'cancelAllIDS' => $params->fromPost('cancelAllIDS') - ) + ] ); } else { return $this->getController()->confirm( @@ -130,11 +130,11 @@ class StorageRetrievalRequests extends AbstractRequestBase $url, $url, 'confirm_storage_retrieval_request_cancel_selected_text', - array( + [ 'cancelSelected' => 1, 'cancelSelectedIDS' => $params->fromPost('cancelSelectedIDS') - ) + ] ); } } @@ -145,13 +145,13 @@ class StorageRetrievalRequests extends AbstractRequestBase if (!in_array($info, $this->getSession()->validIds)) { $flashMsg->setNamespace('error') ->addMessage('error_inconsistent_parameters'); - return array(); + return []; } } // Add Patron Data to Submitted Data $cancelResults = $catalog->cancelStorageRetrievalRequests( - array('details' => $details, 'patron' => $patron) + ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { $flashMsg->setNamespace('error')->addMessage( @@ -175,6 +175,6 @@ class StorageRetrievalRequests extends AbstractRequestBase 'storage_retrieval_request_empty_selection' ); } - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/Controller/QRCodeController.php b/module/VuFind/src/VuFind/Controller/QRCodeController.php index 0967300e7e3..de991977876 100644 --- a/module/VuFind/src/VuFind/Controller/QRCodeController.php +++ b/module/VuFind/src/VuFind/Controller/QRCodeController.php @@ -79,11 +79,11 @@ class QRCodeController extends AbstractBase $this->getLoader()->loadQRCode( $this->params()->fromQuery('text'), - array( + [ 'level' => $this->params()->fromQuery('level', "L"), 'size' => $this->params()->fromQuery('size', "3"), 'margin' => $this->params()->fromQuery('margin', "4"), - ) + ] ); return $this->displayQRCode(); } diff --git a/module/VuFind/src/VuFind/Controller/RecordController.php b/module/VuFind/src/VuFind/Controller/RecordController.php index 2d34e6597e6..4af5c40ae2a 100644 --- a/module/VuFind/src/VuFind/Controller/RecordController.php +++ b/module/VuFind/src/VuFind/Controller/RecordController.php @@ -107,10 +107,10 @@ class RecordController extends AbstractRecord $catalog = $this->getILS(); $checkHolds = $catalog->checkFunction( 'Holds', - array( + [ 'id' => $driver->getUniqueID(), 'patron' => $patron - ) + ] ); if (!$checkHolds) { return $this->forwardTo('Record', 'Home'); @@ -133,10 +133,10 @@ class RecordController extends AbstractRecord // Send various values to the view so we can build the form: $pickup = $catalog->getPickUpLocations($patron, $gatheredDetails); $requestGroups = $catalog->checkCapability( - 'getRequestGroups', array($driver->getUniqueID(), $patron) - ) ? $catalog->getRequestGroups($driver->getUniqueID(), $patron) : array(); + 'getRequestGroups', [$driver->getUniqueID(), $patron] + ) ? $catalog->getRequestGroups($driver->getUniqueID(), $patron) : []; $extraHoldFields = isset($checkHolds['extraHoldFields']) - ? explode(":", $checkHolds['extraHoldFields']) : array(); + ? explode(":", $checkHolds['extraHoldFields']) : []; // Process form submissions if necessary: if (!is_null($this->params()->fromPost('placeHold'))) { @@ -158,7 +158,7 @@ class RecordController extends AbstractRecord // if successful, we will redirect and can stop here. // Add Patron Data to Submitted Data - $holdDetails = $gatheredDetails + array('patron' => $patron); + $holdDetails = $gatheredDetails + ['patron' => $patron]; // Attempt to place the hold: $function = (string)$checkHolds['function']; @@ -166,13 +166,13 @@ class RecordController extends AbstractRecord // Success: Go to Display Holds if (isset($results['success']) && $results['success'] == true) { - $msg = array( + $msg = [ 'html' => true, 'msg' => 'hold_place_success_html', - 'tokens' => array( + 'tokens' => [ '%%url%%' => $this->url()->fromRoute('myresearch-holds') - ), - ); + ], + ]; $this->flashMessenger()->setNamespace('info')->addMessage($msg); return $this->redirectToRecord('#top'); } else { @@ -216,7 +216,7 @@ class RecordController extends AbstractRecord || $gatheredDetails['level'] != 'copy'); return $this->createViewModel( - array( + [ 'gatheredDetails' => $gatheredDetails, 'pickup' => $pickup, 'defaultPickup' => $defaultPickup, @@ -228,7 +228,7 @@ class RecordController extends AbstractRecord 'requestGroupNeeded' => $requestGroupNeeded, 'helpText' => isset($checkHolds['helpText']) ? $checkHolds['helpText'] : null - ) + ] ); } @@ -250,10 +250,10 @@ class RecordController extends AbstractRecord $catalog = $this->getILS(); $checkRequests = $catalog->checkFunction( 'StorageRetrievalRequests', - array( + [ 'id' => $driver->getUniqueID(), 'patron' => $patron - ) + ] ); if (!$checkRequests) { return $this->forwardTo('Record', 'Home'); @@ -278,7 +278,7 @@ class RecordController extends AbstractRecord // Send various values to the view so we can build the form: $pickup = $catalog->getPickUpLocations($patron, $gatheredDetails); $extraFields = isset($checkRequests['extraFields']) - ? explode(":", $checkRequests['extraFields']) : array(); + ? explode(":", $checkRequests['extraFields']) : []; // Process form submissions if necessary: if (!is_null($this->params()->fromPost('placeStorageRetrievalRequest'))) { @@ -286,7 +286,7 @@ class RecordController extends AbstractRecord // if successful, we will redirect and can stop here. // Add Patron Data to Submitted Data - $details = $gatheredDetails + array('patron' => $patron); + $details = $gatheredDetails + ['patron' => $patron]; // Attempt to place the hold: $function = (string)$checkRequests['function']; @@ -329,7 +329,7 @@ class RecordController extends AbstractRecord } return $this->createViewModel( - array( + [ 'gatheredDetails' => $gatheredDetails, 'pickup' => $pickup, 'defaultPickup' => $defaultPickup, @@ -338,7 +338,7 @@ class RecordController extends AbstractRecord 'defaultRequiredDate' => $defaultRequired, 'helpText' => isset($checkRequests['helpText']) ? $checkRequests['helpText'] : null - ) + ] ); } @@ -360,10 +360,10 @@ class RecordController extends AbstractRecord $catalog = $this->getILS(); $checkRequests = $catalog->checkFunction( 'ILLRequests', - array( + [ 'id' => $driver->getUniqueID(), 'patron' => $patron - ) + ] ); if (!$checkRequests) { return $this->forwardTo('Record', 'Home'); @@ -388,7 +388,7 @@ class RecordController extends AbstractRecord // Send various values to the view so we can build the form: $extraFields = isset($checkRequests['extraFields']) - ? explode(":", $checkRequests['extraFields']) : array(); + ? explode(":", $checkRequests['extraFields']) : []; // Process form submissions if necessary: if (!is_null($this->params()->fromPost('placeILLRequest'))) { @@ -396,7 +396,7 @@ class RecordController extends AbstractRecord // if successful, we will redirect and can stop here. // Add Patron Data to Submitted Data - $details = $gatheredDetails + array('patron' => $patron); + $details = $gatheredDetails + ['patron' => $patron]; // Attempt to place the hold: $function = (string)$checkRequests['function']; @@ -443,7 +443,7 @@ class RecordController extends AbstractRecord $pickupLocations = $catalog->getPickUpLocations($patron, $gatheredDetails); return $this->createViewModel( - array( + [ 'gatheredDetails' => $gatheredDetails, 'pickupLibraries' => $pickupLibraries, 'pickupLocations' => $pickupLocations, @@ -452,7 +452,7 @@ class RecordController extends AbstractRecord 'defaultRequiredDate' => $defaultRequired, 'helpText' => isset($checkRequests['helpText']) ? $checkRequests['helpText'] : null - ) + ] ); } diff --git a/module/VuFind/src/VuFind/Controller/RecordsController.php b/module/VuFind/src/VuFind/Controller/RecordsController.php index f4ed7f0d454..1a11b9a5771 100644 --- a/module/VuFind/src/VuFind/Controller/RecordsController.php +++ b/module/VuFind/src/VuFind/Controller/RecordsController.php @@ -55,7 +55,7 @@ class RecordsController extends AbstractSearch public function homeAction() { // If there is exactly one record, send the user directly there: - $ids = $this->params()->fromQuery('id', array()); + $ids = $this->params()->fromQuery('id', []); if (count($ids) == 1) { $details = $this->getRecordRouter()->getTabRouteDetails($ids[0]); $target = $this->url()->fromRoute($details['route'], $details['params']); diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 6ee303bea30..42b8f374b47 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -97,7 +97,7 @@ class SearchController extends AbstractSearch if ((!isset($config->Mail->require_login) || $config->Mail->require_login) && !$this->getUser() ) { - return $this->forceLogin(null, array('emailurl' => $view->url)); + return $this->forceLogin(null, ['emailurl' => $view->url]); } // Check if we have a URL in login followup data -- this should override @@ -143,15 +143,15 @@ class SearchController extends AbstractSearch */ protected function getIllustrationSettings($savedSearch = false) { - $illYes = array( + $illYes = [ 'text' => 'Has Illustrations', 'value' => 1, 'selected' => false - ); - $illNo = array( + ]; + $illNo = [ 'text' => 'Not Illustrated', 'value' => 0, 'selected' => false - ); - $illAny = array( + ]; + $illAny = [ 'text' => 'No Preference', 'value' => -1, 'selected' => false - ); + ]; // Find the selected value by analyzing facets -- if we find match, remove // the offending facet to avoid inappropriate items appearing in the @@ -169,7 +169,7 @@ class SearchController extends AbstractSearch } else { $illAny['selected'] = true; } - return array($illYes, $illNo, $illAny); + return [$illYes, $illNo, $illAny]; } /** @@ -246,7 +246,7 @@ class SearchController extends AbstractSearch ); // Build arrays of history entries - $saved = $unsaved = array(); + $saved = $unsaved = []; // Loop through the history foreach ($searchHistory as $current) { @@ -272,7 +272,7 @@ class SearchController extends AbstractSearch } return $this->createViewModel( - array('saved' => $saved, 'unsaved' => $unsaved) + ['saved' => $saved, 'unsaved' => $unsaved] ); } @@ -284,12 +284,12 @@ class SearchController extends AbstractSearch public function homeAction() { return $this->createViewModel( - array( + [ 'results' => $this->getHomePageFacets(), 'hierarchicalFacets' => $this->getHierarchicalFacets(), 'hierarchicalFacetSortOptions' => $this->getHierarchicalFacetSortSettings() - ) + ] ); } @@ -306,10 +306,10 @@ class SearchController extends AbstractSearch } return $this->createViewModel( - array( + [ 'fundList' => $this->newItems()->getFundList(), 'ranges' => $this->newItems()->getRanges() - ) + ] ); } @@ -400,11 +400,11 @@ class SearchController extends AbstractSearch // send options to the view: $catalog = $this->getILS(); return $this->createViewModel( - array( + [ 'deptList' => $catalog->getDepartments(), 'instList' => $catalog->getInstructors(), 'courseList' => $catalog->getCourses() - ) + ] ); } @@ -424,7 +424,7 @@ class SearchController extends AbstractSearch ) ); return $this->createViewModel( - array('params' => $params, 'results' => $results) + ['params' => $params, 'results' => $results] ); } @@ -577,7 +577,7 @@ class SearchController extends AbstractSearch case 'describe': $config = $this->getConfig(); $xml = $this->getViewRenderer()->render( - 'search/opensearch-describe.phtml', array('site' => $config->Site) + 'search/opensearch-describe.phtml', ['site' => $config->Site] ); break; default: @@ -617,7 +617,7 @@ class SearchController extends AbstractSearch $headers = $response->getHeaders(); $headers->addHeaderLine('Content-type', 'application/javascript'); $response->setContent( - json_encode(array($query->get('lookfor', ''), $suggestions)) + json_encode([$query->get('lookfor', ''), $suggestions]) ); return $response; } @@ -644,7 +644,7 @@ class SearchController extends AbstractSearch $facetConfig = $this->getConfig('facets'); return isset($facetConfig->SpecialFacets->hierarchical) ? $facetConfig->SpecialFacets->hierarchical->toArray() - : array(); + : []; } /** @@ -657,7 +657,7 @@ class SearchController extends AbstractSearch $facetConfig = $this->getConfig('facets'); return isset($facetConfig->SpecialFacets->hierarchicalFacetSortOptions) ? $facetConfig->SpecialFacets->hierarchicalFacetSortOptions->toArray() - : array(); + : []; } } diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index 3fcabde1211..eaff57a2071 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -80,7 +80,7 @@ class SummonController extends AbstractSearch { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 1000); + $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); } /** @@ -119,7 +119,7 @@ class SummonController extends AbstractSearch public function homeAction() { return $this->createViewModel( - array('results' => $this->getHomePageFacets()) + ['results' => $this->getHomePageFacets()] ); } @@ -153,13 +153,13 @@ class SummonController extends AbstractSearch $params = $results->getParams(); $facetsToShow = isset($config->Advanced_Facets) ? $config->Advanced_Facets - : array('Language' => 'Language', 'ContentType' => 'Format'); + : ['Language' => 'Language', 'ContentType' => 'Format']; if (isset($config->Advanced_Facet_Settings->orFacets)) { $orFields = array_map( 'trim', explode(',', $config->Advanced_Facet_Settings->orFacets) ); } else { - $orFields = array(); + $orFields = []; } foreach ($facetsToShow as $facet => $label) { $useOr = (isset($orFields[0]) && $orFields[0] == '*') diff --git a/module/VuFind/src/VuFind/Controller/SummonrecordController.php b/module/VuFind/src/VuFind/Controller/SummonrecordController.php index af2fb220f9e..3f727e231d1 100644 --- a/module/VuFind/src/VuFind/Controller/SummonrecordController.php +++ b/module/VuFind/src/VuFind/Controller/SummonrecordController.php @@ -84,6 +84,6 @@ class SummonrecordController extends AbstractRecord { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 1000); + $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); } } diff --git a/module/VuFind/src/VuFind/Controller/UpgradeController.php b/module/VuFind/src/VuFind/Controller/UpgradeController.php index 20663f0d153..26117f86fae 100644 --- a/module/VuFind/src/VuFind/Controller/UpgradeController.php +++ b/module/VuFind/src/VuFind/Controller/UpgradeController.php @@ -117,7 +117,7 @@ class UpgradeController extends AbstractBase { parent::attachDefaultListeners(); $events = $this->getEventManager(); - $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 1000); + $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); } /** @@ -308,7 +308,7 @@ class UpgradeController extends AbstractBase } // Check for missing columns. - $mT = $this->logsql ? $missingTables : array(); + $mT = $this->logsql ? $missingTables : []; $missingCols = $this->dbUpgrade()->getMissingColumns($mT); if (!empty($missingCols)) { // Only manipulate DB if we're not in logging mode: @@ -327,7 +327,7 @@ class UpgradeController extends AbstractBase } // Check for modified columns. - $mC = $this->logsql ? $missingCols : array(); + $mC = $this->logsql ? $missingCols : []; $modifiedCols = $this->dbUpgrade()->getModifiedColumns($mT, $mC); if (!empty($modifiedCols)) { // Only manipulate DB if we're not in logging mode: @@ -415,7 +415,7 @@ class UpgradeController extends AbstractBase return $this->forwardTo('Upgrade', 'Home'); } - return $this->createViewModel(array('sql' => $this->session->sql)); + return $this->createViewModel(['sql' => $this->session->sql]); } /** @@ -453,7 +453,7 @@ class UpgradeController extends AbstractBase } } - return $this->createViewModel(array('dbrootuser' => $dbrootuser)); + return $this->createViewModel(['dbrootuser' => $dbrootuser]); } /** @@ -511,9 +511,9 @@ class UpgradeController extends AbstractBase } return $this->createViewModel( - array( + [ 'anonymousTags' => $this->params()->fromQuery('anonymousCnt') - ) + ] ); } @@ -694,7 +694,7 @@ class UpgradeController extends AbstractBase // We're finally done -- display any warnings that we collected during // the process. $allWarnings = array_merge( - isset($this->cookie->warnings) ? $this->cookie->warnings : array(), + isset($this->cookie->warnings) ? $this->cookie->warnings : [], (array)$this->session->warnings ); foreach ($allWarnings as $warning) { @@ -703,13 +703,13 @@ class UpgradeController extends AbstractBase } return $this->createViewModel( - array( + [ 'configDir' => dirname( ConfigLocator::getLocalConfigPath('config.ini', null, true) ), 'importDir' => LOCAL_OVERRIDE_DIR . '/import', 'oldVersion' => $this->cookie->oldVersion - ) + ] ); } @@ -725,7 +725,7 @@ class UpgradeController extends AbstractBase } $storage = $this->session->getManager()->getStorage(); $storage[$this->session->getName()] - = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); + = new ArrayObject([], ArrayObject::ARRAY_AS_PROPS); return $this->forwardTo('Upgrade', 'Home'); } } diff --git a/module/VuFind/src/VuFind/Cookie/Container.php b/module/VuFind/src/VuFind/Cookie/Container.php index efbec51cadf..b1778220063 100644 --- a/module/VuFind/src/VuFind/Cookie/Container.php +++ b/module/VuFind/src/VuFind/Cookie/Container.php @@ -64,7 +64,7 @@ class Container */ public function getAllValues() { - $retVal = array(); + $retVal = []; foreach ($_COOKIE as $key => $value) { if (substr($key, 0, strlen($this->groupName)) == $this->groupName) { $retVal[substr($key, strlen($this->groupName))] = $value; diff --git a/module/VuFind/src/VuFind/Cover/Generator.php b/module/VuFind/src/VuFind/Cover/Generator.php index d03b02755e5..fdd3c3ee99c 100644 --- a/module/VuFind/src/VuFind/Cover/Generator.php +++ b/module/VuFind/src/VuFind/Cover/Generator.php @@ -44,7 +44,7 @@ class Generator * * @var array */ - protected $settings = array(); + protected $settings = []; /** * Reserved color */ @@ -60,10 +60,10 @@ class Generator * @param \VuFindTheme\ThemeInfo $themeTools For font loading * @param array $settings Overwrite styles */ - public function __construct($themeTools, $settings = array()) + public function __construct($themeTools, $settings = []) { $this->themeTools = $themeTools; - $default = array( + $default = [ 'mode' => 'grid', 'authorFont' => 'DroidSerif-Bold.ttf', 'fontSize' => 7, @@ -76,7 +76,7 @@ class Generator 'titleFont' => 'DroidSerif-Bold.ttf', 'topPadding' => 19, 'wrapWidth' => 80, - ); + ]; foreach ($settings as $i => $setting) { $default[$i] = $setting; } @@ -401,7 +401,7 @@ class Generator protected function fontPath($font) { // Check all supported image formats: - $filenames = array('css/font/' . $font); + $filenames = ['css/font/' . $font]; $fileMatch = $this->themeTools->findContainingTheme($filenames, true); return empty($fileMatch) ? false : $fileMatch; } diff --git a/module/VuFind/src/VuFind/Cover/Loader.php b/module/VuFind/src/VuFind/Cover/Loader.php index 6a94e81a303..988ce2cc2e3 100644 --- a/module/VuFind/src/VuFind/Cover/Loader.php +++ b/module/VuFind/src/VuFind/Cover/Loader.php @@ -53,7 +53,7 @@ class Loader extends \VuFind\ImageLoader * * @var array */ - protected $validSizes = array('small', 'medium', 'large'); + protected $validSizes = ['small', 'medium', 'large']; /** * VuFind configuration settings @@ -158,7 +158,7 @@ class Loader extends \VuFind\ImageLoader { return new \VuFind\Cover\Generator( $this->themeTools, - array('mode' => $this->config->Content->makeDynamicCovers) + ['mode' => $this->config->Content->makeDynamicCovers] ); } @@ -245,7 +245,7 @@ class Loader extends \VuFind\ImageLoader */ protected function getIdentifiers() { - $ids = array(); + $ids = []; if ($this->isbn && $this->isbn->isValid()) { $ids['isbn'] = $this->isbn; } @@ -351,7 +351,7 @@ class Loader extends \VuFind\ImageLoader // Try to find an icon: $iconFile = $this->searchTheme( 'images/' . $this->size . '/' . $this->type, - array('.png', '.gif', '.jpg') + ['.png', '.gif', '.jpg'] ); if ($iconFile !== false) { // Most content-type headers match file extensions... but diff --git a/module/VuFind/src/VuFind/Crypt/RC4.php b/module/VuFind/src/VuFind/Crypt/RC4.php index 7b0f5134b71..b71cf8de8c1 100644 --- a/module/VuFind/src/VuFind/Crypt/RC4.php +++ b/module/VuFind/src/VuFind/Crypt/RC4.php @@ -59,7 +59,7 @@ class RC4 * Email: ali[at]farhadi[dot]ir * Website: http://farhadi.ir/ */ - $s = array(); + $s = []; for ($i = 0; $i<256; $i++) { $s[$i] = $i; } diff --git a/module/VuFind/src/VuFind/Date/Converter.php b/module/VuFind/src/VuFind/Date/Converter.php index f3d1a47ffdc..ef28a8aaeda 100644 --- a/module/VuFind/src/VuFind/Date/Converter.php +++ b/module/VuFind/src/VuFind/Date/Converter.php @@ -101,10 +101,10 @@ class Converter // These are date formats that we definitely know how to handle, and some // benefit from special processing. However, items not found in this list // will still be attempted in a generic fashion before giving up. - $validFormats = array( + $validFormats = [ "m-d-Y", "m-d-y", "m/d/Y", "m/d/y", "U", "m-d-y H:i", "Y-m-d", "Y-m-d H:i" - ); + ]; $isValid = in_array($inputFormat, $validFormats); if ($isValid) { if ($inputFormat == 'U') { @@ -118,9 +118,9 @@ class Converter $regEx = '/0*([0-9]+)(-|\/)0*([0-9]+)(-|\/)0*([0-9]+)/'; $dateString = trim(preg_replace($regEx, '$1/$3/$5', $dateString)); } - $errors = array( - 'warning_count' => 0, 'error_count' => 0, 'errors' => array() - ); + $errors = [ + 'warning_count' => 0, 'error_count' => 0, 'errors' => [] + ]; try { $date = new DateTime($dateString, $this->timezone); } catch (\Exception $e) { diff --git a/module/VuFind/src/VuFind/Db/AdapterFactory.php b/module/VuFind/src/VuFind/Db/AdapterFactory.php index f681818dbb7..7485deef120 100644 --- a/module/VuFind/src/VuFind/Db/AdapterFactory.php +++ b/module/VuFind/src/VuFind/Db/AdapterFactory.php @@ -109,7 +109,7 @@ class AdapterFactory case 'mysqli': $options['charset'] = isset($this->config->Database->charset) ? $this->config->Database->charset : 'utf8'; - $options['options'] = array('buffer_results' => true); + $options['options'] = ['buffer_results' => true]; break; } @@ -158,13 +158,13 @@ class AdapterFactory $password = !is_null($overridePass) ? $overridePass : $password; // Set up default options: - $options = array( + $options = [ 'driver' => $this->getDriverName($type), 'hostname' => $host, 'username' => $username, 'password' => $password, 'database' => $dbName - ); + ]; return $this->getAdapterFromOptions($options); } diff --git a/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php b/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php index e2eb1bf41d6..e25c7f1b7cd 100644 --- a/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php +++ b/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php @@ -45,6 +45,6 @@ class ChangeTracker extends RowGateway */ public function __construct($adapter) { - parent::__construct(array('core', 'id'), 'change_tracker', $adapter); + parent::__construct(['core', 'id'], 'change_tracker', $adapter); } } diff --git a/module/VuFind/src/VuFind/Db/Row/OaiResumption.php b/module/VuFind/src/VuFind/Db/Row/OaiResumption.php index 4ce63054dc6..6193bad21ce 100644 --- a/module/VuFind/src/VuFind/Db/Row/OaiResumption.php +++ b/module/VuFind/src/VuFind/Db/Row/OaiResumption.php @@ -56,7 +56,7 @@ class OaiResumption extends RowGateway public function restoreParams() { $parts = explode('&', $this->params); - $params = array(); + $params = []; foreach ($parts as $part) { list($key, $value) = explode('=', $part); $key = urldecode($key); @@ -76,7 +76,7 @@ class OaiResumption extends RowGateway public function saveParams($params) { ksort($params); - $processedParams = array(); + $processedParams = []; foreach ($params as $key => $value) { $processedParams[] = urlencode($key) . '=' . urlencode($value); } diff --git a/module/VuFind/src/VuFind/Db/Row/Tags.php b/module/VuFind/src/VuFind/Db/Row/Tags.php index 4f8c8b84c5d..30d9e212b6f 100644 --- a/module/VuFind/src/VuFind/Db/Row/Tags.php +++ b/module/VuFind/src/VuFind/Db/Row/Tags.php @@ -68,17 +68,17 @@ class Tags extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface $tag = $this; $callback = function ($select) use ($tag, $source, $sort, $offset, $limit) { $select->columns( - array( + [ new Expression( - 'DISTINCT(?)', array('resource.id'), - array(Expression::TYPE_IDENTIFIER) + 'DISTINCT(?)', ['resource.id'], + [Expression::TYPE_IDENTIFIER] ), '*' - ) + ] ); $select->join( - array('rt' => 'resource_tags'), + ['rt' => 'resource_tags'], 'resource.id = rt.resource_id', - array() + [] ); $select->where->equalTo('rt.tag_id', $tag->id); diff --git a/module/VuFind/src/VuFind/Db/Row/User.php b/module/VuFind/src/VuFind/Db/Row/User.php index 68092c83c83..a951bff8343 100644 --- a/module/VuFind/src/VuFind/Db/Row/User.php +++ b/module/VuFind/src/VuFind/Db/Row/User.php @@ -184,7 +184,7 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface, } // Perform encryption: - $cipher = new BlockCipher(new Mcrypt(array('algorithm' => 'blowfish'))); + $cipher = new BlockCipher(new Mcrypt(['algorithm' => 'blowfish'])); $cipher->setKey($this->encryptionKey); return $encrypt ? $cipher->encrypt($text) : $cipher->decrypt($text); } @@ -220,29 +220,29 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface, $userId = $this->id; $callback = function ($select) use ($userId, $resourceId, $listId, $source) { $select->columns( - array( + [ 'id' => new Expression( - 'min(?)', array('tags.id'), - array(Expression::TYPE_IDENTIFIER) + 'min(?)', ['tags.id'], + [Expression::TYPE_IDENTIFIER] ), 'tag', 'cnt' => new Expression( - 'COUNT(DISTINCT(?))', array('rt.resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['rt.resource_id'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->join( - array('rt' => 'resource_tags'), 'tags.id = rt.tag_id', array() + ['rt' => 'resource_tags'], 'tags.id = rt.tag_id', [] ); $select->join( - array('r' => 'resource'), 'rt.resource_id = r.id', array() + ['r' => 'resource'], 'rt.resource_id = r.id', [] ); $select->join( - array('ur' => 'user_resource'), 'r.id = ur.resource_id', array() + ['ur' => 'user_resource'], 'r.id = ur.resource_id', [] ); - $select->group(array('tag')) - ->order(array('tag')); + $select->group(['tag']) + ->order(['tag']); $select->where->equalTo('ur.user_id', $userId) ->equalTo('rt.user_id', $userId) @@ -303,26 +303,26 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface, $userId = $this->id; $callback = function ($select) use ($userId) { $select->columns( - array( + [ '*', 'cnt' => new Expression( - 'COUNT(DISTINCT(?))', array('ur.resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['ur.resource_id'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->join( - array('ur' => 'user_resource'), 'user_list.id = ur.list_id', - array(), $select::JOIN_LEFT + ['ur' => 'user_resource'], 'user_list.id = ur.list_id', + [], $select::JOIN_LEFT ); $select->where->equalTo('user_list.user_id', $userId); $select->group( - array( + [ 'user_list.id', 'user_list.user_id', 'title', 'description', 'created', 'public' - ) + ] ); - $select->order(array('title')); + $select->order(['title']); }; $table = $this->getDbTable('UserList'); @@ -393,7 +393,7 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface, $resourceTable = $this->getDbTable('Resource'); $resources = $resourceTable->findResources($ids, $source); - $resourceIDs = array(); + $resourceIDs = []; foreach ($resources as $current) { $resourceIDs[] = $current->id; } @@ -444,6 +444,6 @@ class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface, */ public function getRoles() { - return array('loggedin'); + return ['loggedin']; } } diff --git a/module/VuFind/src/VuFind/Db/Row/UserList.php b/module/VuFind/src/VuFind/Db/Row/UserList.php index c1e2e5edaa1..e44be974069 100644 --- a/module/VuFind/src/VuFind/Db/Row/UserList.php +++ b/module/VuFind/src/VuFind/Db/Row/UserList.php @@ -76,9 +76,9 @@ class UserList extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterf public function getTags() { $table = $this->getDbTable('User'); - $user = $table->select(array('id' => $this->user_id))->current(); + $user = $table->select(['id' => $this->user_id])->current(); if (empty($user)) { - return array(); + return []; } return $user->getTags(null, $this->id); } @@ -172,7 +172,7 @@ class UserList extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterf $resourceTable = $this->getDbTable('Resource'); $resources = $resourceTable->findResources($ids, $source); - $resourceIDs = array(); + $resourceIDs = []; foreach ($resources as $current) { $resourceIDs[] = $current->id; } diff --git a/module/VuFind/src/VuFind/Db/Table/ChangeTracker.php b/module/VuFind/src/VuFind/Db/Table/ChangeTracker.php index 1c11e6b871f..658279d1832 100644 --- a/module/VuFind/src/VuFind/Db/Table/ChangeTracker.php +++ b/module/VuFind/src/VuFind/Db/Table/ChangeTracker.php @@ -64,7 +64,7 @@ class ChangeTracker extends Gateway */ public function retrieve($core, $id) { - return $this->select(array('core' => $core, 'id' => $id))->current(); + return $this->select(['core' => $core, 'id' => $id])->current(); } /** diff --git a/module/VuFind/src/VuFind/Db/Table/Comments.php b/module/VuFind/src/VuFind/Db/Table/Comments.php index 5c412c9fbc3..01bafd3ef3a 100644 --- a/module/VuFind/src/VuFind/Db/Table/Comments.php +++ b/module/VuFind/src/VuFind/Db/Table/Comments.php @@ -60,14 +60,14 @@ class Comments extends Gateway $resourceTable = $this->getDbTable('Resource'); $resource = $resourceTable->findResource($id, $source, false); if (empty($resource)) { - return array(); + return []; } $callback = function ($select) use ($resource) { - $select->columns(array('*')); + $select->columns(['*']); $select->join( - array('u' => 'user'), 'u.id = comments.user_id', - array('firstname', 'lastname') + ['u' => 'user'], 'u.id = comments.user_id', + ['firstname', 'lastname'] ); $select->where->equalTo('comments.resource_id', $resource->id); $select->order('comments.created'); @@ -92,7 +92,7 @@ class Comments extends Gateway } // Comment row must exist: - $matches = $this->select(array('id' => $id)); + $matches = $this->select(['id' => $id]); if (count($matches) == 0 || !($row = $matches->current())) { return false; } @@ -116,17 +116,17 @@ class Comments extends Gateway { $select = $this->sql->select(); $select->columns( - array( + [ 'users' => new Expression( - 'COUNT(DISTINCT(?))', array('user_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['user_id'], + [Expression::TYPE_IDENTIFIER] ), 'resources' => new Expression( - 'COUNT(DISTINCT(?))', array('resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['resource_id'], + [Expression::TYPE_IDENTIFIER] ), 'total' => new Expression('COUNT(*)') - ) + ] ); $statement = $this->sql->prepareStatementForSqlObject($select); $result = $statement->execute(); diff --git a/module/VuFind/src/VuFind/Db/Table/OaiResumption.php b/module/VuFind/src/VuFind/Db/Table/OaiResumption.php index bb14a0be64c..8d3fa52aab0 100644 --- a/module/VuFind/src/VuFind/Db/Table/OaiResumption.php +++ b/module/VuFind/src/VuFind/Db/Table/OaiResumption.php @@ -70,7 +70,7 @@ class OaiResumption extends Gateway */ public function findToken($token) { - return $this->select(array('id' => $token))->current(); + return $this->select(['id' => $token])->current(); } /** diff --git a/module/VuFind/src/VuFind/Db/Table/Resource.php b/module/VuFind/src/VuFind/Db/Table/Resource.php index b3543a321f3..91ae95ca661 100644 --- a/module/VuFind/src/VuFind/Db/Table/Resource.php +++ b/module/VuFind/src/VuFind/Db/Table/Resource.php @@ -78,7 +78,7 @@ class Resource extends Gateway if (empty($id)) { throw new \Exception('Resource ID cannot be empty'); } - $select = $this->select(array('record_id' => $id, 'source' => $source)); + $select = $this->select(['record_id' => $id, 'source' => $source]); $result = $select->current(); // Create row if it does not already exist and creation is enabled: @@ -132,7 +132,7 @@ class Resource extends Gateway * * @return \Zend\Db\ResultSet\AbstractResultSet */ - public function getFavorites($user, $list = null, $tags = array(), + public function getFavorites($user, $list = null, $tags = [], $sort = null, $offset = 0, $limit = null ) { // Set up base query: @@ -140,16 +140,16 @@ class Resource extends Gateway return $this->select( function ($s) use ($user, $list, $tags, $sort, $offset, $limit, $obj) { $s->columns( - array( + [ new Expression( - 'DISTINCT(?)', array('resource.id'), - array(Expression::TYPE_IDENTIFIER) + 'DISTINCT(?)', ['resource.id'], + [Expression::TYPE_IDENTIFIER] ), '*' - ) + ] ); $s->join( - array('ur' => 'user_resource'), 'resource.id = ur.resource_id', - array() + ['ur' => 'user_resource'], 'resource.id = ur.resource_id', + [] ); $s->where->equalTo('ur.user_id', $user); @@ -216,9 +216,9 @@ class Resource extends Gateway public static function applySort($query, $sort, $alias = 'resource') { // Apply sorting, if necessary: - $legalSorts = array( + $legalSorts = [ 'title', 'title desc', 'author', 'author desc', 'year', 'year desc' - ); + ]; if (!empty($sort) && in_array(strtolower($sort), $legalSorts)) { // Strip off 'desc' to obtain the raw field name -- we'll need it // to sort null values to the bottom: @@ -226,14 +226,14 @@ class Resource extends Gateway $rawField = trim($parts[0]); // Start building the list of sort fields: - $order = array(); + $order = []; // The title field can't be null, so don't bother with the extra // isnull() sort in that case. if (strtolower($rawField) != 'title') { $order[] = new Expression( - 'isnull(?)', array($alias . '.' . $rawField), - array(Expression::TYPE_IDENTIFIER) + 'isnull(?)', [$alias . '.' . $rawField], + [Expression::TYPE_IDENTIFIER] ); } diff --git a/module/VuFind/src/VuFind/Db/Table/ResourceTags.php b/module/VuFind/src/VuFind/Db/Table/ResourceTags.php index dccb8732410..853cde2c9fb 100644 --- a/module/VuFind/src/VuFind/Db/Table/ResourceTags.php +++ b/module/VuFind/src/VuFind/Db/Table/ResourceTags.php @@ -105,7 +105,7 @@ class ResourceTags extends Gateway public function checkForTags($ids) { // Set up return arrays: - $retVal = array('present' => array(), 'missing' => array()); + $retVal = ['present' => [], 'missing' => []]; // Look up IDs in the table: $callback = function ($select) use ($ids) { @@ -143,15 +143,15 @@ class ResourceTags extends Gateway { $callback = function ($select) use ($tag, $userId, $listId) { $select->columns( - array( + [ 'resource_id' => new Expression( - 'DISTINCT(?)', array('resource_tags.resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'DISTINCT(?)', ['resource_tags.resource_id'], + [Expression::TYPE_IDENTIFIER] ), '*' - ) + ] ); $select->join( - array('t' => 'tags'), 'resource_tags.tag_id = t.id', array() + ['t' => 'tags'], 'resource_tags.tag_id = t.id', [] ); $select->where->equalTo('t.tag', $tag) ->where->equalTo('resource_tags.user_id', $userId); @@ -174,17 +174,17 @@ class ResourceTags extends Gateway { $select = $this->sql->select(); $select->columns( - array( + [ 'users' => new Expression( - 'COUNT(DISTINCT(?))', array('user_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['user_id'], + [Expression::TYPE_IDENTIFIER] ), 'resources' => new Expression( - 'COUNT(DISTINCT(?))', array('resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['resource_id'], + [Expression::TYPE_IDENTIFIER] ), 'total' => new Expression('COUNT(*)') - ) + ] ); $statement = $this->sql->prepareStatementForSqlObject($select); $result = $statement->execute(); @@ -215,7 +215,7 @@ class ResourceTags extends Gateway $select->where->equalTo('user_id', $user); if (!is_null($resource)) { if (!is_array($resource)) { - $resource = array($resource); + $resource = [$resource]; } $select->where->in('resource_id', $resource); } @@ -242,7 +242,7 @@ class ResourceTags extends Gateway // Check for orphans: if (count($potentialOrphans) > 0) { - $ids = array(); + $ids = []; foreach ($potentialOrphans as $current) { $ids[] = $current->tag_id; } @@ -279,7 +279,7 @@ class ResourceTags extends Gateway $callback = function ($select) { $select->where->isNull('user_id'); }; - $this->update(array('user_id' => $id), $callback); + $this->update(['user_id' => $id], $callback); } /** @@ -296,9 +296,9 @@ class ResourceTags extends Gateway ) { $callback = function ($select) use ($userId, $resourceId, $tagId) { $select->join( - array('r' => 'resource'), + ['r' => 'resource'], 'resource_tags.resource_id = r.id', - array("title" => "title") + ["title" => "title"] ); if (!is_null($userId)) { $select->where->equalTo('resource_tags.user_id', $userId); @@ -309,8 +309,8 @@ class ResourceTags extends Gateway if (!is_null($tagId)) { $select->where->equalTo('resource_tags.tag_id', $tagId); } - $select->group(array("resource_id")); - $select->order(array("title")); + $select->group(["resource_id"]); + $select->order(["title"]); }; return $this->select($callback); } @@ -329,9 +329,9 @@ class ResourceTags extends Gateway $callback = function ($select) use ($userId, $resourceId, $tagId) { $select->join( - array('t' => 'tags'), + ['t' => 'tags'], 'resource_tags.tag_id = t.id', - array("tag" => "tag") + ["tag" => "tag"] ); if (!is_null($userId)) { $select->where->equalTo('resource_tags.user_id', $userId); @@ -342,8 +342,8 @@ class ResourceTags extends Gateway if (!is_null($tagId)) { $select->where->equalTo('resource_tags.tag_id', $tagId); } - $select->group(array("tag_id")); - $select->order(array("tag")); + $select->group(["tag_id"]); + $select->order(["tag"]); }; return $this->select($callback); } @@ -361,9 +361,9 @@ class ResourceTags extends Gateway { $callback = function ($select) use ($userId, $resourceId, $tagId) { $select->join( - array('u' => 'user'), + ['u' => 'user'], 'resource_tags.user_id = u.id', - array("username" => "username") + ["username" => "username"] ); if (!is_null($userId)) { $select->where->equalTo('resource_tags.user_id', $userId); @@ -374,8 +374,8 @@ class ResourceTags extends Gateway if (!is_null($tagId)) { $select->where->equalTo('resource_tags.tag_id', $tagId); } - $select->group(array("user_id")); - $select->order(array("username")); + $select->group(["user_id"]); + $select->order(["username"]); }; return $this->select($callback); } @@ -397,25 +397,25 @@ class ResourceTags extends Gateway $order = null, $page = null, $limit = 20 ) { $order = (null !== $order) - ? array($order) - : array("username", "tag", "title"); + ? [$order] + : ["username", "tag", "title"]; $sql = $this->getSql(); $select = $sql->select(); $select->join( - array('t' => 'tags'), + ['t' => 'tags'], 'resource_tags.tag_id = t.id', - array("tag" => "tag") + ["tag" => "tag"] ); $select->join( - array('u' => 'user'), + ['u' => 'user'], 'resource_tags.user_id = u.id', - array("username" => "username") + ["username" => "username"] ); $select->join( - array('r' => 'resource'), + ['r' => 'resource'], 'resource_tags.resource_id = r.id', - array("title" => "title") + ["title" => "title"] ); if (null !== $userId) { $select->where->equalTo('resource_tags.user_id', $userId); diff --git a/module/VuFind/src/VuFind/Db/Table/Search.php b/module/VuFind/src/VuFind/Db/Table/Search.php index d77839a4349..db33c561595 100644 --- a/module/VuFind/src/VuFind/Db/Table/Search.php +++ b/module/VuFind/src/VuFind/Db/Table/Search.php @@ -56,7 +56,7 @@ class Search extends Gateway */ public function destroySession($sid) { - $this->delete(array('session_id' => $sid, 'saved' => 0)); + $this->delete(['session_id' => $sid, 'saved' => 0]); } /** @@ -110,7 +110,7 @@ class Search extends Gateway */ public function getRowById($id, $exceptionIfMissing = true) { - $row = $this->select(array('id' => $id))->current(); + $row = $this->select(['id' => $id])->current(); if (empty($row) && $exceptionIfMissing) { throw new \Exception('Cannot find id ' . $id); } @@ -148,7 +148,7 @@ class Search extends Gateway * @return void */ public function saveSearch(\VuFind\Search\Results\PluginManager $manager, - $newSearch, $sessionId, $searchHistory = array() + $newSearch, $sessionId, $searchHistory = [] ) { // Duplicate elimination foreach ($searchHistory as $oldSearch) { @@ -178,11 +178,11 @@ class Search extends Gateway // If we got this far, we didn't find a saved duplicate, so we should // save the new search: - $data = array( + $data = [ 'session_id' => $sessionId, 'created' => date('Y-m-d'), 'search_object' => serialize(new minSO($newSearch)) - ); + ]; $this->insert($data); $row = $this->getRowById($this->getLastInsertValue()); diff --git a/module/VuFind/src/VuFind/Db/Table/Session.php b/module/VuFind/src/VuFind/Db/Table/Session.php index 3a2984f3dac..83720b7621e 100644 --- a/module/VuFind/src/VuFind/Db/Table/Session.php +++ b/module/VuFind/src/VuFind/Db/Table/Session.php @@ -58,7 +58,7 @@ class Session extends Gateway */ public function getBySessionId($sid, $create = true) { - $row = $this->select(array('session_id' => $sid))->current(); + $row = $this->select(['session_id' => $sid])->current(); if ($create && empty($row)) { $row = $this->createRow(); $row->session_id = $sid; diff --git a/module/VuFind/src/VuFind/Db/Table/Tags.php b/module/VuFind/src/VuFind/Db/Table/Tags.php index ec8316a20e1..4343d59fed5 100644 --- a/module/VuFind/src/VuFind/Db/Table/Tags.php +++ b/module/VuFind/src/VuFind/Db/Table/Tags.php @@ -58,7 +58,7 @@ class Tags extends Gateway */ public function getByText($tag, $create = true) { - $result = $this->select(array('tag' => $tag))->current(); + $result = $this->select(['tag' => $tag])->current(); if (empty($result) && $create) { $result = $this->createRow(); $result->tag = $tag; @@ -79,7 +79,7 @@ class Tags extends Gateway public function matchText($text, $sort = 'alphabetical', $limit = 100) { $callback = function ($select) use ($text) { - $select->where->literal('lower(tag) like lower(?)', array($text . '%')); + $select->where->literal('lower(tag) like lower(?)', [$text . '%']); }; return $this->getTagList($sort, $limit, $callback); } @@ -103,28 +103,28 @@ class Tags extends Gateway return $this->select( function ($select) use ($id, $source, $limit, $list, $user, $sort) { $select->columns( - array( + [ 'id', 'tag', 'cnt' => new Expression( - 'COUNT(?)', array('tags.tag'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(?)', ['tags.tag'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->join( - array('rt' => 'resource_tags'), 'tags.id = rt.tag_id', array() + ['rt' => 'resource_tags'], 'tags.id = rt.tag_id', [] ); $select->join( - array('r' => 'resource'), 'rt.resource_id = r.id', array() + ['r' => 'resource'], 'rt.resource_id = r.id', [] ); $select->where->equalTo('r.record_id', $id) ->equalTo('r.source', $source); - $select->group(array('tags.id', 'tag')); + $select->group(['tags.id', 'tag']); if ($sort == 'count') { - $select->order(array('cnt DESC', 'tags.tag')); + $select->order(['cnt DESC', 'tags.tag']); } else if ($sort == 'tag') { - $select->order(array('tags.tag')); + $select->order(['tags.tag']); } if ($limit > 0) { @@ -158,20 +158,20 @@ class Tags extends Gateway { $callback = function ($select) use ($sort, $limit, $extra_where) { $select->columns( - array( + [ 'id', 'tag', 'cnt' => new Expression( - 'COUNT(DISTINCT(?))', array('resource_tags.resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['resource_tags.resource_id'], + [Expression::TYPE_IDENTIFIER] ), 'posted' => new Expression( - 'MAX(?)', array('resource_tags.posted'), - array(Expression::TYPE_IDENTIFIER) + 'MAX(?)', ['resource_tags.posted'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->join( - 'resource_tags', 'tags.id = resource_tags.tag_id', array() + 'resource_tags', 'tags.id = resource_tags.tag_id', [] ); if (is_callable($extra_where)) { $extra_where($select); @@ -179,14 +179,14 @@ class Tags extends Gateway $select->group('tags.tag'); switch ($sort) { case 'alphabetical': - $select->order(array('tags.tag', 'cnt DESC')); + $select->order(['tags.tag', 'cnt DESC']); break; case 'popularity': - $select->order(array('cnt DESC', 'tags.tag')); + $select->order(['cnt DESC', 'tags.tag']); break; case 'recent': $select->order( - array('posted DESC', 'cnt DESC', 'tags.tag') + ['posted DESC', 'cnt DESC', 'tags.tag'] ); break; } @@ -196,12 +196,12 @@ class Tags extends Gateway } }; - $tagList = array(); + $tagList = []; foreach ($this->select($callback) as $t) { - $tagList[] = array( + $tagList[] = [ 'tag' => $t->tag, 'cnt' => $t->cnt - ); + ]; } return $tagList; } @@ -236,15 +236,15 @@ class Tags extends Gateway { $callback = function ($select) { $select->columns( - array( + [ 'tag', 'cnt' => new Expression( - 'COUNT(?)', array('tag'), array(Expression::TYPE_IDENTIFIER) + 'COUNT(?)', ['tag'], [Expression::TYPE_IDENTIFIER] ), 'id' => new Expression( - 'MIN(?)', array('id'), array(Expression::TYPE_IDENTIFIER) + 'MIN(?)', ['id'], [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->group('tag'); $select->having->greaterThan('cnt', 1); @@ -267,7 +267,7 @@ class Tags extends Gateway return; } $table = $this->getDbTable('ResourceTags'); - $result = $table->select(array('tag_id' => $source)); + $result = $table->select(['tag_id' => $source]); foreach ($result as $current) { // Move the link to the target ID: @@ -281,7 +281,7 @@ class Tags extends Gateway } // Remove the source tag: - $this->delete(array('id' => $source)); + $this->delete(['id' => $source]); } /** @@ -294,7 +294,7 @@ class Tags extends Gateway protected function fixDuplicateTag($tag) { // Make sure this really is a duplicate. - $result = $this->select(array('tag' => $tag)); + $result = $this->select(['tag' => $tag]); if (count($result) < 2) { return; } diff --git a/module/VuFind/src/VuFind/Db/Table/User.php b/module/VuFind/src/VuFind/Db/Table/User.php index 9978af7f188..08c893d533c 100644 --- a/module/VuFind/src/VuFind/Db/Table/User.php +++ b/module/VuFind/src/VuFind/Db/Table/User.php @@ -67,7 +67,7 @@ class User extends Gateway */ public function getByUsername($username, $create = true) { - $row = $this->select(array('username' => $username))->current(); + $row = $this->select(['username' => $username])->current(); if ($create && empty($row)) { $row = $this->createRow(); $row->username = $username; @@ -85,7 +85,7 @@ class User extends Gateway */ public function getByEmail($email) { - $row = $this->select(array('email' => $email))->current(); + $row = $this->select(['email' => $email])->current(); return $row; } @@ -125,7 +125,7 @@ class User extends Gateway */ public function getByVerifyHash($hash) { - $row = $this->select(array('verify_hash' => $hash))->current(); + $row = $this->select(['verify_hash' => $hash])->current(); return $row; } } diff --git a/module/VuFind/src/VuFind/Db/Table/UserList.php b/module/VuFind/src/VuFind/Db/Table/UserList.php index 2b0e6bf238c..9791950cf79 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserList.php +++ b/module/VuFind/src/VuFind/Db/Table/UserList.php @@ -80,7 +80,7 @@ class UserList extends Gateway */ public function getExisting($id) { - $result = $this->select(array('id' => $id))->current(); + $result = $this->select(['id' => $id])->current(); if (empty($result)) { throw new RecordMissingException('Cannot load list ' . $id); } @@ -103,23 +103,23 @@ class UserList extends Gateway // Set up base query: $callback = function ($select) use ($resourceId, $source, $userId) { $select->columns( - array( + [ new Expression( - 'DISTINCT(?)', array('user_list.id'), - array(Expression::TYPE_IDENTIFIER) + 'DISTINCT(?)', ['user_list.id'], + [Expression::TYPE_IDENTIFIER] ), '*' - ) + ] ); $select->join( - array('ur' => 'user_resource'), 'ur.list_id = user_list.id', - array() + ['ur' => 'user_resource'], 'ur.list_id = user_list.id', + [] ); $select->join( - array('r' => 'resource'), 'r.id = ur.resource_id', array() + ['r' => 'resource'], 'r.id = ur.resource_id', [] ); $select->where->equalTo('r.source', $source) ->equalTo('r.record_id', $resourceId); - $select->order(array('title')); + $select->order(['title']); if (!is_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 a46aa12968c..b6645fbd7a3 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserResource.php +++ b/module/VuFind/src/VuFind/Db/Table/UserResource.php @@ -64,21 +64,21 @@ class UserResource extends Gateway ) { $callback = function ($select) use ($resourceId, $source, $listId, $userId) { $select->columns( - array( + [ new Expression( - 'DISTINCT(?)', array('user_resource.id'), - array(Expression::TYPE_IDENTIFIER) + 'DISTINCT(?)', ['user_resource.id'], + [Expression::TYPE_IDENTIFIER] ), '*' - ) + ] ); $select->join( - array('r' => 'resource'), 'r.id = user_resource.resource_id', - array() + ['r' => 'resource'], 'r.id = user_resource.resource_id', + [] ); $select->join( - array('ul' => 'user_list'), + ['ul' => 'user_list'], 'user_resource.list_id = ul.id', - array('list_title' => 'title', 'list_id' => 'id') + ['list_title' => 'title', 'list_id' => 'id'] ); $select->where->equalTo('r.source', $source) ->equalTo('r.record_id', $resourceId); @@ -106,10 +106,10 @@ class UserResource extends Gateway public function createOrUpdateLink($resource_id, $user_id, $list_id, $notes = '' ) { - $params = array( + $params = [ 'resource_id' => $resource_id, 'list_id' => $list_id, 'user_id' => $user_id - ); + ]; $result = $this->select($params)->current(); // Only create row if it does not already exist: @@ -150,7 +150,7 @@ class UserResource extends Gateway $select->where->equalTo('user_id', $user_id); if (!is_null($resource_id)) { if (!is_array($resource_id)) { - $resource_id = array($resource_id); + $resource_id = [$resource_id]; } $select->where->in('resource_id', $resource_id); } @@ -172,21 +172,21 @@ class UserResource extends Gateway { $select = $this->sql->select(); $select->columns( - array( + [ 'users' => new Expression( - 'COUNT(DISTINCT(?))', array('user_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['user_id'], + [Expression::TYPE_IDENTIFIER] ), 'lists' => new Expression( - 'COUNT(DISTINCT(?))', array('list_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['list_id'], + [Expression::TYPE_IDENTIFIER] ), 'resources' => new Expression( - 'COUNT(DISTINCT(?))', array('resource_id'), - array(Expression::TYPE_IDENTIFIER) + 'COUNT(DISTINCT(?))', ['resource_id'], + [Expression::TYPE_IDENTIFIER] ), 'total' => new Expression('COUNT(*)') - ) + ] ); $statement = $this->sql->prepareStatementForSqlObject($select); $result = $statement->execute(); diff --git a/module/VuFind/src/VuFind/Db/Table/UserStats.php b/module/VuFind/src/VuFind/Db/Table/UserStats.php index 6b64a7dced9..ffa4c684f75 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserStats.php +++ b/module/VuFind/src/VuFind/Db/Table/UserStats.php @@ -62,33 +62,33 @@ class UserStats extends Gateway $callback = function ($select) use ($withVersions, $limit) { if ($withVersions) { $select->columns( - array( + [ 'browserName' => new Expression( 'CONCAT_WS(" ",?,?)', - array('browser', 'browserVersion'), - array( + ['browser', 'browserVersion'], + [ Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER - ) + ] ), 'count' => new Expression( 'COUNT(DISTINCT (?))', - array('session'), - array(Expression::TYPE_IDENTIFIER) + ['session'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->group('browserName'); } else { $select->columns( - array( + [ 'browserName' => 'browser', 'count' => new Expression( 'COUNT(DISTINCT (?))', - array('session'), - array(Expression::TYPE_IDENTIFIER) + ['session'], + [Expression::TYPE_IDENTIFIER] ) - ) + ] ); $select->group('browser'); } diff --git a/module/VuFind/src/VuFind/Db/Table/UserStatsFields.php b/module/VuFind/src/VuFind/Db/Table/UserStatsFields.php index 9a38122f8ce..0e04f258fa1 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserStatsFields.php +++ b/module/VuFind/src/VuFind/Db/Table/UserStatsFields.php @@ -63,11 +63,11 @@ class UserStatsFields extends Gateway $value = ($value) ? "true" : "false"; } $this->insert( - array( + [ 'id' => $userData['id'], 'field' => $field . "", 'value' => $value . "", - ) + ] ); } // User data @@ -83,25 +83,25 @@ class UserStatsFields extends Gateway * * @return associative array */ - public function getFields($fields, $values = array()) + public function getFields($fields, $values = []) { if (empty($fields)) { return null; } if (!is_array($fields)) { - $fields = array($fields); + $fields = [$fields]; } $callback = function ($select) use ($fields, $values) { $select->columns( - array($fields[0] => 'value') + [$fields[0] => 'value'] ); $select->where->equalTo('field', $fields[0]); for ($i = 1;$i<count($fields);$i++) { $select->where->equalTo('field' . $i . '.field', $fields[$i]); $select->join( - array('field' . $i => 'user_stats_fields'), + ['field' . $i => 'user_stats_fields'], 'user_stats_fields.id=field' . $i . '.id', - array($fields[$i] => 'field' . $i . '.value') + [$fields[$i] => 'field' . $i . '.value'] ); } foreach ($values as $key => $value) { diff --git a/module/VuFind/src/VuFind/Export.php b/module/VuFind/src/VuFind/Export.php index 53c9042587d..a1a6d6e79ce 100644 --- a/module/VuFind/src/VuFind/Export.php +++ b/module/VuFind/src/VuFind/Export.php @@ -80,7 +80,7 @@ class Export public function getBulkOptions() { if ($this->bulkOptions === false) { - $this->bulkOptions = array(); + $this->bulkOptions = []; if (isset($this->mainConfig->BulkExport->enabled) && isset($this->mainConfig->BulkExport->options) && $this->mainConfig->BulkExport->enabled @@ -112,7 +112,7 @@ class Export */ public function getBulkUrl($view, $format, $ids) { - $params = array(); + $params = []; $params[] = 'f=' . urlencode($format); foreach ($ids as $id) { $params[] = urlencode('i[]') . '=' . urlencode($id); @@ -190,7 +190,7 @@ class Export if (isset($this->exportConfig->$format->combineXpath)) { $ns = isset($this->exportConfig->$format->combineNamespaces) ? $this->exportConfig->$format->combineNamespaces->toArray() - : array(); + : []; $ns = array_map( function ($current) { return explode('|', $current, 2); @@ -235,7 +235,7 @@ class Export public function recordSupportsFormat($driver, $format) { // Check if the driver explicitly disallows the format: - if ($driver->tryMethod('exportDisabled', array($format))) { + if ($driver->tryMethod('exportDisabled', [$format])) { return false; } @@ -244,7 +244,7 @@ class Export if (isset($this->exportConfig->$format->requiredMethods)) { foreach ($this->exportConfig->$format->requiredMethods as $method) { // If a required method is missing, give up now: - if (!is_callable(array($driver, $method))) { + if (!is_callable([$driver, $method])) { return false; } } @@ -273,10 +273,10 @@ class Export // if nothing in config array). $active = isset($this->mainConfig->Export) ? $this->mainConfig->Export->toArray() - : array('RefWorks' => true, 'EndNote' => true); + : ['RefWorks' => true, 'EndNote' => true]; // Loop through all possible formats: - $formats = array(); + $formats = []; foreach (array_keys($this->exportConfig->toArray()) as $format) { if (isset($active[$format]) && $active[$format] && $this->recordSupportsFormat($driver, $format) @@ -302,7 +302,7 @@ class Export $formats = $this->getBulkOptions(); foreach ($drivers as $driver) { // Filter out unsupported export formats: - $newFormats = array(); + $newFormats = []; foreach ($formats as $current) { if ($this->recordSupportsFormat($driver, $current)) { $newFormats[] = $current; @@ -323,7 +323,7 @@ class Export public function getHeaders($format) { return isset($this->exportConfig->$format->headers) - ? $this->exportConfig->$format->headers : array(); + ? $this->exportConfig->$format->headers : []; } /** diff --git a/module/VuFind/src/VuFind/Feed/Writer/Extension/DublinCore/Entry.php b/module/VuFind/src/VuFind/Feed/Writer/Extension/DublinCore/Entry.php index 9504e14866e..28ba36afd11 100644 --- a/module/VuFind/src/VuFind/Feed/Writer/Extension/DublinCore/Entry.php +++ b/module/VuFind/src/VuFind/Feed/Writer/Extension/DublinCore/Entry.php @@ -50,7 +50,7 @@ class Entry extends ParentEntry * * @var array */ - protected $dcFormats = array(); + protected $dcFormats = []; /** * Date diff --git a/module/VuFind/src/VuFind/Harvester/OAI.php b/module/VuFind/src/VuFind/Harvester/OAI.php index 51176043984..1b0703b2aba 100644 --- a/module/VuFind/src/VuFind/Harvester/OAI.php +++ b/module/VuFind/src/VuFind/Harvester/OAI.php @@ -102,14 +102,14 @@ class OAI * * @var array */ - protected $idSearch = array(); + protected $idSearch = []; /** * Replacements for regular expression matches * * @var array */ - protected $idReplace = array(); + protected $idReplace = []; /** * Directory for storing harvested files @@ -179,14 +179,14 @@ class OAI * * @var array */ - protected $injectHeaderElements = array(); + protected $injectHeaderElements = []; /** * Associative array of setSpec => setName * * @var array */ - protected $setNames = array(); + protected $setNames = []; /** * Filename for logging harvested IDs (false for none) @@ -256,7 +256,7 @@ class OAI // Disable SSL verification if requested: if (isset($settings['sslverifypeer']) && !$settings['sslverifypeer']) { - $this->client->setOptions(array('sslverifypeer' => false)); + $this->client->setOptions(['sslverifypeer' => false]); } // Don't time out during harvest!! @@ -319,7 +319,7 @@ class OAI // Normalize sets setting to an array: $sets = (array)$this->set; if (empty($sets)) { - $sets = array(null); + $sets = [null]; } // Loop through all of the selected sets: @@ -387,7 +387,7 @@ class OAI { // Remove timezone markers -- we don't want PHP to outsmart us by adjusting // the time zone! - $date = str_replace(array('T', 'Z'), array(' ', ''), $date); + $date = str_replace(['T', 'Z'], [' ', ''], $date); // Translate to a timestamp: return strtotime($date); @@ -414,7 +414,7 @@ class OAI * * @return object SimpleXML-formatted response. */ - protected function sendRequest($verb, $params = array()) + protected function sendRequest($verb, $params = []) { // Debug: if ($this->verbose) { @@ -428,7 +428,7 @@ class OAI // Set up the request: $this->client->resetParameters(); $this->client->setUri($this->baseURL); - $this->client->setOptions(array('timeout' => $this->timeout)); + $this->client->setOptions(['timeout' => $this->timeout]); // Set authentication, if necessary: if ($this->httpUser && $this->httpPass) { @@ -701,7 +701,7 @@ class OAI // On the first pass through the following loop, we want to get the // first page of sets without using a resumption token: - $params = array(); + $params = []; // Grab set information until we have it all (at which point we will // break out of this otherwise-infinite loop): @@ -770,11 +770,11 @@ class OAI $this->writeLine('Processing ' . count($records) . " records..."); // Array for tracking successfully harvested IDs: - $harvestedIds = array(); + $harvestedIds = []; // Array for tracking deleted IDs and string for tracking inner HTML // (both of these variables are used only when in 'combineRecords' mode): - $deletedIds = array(); + $deletedIds = []; $innerXML = ''; // Loop through the records: @@ -845,7 +845,7 @@ class OAI // Determine start and end tags from configuration: $start = $this->combineRecordsTag; $tmp = explode(' ', $start); - $end = '</' . str_replace(array('<', '>'), '', $tmp[0]) . '>'; + $end = '</' . str_replace(['<', '>'], '', $tmp[0]) . '>'; // Assemble the document: return $start . $innerXML . $end; @@ -893,7 +893,7 @@ class OAI */ protected function getRecordsByDate($from = null, $set = null, $until = null) { - $params = array('metadataPrefix' => $this->metadataPrefix); + $params = ['metadataPrefix' => $this->metadataPrefix]; if (!empty($from)) { $params['from'] = $from; } @@ -915,7 +915,7 @@ class OAI */ protected function getRecordsByToken($token) { - return $this->getRecords(array('resumptionToken' => (string)$token)); + return $this->getRecords(['resumptionToken' => (string)$token]); } /** @@ -935,12 +935,12 @@ class OAI $this->baseURL = $settings['url']; // Settings that may be mapped directly from $settings to class properties: - $mappableSettings = array( + $mappableSettings = [ 'set', 'metadataPrefix', 'idPrefix', 'idSearch', 'idReplace', 'harvestedIdLog', 'injectId', 'injectSetSpec', 'injectSetName', 'injectDate', 'injectHeaderElements', 'verbose', 'sanitize', 'badXMLLog', 'httpUser', 'httpPass', 'timeout', 'combineRecords', 'combineRecordsTag', - ); + ]; foreach ($mappableSettings as $current) { if (isset($settings[$current])) { $this->$current = $settings[$current]; @@ -955,7 +955,7 @@ class OAI // Normalize injectHeaderElements to an array: if (!is_array($this->injectHeaderElements)) { - $this->injectHeaderElements = array($this->injectHeaderElements); + $this->injectHeaderElements = [$this->injectHeaderElements]; } } diff --git a/module/VuFind/src/VuFind/Hierarchy/Driver/AbstractBase.php b/module/VuFind/src/VuFind/Hierarchy/Driver/AbstractBase.php index 1e0b136e082..647f41769de 100644 --- a/module/VuFind/src/VuFind/Hierarchy/Driver/AbstractBase.php +++ b/module/VuFind/src/VuFind/Hierarchy/Driver/AbstractBase.php @@ -89,7 +89,7 @@ abstract class AbstractBase */ public function __construct(\Zend\Config\Config $config, DataManager $dataManager, RendererManager $rendererManager, - $options = array() + $options = [] ) { $this->config = $config; $this->dataManager = $dataManager; diff --git a/module/VuFind/src/VuFind/Hierarchy/Driver/ConfigurationBased.php b/module/VuFind/src/VuFind/Hierarchy/Driver/ConfigurationBased.php index 6f90eb07f3b..f6afcd8c489 100644 --- a/module/VuFind/src/VuFind/Hierarchy/Driver/ConfigurationBased.php +++ b/module/VuFind/src/VuFind/Hierarchy/Driver/ConfigurationBased.php @@ -122,7 +122,7 @@ class ConfigurationBased extends AbstractBase public function getTreeSettings() { return isset($this->config->HierarchyTree) - ? $this->config->HierarchyTree->toArray() : array(); + ? $this->config->HierarchyTree->toArray() : []; } /** * Get Collection Link Type from the config file diff --git a/module/VuFind/src/VuFind/Hierarchy/Driver/Factory.php b/module/VuFind/src/VuFind/Hierarchy/Driver/Factory.php index b87ff024399..18efbd71998 100644 --- a/module/VuFind/src/VuFind/Hierarchy/Driver/Factory.php +++ b/module/VuFind/src/VuFind/Hierarchy/Driver/Factory.php @@ -58,10 +58,10 @@ class Factory // Set up options based on global VuFind settings: $configReader = $sm->get('VuFind\Config'); $globalConfig = $configReader->get('config'); - $options = array( + $options = [ 'enabled' => isset($globalConfig->Hierarchy->showTree) ? $globalConfig->Hierarchy->showTree : false - ); + ]; // Load driver-specific configuration: $driverConfig = $configReader->get($config); diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/AbstractBase.php b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/AbstractBase.php index d22aadebbf3..525640d7318 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/AbstractBase.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/AbstractBase.php @@ -84,7 +84,7 @@ abstract class AbstractBase implements \Zend\Log\LoggerAwareInterface * * @return string */ - abstract public function getXML($id, $options = array()); + abstract public function getXML($id, $options = []); /** * Does this data source support the specified hierarchy ID? diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Factory.php b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Factory.php index 5786514afeb..403360853e1 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Factory.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Factory.php @@ -58,7 +58,7 @@ class Factory ->get('HierarchyDefault'); $filters = isset($hierarchyFilters->HierarchyTree->filterQueries) ? $hierarchyFilters->HierarchyTree->filterQueries->toArray() - : array(); + : []; return new Solr( $sm->getServiceLocator()->get('VuFind\Search'), rtrim($cacheDir, '/') . '/hierarchy', diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php index d7da9a0e962..1947ff51c2e 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/Solr.php @@ -62,7 +62,7 @@ class Solr extends AbstractBase * * @var array */ - protected $filters = array(); + protected $filters = []; /** * Constructor. @@ -72,7 +72,7 @@ class Solr extends AbstractBase * @param array $filters Filters to apply to Solr tree queries */ public function __construct(SearchService $search, $cacheDir = null, - $filters = array() + $filters = [] ) { $this->searchService = $search; if (null !== $cacheDir) { @@ -92,7 +92,7 @@ class Solr extends AbstractBase * * @return string */ - public function getXML($id, $options = array()) + public function getXML($id, $options = []) { $top = $this->searchService->retrieve('Solr', $id)->getRecords(); if (!isset($top[0])) { @@ -153,12 +153,12 @@ class Solr extends AbstractBase ); $results = $this->searchService->search( 'Solr', $query, 0, 10000, - new ParamBag(array('fq' => $this->filters, 'hl' => 'false')) + new ParamBag(['fq' => $this->filters, 'hl' => 'false']) ); if ($results->getTotal() < 1) { return ''; } - $xml = array(); + $xml = []; $sorting = $this->getHierarchyDriver()->treeSorting(); foreach ($results->getRecords() as $current) { @@ -182,7 +182,7 @@ class Solr extends AbstractBase if ($sorting) { $positions = $current->getHierarchyPositionsInParents(); $sequence = isset($positions[$parentID]) ? $positions[$parentID] : 0; - $xml[] = array($sequence, $xmlNode); + $xml[] = [$sequence, $xmlNode]; } else { $xml[] = $xmlNode; } @@ -203,7 +203,7 @@ class Solr extends AbstractBase * * @return string */ - public function getJSON($id, $options = array()) + public function getJSON($id, $options = []) { $top = $this->searchService->retrieve('Solr', $id)->getRecords(); if (!isset($top[0])) { @@ -225,13 +225,13 @@ class Solr extends AbstractBase return $json; } else { $starttime = microtime(true); - $json = array( + $json = [ 'id' => $id, 'type' => $top->isCollection() ? 'collection' : 'record', 'title' => $top->getTitle() - ); + ]; $children = $this->getChildrenJson($id, $count); if (!empty($children)) { $json['children'] = $children; @@ -269,12 +269,12 @@ class Solr extends AbstractBase ); $results = $this->searchService->search( 'Solr', $query, 0, 10000, - new ParamBag(array('fq' => $this->filters, 'hl' => 'false')) + new ParamBag(['fq' => $this->filters, 'hl' => 'false']) ); if ($results->getTotal() < 1) { return ''; } - $json = array(); + $json = []; $sorting = $this->getHierarchyDriver()->treeSorting(); foreach ($results->getRecords() as $current) { @@ -285,13 +285,13 @@ class Solr extends AbstractBase ? $titles[$parentID] : $current->getTitle(); $this->debug("$parentID: " . $current->getUniqueID()); - $childNode = array( + $childNode = [ 'id' => $current->getUniqueID(), 'type' => $current->isCollection() ? 'collection' : 'record', 'title' => htmlspecialchars($title) - ); + ]; if ($current->isCollection()) { $children = $this->getChildrenJson( $current->getUniqueID(), @@ -307,7 +307,7 @@ class Solr extends AbstractBase if ($sorting) { $positions = $current->getHierarchyPositionsInParents(); $sequence = isset($positions[$parentID]) ? $positions[$parentID] : 0; - $json[] = array($sequence, $childNode); + $json[] = [$sequence, $childNode]; } else { $json[] = $childNode; } @@ -355,7 +355,7 @@ class Solr extends AbstractBase || $settings['checkAvailability'] == 1 ) { $results = $this->searchService->retrieve( - 'Solr', $id, new ParamBag(array('fq' => $this->filters)) + 'Solr', $id, new ParamBag(['fq' => $this->filters]) ); if ($results->getTotal() < 1) { return false; diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/XMLFile.php b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/XMLFile.php index 832ff9b1d61..30809f7169f 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/XMLFile.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeDataSource/XMLFile.php @@ -82,7 +82,7 @@ class XMLFile extends AbstractBase * * @return string */ - public function getXML($id, $options = array()) + public function getXML($id, $options = []) { return file_get_contents($this->getFilename($id)); } diff --git a/module/VuFind/src/VuFind/Hierarchy/TreeRenderer/JSTree.php b/module/VuFind/src/VuFind/Hierarchy/TreeRenderer/JSTree.php index 5c2e0ebc8f7..e2e635e2818 100644 --- a/module/VuFind/src/VuFind/Hierarchy/TreeRenderer/JSTree.php +++ b/module/VuFind/src/VuFind/Hierarchy/TreeRenderer/JSTree.php @@ -80,16 +80,16 @@ class JSTree extends AbstractBase if (in_array($hierarchyID, $inHierarchies) && $this->getDataSource()->supports($hierarchyID) ) { - return array( + return [ $hierarchyID => $this->getHierarchyName( $hierarchyID, $inHierarchies, $inHierarchiesTitle ) - ); + ]; } } else { // Return All Hierarchies $i = 0; - $hierarchies = array(); + $hierarchies = []; foreach ($inHierarchies as $hierarchyTopID) { if ($this->getDataSource()->supports($hierarchyTopID)) { $hierarchies[$hierarchyTopID] = $inHierarchiesTitle[$i]; @@ -200,20 +200,20 @@ class JSTree extends AbstractBase */ protected function formatJSON($node, $context, $hierarchyID) { - $ret = array( + $ret = [ 'id' => preg_replace('/\W/', '-', $node->id), 'text' => $node->title, - 'li_attr' => array( + 'li_attr' => [ 'recordid' => $node->id - ), - 'a_attr' => array( + ], + 'a_attr' => [ 'href' => $this->getContextualUrl($node, $context, $hierarchyID), 'title' => $node->title - ), + ], 'type' => $node->type - ); + ]; if (isset($node->children)) { - $ret['children'] = array(); + $ret['children'] = []; for ($i = 0;$i<count($node->children);$i++) { $ret['children'][$i] = $this ->formatJSON($node->children[$i], $context, $hierarchyID); @@ -233,15 +233,15 @@ class JSTree extends AbstractBase */ protected function getContextualUrl($node, $context, $collectionID) { - $params = array( + $params = [ 'id' => $node->id, 'tab' => 'HierarchyTree' - ); - $options = array( - 'query' => array( + ]; + $options = [ + 'query' => [ 'recordID' => $node->id - ) - ); + ] + ]; if ($context == 'Collection') { return $this->router->fromRoute('collection', $params, $options) . '#tabnav'; @@ -276,14 +276,14 @@ class JSTree extends AbstractBase ); // Set up parameters for XSL transformation - $params = array( + $params = [ 'titleText' => $this->translate('collection_view_record'), 'collectionID' => $hierarchyID, 'collectionTitle' => $hierarchyTitle, 'baseURL' => rtrim($this->router->fromRoute('home'), '/'), 'context' => $context, 'recordID' => $recordID - ); + ]; // Transform the XML $xmlFile = $this->getDataSource()->getXML($hierarchyID); diff --git a/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php b/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php index de79ebc4229..1d55af81822 100644 --- a/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php +++ b/module/VuFind/src/VuFind/I18n/Translator/Loader/ExtendedIni.php @@ -61,7 +61,7 @@ class ExtendedIni implements FileLoaderInterface * * @var array */ - protected $loadedFiles = array(); + protected $loadedFiles = []; /** * Helper for reading .ini files from disk. @@ -80,13 +80,13 @@ class ExtendedIni implements FileLoaderInterface * @param ExtendedIniReader $reader Helper for reading .ini files from * disk. */ - public function __construct($pathStack = array(), $fallbackLocales = null, + public function __construct($pathStack = [], $fallbackLocales = null, ExtendedIniReader $reader = null ) { $this->pathStack = $pathStack; $this->fallbackLocales = $fallbackLocales; if (!empty($this->fallbackLocales) && !is_array($this->fallbackLocales)) { - $this->fallbackLocales = array($this->fallbackLocales); + $this->fallbackLocales = [$this->fallbackLocales]; } $this->reader = ($reader === null) ? new ExtendedIniReader() : $reader; } @@ -129,7 +129,7 @@ class ExtendedIni implements FileLoaderInterface */ protected function resetLoadedFiles() { - $this->loadedFiles = array(); + $this->loadedFiles = []; } /** diff --git a/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php b/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php index 146158320f0..1a41ec82c91 100644 --- a/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php +++ b/module/VuFind/src/VuFind/I18n/Translator/TranslatorAwareTrait.php @@ -96,7 +96,7 @@ trait TranslatorAwareTrait * * @return string */ - public function translate($str, $tokens = array(), $default = null) + public function translate($str, $tokens = [], $default = null) { $msg = null === $this->translator ? $str : $this->translator->translate($str); @@ -108,7 +108,7 @@ trait TranslatorAwareTrait // Do we need to perform substitutions? if (!empty($tokens)) { - $in = $out = array(); + $in = $out = []; foreach ($tokens as $key => $value) { $in[] = $key; $out[] = $value; diff --git a/module/VuFind/src/VuFind/ILS/Connection.php b/module/VuFind/src/VuFind/ILS/Connection.php index 88a294a607d..5cfe3822735 100644 --- a/module/VuFind/src/VuFind/ILS/Connection.php +++ b/module/VuFind/src/VuFind/ILS/Connection.php @@ -198,7 +198,7 @@ class Connection implements TranslatorAwareInterface // Determine config file name based on class name: $parts = explode('\\', $this->getDriverClass()); $config = $this->configReader->get(end($parts)); - return is_object($config) ? $config->toArray() : array(); + return is_object($config) ? $config->toArray() : []; } /** @@ -217,7 +217,7 @@ class Connection implements TranslatorAwareInterface { // Extract the configuration from the driver if available: $functionConfig = $this->checkCapability( - 'getConfig', array($function, $params) + 'getConfig', [$function, $params] ) ? $this->getDriver()->getConfig($function, $params) : false; // See if we have a corresponding check method to analyze the response: @@ -251,10 +251,10 @@ class Connection implements TranslatorAwareInterface // the full parameter expected by placeHold() but should contain the // necessary details for determining eligibility. if ($this->getHoldsMode() != "none" - && $this->checkCapability('placeHold', array($params ?: array())) + && $this->checkCapability('placeHold', [$params ?: []]) && isset($functionConfig['HMACKeys']) ) { - $response = array('function' => "placeHold"); + $response = ['function' => "placeHold"]; $response['HMACKeys'] = explode(":", $functionConfig['HMACKeys']); if (isset($functionConfig['defaultRequiredDate'])) { $response['defaultRequiredDate'] @@ -273,8 +273,8 @@ class Connection implements TranslatorAwareInterface } } else { $id = isset($params['id']) ? $params['id'] : null; - if ($this->checkCapability('getHoldLink', array($id, array()))) { - $response = array('function' => "getHoldLink"); + if ($this->checkCapability('getHoldLink', [$id, []])) { + $response = ['function' => "getHoldLink"]; } } return $response; @@ -304,14 +304,14 @@ class Connection implements TranslatorAwareInterface // approximation. if (isset($this->config->cancel_holds_enabled) && $this->config->cancel_holds_enabled == true - && $this->checkCapability('cancelHolds', array($params ?: array())) + && $this->checkCapability('cancelHolds', [$params ?: []]) ) { - $response = array('function' => "cancelHolds"); + $response = ['function' => "cancelHolds"]; } else if (isset($this->config->cancel_holds_enabled) && $this->config->cancel_holds_enabled == true - && $this->checkCapability('getCancelHoldLink', array($params ?: array())) + && $this->checkCapability('getCancelHoldLink', [$params ?: []]) ) { - $response = array('function' => "getCancelHoldLink"); + $response = ['function' => "getCancelHoldLink"]; } return $response; } @@ -339,14 +339,14 @@ class Connection implements TranslatorAwareInterface // approximation. if (isset($this->config->renewals_enabled) && $this->config->renewals_enabled == true - && $this->checkCapability('renewMyItems', array($params ?: array())) + && $this->checkCapability('renewMyItems', [$params ?: []]) ) { - $response = array('function' => "renewMyItems"); + $response = ['function' => "renewMyItems"]; } else if (isset($this->config->renewals_enabled) && $this->config->renewals_enabled == true - && $this->checkCapability('renewMyItemsLink', array($params ?: array())) + && $this->checkCapability('renewMyItemsLink', [$params ?: []]) ) { - $response = array('function' => "renewMyItemsLink"); + $response = ['function' => "renewMyItemsLink"]; } return $response; } @@ -372,10 +372,10 @@ class Connection implements TranslatorAwareInterface // $params doesn't include all of the keys used by // placeStorageRetrievalRequest, but it is the best we can do in the context. $check = $this->checkCapability( - 'placeStorageRetrievalRequest', array($params ?: array()) + 'placeStorageRetrievalRequest', [$params ?: []] ); if ($check && isset($functionConfig['HMACKeys'])) { - $response = array('function' => 'placeStorageRetrievalRequest'); + $response = ['function' => 'placeStorageRetrievalRequest']; $response['HMACKeys'] = explode(':', $functionConfig['HMACKeys']); if (isset($functionConfig['extraFields'])) { $response['extraFields'] = $functionConfig['extraFields']; @@ -414,22 +414,22 @@ class Connection implements TranslatorAwareInterface && $this->config->cancel_storage_retrieval_requests_enabled ) { $check = $this->checkCapability( - 'cancelStorageRetrievalRequests', array($params ?: array()) + 'cancelStorageRetrievalRequests', [$params ?: []] ); if ($check) { - $response = array('function' => 'cancelStorageRetrievalRequests'); + $response = ['function' => 'cancelStorageRetrievalRequests']; } else { - $cancelParams = array( - $params ?: array(), + $cancelParams = [ + $params ?: [], isset($params['patron']) ? $params['patron'] : null - ); + ]; $check2 = $this->checkCapability( 'getCancelStorageRetrievalRequestLink', $cancelParams ); if ($check2) { - $response = array( + $response = [ 'function' => 'getCancelStorageRetrievalRequestLink' - ); + ]; } } } @@ -455,10 +455,10 @@ class Connection implements TranslatorAwareInterface // $params doesn't include all of the keys used by // placeILLRequest, but it is the best we can do in the context. - if ($this->checkCapability('placeILLRequest', array($params ?: array())) + if ($this->checkCapability('placeILLRequest', [$params ?: []]) && isset($functionConfig['HMACKeys']) ) { - $response = array('function' => 'placeILLRequest'); + $response = ['function' => 'placeILLRequest']; $response['HMACKeys'] = explode(':', $functionConfig['HMACKeys']); if (isset($functionConfig['extraFields'])) { $response['extraFields'] = $functionConfig['extraFields']; @@ -496,22 +496,22 @@ class Connection implements TranslatorAwareInterface && $this->config->cancel_ill_requests_enabled ) { $check = $this->checkCapability( - 'cancelILLRequests', array($params ?: array()) + 'cancelILLRequests', [$params ?: []] ); if ($check) { - $response = array('function' => 'cancelILLRequests'); + $response = ['function' => 'cancelILLRequests']; } else { - $cancelParams = array( - $params ?: array(), + $cancelParams = [ + $params ?: [], isset($params['patron']) ? $params['patron'] : null - ); + ]; $check2 = $this->checkCapability( 'getCancelILLRequestLink', $cancelParams ); if ($check2) { - $response = array( + $response = [ 'function' => 'getCancelILLRequestLink' - ); + ]; } } } @@ -536,8 +536,8 @@ class Connection implements TranslatorAwareInterface */ protected function checkMethodchangePassword($functionConfig, $params) { - if ($this->checkCapability('changePassword', array($params ?: array()))) { - return array('function' => 'changePassword'); + if ($this->checkCapability('changePassword', [$params ?: []])) { + return ['function' => 'changePassword']; } return false; } @@ -573,7 +573,7 @@ class Connection implements TranslatorAwareInterface public function checkRequestIsValid($id, $data, $patron) { if ($this->checkCapability( - 'checkRequestIsValid', array($id, $data, $patron) + 'checkRequestIsValid', [$id, $data, $patron] )) { return $this->getDriver()->checkRequestIsValid($id, $data, $patron); } @@ -598,7 +598,7 @@ class Connection implements TranslatorAwareInterface public function checkStorageRetrievalRequestIsValid($id, $data, $patron) { if ($this->checkCapability( - 'checkStorageRetrievalRequestIsValid', array($id, $data, $patron) + 'checkStorageRetrievalRequestIsValid', [$id, $data, $patron] )) { return $this->getDriver()->checkStorageRetrievalRequestIsValid( $id, $data, $patron @@ -624,7 +624,7 @@ class Connection implements TranslatorAwareInterface public function checkILLRequestIsValid($id, $data, $patron) { if ($this->checkCapability( - 'checkILLRequestIsValid', array($id, $data, $patron) + 'checkILLRequestIsValid', [$id, $data, $patron] )) { return $this->getDriver()->checkILLRequestIsValid( $id, $data, $patron @@ -686,7 +686,7 @@ class Connection implements TranslatorAwareInterface public function hasHoldings($id) { // Graceful degradation -- return true if no method supported. - return $this->checkCapability('hasHoldings', array($id)) + return $this->checkCapability('hasHoldings', [$id]) ? $this->getDriver()->hasHoldings($id) : true; } @@ -713,11 +713,11 @@ class Connection implements TranslatorAwareInterface * * @return bool */ - public function checkCapability($method, $params = array()) + public function checkCapability($method, $params = []) { // First check that the function is callable without the expense of // initializing the driver: - if (is_callable(array($this->getDriverClass(), $method))) { + if (is_callable([$this->getDriverClass(), $method])) { // At least drivers implementing the __call() magic method must also // implement supportsMethod() to verify that the method is actually // usable: @@ -742,7 +742,7 @@ class Connection implements TranslatorAwareInterface { return isset($this->config->holdings_text_fields) ? $this->config->holdings_text_fields->toArray() - : array('notes', 'summary', 'supplements', 'indexes'); + : ['notes', 'summary', 'supplements', 'indexes']; } /** @@ -755,7 +755,7 @@ class Connection implements TranslatorAwareInterface public function getPasswordPolicy($patron) { return $this->checkCapability( - 'getConfig', array('changePassword', compact('patron')) + 'getConfig', ['changePassword', compact('patron')] ) ? $this->getDriver()->getConfig('changePassword', compact('patron')) : false; } @@ -775,7 +775,7 @@ class Connection implements TranslatorAwareInterface { if ($this->checkCapability($methodName, $params)) { return call_user_func_array( - array($this->getDriver(), $methodName), $params + [$this->getDriver(), $methodName], $params ); } throw new ILSException( diff --git a/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php b/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php index 4d9c6ed7017..9afe7ab7ae1 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php +++ b/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php @@ -45,7 +45,7 @@ abstract class AbstractBase implements DriverInterface * * @var array */ - protected $config = array(); + protected $config = []; /** * Set configuration. diff --git a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php index 3b89e607205..ff6c41cb4a9 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php @@ -82,7 +82,7 @@ class AlephTranslator */ public function parsetable($file, $callback) { - $result = array(); + $result = []; $file_handle = fopen($file, "r, ccs=UTF-8"); $rgxp = ""; while (!feof($file_handle)) { @@ -97,7 +97,7 @@ class AlephTranslator $matches = ""; if (preg_match($rgxp, $line, $matches)) { call_user_func_array( - $callback, array($matches, &$result, $this->charset) + $callback, [$matches, &$result, $this->charset] ); } } @@ -184,10 +184,10 @@ class AlephTranslator } $desc = iconv($charset, 'UTF-8', $matches[5]); $key = trim($lib) . "|" . trim($no1) . "|" . trim($no2); - $tab15[trim($key)] = array( + $tab15[trim($key)] = [ "desc" => trim($desc), "loan" => $matches[6], "request" => $matches[8], "opac" => $matches[10] - ); + ]; } /** @@ -206,7 +206,7 @@ class AlephTranslator $sub = trim(preg_replace("/#/", "", $sub)); $desc = trim(iconv($charset, 'UTF-8', $matches[4])); $key = $code . "|" . $sub; - $tab40[trim($key)] = array( "desc" => $desc ); + $tab40[trim($key)] = [ "desc" => $desc ]; } /** @@ -224,7 +224,7 @@ class AlephTranslator $sublib = trim($matches[1]); $desc = trim(iconv($charset, 'UTF-8', $matches[5])); $tab = trim($matches[6]); - $tab_sub_library[$sublib] = array( "desc" => $desc, "tab15" => $tab ); + $tab_sub_library[$sublib] = [ "desc" => $desc, "tab15" => $tab ]; } /** @@ -357,9 +357,9 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function init() { // Validate config - $required = array( + $required = [ 'host', 'bib', 'useradm', 'admlib', 'dlfport', 'available_statuses' - ); + ]; foreach ($required as $current) { if (!isset($this->config['Catalog'][$current])) { throw new ILSException("Missing Catalog/{$current} config setting."); @@ -443,10 +443,10 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $url = $this->appendQueryString($url, $params); if ($auth) { $url = $this->appendQueryString( - $url, array( + $url, [ 'user_name' => $this->wwwuser, 'user_password' => $this->wwwpasswd - ) + ] ); } $result = $this->doHTTPRequest($url); @@ -485,10 +485,10 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, if ($replyCode != "0000") { $replyText = (string) $result->{'reply-text'}; $this->logError( - "DLF request failed", array( + "DLF request failed", [ 'url' => $url, 'reply-code' => $replyCode, 'reply-message' => $replyText - ) + ] ); $ex = new AlephRestfulException($replyText, $replyCode); $ex->setXmlResponse($result); @@ -573,7 +573,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, protected function parseId($id) { if (count($this->bib) == 1) { - return array($this->bib[0], $id); + return [$this->bib[0], $id]; } else { return explode('-', $id); } @@ -636,14 +636,14 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $sep = ","; } $xml = $this->doXRequest( - "publish_avail", array('library' => $bib, 'doc_num' => $doc_nums), false + "publish_avail", ['library' => $bib, 'doc_num' => $doc_nums], false ); - $holding = array(); + $holding = []; foreach ($xml->xpath('/publish-avail/OAI-PMH') as $rec) { $identifier = $rec->xpath(".//identifier/text()"); $id = ((count($this->bib) > 1) ? $bib . "-" : "") . substr($identifier[0], strrpos($identifier[0], ':') + 1); - $temp = array(); + $temp = []; foreach ($rec->xpath(".//datafield[@tag='AVA']") as $datafield) { $status = $datafield->xpath('./subfield[@code="e"]/text()'); $location = $datafield->xpath('./subfield[@code="a"]/text()'); @@ -651,7 +651,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $availability = ($status[0] == 'available' || $status[0] == 'check_holdings'); $reserve = true; - $temp[] = array( + $temp[] = [ 'id' => $id, 'availability' => $availability, 'status' => (string) $status[0], @@ -659,7 +659,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, 'signature' => (string) $signature[0], 'reserve' => $reserve, 'callnumber' => (string) $signature[0] - ); + ]; } $holding[] = $temp; } @@ -681,17 +681,17 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, { if (!$this->xserver_enabled) { if (!$this->quick_availability) { - return array(); + return []; } - $result = array(); + $result = []; foreach ($idList as $id) { $items = $this->getStatus($id); $result[] = $items; } return $result; } - $ids = array(); - $holdings = array(); + $ids = []; + $holdings = []; foreach ($idList as $id) { list($bib, $sys_no) = $this->parseId($id); $ids[$bib][] = $sys_no; @@ -722,16 +722,16 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, */ public function getHolding($id, array $patron = null) { - $holding = array(); + $holding = []; list($bib, $sys_no) = $this->parseId($id); $resource = $bib . $sys_no; - $params = array('view' => 'full'); + $params = ['view' => 'full']; if (!empty($patron['id'])) { $params['patron'] = $patron['id']; } else if (isset($this->defaultPatronId)) { $params['patron'] = $this->defaultPatronId; } - $xml = $this->doRestDLFRequest(array('record', $resource, 'items'), $params); + $xml = $this->doRestDLFRequest(['record', $resource, 'items'], $params); foreach ($xml->{'items'}->{'item'} as $item) { $item_status = (string) $item->{'z30-item-status-code'}; // $isc // $ipsc: @@ -743,12 +743,12 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $sub_library_code, $item_status, $item_process_status ); } else { - $item_status = array( + $item_status = [ 'opac' => 'Y', 'request' => 'C', 'desc' => (string) $z30->{'z30-item-status'}, 'sub_lib_desc' => (string) $z30->{'z30-sub-library'} - ); + ]; } if ($item_status['opac'] != 'Y') { continue; @@ -756,7 +756,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $availability = false; //$reserve = ($item_status['request'] == 'C')?'N':'Y'; $collection = (string) $z30->{'z30-collection'}; - $collection_desc = array('desc' => $collection); + $collection_desc = ['desc' => $collection]; if ($this->translator) { $collection_code = (string) $item->{'z30-collection-code'}; $collection_desc = $this->translator->tab40Translate( @@ -777,7 +777,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $hold_request = $item->xpath('info[@type="HoldRequest"]/@allowed'); $addLink = ($hold_request[0] == 'Y'); } - $matches = array(); + $matches = []; if (preg_match( "/([0-9]*\\/[a-zA-Z]*\\/[0-9]*);([a-zA-Z ]*)/", $status, $matches )) { @@ -810,7 +810,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $item_id = $item->attributes()->href; $item_id = substr($item_id, strrpos($item_id, '/') + 1); $note = (string) $z30->{'z30-note-opac'}; - $holding[] = array( + $holding[] = [ 'id' => $id, 'item_id' => $item_id, 'availability' => $availability, @@ -822,7 +822,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, 'number' => (string) $z30->{'z30-inventory-number'}, 'barcode' => (string) $z30->{'z30-barcode'}, 'description' => (string) $z30->{'z30-description'}, - 'notes' => ($note == null) ? null : array($note), + 'notes' => ($note == null) ? null : [$note], 'is_holdable' => true, 'addLink' => $addLink, 'holdtype' => 'hold', @@ -833,7 +833,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, 'sub_lib_desc' => (string) $item_status['sub_lib_desc'], 'no_of_loans' => (string) $z30->{'$no_of_loans'}, 'requested' => (string) $requested - ); + ]; } return $holding; } @@ -869,13 +869,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getMyTransactions($user, $history = false) { $userId = $user['id']; - $transList = array(); - $params = array("view" => "full"); + $transList = []; + $params = ["view" => "full"]; if ($history) { $params["type"] = "history"; } $xml = $this->doRestDLFRequest( - array('patron', $userId, 'circulationActions', 'loans'), $params + ['patron', $userId, 'circulationActions', 'loans'], $params ); foreach ($xml->xpath('//loan') as $item) { $z36 = $item->z36; @@ -903,14 +903,14 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $author = (string) $z13->{'z13-author'}; $isbn = (string) $z13->{'z13-isbn-issn'}; $barcode = (string) $z30->{'z30-barcode'}; - $transList[] = array( + $transList[] = [ //'type' => $type, 'id' => ($history) ? null : $this->barcodeToID($barcode), 'item_id' => $group, 'location' => $location, 'title' => $title, 'author' => $author, - 'isbn' => array($isbn), + 'isbn' => [$isbn], 'reqnum' => $reqnum, 'barcode' => $barcode, 'duedate' => $this->parseDate($due), @@ -919,7 +919,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, //'delete' => $delete, 'renewable' => true, //'create' => $this->parseDate($create) - ); + ]; } return $transList; } @@ -955,23 +955,23 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function renewMyItems($details) { $patron = $details['patron']; - $result = array(); + $result = []; foreach ($details['details'] as $id) { try { $this->doRestDLFRequest( - array( + [ 'patron', $patron['id'], 'circulationActions', 'loans', $id - ), + ], null, 'POST', null ); - $result[$id] = array('success' => true); + $result[$id] = ['success' => true]; } catch (AlephRestfulException $ex) { - $result[$id] = array( + $result[$id] = [ 'success' => false, 'sysMessage' => $ex->getMessage() - ); + ]; } } - return array('blocks' => false, 'details' => $result); + return ['blocks' => false, 'details' => $result]; } /** @@ -988,10 +988,10 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getMyHolds($user) { $userId = $user['id']; - $holdList = array(); + $holdList = []; $xml = $this->doRestDLFRequest( - array('patron', $userId, 'circulationActions', 'requests', 'holds'), - array('view' => 'full') + ['patron', $userId, 'circulationActions', 'requests', 'holds'], + ['view' => 'full'] ); foreach ($xml->xpath('//hold-request') as $item) { $z37 = $item->z37; @@ -1023,13 +1023,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $holddate = $this->parseDate($holddate); } $delete = ($delete[0] == "Y"); - $holdList[] = array( + $holdList[] = [ 'type' => $type, 'item_id' => $item_id, 'location' => $location, 'title' => $title, 'author' => $author, - 'isbn' => array($isbn), + 'isbn' => [$isbn], 'reqnum' => $reqnum, 'barcode' => $barcode, 'id' => $this->barcodeToID($barcode), @@ -1039,7 +1039,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, 'create' => $this->parseDate($create), 'status' => $status, 'position' => ltrim($seq, '0') - ); + ]; } } return $holdList; @@ -1077,13 +1077,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $patron = $details['patron']; $patronId = $patron['id']; $count = 0; - $statuses = array(); + $statuses = []; foreach ($details['details'] as $id) { $result = $this->doRestDLFRequest( - array( + [ 'patron', $patronId, 'circulationActions', 'requests', 'holds', $id - ), null, "DELETE" + ], null, "DELETE" ); $reply_code = $result->{'reply-code'}; if ($reply_code != "0000") { @@ -1091,14 +1091,14 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, if ($message == null) { $message = $result->{'reply-text'}; } - $statuses[$id] = array( + $statuses[$id] = [ 'success' => false, 'status' => 'cancel_hold_failed', 'sysMessage' => (string) $message - ); + ]; } else { $count++; $statuses[$id] - = array('success' => true, 'status' => 'cancel_hold_ok'); + = ['success' => true, 'status' => 'cancel_hold_ok']; } } $statuses['count'] = $count; @@ -1118,12 +1118,12 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, */ public function getMyFines($user) { - $finesList = array(); - $finesListSort = array(); + $finesList = []; + $finesListSort = []; $xml = $this->doRestDLFRequest( - array('patron', $user['id'], 'circulationActions', 'cash'), - array("view" => "full") + ['patron', $user['id'], 'circulationActions', 'cash'], + ["view" => "full"] ); foreach ($xml->xpath('//cash') as $item) { @@ -1150,7 +1150,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, //$cashdate = date('d-m-Y', strtotime((string) $z31->{'z31-date'})); $balance = 0; - $finesListSort["$cashref"] = array( + $finesListSort["$cashref"] = [ "title" => $title, "barcode" => $barcode, "amount" => $amount, @@ -1159,7 +1159,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, "checkout" => $this->parseDate($checkout), "balance" => $balance, "id" => $id - ); + ]; } ksort($finesListSort); foreach (array_keys($finesListSort) as $key) { @@ -1171,7 +1171,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $transactiontype = $finesListSort[$key]["transactiontype"]; $balance += $finesListSort[$key]["amount"]; $id = $finesListSort[$key]["id"]; - $finesList[] = array( + $finesList[] = [ "title" => $title, "barcode" => $barcode, "amount" => $amount, @@ -1181,7 +1181,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, "checkout" => $checkout, "id" => $id, "printLink" => "test", - ); + ]; } return $finesList; } @@ -1215,16 +1215,16 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, */ public function getMyProfileX($user) { - $recordList = array(); + $recordList = []; if (!isset($user['college'])) { $user['college'] = $this->useradm; } $xml = $this->doXRequest( "bor-info", - array( + [ 'loans' => 'N', 'cash' => 'N', 'hold' => 'N', 'library' => $user['college'], 'bor_id' => $user['id'] - ), true + ], true ); $id = (string) $xml->z303->{'z303-id'}; $address1 = (string) $xml->z304->{'z304-address-2'}; @@ -1276,7 +1276,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getMyProfileDLF($user) { $xml = $this->doRestDLFRequest( - array('patron', $user['id'], 'patronInformation', 'address') + ['patron', $user['id'], 'patronInformation', 'address'] ); $address = $xml->xpath('//address-information'); $address = $address[0]; @@ -1307,7 +1307,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $recordList['dateTo'] = $dateTo; $recordList['id'] = $user['id']; $xml = $this->doRestDLFRequest( - array('patron', $user['id'], 'patronStatus', 'registration') + ['patron', $user['id'], 'patronStatus', 'registration'] ); $status = $xml->xpath("//institution/z305-bor-status"); $expiry = $xml->xpath("//institution/z305-expiry-date"); @@ -1331,22 +1331,22 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function patronLogin($user, $password) { if ($password == null) { - $temp = array("id" => $user); + $temp = ["id" => $user]; $temp['college'] = $this->useradm; return $this->getMyProfile($temp); } try { $xml = $this->doXRequest( 'bor-auth', - array( + [ 'library' => $this->useradm, 'bor_id' => $user, 'verification' => $password - ), true + ], true ); } catch (\Exception $ex) { throw new ILSException($ex->getMessage()); } - $patron = array(); + $patron = []; $name = $xml->z303->{'z303-name'}; if (strstr($name, ",")) { list($lastName, $firstName) = explode(",", $name); @@ -1390,9 +1390,9 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, list($bib, $sys_no) = $this->parseId($id); $resource = $bib . $sys_no; $xml = $this->doRestDLFRequest( - array('patron', $patronId, 'record', $resource, 'items', $group) + ['patron', $patronId, 'record', $resource, 'items', $group] ); - $locations = array(); + $locations = []; $part = $xml->xpath('//pickup-locations'); if ($part) { foreach ($part[0]->children() as $node) { @@ -1413,10 +1413,10 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $date = $date[0]; $date = "" . substr($date, 6, 2) . "." . substr($date, 4, 2) . "." . substr($date, 0, 4); - return array( + return [ 'pickup-locations' => $locations, 'last-interest-date' => $date, 'order' => $requests + 1 - ); + ]; } /** @@ -1483,10 +1483,10 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $requiredBy = $this->dateConverter ->convertFromDisplayDate('Ymd', $details['requiredBy']); } catch (DateException $de) { - return array( + return [ 'success' => false, 'sysMessage' => 'hold_date_invalid' - ); + ]; } $patronId = $patron['id']; $body = new \SimpleXMLElement( @@ -1502,22 +1502,22 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $body = 'post_xml=' . $body->asXML(); try { $this->doRestDLFRequest( - array( + [ 'patron', $patronId, 'record', $recordId, 'items', $itemId, 'hold' - ), null, "PUT", $body + ], null, "PUT", $body ); } catch (AlephRestfulException $exception) { $message = $exception->getMessage(); $note = $exception->getXmlResponse() ->xpath('/put-item-hold/create-hold/note[@type="error"]'); $note = $note[0]; - return array( + return [ 'success' => false, 'sysMessage' => "$message ($note)" - ); + ]; } - return array('success' => true); + return ['success' => true]; } /** @@ -1535,13 +1535,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, foreach ($this->bib as $base) { try { $xml = $this->doXRequest( - "find", array("base" => $base, "request" => "BAR=$bar"), false + "find", ["base" => $base, "request" => "BAR=$bar"], false ); $docs = (int) $xml->{"no_records"}; if ($docs == 1) { $set = (string) $xml->{"set_number"}; $result = $this->doXRequest( - "present", array("set_number" => $set, "set_entry" => "1"), + "present", ["set_number" => $set, "set_entry" => "1"], false ); $id = $result->xpath('//doc_number/text()'); @@ -1598,13 +1598,13 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, if (isset($this->config['Holds'])) { return $this->config['Holds']; } - return array( + return [ "HMACKeys" => "id:item_id", "extraHoldFields" => "comments:requiredByDate:pickUpLocation", "defaultRequiredDate" => "0:1:0" - ); + ]; } else { - return array(); + return []; } } @@ -1631,16 +1631,16 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, $details = $this->getHoldingInfoForItem( $patron['id'], $holdInfo['id'], $holdInfo['item_id'] ); - $pickupLocations = array(); + $pickupLocations = []; foreach ($details['pickup-locations'] as $key => $value) { - $pickupLocations[] = array( + $pickupLocations[] = [ "locationID" => $key, "locationDisplay" => $value - ); + ]; } return $pickupLocations; } else { $default = $this->getDefaultPickUpLocation($patron); - return empty($default) ? array() : array($default); + return empty($default) ? [] : [$default]; } } @@ -1700,7 +1700,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -1726,7 +1726,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getNewItems($page, $limit, $daysOld, $fundId = null) { // TODO - $items = array(); + $items = []; return $items; } @@ -1741,7 +1741,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getDepartments() { // TODO - return array(); + return []; } /** @@ -1755,7 +1755,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getInstructors() { // TODO - return array(); + return []; } /** @@ -1769,7 +1769,7 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function getCourses() { // TODO - return array(); + return []; } /** @@ -1789,6 +1789,6 @@ class Aleph extends AbstractBase implements \Zend\Log\LoggerAwareInterface, public function findReserves($course, $inst, $dept) { // TODO - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Amicus.php b/module/VuFind/src/VuFind/ILS/Driver/Amicus.php index 0dce9f0b6fc..ff02774fbc0 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Amicus.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Amicus.php @@ -155,7 +155,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface // shelf) status, collecting any other statuses we find along the // way... $notCharged = false; - $otherStatuses = array(); + $otherStatuses = []; foreach ($statusArray as $status) { switch ($status) { case 'Disponible': @@ -170,7 +170,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface // If we found other statuses or if we failed to find "Not Charged," // the item is not available! $available = (count($otherStatuses) == 0 && $notCharged); - return array('available' => $available, 'otherStatuses' => $otherStatuses); + return ['available' => $available, 'otherStatuses' => $otherStatuses]; } /** @@ -317,7 +317,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface } $prestados = 0; $reservados = 0; - $possibleQueries = array($items); + $possibleQueries = [$items]; // Loop through the possible queries and try each in turn -- the first one // that yields results will cause the function to return. @@ -332,7 +332,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface } // Build Array of Item Information - $data = array(); + $data = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { $prestados = $this->sacaStatus($row['CPY_ID_NBR']); $reservados = $this->sacaReservas($row['CPY_ID_NBR']); @@ -341,14 +341,14 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $multiple = $this->translate("Multiple Locations"); $textoLoc = $this->translate("Multiple"); $textoSign = $this->translate("Multiple Locations"); - $data[$row['BIB_ITM_NBR']] = array( + $data[$row['BIB_ITM_NBR']] = [ 'id' => $id, 'status' => $prestados, - 'status_array' => array($prestados), + 'status_array' => [$prestados], 'location' => $textoLoc, 'reserve' => $reservados, 'callnumber' => $textoSign - ); + ]; } else { $multiple = $row['LOCATION']; if ($multiple == 'Deposito2') { @@ -357,14 +357,14 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface if ($multiple == 'Deposito') { $multiple = "Depósito"; } - $data[$row['BIB_ITM_NBR']] = array( + $data[$row['BIB_ITM_NBR']] = [ 'id' => $id, 'status' => $prestados, - 'status_array' => array($prestados), + 'status_array' => [$prestados], 'location' => $multiple, 'reserve' => $reservados, 'callnumber' => $row['CALLNUMBER'] - ); + ]; } } else { $status_array = & $data[$row['BIB_ITM_NBR']]['status_array']; @@ -376,14 +376,14 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface // If we found any information, break out of the foreach loop; // we don't need to try any more queries. if (count($data) == 0) { - $data[$id] = array( + $data[$id] = [ 'id' => $id, 'status' => $prestados, - 'status_array' => array($prestados), + 'status_array' => [$prestados], 'location' => $this->translate("No copies"), 'reserve' => $reservados, 'callnumber' => $this->translate("No copies") - ); + ]; break; } if (count($data) > 0) { @@ -391,7 +391,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface } } // Process the raw data into final status information: - $status = array(); + $status = []; foreach ($data as $current) { // Get availability/status info based on the array of status codes: $availability = $this->determineAvailability($current['status_array']); @@ -420,7 +420,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getStatuses($idList) { - $status = array(); + $status = []; foreach ($idList as $id) { $status[] = $this->getStatus($id); @@ -457,7 +457,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface "and CPY_ID.BIB_ITM_NBR = '$id' " . "order by SHLF_LIST_SRT_FORM ASC, CPY_ID.CPY_ID_NBR ASC"; - $possibleQueries = array($items); + $possibleQueries = [$items]; // Loop through the possible queries and try each in turn -- the first one // that yields results will cause us to break out of the loop. @@ -471,7 +471,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface } // Build Holdings Array - $data = array(); + $data = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { // Determine Location $loc = $row['LOCATION']; @@ -483,8 +483,8 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface } $status = $this->sacaStatus($row['CPY_ID_NBR']); - $availability = $this->determineAvailability(array($status)); - $currentItem = array( + $availability = $this->determineAvailability([$status]); + $currentItem = [ 'id' => $id, 'availability' => $availability['available'], 'status' => $status, @@ -498,7 +498,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface 'number' => count($data) +1, 'item_id' => $row['CPY_ID_NBR'], 'barcode' => $row['BRCDE_NBR'] - ); + ]; $data[] = $currentItem; } // If we found data, we can leave the foreach loop -- we don't need to @@ -529,11 +529,11 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface "WHERE CPY_ID.BIB_ITM_NBR = '$id' " . "order by CPY_ID.SHLF_LIST_KEY_NBR ASC, CPY_ID.CPY_ID_NBR ASC"; try { - $data = array(); + $data = []; $sqlStmt = $this->db->prepare($sql); $sqlStmt->execute(); while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $data[] = array('issue' => $row['ENUMCHRON']); + $data[] = ['issue' => $row['ENUMCHRON']]; } return $data; } catch (PDOException $e) { @@ -564,7 +564,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $sqlStmt->execute(); $row = $sqlStmt->fetch(PDO::FETCH_ASSOC); if (isset($row['LOGIN']) && ($row['LOGIN'] != '')) { - return array( + return [ 'id' => $row['LOGIN'], 'firstname' => $row['FIRST_NAME'], 'lastname' => $lname, @@ -575,7 +575,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface // might be worth investigating further if needed later. 'email' => null, 'major' => null, - 'college' => null); + 'college' => null]; } else { return null; } @@ -598,7 +598,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getMyTransactions($patron) { - $transList = array(); + $transList = []; $sql = "SELECT TO_CHAR(CIRT_ITM.CIRT_ITM_DUE_DTE,'DD/MM/YYYY') " . "AS DUEDATE, CIRT_ITM.BIB_ITM_NBR AS BIB_ID " . @@ -609,8 +609,8 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $sqlStmt = $this->db->prepare($sql); $sqlStmt->execute(); while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $transList[] = array('duedate' => $row['DUEDATE'], - 'id' => $row['BIB_ID']); + $transList[] = ['duedate' => $row['DUEDATE'], + 'id' => $row['BIB_ID']]; } return $transList; } catch (PDOException $e) { @@ -631,7 +631,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getMyFines($patron) { - $fineList = array(); + $fineList = []; $sql = "SELECT UNIQUE TO_CHAR(CIRT_ITM.CIRT_ITM_CHRG_OUT_DTE,'DD/MM/YYYY') " . "AS ORIG_CHARGE_DATE, " @@ -645,9 +645,9 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $sqlStmt = $this->db->prepare($sql); $sqlStmt->execute(); while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $fineList[] = array('checkout' => $row['ORIG_CHARGE_DATE'], + $fineList[] = ['checkout' => $row['ORIG_CHARGE_DATE'], 'duedate' => $row['DUE_DATE'], - 'id' => $row['BIB_ID']); + 'id' => $row['BIB_ID']]; } return $fineList; } catch (PDOException $e) { @@ -668,7 +668,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getMyHolds($patron) { - $holdList = array(); + $holdList = []; $sql = "SELECT CIRTN_HLD.BIB_ITM_NBR AS BIB_ID, " . "CIRTN_HLD.CIRTN_HLD_LCTN_ORG_NBR AS PICKUP_LOCATION, " . @@ -682,11 +682,11 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $sqlStmt = $this->db->prepare($sql); $sqlStmt->execute(); while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $holdList[] = array('type' => $row['HOLD_RECALL_TYPE'], + $holdList[] = ['type' => $row['HOLD_RECALL_TYPE'], 'id' => $row['BIB_ID'], 'location' => $row['PICKUP_LOCATION'], 'expire' => $row['EXPIRE_DATE'], - 'create' => $row['CREATE_DATE']); + 'create' => $row['CREATE_DATE']]; } return $holdList; } catch (PDOException $e) { @@ -729,14 +729,14 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface $sqlStmt->execute(); $row = $sqlStmt->fetch(PDO::FETCH_ASSOC); if ($row) { - $patron = array('firstname' => $row['FIRST_NAME'], + $patron = ['firstname' => $row['FIRST_NAME'], 'lastname' => $row['LAST_NAME'], 'address1' => $row['ADDRESS_LINE1'], 'address2' => $row['ADDRESS_LINE2'], 'zip' => $row['ZIP_POSTAL'], 'phone' => $row['TFNO'], 'email' => $row['EMAIL'], - 'group' => $row['PATRON_GROUP_NAME']); + 'group' => $row['PATRON_GROUP_NAME']]; return $patron; } else { return null; @@ -787,7 +787,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - $items = array(); + $items = []; // Prevent unnecessary load on voyager if ($daysOld > 30) { @@ -847,7 +847,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getFunds() { - $list = array(); + $list = []; $sql = "select distinct * from " . "(select initcap(lower(FUND.FUND_NME)) as name from FUND) " . @@ -881,7 +881,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function findReserves($course, $inst, $dept) { - $recordList = array(); + $recordList = []; $dept = str_replace("'", "", $dept); $dept = str_replace("\"", "", $dept); @@ -951,7 +951,7 @@ class Amicus extends AbstractBase implements TranslatorAwareInterface */ public function getSuppressedRecords() { - $list = array(); + $list = []; $sql = "SELECT BIB_AUT_ITM_NBR as BIB_ID " . "FROM CTLGG_TRSTN_ACTVT_LOG " . "WHERE STATS_TRSTN_TYP_CDE = 4 " . diff --git a/module/VuFind/src/VuFind/ILS/Driver/ClaviusSQL.php b/module/VuFind/src/VuFind/ILS/Driver/ClaviusSQL.php index 52170665243..94bc4b2f79d 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/ClaviusSQL.php +++ b/module/VuFind/src/VuFind/ILS/Driver/ClaviusSQL.php @@ -153,7 +153,7 @@ class ClaviusSQL extends AbstractBase public function getDepartments() { if (!is_array($this->locations)) { - $this->locations = array(); + $this->locations = []; try { // TODO - overit/upavit funkcnost na MSSQL a Oracle $sqlLoc = "SELECT TRIM(lokace) as lokace, TRIM(jmeno) as jmeno " . @@ -182,12 +182,12 @@ class ClaviusSQL extends AbstractBase public function getFineTypes() { if (!is_array($this->fineTypes)) { - $this->fineTypes = array("G" => "Registracnàpoplatek", + $this->fineTypes = ["G" => "Registracnàpoplatek", "H" => "UpomÃÂnka", "J" => "Poplatek za rezervaci", "L" => "Poplatek za pujcenÃÂ", "M" => "Kauce za výpujcku" - ); + ]; // TODO MSsql Oracle $sql = "SELECT kod, nazev FROM defpopl"; try { @@ -252,11 +252,11 @@ class ClaviusSQL extends AbstractBase $sqlSt = $this->db->prepare($sql); $sqlSt->execute(); $result = $sqlSt->fetchAll(); - $return = array('count' => count($result), 'results' => array()); + $return = ['count' => count($result), 'results' => []]; foreach ($result as $row) { - $return['results'][] = array( + $return['results'][] = [ 'id' => $this->getLongId($row['tcislo'], $row['druhdoku']) - ); + ]; } return $return; } catch (PDOException $e) { @@ -322,7 +322,7 @@ class ClaviusSQL extends AbstractBase */ public function getHolding($id, array $patron = null) { - $holding = array(); + $holding = []; $originalId = $id; //if ($this->idPrefix) { $id = ltrim(substr($id, -11), "0"); } $id = $this->getShortID($id); @@ -336,12 +336,12 @@ class ClaviusSQL extends AbstractBase . "FROM kpujcky WHERE scislo = :scislo ORDER BY datum2 DESC LIMIT 1"; try { $sqlSt = $this->db->prepare($sql); - $sqlSt->execute(array(':id' => $id)); + $sqlSt->execute([':id' => $id]); $sqlSt2 = $this->db->prepare($sql2); /**** TODO reserve *******/ foreach ($sqlSt->fetchAll() as $item) { $reserve = "N"; - $sqlSt2->execute(array(':scislo' => $item['scislo'])); + $sqlSt2->execute([':scislo' => $item['scislo']]); $item2 = $sqlSt2->fetch(); if (!$item2) { $availability = true; @@ -353,7 +353,7 @@ class ClaviusSQL extends AbstractBase $duedate = $item2['duedate']; } $locs = $this->getDepartments(); - $holding[] = array( + $holding[] = [ 'id' => $originalId, //'location' => $item['location'], 'location' => $locs[$item['location']], @@ -366,7 +366,7 @@ class ClaviusSQL extends AbstractBase 'status' => $status, 'duedate' => $duedate, 'reserve' => $reserve, - ); + ]; } return $holding; } catch (PDOException $e) { @@ -422,7 +422,7 @@ class ClaviusSQL extends AbstractBase */ public function getMyFines($patron) { - $fines = array(); + $fines = []; $reasons = $this->getFineTypes(); // TODO mssql, oracle $sql = "SELECT scislo as amount, co as reason, " @@ -430,9 +430,9 @@ class ClaviusSQL extends AbstractBase . "FROM poplatky WHERE ccislo = :patronId ORDER BY datum DESC"; try { $sqlSt = $this->db->prepare($sql); - $sqlSt->execute(array(':patronId' => $patron['id'])); + $sqlSt->execute([':patronId' => $patron['id']]); foreach ($sqlSt->fetchAll() as $fine) { - $fines[] = array( + $fines[] = [ 'amount' => abs($fine['amount']), 'checkout' => null, // TODO maybe 'fine' => $reasons[$fine['reason']], @@ -440,7 +440,7 @@ class ClaviusSQL extends AbstractBase 'createdate' => $fine['createdate'], 'duedate' => null, // TODO maybe 'id' => null, // TODO maybe - ); + ]; } return $fines; } catch (PDOException $e) { @@ -468,11 +468,11 @@ class ClaviusSQL extends AbstractBase */ public function getPickUpLocations($patron = false, $holdDetails = null) { - $locations = array(); + $locations = []; foreach ($this->getDepartments() as $id => $text) { - $locations[] = array('locationID' => $id, + $locations[] = ['locationID' => $id, 'locationDisplay' => $text - ); + ]; } return $locations; } @@ -515,7 +515,7 @@ class ClaviusSQL extends AbstractBase public function getMyHolds($patron) { // TODO - return array(); + return []; } /** @@ -537,16 +537,16 @@ class ClaviusSQL extends AbstractBase */ public function getMyProfile($patron) { - $profile = array(); + $profile = []; $sql = "SELECT jmeno, tulice, tmesto, tpsc, telefon " . "FROM ctenari WHERE ccislo = :userId"; try { $sqlSt = $this->db->prepare($sql); - $sqlSt->execute(array(':userId' => $patron['id'])); + $sqlSt->execute([':userId' => $patron['id']]); $patron2 = $sqlSt->fetch(); $names = $this->explodeName($patron2['jmeno']); if ($patron2) { - $profile = array( + $profile = [ 'firstname' => $names['firstname'], 'lastname' => $names['lastname'], 'address1' => $patron2['tulice'], @@ -554,7 +554,7 @@ class ClaviusSQL extends AbstractBase 'zip' => $patron2['tpsc'], 'phone' => $patron2['telefon'] ? $patron2['telefon'] : null, 'group' => null //TODO - Maybe - ); + ]; } } catch (PDOException $e) { throw new ILSException($e->getMessage()); @@ -578,7 +578,7 @@ class ClaviusSQL extends AbstractBase public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -616,7 +616,7 @@ class ClaviusSQL extends AbstractBase */ public function getStatuses($idLst) { - $statusLst = array(); + $statusLst = []; foreach ($idLst as $id) { $statusLst[] = $this->getStatus($id); } @@ -632,7 +632,7 @@ class ClaviusSQL extends AbstractBase public function getSuppressedRecords() { // TODO - MAYBE - return array(); + return []; } /** @@ -644,7 +644,7 @@ class ClaviusSQL extends AbstractBase */ protected function explodeName($name) { - $names = array(); + $names = []; $nameArray = explode(" ", $name); $names['lastname'] = array_pop($nameArray); $names['firstname'] = implode(" ", $nameArray); @@ -746,7 +746,7 @@ class ClaviusSQL extends AbstractBase . " pin, pohlavi FROM ctenari WHERE ccislo = :userId"; try { $sqlStPatron = $this->db->prepare($sqlPatron); - $sqlStPatron->execute(array(':userId' => $username)); + $sqlStPatron->execute([':userId' => $username]); $patronRow = $sqlStPatron->fetch(); if (!$patronRow) { return null; @@ -767,7 +767,7 @@ class ClaviusSQL extends AbstractBase } } $names = $this->explodeName($patronRow['jmeno']); - $patron = array( + $patron = [ 'id' => $patronRow['ccislo'], 'firstname' => $names['firstname'], 'lastname' => $names['lastname'], @@ -776,7 +776,7 @@ class ClaviusSQL extends AbstractBase 'email' => $patronRow['mail'] ? $patronRow['mail'] : null, 'major' => null, 'college' => null - ); + ]; return $patron; } @@ -825,13 +825,13 @@ class ClaviusSQL extends AbstractBase WHERE k.ccislo = :userId AND k.co = :action"; try { $sqlSt = $this->db->prepare($sql); - $sqlSt->execute(array(':userId' => $user['id'], ':action' => 'P')); - $transactions = array(); + $sqlSt->execute([':userId' => $user['id'], ':action' => 'P']); + $transactions = []; foreach ($sqlSt->fetchAll() as $item) { $id = $this->getLongId($item['tcislo'], $item['druhdoku']); //TODO - requests //$requestsSql = ""; - $transactions[] = array( + $transactions[] = [ 'duedate' => $item['duedate'], 'id' => $id, 'barcode' => $item['duedate'], @@ -843,7 +843,7 @@ class ClaviusSQL extends AbstractBase 'message' => '', 'title' => $item['title'], 'item_id' => $item['item_id'] // TODO - maybe for renewals - ); + ]; } return $transactions; } catch (PDOException $e) { diff --git a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php index 55005c81a07..c98017ef1f7 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php @@ -120,7 +120,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface */ public function getStatuses($ids) { - $items = array(); + $items = []; foreach ($ids as $id) { $items[] = $this->getShortStatus($id); } @@ -173,7 +173,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -206,7 +206,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface $daia = $this->queryDAIA($id); // get Availability information from DAIA $documentlist = $daia->getElementsByTagName('document'); - $status = array(); + $status = []; for ($b = 0; $documentlist->item($b) !== null; $b++) { $itemlist = $documentlist->item($b)->getElementsByTagName('item'); $ilslink = ''; @@ -214,7 +214,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface $ilslink = $documentlist->item($b)->attributes ->getNamedItem('href')->nodeValue; } - $emptyResult = array( + $emptyResult = [ 'callnumber' => '-', 'availability' => '0', 'number' => 1, @@ -228,9 +228,9 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface 'location' => '', 'ilslink' => $ilslink, 'label' => 'No samples' - ); + ]; for ($c = 0; $itemlist->item($c) !== null; $c++) { - $result = array( + $result = [ 'callnumber' => '', 'availability' => '0', 'number' => ($c+1), @@ -247,8 +247,8 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface 'location.id' => '', 'location.href' => '', 'label' => '', - 'notes' => array() - ); + 'notes' => [] + ]; $result['item_id'] = $itemlist->item($c)->attributes ->getNamedItem('id')->nodeValue; if ($itemlist->item($c)->attributes->getNamedItem('href') !== null) { @@ -467,7 +467,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface $label = "Unknown"; $storage = "Unknown"; $presenceOnly = '1'; - $holding = array(); + $holding = []; for ($c = 0; $itemlist->item($c) !== null; $c++) { $earliest_href = ''; $storageElements = $itemlist->item($c)->getElementsByTagName('storage'); @@ -506,9 +506,9 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface $unavailableElements = $itemlist->item($c) ->getElementsByTagName('unavailable'); if ($unavailableElements->item(0) !== null) { - $earliest = array(); - $queue = array(); - $hrefs = array(); + $earliest = []; + $queue = []; + $hrefs = []; for ($n = 0; $unavailableElements->item($n) !== null; $n++) { $unavailHref = $unavailableElements->item($n)->attributes ->getNamedItem('href'); @@ -573,7 +573,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface if ($earliest_queue > 0) { $reserve = 'Y'; } - $holding[] = array('availability' => $availability, + $holding[] = ['availability' => $availability, 'id' => $id, 'status' => "$status", 'location' => "$storage", @@ -584,7 +584,7 @@ class DAIA extends AbstractBase implements \Zend\Log\LoggerAwareInterface 'leanable' => $leanable, 'recallhref' => $earliest_href, 'number' => ($c+1), - 'presenceOnly' => $presenceOnly); + 'presenceOnly' => $presenceOnly]; } return $holding; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Demo.php b/module/VuFind/src/VuFind/ILS/Driver/Demo.php index 56331a390fe..f765b99e447 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Demo.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Demo.php @@ -228,7 +228,7 @@ class Demo extends AbstractBase protected function getRandomHolding($id, $number, array $patron = null) { $status = $this->getFakeStatus(); - return array( + return [ 'id' => $id, 'source' => $this->getRecordSource(), 'item_id' => $number, @@ -251,7 +251,7 @@ class Demo extends AbstractBase 'addILLRequestLink' => $patron ? rand()%10 == 0 ? 'block' : 'check' : false - ); + ]; } /** @@ -264,13 +264,13 @@ class Demo extends AbstractBase { switch (rand(1, 4)) { case 1: - return array('isbn' => '1558612742'); + return ['isbn' => '1558612742']; case 2: - return array('oclc' => '55114477'); + return ['oclc' => '55114477']; case 3: - return array('issn' => '1133-0686'); + return ['issn' => '1133-0686']; } - return array('upc' => '733961100525'); + return ['upc' => '733961100525']; } /** @@ -293,14 +293,14 @@ class Demo extends AbstractBase for ($i = 0; $i < $items; $i++) { $location = $this->getFakeLoc(false); $randDays = rand() % 10; - $currentItem = array( + $currentItem = [ "location" => $location, "create" => date("j-M-y", strtotime("now - {$randDays} days")), "expire" => date("j-M-y", strtotime("now + 30 days")), "reqnum" => sprintf("%06d", $i), "item_id" => $i, "reqnum" => $i - ); + ]; // Inject a random identifier of some sort: $currentItem += $this->getRandomItemIdentifier(); if ($i == 2 || rand()%5 == 1) { @@ -386,7 +386,7 @@ class Demo extends AbstractBase $id = $id . ""; // make it a string for consistency // How many items are there? $records = rand()%15; - $holding = array(); + $holding = []; // NOTE: Ran into an interesting bug when using: @@ -421,7 +421,7 @@ class Demo extends AbstractBase * * @return array */ - public function setStatus($id, $holding = array(), $append = true) + public function setStatus($id, $holding = [], $append = true) { $id = (string)$id; $i = ($this->session->statuses) ? count($this->session->statuses)+1 : 1; @@ -435,11 +435,11 @@ class Demo extends AbstractBase $this->session->statuses[$id][] = $holding; } else { // if we're over-writing or if there's nothing stored for this id - $this->session->statuses[$id] = array($holding); + $this->session->statuses[$id] = [$holding]; } } else { // brand new status storage! - $this->session->statuses = array($id => array($holding)); + $this->session->statuses = [$id => [$holding]]; } return $holding; } @@ -456,10 +456,10 @@ class Demo extends AbstractBase $id = (string)$id; // if statuses is already stored if ($this->session->statuses) { - $this->session->statuses[$id] = array(); + $this->session->statuses[$id] = []; } else { // brand new status storage! - $this->session->statuses = array($id => array()); + $this->session->statuses = [$id => []]; } } @@ -495,7 +495,7 @@ class Demo extends AbstractBase // Random Seed srand(time()); - $status = array(); + $status = []; foreach ($ids as $id) { $status[] = $this->getStatus($id); } @@ -524,12 +524,12 @@ class Demo extends AbstractBase foreach (array_keys($status) as $i) { $itemNum = $i + 1; $noteCount = rand(1, 3); - $status[$i]['notes'] = array(); + $status[$i]['notes'] = []; for ($j = 1; $j <= $noteCount; $j++) { $status[$i]['notes'][] = "Item $itemNum note $j"; } $summCount = rand(1, 3); - $status[$i]['summary'] = array(); + $status[$i]['summary'] = []; for ($j = 1; $j <= $summCount; $j++) { $status[$i]['summary'][] = "Item $itemNum summary $j"; } @@ -552,9 +552,9 @@ class Demo extends AbstractBase public function getPurchaseHistory($id) { $issues = rand(0, 3); - $retval = array(); + $retval = []; for ($i = 0; $i < $issues; $i++) { - $retval[] = array('issue' => 'issue ' . ($i + 1)); + $retval[] = ['issue' => 'issue ' . ($i + 1)]; } return $retval; } @@ -573,7 +573,7 @@ class Demo extends AbstractBase */ public function patronLogin($barcode, $password) { - $user = array(); + $user = []; $user['id'] = trim($barcode); $user['firstname'] = trim("Lib"); @@ -598,7 +598,7 @@ class Demo extends AbstractBase */ public function getMyProfile($patron) { - $patron = array( + $patron = [ 'firstname' => 'Lib', 'lastname' => 'Rarian', 'address1' => 'Somewhere...', @@ -608,7 +608,7 @@ class Demo extends AbstractBase 'country' => 'Country', 'phone' => '1900 CALL ME', 'group' => 'Library Staff' - ); + ]; return $patron; } @@ -630,7 +630,7 @@ class Demo extends AbstractBase // 90% of 1-18 (give or take some odd maths) $fines = rand()%20 - 2; - $fineList = array(); + $fineList = []; for ($i = 0; $i < $fines; $i++) { // How many days overdue is the item? $day_overdue = rand()%30 + 5; @@ -639,7 +639,7 @@ class Demo extends AbstractBase // 50c a day fine? $fine = $day_overdue * 0.50; - $fineList[] = array( + $fineList[] = [ "amount" => $fine * 100, "checkout" => date("j-M-y", $checkout), // After 20 days it becomes 'Long Overdue' @@ -648,7 +648,7 @@ class Demo extends AbstractBase "balance" => (rand()%100 > 49 ? $fine/2 : $fine) * 100, "duedate" => date("j-M-y", strtotime("now - $day_overdue days")) - ); + ]; // Some fines will have no id or title: if (rand() % 3 != 1) { if ($this->idsInMyResearch) { @@ -742,7 +742,7 @@ class Demo extends AbstractBase // 90% of 1-9 (give or take some odd maths) $trans = rand()%10 - 1; - $transList = array(); + $transList = []; for ($i = 0; $i < $trans; $i++) { // When is it due? +/- up to 15 days $due_relative = rand()%30 - 15; @@ -775,7 +775,7 @@ class Demo extends AbstractBase if ($i == 2 || rand()%5 == 1) { // Mimic an ILL loan - $transList[] = $this->getRandomItemIdentifier() + array( + $transList[] = $this->getRandomItemIdentifier() + [ 'duedate' => $due_date, 'dueStatus' => $dueStatus, 'barcode' => sprintf("%08d", rand()%50000), @@ -790,9 +790,9 @@ class Demo extends AbstractBase 'institution_name' => 'ILL Library', 'institution_dbkey' => 'ill_institution', 'borrowingLocation' => 'ILL Service Desk' - ); + ]; } else { - $transList[] = $this->getRandomItemIdentifier() + array( + $transList[] = $this->getRandomItemIdentifier() + [ 'duedate' => $due_date, 'dueStatus' => $dueStatus, 'barcode' => sprintf("%08d", rand()%50000), @@ -802,7 +802,7 @@ class Demo extends AbstractBase 'item_id' => $i, 'renewable' => $renew < $renewLimit, 'borrowingLocation' => $this->getFakeLoc() - ); + ]; if ($this->idsInMyResearch) { $transList[$i]['id'] = $this->getRandomBibId(); $transList[$i]['source'] = $this->getRecordSource(); @@ -837,20 +837,20 @@ class Demo extends AbstractBase */ public function getPickUpLocations($patron = false, $holdDetails = null) { - return array( - array( + return [ + [ 'locationID' => 'A', 'locationDisplay' => 'Campus A' - ), - array( + ], + [ 'locationID' => 'B', 'locationDisplay' => 'Campus B' - ), - array( + ], + [ 'locationID' => 'C', 'locationDisplay' => 'Campus C' - ) - ); + ] + ]; } /** @@ -932,16 +932,16 @@ class Demo extends AbstractBase */ public function getRequestGroups($bibId = null, $patron = null) { - return array( - array( + return [ + [ 'id' => 1, 'name' => 'Main Library' - ), - array( + ], + [ 'id' => 2, 'name' => 'Branch Library' - ) - ); + ] + ]; } /** @@ -953,7 +953,7 @@ class Demo extends AbstractBase */ public function getFunds() { - return array("Fund A", "Fund B", "Fund C"); + return ["Fund A", "Fund B", "Fund C"]; } /** @@ -965,7 +965,7 @@ class Demo extends AbstractBase */ public function getDepartments() { - return array("Dept. A", "Dept. B", "Dept. C"); + return ["Dept. A", "Dept. B", "Dept. C"]; } /** @@ -977,7 +977,7 @@ class Demo extends AbstractBase */ public function getInstructors() { - return array("Instructor A", "Instructor B", "Instructor C"); + return ["Instructor A", "Instructor B", "Instructor C"]; } /** @@ -989,7 +989,7 @@ class Demo extends AbstractBase */ public function getCourses() { - return array("Course A", "Course B", "Course C"); + return ["Course A", "Course B", "Course C"]; } /** @@ -1016,7 +1016,7 @@ class Demo extends AbstractBase // Pick a random number of results to return -- don't exceed limit or 30, // whichever is smaller (this can be pretty slow due to the random ID code). $count = rand(0, $limit > 30 ? 30 : $limit); - $results = array(); + $results = []; for ($x = 0; $x < $count; $x++) { $randomId = $this->getRandomBibId(); @@ -1025,9 +1025,9 @@ class Demo extends AbstractBase $results[] = $randomId; } } - $retVal = array('count' => count($results), 'results' => array()); + $retVal = ['count' => count($results), 'results' => []]; foreach ($results as $result) { - $retVal['results'][] = array('id' => $result); + $retVal['results'][] = ['id' => $result]; } return $retVal; } @@ -1049,7 +1049,7 @@ class Demo extends AbstractBase { // Pick a random number of results to return -- don't exceed 30. $count = rand(0, 30); - $results = array(); + $results = []; for ($x = 0; $x < $count; $x++) { $randomId = $this->getRandomBibId(); @@ -1059,9 +1059,9 @@ class Demo extends AbstractBase } } - $retVal = array(); + $retVal = []; foreach ($results as $current) { - $retVal[] = array('BIB_ID' => $current); + $retVal[] = ['BIB_ID' => $current]; } return $retVal; } @@ -1082,7 +1082,7 @@ class Demo extends AbstractBase // Rewrite the holds in the session, removing those the user wants to // cancel. $newHolds = new ArrayObject(); - $retVal = array('count' => 0, 'items' => array()); + $retVal = ['count' => 0, 'items' => []]; foreach ($this->session->holds as $current) { if (!in_array($current['reqnum'], $cancelDetails['details'])) { $newHolds->append($current); @@ -1090,19 +1090,19 @@ class Demo extends AbstractBase // 50% chance of cancel failure for testing purposes if (rand() % 2) { $retVal['count']++; - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => true, 'status' => 'hold_cancel_success' - ); + ]; } else { $newHolds->append($current); - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => false, 'status' => 'hold_cancel_fail', 'sysMessage' => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } } } @@ -1145,7 +1145,7 @@ class Demo extends AbstractBase // Rewrite the items in the session, removing those the user wants to // cancel. $newRequests = new ArrayObject(); - $retVal = array('count' => 0, 'items' => array()); + $retVal = ['count' => 0, 'items' => []]; foreach ($this->session->storageRetrievalRequests as $current) { if (!in_array($current['reqnum'], $cancelDetails['details'])) { $newRequests->append($current); @@ -1153,19 +1153,19 @@ class Demo extends AbstractBase // 50% chance of cancel failure for testing purposes if (rand() % 2) { $retVal['count']++; - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => true, 'status' => 'storage_retrieval_request_cancel_success' - ); + ]; } else { $newRequests->append($current); - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => false, 'status' => 'storage_retrieval_request_cancel_fail', 'sysMessage' => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } } } @@ -1206,15 +1206,15 @@ class Demo extends AbstractBase { // Simulate an account block at random. if (rand() % 4 == 1) { - return array( - 'blocks' => array( + return [ + 'blocks' => [ 'Simulated account block; try again and it will work eventually.' - ) - ); + ] + ]; } // Set up successful return value. - $finalResult = array('blocks' => false, 'details' => array()); + $finalResult = ['blocks' => false, 'details' => []]; // Grab transactions from session so we can modify them: $transactions = $this->session->transactions; @@ -1230,21 +1230,21 @@ class Demo extends AbstractBase = $transactions[$i]['renew'] < $transactions[$i]['renewLimit']; - $finalResult['details'][$current['item_id']] = array( + $finalResult['details'][$current['item_id']] = [ "success" => true, "new_date" => $transactions[$i]['duedate'], "new_time" => '', "item_id" => $current['item_id'], - ); + ]; } else { - $finalResult['details'][$current['item_id']] = array( + $finalResult['details'][$current['item_id']] = [ "success" => false, "new_date" => false, "item_id" => $current['item_id'], "sysMessage" => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } } } @@ -1309,12 +1309,12 @@ class Demo extends AbstractBase { // Simulate failure: if (rand() % 2) { - return array( + return [ "success" => false, "sysMessage" => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } if (!isset($this->session->holds)) { @@ -1336,15 +1336,15 @@ class Demo extends AbstractBase ); } catch (DateException $e) { // Expiration date is invalid - return array( + return [ 'success' => false, 'sysMessage' => 'hold_date_invalid' - ); + ]; } } if ($expire <= time()) { - return array( + return [ 'success' => false, 'sysMessage' => 'hold_date_past' - ); + ]; } $requestGroup = ''; @@ -1357,7 +1357,7 @@ class Demo extends AbstractBase } } $this->session->holds->append( - array( + [ 'id' => $holdDetails['id'], 'source' => $this->getRecordSource(), 'location' => $holdDetails['pickUpLocation'], @@ -1368,10 +1368,10 @@ class Demo extends AbstractBase 'volume' => '', 'processed' => '', 'requestGroup' => $requestGroup - ) + ] ); - return array('success' => true); + return ['success' => true]; } /** @@ -1409,19 +1409,19 @@ class Demo extends AbstractBase public function placeStorageRetrievalRequest($details) { if (!$this->storageRetrievalRequests) { - return array( + return [ "success" => false, "sysMessage" => 'Storage Retrieval Requests are disabled.' - ); + ]; } // Simulate failure: if (rand() % 2) { - return array( + return [ "success" => false, "sysMessage" => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } if (!isset($this->session->storageRetrievalRequests)) { @@ -1444,21 +1444,21 @@ class Demo extends AbstractBase ); } catch (DateException $e) { // Expiration date is invalid - return array( + return [ 'success' => false, 'sysMessage' => 'storage_retrieval_request_date_invalid' - ); + ]; } } if ($expire <= time()) { - return array( + return [ 'success' => false, 'sysMessage' => 'storage_retrieval_request_date_past' - ); + ]; } $this->session->storageRetrievalRequests->append( - array( + [ 'id' => $details['id'], 'source' => $this->getRecordSource(), 'location' => $details['pickUpLocation'], @@ -1467,10 +1467,10 @@ class Demo extends AbstractBase 'processed' => rand()%3 == 0 ? date('j-M-y', $expire) : '', 'reqnum' => sprintf('%06d', $nextId), 'item_id' => $nextId - ) + ] ); - return array('success' => true); + return ['success' => true]; } /** @@ -1508,19 +1508,19 @@ class Demo extends AbstractBase public function placeILLRequest($details) { if (!$this->ILLRequests) { - return array( + return [ 'success' => false, 'sysMessage' => 'ILL requests are disabled.' - ); + ]; } // Simulate failure: if (rand() % 2) { - return array( + return [ 'success' => false, 'sysMessage' => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } if (!isset($this->session->ILLRequests)) { @@ -1543,17 +1543,17 @@ class Demo extends AbstractBase ); } catch (DateException $e) { // Expiration Date is invalid - return array( + return [ 'success' => false, 'sysMessage' => 'ill_request_date_invalid' - ); + ]; } } if ($expire <= time()) { - return array( + return [ 'success' => false, 'sysMessage' => 'ill_request_date_past' - ); + ]; } // Verify pickup library and location @@ -1570,14 +1570,14 @@ class Demo extends AbstractBase } } if (!$pickupLocation) { - return array( + return [ 'success' => false, 'sysMessage' => 'ill_request_place_fail_missing' - ); + ]; } $this->session->ILLRequests->append( - array( + [ 'id' => $details['id'], 'source' => $this->getRecordSource(), 'location' => $pickupLocation, @@ -1586,10 +1586,10 @@ class Demo extends AbstractBase 'processed' => rand()%3 == 0 ? date('j-M-y', $expire) : '', 'reqnum' => sprintf('%06d', $nextId), 'item_id' => $nextId - ) + ] ); - return array('success' => true); + return ['success' => true]; } /** @@ -1611,18 +1611,18 @@ class Demo extends AbstractBase return false; } - $details = array( - array( + $details = [ + [ 'id' => 1, 'name' => 'Main Library', 'isDefault' => true - ), - array( + ], + [ 'id' => 2, 'name' => 'Branch Library', 'isDefault' => false - ) - ); + ] + ]; return $details; } @@ -1645,33 +1645,33 @@ class Demo extends AbstractBase { switch ($pickupLib) { case 1: - return array( - array( + return [ + [ 'id' => 1, 'name' => 'Circulation Desk', 'isDefault' => true - ), - array( + ], + [ 'id' => 2, 'name' => 'Reference Desk', 'isDefault' => false - ) - ); + ] + ]; case 2: - return array( - array( + return [ + [ 'id' => 3, 'name' => 'Main Desk', 'isDefault' => false - ), - array( + ], + [ 'id' => 4, 'name' => 'Library Bus', 'isDefault' => true - ) - ); + ] + ]; } - return array(); + return []; } /** @@ -1691,7 +1691,7 @@ class Demo extends AbstractBase // Rewrite the items in the session, removing those the user wants to // cancel. $newRequests = new ArrayObject(); - $retVal = array('count' => 0, 'items' => array()); + $retVal = ['count' => 0, 'items' => []]; foreach ($this->session->ILLRequests as $current) { if (!in_array($current['reqnum'], $cancelDetails['details'])) { $newRequests->append($current); @@ -1699,19 +1699,19 @@ class Demo extends AbstractBase // 50% chance of cancel failure for testing purposes if (rand() % 2) { $retVal['count']++; - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => true, 'status' => 'ill_request_cancel_success' - ); + ]; } else { $newRequests->append($current); - $retVal['items'][$current['item_id']] = array( + $retVal['items'][$current['item_id']] = [ 'success' => false, 'status' => 'ill_request_cancel_fail', 'sysMessage' => 'Demonstrating failure; keep trying and ' . 'it will work eventually.' - ); + ]; } } } @@ -1751,14 +1751,14 @@ class Demo extends AbstractBase public function changePassword($details) { if (rand() % 3) { - return array('success' => true, 'status' => 'change_password_ok'); + return ['success' => true, 'status' => 'change_password_ok']; } - return array( + return [ 'success' => false, 'status' => 'An error has occurred', 'sysMessage' => 'Demonstrating failure; keep trying and it will work eventually.' - ); + ]; } /** @@ -1774,25 +1774,25 @@ class Demo extends AbstractBase public function getConfig($function, $params = null) { if ($function == 'Holds') { - return array( + return [ 'HMACKeys' => 'id:item_id:level', 'extraHoldFields' => 'comments:requestGroup:pickUpLocation:requiredByDate', 'defaultRequiredDate' => 'driver:0:2:0', - ); + ]; } if ($function == 'StorageRetrievalRequests' && $this->storageRetrievalRequests ) { - return array( + return [ 'HMACKeys' => 'id', 'extraFields' => 'comments:pickUpLocation:requiredByDate:item-issue', 'helpText' => 'This is a storage retrieval request help text' . ' with some <span style="color: red">styling</span>.' - ); + ]; } if ($function == 'ILLRequests' && $this->ILLRequests) { - return array( + return [ 'enabled' => true, 'HMACKeys' => 'number', 'extraFields' => @@ -1800,14 +1800,14 @@ class Demo extends AbstractBase 'defaultRequiredDate' => '0:1:0', 'helpText' => 'This is an ILL request help text' . ' with some <span style="color: red">styling</span>.' - ); + ]; } if ($function == 'changePassword') { - return array( + return [ 'minLength' => 4, 'maxLength' => 20 - ); + ]; } - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php b/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php index c672f4f7fc4..aba199a9d77 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php @@ -107,7 +107,7 @@ class Evergreen extends AbstractBase */ public function getStatus($id) { - $holding = array(); + $holding = []; // Build SQL Statement $sql = <<<HERE @@ -121,7 +121,7 @@ HERE; // Execute SQL try { - $holding = array(); + $holding = []; $sqlStmt = $this->db->prepare($sql); $sqlStmt->bindParam(1, $id, PDO::PARAM_INT); $sqlStmt->execute(); @@ -146,14 +146,14 @@ HERE; break; } - $holding[] = array( + $holding[] = [ 'id' => $id, 'availability' => $available, 'status' => $row['status'], 'location' => $row['location'], 'reserve' => $reserve, 'callnumber' => $row['callnumber'] - ); + ]; } return $holding; @@ -172,7 +172,7 @@ HERE; */ public function getStatuses($idList) { - $status = array(); + $status = []; foreach ($idList as $id) { $status[] = $this->getStatus($id); } @@ -196,7 +196,7 @@ HERE; */ public function getHolding($id, array $patron = null) { - $holding = array(); + $holding = []; // Build SQL Statement $sql = <<<HERE @@ -252,7 +252,7 @@ HERE; } else { $due_date = ""; } - $holding[] = array( + $holding[] = [ 'id' => $id, 'availability' => $available, 'status' => $row['status'], @@ -262,7 +262,7 @@ HERE; 'duedate' => $due_date, 'number' => $row['copy_number'], 'barcode' => $row['barcode'] - ); + ]; } return $holding; @@ -284,7 +284,7 @@ HERE; public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -324,7 +324,7 @@ HERE; $sqlStmt->execute(); $row = $sqlStmt->fetch(PDO::FETCH_ASSOC); if (isset($row['id']) && ($row['id'] != '')) { - $return = array(); + $return = []; $return['id'] = $row['id']; $return['firstname'] = $row['firstname']; $return['lastname'] = $row['lastname']; @@ -356,7 +356,7 @@ HERE; */ public function getMyTransactions($patron) { - $transList = array(); + $transList = []; $sql = "select circulation.target_copy as bib_id, " . "extract (year from circulation.due_date) as due_year, " . @@ -378,8 +378,8 @@ HERE; $due_date = ""; } - $transList[] = array('duedate' => $due_date, - 'id' => $row['bib_id']); + $transList[] = ['duedate' => $due_date, + 'id' => $row['bib_id']]; } return $transList; } catch (PDOException $e) { @@ -400,7 +400,7 @@ HERE; */ public function getMyFines($patron) { - $fineList = array(); + $fineList = []; $sql = "select billable_xact_summary.total_owed, " . "billable_xact_summary.balance_owed, " . @@ -431,12 +431,12 @@ HERE; $charge_date = ""; } - $fineList[] = array('amount' => $row['total_owed'], + $fineList[] = ['amount' => $row['total_owed'], 'fine' => $row['last_billing_type'], 'balance' => $row['balance_owed'], 'checkout' => $charge_date, 'duedate' => "", - 'id' => $row['target_copy']); + 'id' => $row['target_copy']]; } return $fineList; } catch (PDOException $e) { @@ -457,7 +457,7 @@ HERE; */ public function getMyHolds($patron) { - $holdList = array(); + $holdList = []; $sql = "select hold_request.hold_type, hold_request.current_copy, " . "extract (year from hold_request.expire_time) as exp_year, " . @@ -492,11 +492,11 @@ HERE; $exp_time = ""; } - $holdList[] = array('type' => $row['hold_type'], + $holdList[] = ['type' => $row['hold_type'], 'id' => $row['current_copy'], 'location' => $row['lib_name'], 'expire' => $exp_time, - 'create' => $req_time); + 'create' => $req_time]; } return $holdList; } catch (PDOException $e) { @@ -542,7 +542,7 @@ HERE; } if ($row) { - $patron = array( + $patron = [ 'firstname' => $row['first_given_name'], 'lastname' => $row['family_name'], 'address1' => $row['street1'], @@ -550,7 +550,7 @@ HERE; 'zip' => $row['post_code'], 'phone' => $phone, 'group' => $row['usrgroup'] - ); + ]; return $patron; } else { return null; @@ -639,7 +639,7 @@ HERE; */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - $items = array(); + $items = []; // Prevent unnecessary load // (Taken from Voyager driver - does Evergreen need this?) @@ -723,7 +723,7 @@ HERE; */ public function getSuppressedRecords() { - $list = array(); + $list = []; $sql = "select copy.id as id " . "from $this->dbName.asset " . @@ -755,7 +755,7 @@ HERE; public function getDepartments() { // TODO - return array(); + return []; } /** @@ -769,7 +769,7 @@ HERE; public function getInstructors() { // TODO - return array(); + return []; } /** @@ -783,7 +783,7 @@ HERE; public function getCourses() { // TODO - return array(); + return []; } /** @@ -803,6 +803,6 @@ HERE; public function findReserves($course, $inst, $dept) { // TODO - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Horizon.php b/module/VuFind/src/VuFind/ILS/Driver/Horizon.php index 6f4f06fa74c..18abd094605 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Horizon.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Horizon.php @@ -187,11 +187,11 @@ class Horizon extends AbstractBase } } - $statusValues = array('available' => $available, - 'reserve' => $reserve); + $statusValues = ['available' => $available, + 'reserve' => $reserve]; if (isset($duedate)) { - $statusValues += array('duedate' => $duedate); + $statusValues += ['duedate' => $duedate]; } return $statusValues; } @@ -208,7 +208,7 @@ class Horizon extends AbstractBase // Query holding information based on id field defined in // import/marc.properties // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "i.item# as ITEM_ID", "i.item_status as STATUS_CODE", "ist.descr as STATUS", @@ -229,34 +229,34 @@ class Horizon extends AbstractBase "i.notes as NOTES", "ist.available_for_request IS_HOLDABLE", - ); + ]; // From - $sqlFrom = array("item i"); + $sqlFrom = ["item i"]; // inner Join - $sqlInnerJoin = array( + $sqlInnerJoin = [ "item_status ist on i.item_status = ist.item_status", "location l on i.location = l.location", - ); + ]; - $sqlLeftOuterJoin = array( + $sqlLeftOuterJoin = [ "circ_history ch on ch.item# = i.item#" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "i.bib# = " . addslashes($id), "i.staff_only = 0" - ); + ]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'innerJoin' => $sqlInnerJoin, 'leftOuterJoin' => $sqlLeftOuterJoin, 'where' => $sqlWhere - ); + ]; return $sqlArray; } @@ -284,7 +284,7 @@ class Horizon extends AbstractBase $duedate = $statusValues['duedate']; } - $holding = array( + $holding = [ 'id' => $id, 'availability' => $statusValues['available'], 'item_id' => $row['ITEM_ID'], @@ -298,16 +298,16 @@ class Horizon extends AbstractBase 'requests_placed' => $row['REQUEST'], 'is_holdable' => $row['IS_HOLDABLE'], - ); + ]; // Only set the number key if there is actually volume data if ($row['NUMBER'] != '') { - $holding += array('number' => $row['NUMBER']); + $holding += ['number' => $row['NUMBER']]; } // Only set the notes key if there are actually notes to display if ($row['NOTES'] != '') { - $holding += array('notes' => array($row['NOTES'])); + $holding += ['notes' => [$row['NOTES']]]; } return $holding; @@ -334,7 +334,7 @@ class Horizon extends AbstractBase $sql = $this->buildSqlFromArray($sqlArray); try { - $holding = array(); + $holding = []; $sqlStmt = mssql_query($sql); while ($row = mssql_fetch_assoc($sqlStmt)) { $holding[] = $this->processHoldingRow($id, $row, $patron); @@ -358,12 +358,12 @@ class Horizon extends AbstractBase $item_status = $row['STATUS_CODE']; //get the item status code $statusValues = $this->parseStatus($item_status); - $status = array('id' => $id, + $status = ['id' => $id, 'availability' => $statusValues['available'], 'status' => $row['STATUS'], 'location' => $row['LOCATION'], 'reserve' => $statusValues['reserve'], - 'callnumber' => $row['CALLNUMBER']); + 'callnumber' => $row['CALLNUMBER']]; return $status; } @@ -382,7 +382,7 @@ class Horizon extends AbstractBase */ public function getStatus($id) { - $idList = array($id); + $idList = [$id]; $status = $this->getStatuses($idList); return current($status); } @@ -399,29 +399,29 @@ class Horizon extends AbstractBase // Query holding information based on id field defined in // import/marc.properties // Expressions - $sqlExpressions = array("i.bib# as ID", + $sqlExpressions = ["i.bib# as ID", "i.item_status as STATUS_CODE", "ist.descr as STATUS", "l.name as LOCATION", - "i.call_reconstructed as CALLNUMBER"); + "i.call_reconstructed as CALLNUMBER"]; // From - $sqlFrom = array("item i"); + $sqlFrom = ["item i"]; // inner Join - $sqlInnerJoin = array("item_status ist on i.item_status = ist.item_status", - "location l on i.location = l.location"); + $sqlInnerJoin = ["item_status ist on i.item_status = ist.item_status", + "location l on i.location = l.location"]; $bibIDs = implode(',', $idList); // Where - $sqlWhere = array("i.bib# in (" . $bibIDs . ")", - "i.staff_only = 0"); + $sqlWhere = ["i.bib# in (" . $bibIDs . ")", + "i.staff_only = 0"]; - $sqlArray = array('expressions' => $sqlExpressions, + $sqlArray = ['expressions' => $sqlExpressions, 'from' => $sqlFrom, 'innerJoin' => $sqlInnerJoin, - 'where' => $sqlWhere); + 'where' => $sqlWhere]; return $sqlArray; } @@ -447,14 +447,14 @@ class Horizon extends AbstractBase // Skip DB call if we have no valid IDs. if (empty($idList)) { - return array(); + return []; } $sqlArray = $this->getStatusesSQL($idList); $sql = $this->buildSqlFromArray($sqlArray); try { - $status = array(); + $status = []; $sqlStmt = mssql_query($sql); while ($row = mssql_fetch_assoc($sqlStmt)) { $id = $row['ID']; @@ -479,7 +479,7 @@ class Horizon extends AbstractBase */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -506,19 +506,19 @@ class Horizon extends AbstractBase "\" and pin# = \"" . addslashes($password) . "\""; try { - $user = array(); + $user = []; $sqlStmt = mssql_query($sql); $row = mssql_fetch_assoc($sqlStmt); if ($row) { list($lastname,$firstname) = explode(', ', $row['FULLNAME']); - $user = array('id' => $username, + $user = ['id' => $username, 'firstname' => $firstname, 'lastname' => $lastname, 'cat_username' => $username, 'cat_password' => $password, 'email' => $row['EMAIL'], 'major' => null, - 'college' => null); + 'college' => null]; return $user; } else { @@ -539,7 +539,7 @@ class Horizon extends AbstractBase protected function getHoldsSQL($patron) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "r.bib# as BIB_NUM", "r.request# as REQNUM", "r.item# as ITEM_ID", @@ -559,42 +559,42 @@ class Horizon extends AbstractBase "as REQUEST_EXPIRE", "convert(varchar(12),dateadd(dd, r.request_date, '1 jan 1970')) " . "as CREATED" - ); + ]; // From - $sqlFrom = array("request r"); + $sqlFrom = ["request r"]; // Join - $sqlJoin = array( + $sqlJoin = [ "borrower_barcode bb on bb.borrower# = r.borrower#", "location l on l.location = r.pickup_location", "title t on t.bib# = r.bib#" - ); + ]; - $sqlLeftOuterJoin = array( + $sqlLeftOuterJoin = [ "item i on i.item# = r.item#", "pubdate_inverted p on p.bib# = r.bib#" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "bb.bbarcode=\"" . addslashes($patron['id']) . "\"" - ); + ]; - $sqlOrder = array( + $sqlOrder = [ "SORT", "t.processed" - ); + ]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'join' => $sqlJoin, 'leftOuterJoin' => $sqlLeftOuterJoin, 'where' => $sqlWhere, 'order' => $sqlOrder - ); + ]; return $sqlArray; } @@ -638,7 +638,7 @@ class Horizon extends AbstractBase ); } - return array( + return [ 'id' => $row['BIB_NUM'], 'location' => $row['LOCATION'], 'reqnum' => $row['REQNUM'], @@ -650,7 +650,7 @@ class Horizon extends AbstractBase 'volume' => $row['VOLUME'], 'publication_year' => $row['PUBLICATION_YEAR'], 'title' => $row['TITLE'] - ); + ]; } return false; } @@ -763,14 +763,14 @@ class Horizon extends AbstractBase $sqlStmt = mssql_query($sql); while ($row = mssql_fetch_assoc($sqlStmt)) { - $fineList[] = array('amount' => $row['AMOUNT'], + $fineList[] = ['amount' => $row['AMOUNT'], 'checkout' => $row['CHECKOUT'], 'fine' => $row['FINE'], 'balance' => $row['BALANCE'], 'createdate' => $row['CREATEDATE'], 'duedate' => $row['DUEDATE'], 'id' => $row['ID'], - 'title' => $row['TITLE']); + 'title' => $row['TITLE']]; } return $fineList; } catch (\Exception $e) { @@ -808,13 +808,13 @@ class Horizon extends AbstractBase $row = mssql_fetch_assoc($sqlStmt); if ($row) { list($lastname,$firstname) = explode(', ', $row['FULLNAME']); - $profile = array('lastname' => $lastname, + $profile = ['lastname' => $lastname, 'firstname' => $firstname, 'address1' => $row['ADDRESS1'], 'address2' => $row['ADDRESS2'], 'zip' => $row['ZIP'], 'phone' => $row['PHONE'], - 'group' => null); + 'group' => null]; return $profile; } else { return null; @@ -834,7 +834,7 @@ class Horizon extends AbstractBase protected function getTransactionSQL($patron) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "convert(varchar(12), dateadd(dd, i.due_date, '01 jan 1970')) " . "as DUEDATE", "i.bib# as BIB_NUM", @@ -845,43 +845,43 @@ class Horizon extends AbstractBase "p.pubdate as PUBLICATION_YEAR", "t.processed as TITLE", "i.item# as ITEM_NUM", - ); + ]; // From - $sqlFrom = array("circ c"); + $sqlFrom = ["circ c"]; // Join - $sqlJoin = array( + $sqlJoin = [ "item i on i.item#=c.item#", "borrower b on b.borrower# = c.borrower#", "borrower_barcode bb on bb.borrower# = c.borrower#", "title t on t.bib# = i.bib#", - ); + ]; // Left Outer Join - $sqlLeftOuterJoin = array( + $sqlLeftOuterJoin = [ "request r on r.item#=c.item#", "pubdate_inverted p on p.bib# = i.bib#" - ); + ]; // Where - $sqlWhere = array( - "bb.bbarcode=\"" . addslashes($patron['id']) . "\""); + $sqlWhere = [ + "bb.bbarcode=\"" . addslashes($patron['id']) . "\""]; // Order by - $sqlOrder = array( + $sqlOrder = [ "i.due_date", "t.processed" - ); + ]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'join' => $sqlJoin, 'leftOuterJoin' => $sqlLeftOuterJoin, 'where' => $sqlWhere, 'order' => $sqlOrder - ); + ]; return $sqlArray; } @@ -915,7 +915,7 @@ class Horizon extends AbstractBase } } - return array( + return [ 'id' => $row['BIB_NUM'], 'item_id' => $row['ITEM_NUM'], 'duedate' => $dueDate, @@ -926,7 +926,7 @@ class Horizon extends AbstractBase 'volume' => $row['VOLUME'], 'publication_year' => $row['PUBLICATION_YEAR'], 'title' => $row['TITLE'] - ); + ]; } /** @@ -943,7 +943,7 @@ class Horizon extends AbstractBase */ public function getMyTransactions($patron) { - $transList = array(); + $transList = []; $sqlArray = $this->getTransactionSQL($patron); $sql = $this->buildSqlFromArray($sqlArray); @@ -969,7 +969,7 @@ class Horizon extends AbstractBase public function getFunds() { // No funds for limiting in Horizon. - return array(); + return []; } /** @@ -1013,7 +1013,7 @@ class Horizon extends AbstractBase . " datediff(dd, '01JAN1970', getdate()) - {$daysOld} " . "order by nb.date desc "; - $results = array(); + $results = []; // Set the rowcount limit before executing the query for IDs mssql_query($limitsql); @@ -1024,13 +1024,13 @@ class Horizon extends AbstractBase $results[] = $row['bib#']; } - $retVal = array('count' => count($results), 'results' => array()); + $retVal = ['count' => count($results), 'results' => []]; foreach ($results as $result) { - $retVal['results'][] = array('id' => $result); + $retVal['results'][] = ['id' => $result]; } return $retVal; } else { - return array('count' => 0, 'results' => array()); + return ['count' => 0, 'results' => []]; } } @@ -1089,7 +1089,7 @@ class Horizon extends AbstractBase */ public function getSuppressedRecords() { - $list = array(); + $list = []; $sql = "select bc.bib#" . " from bib_control bc" . diff --git a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php index 51ce40a4419..560fe47f0e5 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php +++ b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php @@ -104,15 +104,15 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function processHoldingRow($id, $row, $patron) { - $itemData = array( + $itemData = [ 'id' => $row['ITEM_ID'], 'level' => 'item' - ); + ]; $holding = parent::processHoldingRow($id, $row, $patron); - $holding += array( + $holding += [ 'addLink' => $this->checkRequestIsValid($id, $itemData, $patron) - ); + ]; return $holding; } @@ -128,7 +128,7 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function determineRenewability($requested) { - $renewData = array(); + $renewData = []; $renewData['renewable'] = ($requested == 0) ? true : false; @@ -181,40 +181,40 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ public function getPickUpLocations($patron, $holdDetails = null) { - $pickresponse = array(); + $pickresponse = []; if ($this->wsPickUpLocations == false) { // Select - $sqlSelect = array( + $sqlSelect = [ "l.location LOCATIONID", "l.name LOCATIONDISPLAY" - ); + ]; // From - $sqlFrom = array("pickup_location_sort pls"); + $sqlFrom = ["pickup_location_sort pls"]; // Join - $sqlJoin = array( + $sqlJoin = [ "location l on l.location = pls.pickup_location", "borrower b on b.location = pls.location", "borrower_barcode bb on bb.borrower# = b.borrower#" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "pls.display = 1", "bb.bbarcode=\"" . addslashes($patron['id']) . "\"" - ); + ]; // Order by - $sqlOrder = array("l.name"); + $sqlOrder = ["l.name"]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlSelect, 'from' => $sqlFrom, 'join' => $sqlJoin, 'where' => $sqlWhere, 'order' => $sqlOrder - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); @@ -222,10 +222,10 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter $sqlStmt = mssql_query($sql); while ($row = mssql_fetch_assoc($sqlStmt)) { - $pickresponse[] = array( + $pickresponse[] = [ 'locationID' => $row['LOCATIONID'], 'locationDisplay' => $row['LOCATIONDISPLAY'] - ); + ]; } } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -233,10 +233,10 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter } elseif (isset($this->wsPickUpLocations)) { foreach ($this->wsPickUpLocations as $code => $library) { - $pickresponse[] = array( + $pickresponse[] = [ 'locationID' => $code, 'locationDisplay' => $library - ); + ]; } } return $pickresponse; @@ -263,23 +263,23 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter if ($this->wsDefaultPickUpLocation == false) { // Select - $sqlSelect = array("b.location LOCATION"); + $sqlSelect = ["b.location LOCATION"]; // From - $sqlFrom = array("borrower b"); + $sqlFrom = ["borrower b"]; // Join - $sqlJoin = array("borrower_barcode bb on bb.borrower# = b.borrower#"); + $sqlJoin = ["borrower_barcode bb on bb.borrower# = b.borrower#"]; // Where - $sqlWhere = array("bb.bbarcode=\"" . addslashes($patron['id']) . "\""); + $sqlWhere = ["bb.bbarcode=\"" . addslashes($patron['id']) . "\""]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlSelect, 'from' => $sqlFrom, 'join' => $sqlJoin, 'where' => $sqlWhere - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); @@ -364,10 +364,10 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function getSession() { - $params = array("profile" => $this->wsProfile, + $params = ["profile" => $this->wsProfile, "menu" => "account", "GetXML" => "true" - ); + ]; $response = $this->makeRequest($params); @@ -394,13 +394,13 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter // Get Session $session = $this->getSession(); - $params = array("session" => $session, + $params = ["session" => $session, "profile" => $this->wsProfile, "menu" => "account", "sec1" => $userBarcode, "sec2" => $userPassword, "GetXML" => "true" - ); + ]; $response = $this->makeRequest($params); @@ -431,7 +431,7 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter $patron['cat_username'], $patron['cat_password'] ); if ($session) { - $params = array( + $params = [ "session" => $session, "profile" => $this->wsProfile, "bibkey" => $bibId, @@ -442,11 +442,11 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter "source" => "~!horizon", "uri" => "", "GetXML" => "true" - ); + ]; // set itemkey only if available and level is not title-level if ($itemData['item_id'] != '' && $itemData['level'] != 'title') { - $params += array("itemkey" => $itemData['item_id']); + $params += ["itemkey" => $itemData['item_id']]; } $initResponse = $this->makeRequest($params); @@ -469,12 +469,12 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function getItems($session) { - $params = array("session" => $session, + $params = ["session" => $session, "profile" => $this->wsProfile, "menu" => "account", "submenu" => "itemsout", "GetXML" => "true" - ); + ]; $response = $this->makeRequest($params); @@ -497,14 +497,14 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function renewItems($session, $items) { - $params = array("session" => $session, + $params = ["session" => $session, "profile" => $this->wsProfile, "menu" => "account", "submenu" => "itemsout", "renewitemkeys" => $items, "renewitems" => "Renew", "GetXML" => "true" - ); + ]; $response = $this->makeRequest($params); @@ -528,7 +528,7 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function placeRequest($session, $requestDetails) { - $params = array("session" => $session, + $params = ["session" => $session, "profile" => $this->wsProfile, "bibkey" => $requestDetails['bibId'], "aspect" => "submenu13", @@ -538,17 +538,17 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter "source" => "~!horizon", "uri" => "", "GetXML" => "true" - ); + ]; // set itemkey only if available if ($requestDetails['itemId'] != '') { - $params += array("itemkey" => $requestDetails['itemId']); + $params += ["itemkey" => $requestDetails['itemId']]; } $initResponse = $this->makeRequest($params); if ($initResponse->request_confirm) { - $confirmParams = array( + $confirmParams = [ "session" => $session, "profile" => $this->wsProfile, "bibkey" => $requestDetails['bibId'], @@ -564,31 +564,31 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter "pickuplocation" => $requestDetails['pickuplocation'], "notifyby" => $requestDetails['notify'], "GetXML" => "true" - ); + ]; $request = $this->makeRequest($confirmParams); if ($request->request_success) { - $response = array( + $response = [ 'success' => true, 'status' => "hold_success" - ); + ]; } else { - $response = array( + $response = [ 'success' => false, 'status' => "hold_error_fail" - ); + ]; } } else { $sysMessage = false; if ($initResponse->alert->message) { $sysMessage = (string)$initResponse->alert->message; } - $response = array( + $response = [ 'success' => false, 'status' => "hold_error_fail", 'sysMessage' => $sysMessage - ); + ]; } return $response; } @@ -606,29 +606,29 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter */ protected function cancelRequest($session, $data) { - $responseItems = array(); + $responseItems = []; - $params = array("session" => $session, + $params = ["session" => $session, "profile" => $this->wsProfile, "lang" => "eng", "menu" => "account", "submenu" => "holds", "cancelhold" => "Cancel Request", "GetXML" => "true" - ); + ]; foreach ($data as $values) { $cancelData[] = $values['bib_id'] . ':' . $values['item_id']; } - $params += array("waitingholdselected" => $cancelData); + $params += ["waitingholdselected" => $cancelData]; $response = $this->makeRequest($params); // No Indication of Success or Failure if ($response !== false && !$response->error->message) { - $keys = array(); + $keys = []; // Get a list of bib keys from waiting items $currentHolds = $response->holdsdata->waiting->waitingitem; foreach ($currentHolds as $hold) { @@ -643,14 +643,14 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter $itemID = $values['item_id']; // If the bib id is matched, the cancel must have failed if (in_array($values['bib_id'], $keys)) { - $responseItems[$itemID] = array( + $responseItems[$itemID] = [ 'success' => false, 'status' => "hold_cancel_fail" - ); + ]; } else { - $responseItems[$itemID] = array( + $responseItems[$itemID] = [ 'success' => true, 'status' => "hold_cancel_success", - ); + ]; $count = $count+1; } } @@ -661,14 +661,14 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter } foreach ($data as $values) { $itemID = $values['item_id']; - $responseItems[$itemID] = array( + $responseItems[$itemID] = [ 'success' => false, 'status' => "hold_cancel_fail", 'sysMessage' => $message - ); + ]; } } - $result = array('count' => $count, 'items' => $responseItems); + $result = ['count' => $count, 'items' => $responseItems]; return $result; } @@ -697,14 +697,14 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter : $this->getDefaultPickUpLocation(); $notify = $this->config['Holds']['notify']; - $requestDetails = array( + $requestDetails = [ 'bibId' => $bibId, 'pickuplocation' => $pickUpLocationID, 'notify' => $notify - ); + ]; if ($level != 'title' && $itemId != '') { - $requestDetails += array('itemId' => $itemId); + $requestDetails += ['itemId' => $itemId]; } // Register Account @@ -712,9 +712,9 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter if ($session) { $response = $this->placeRequest($session, $requestDetails); } else { - $response = array( + $response = [ 'success' => false, 'status' => "authentication_error_admin" - ); + ]; } return $response; @@ -739,7 +739,7 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter foreach ($details as $cancelItem) { list($bibID, $itemID) = explode("|", $cancelItem); - $cancelIDs[] = array("bib_id" => $bibID, "item_id" => $itemID); + $cancelIDs[] = ["bib_id" => $bibID, "item_id" => $itemID]; } // Register Account @@ -747,9 +747,9 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter if ($session) { $response = $this->cancelRequest($session, $cancelIDs); } else { - $response = array( + $response = [ 'success' => false, 'sysMessage' => "authentication_error_admin" - ); + ]; } return $response; } @@ -793,19 +793,19 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter if ($currentRenewals > $origRenewals) { - $response['details'][$ikey] = array( + $response['details'][$ikey] = [ 'item_id' => $ikey, 'new_date' => $currentDueDate, 'success' => true - ); + ]; } else { - $response['details'][$ikey] = array( + $response['details'][$ikey] = [ 'item_id' => $ikey, 'new_date' => "", 'success' => false, 'sysMessage' => $renewerror - ); + ]; } } $i++; @@ -852,7 +852,7 @@ class HorizonXMLAPI extends Horizon implements \VuFindHttp\HttpServiceAwareInter } } - return array('blocks' => array("authentication_error_admin")); + return ['blocks' => ["authentication_error_admin"]]; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php index 015266057d4..9be05c3728b 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php @@ -154,7 +154,7 @@ class Innovative extends AbstractBase implements // beginning tr tag. $rows = preg_split("/<tr([^>]*)>/", $r); $count = 0; - $keys = array_pad(array(), 10, ""); + $keys = array_pad([], 10, ""); $loc_col_name = $this->config['OPAC']['location_column']; $call_col_name = $this->config['OPAC']['call_no_column']; @@ -164,7 +164,7 @@ class Innovative extends AbstractBase implements $stat_avail = $this->config['OPAC']['status_avail']; $stat_due = $this->config['OPAC']['status_due']; - $ret = array(); + $ret = []; foreach ($rows as $row) { // Split up the contents of the row based on the th or td tag, excluding // the tags themselves. @@ -251,7 +251,7 @@ class Innovative extends AbstractBase implements */ public function getStatuses($ids) { - $items = array(); + $items = []; $count = 0; foreach ($ids as $id) { $items[$count] = $this->getStatus($id); @@ -296,7 +296,7 @@ class Innovative extends AbstractBase implements public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -380,13 +380,13 @@ class Innovative extends AbstractBase implements // released under the GPL $api_contents = trim(strip_tags($result)); $api_array_lines = explode("\n", $api_contents); - $api_data = array('PBARCODE' => false); + $api_data = ['PBARCODE' => false]; foreach ($api_array_lines as $api_line) { $api_line = str_replace("p=", "peq", $api_line); $api_line_arr = explode("=", $api_line); - $regex_match = array("/\[(.*?)\]/","/\s/","/#/"); - $regex_replace = array('','','NUM'); + $regex_match = ["/\[(.*?)\]/","/\s/","/#/"]; + $regex_replace = ['','','NUM']; $key = trim( preg_replace($regex_match, $regex_replace, $api_line_arr[0]) ); @@ -401,7 +401,7 @@ class Innovative extends AbstractBase implements } // return patron info - $ret = array(); + $ret = []; $ret['id'] = $api_data['PBARCODE']; // or should I return patron id num? $names = explode(',', $api_data['PATRNNAME']); $ret['firstname'] = $names[1]; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Koha.php b/module/VuFind/src/VuFind/ILS/Driver/Koha.php index 0d0880aa940..6a609a52dde 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Koha.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Koha.php @@ -115,7 +115,7 @@ class Koha extends AbstractBase */ public function getHolding($id, array $patron = null) { - $holding = array(); + $holding = []; $available = true; $duedate = $status = ''; $inum = 0; @@ -127,7 +127,7 @@ class Koha extends AbstractBase " order by itemnumber"; try { $itemSqlStmt = $this->db->prepare($sql); - $itemSqlStmt->execute(array(':id' => $id)); + $itemSqlStmt->execute([':id' => $id]); foreach ($itemSqlStmt->fetchAll() as $rowItem) { $inum = $rowItem['ITEMNO']; $sql = "select date_due as DUEDATE from issues " . @@ -138,7 +138,7 @@ class Koha extends AbstractBase // If the item is available for loan, then check its current // status $issueSqlStmt = $this->db->prepare($sql); - $issueSqlStmt->execute(array(':inum' => $inum)); + $issueSqlStmt->execute([':inum' => $inum]); $rowIssue = $issueSqlStmt->fetch(); if ($rowIssue) { $available = false; @@ -163,7 +163,7 @@ class Koha extends AbstractBase $sql = "select branchname as BNAME from branches where " . "branchcode = :loc"; $locSqlStmt = $this->db->prepare($sql); - $locSqlStmt->execute(array(':loc' => $loc)); + $locSqlStmt->execute([':loc' => $loc]); $row = $locSqlStmt->fetch(); if ($row) { $loc = $row['BNAME']; @@ -179,7 +179,7 @@ class Koha extends AbstractBase : $loc . ": " . 'Unknown'; //A default value is stored for null - $holding[] = array( + $holding[] = [ 'id' => $id, 'availability' => $available, 'item_num' => $rowItem['ITEMNO'], @@ -194,7 +194,7 @@ class Koha extends AbstractBase ? 'Unknown' : $rowItem['BARCODE'], 'number' => (null == $rowItem['COPYNO']) ? 'Unknown' : $rowItem['COPYNO'] - ); + ]; } return $holding; } @@ -238,7 +238,7 @@ class Koha extends AbstractBase { $sql = $sqlStmt = $row = ''; $id = 0; - $fineLst = array(); + $fineLst = []; try { $id = $patron['id']; $sql = "select round(accountlines.amount*100) as AMOUNT, " . @@ -252,16 +252,16 @@ class Koha extends AbstractBase "join items on accountlines.itemnumber = items.itemnumber " . "where accountlines.borrowernumber = :id"; $sqlStmt = $this->db->prepare($sql); - $sqlStmt->execute(array(':id' => $id)); + $sqlStmt->execute([':id' => $id]); foreach ($sqlStmt->fetchAll() as $row) { - $fineLst[] = array( + $fineLst[] = [ 'amount' => (null == $row['AMOUNT']) ? 0 : $row['AMOUNT'], 'checkout' => $row['CHECKOUT'], 'fine' => (null == $row['FINE']) ? 'Unknown' : $row['FINE'], 'balance' => (null == $row['BALANCE']) ? 0 : $row['BALANCE'], 'duedate' => $row['DUEDATE'], 'id' => $row['BIBNO'] - ); + ]; } return $fineLst; } @@ -285,7 +285,7 @@ class Koha extends AbstractBase { $sql = $sqlStmt = $row = ''; $id = 0; - $holdLst = array(); + $holdLst = []; try { $id = $patron['id']; $sql = "select reserves.biblionumber as BIBNO, " . @@ -295,14 +295,14 @@ class Koha extends AbstractBase "join branches on reserves.branchcode = branches.branchcode " . "where reserves.borrowernumber = :id"; $sqlStmt = $this->db->prepare($sql); - $sqlStmt->execute(array(':id' => $id)); + $sqlStmt->execute([':id' => $id]); foreach ($sqlStmt->fetchAll() as $row) { - $holdLst[] = array( + $holdLst[] = [ 'id' => $row['BIBNO'], 'location' => $row['BRNAME'], 'expire' => $row['EXDATE'], 'create' => $row['RSVDATE'] - ); + ]; } return $holdLst; } @@ -325,17 +325,17 @@ class Koha extends AbstractBase { $id = 0; $sql = $sqlStmt = $row = ''; - $profile = array(); + $profile = []; try { $id = $patron['id']; $sql = "select address as ADDR1, address2 as ADDR2, zipcode as ZIP, " . "phone as PHONE, categorycode as GRP from borrowers " . "where borrowernumber = :id"; $sqlStmt = $this->db->prepare($sql); - $sqlStmt->execute(array(':id' => $id)); + $sqlStmt->execute([':id' => $id]); $row = $sqlStmt->fetch(); if ($row) { - $profile = array( + $profile = [ 'firstname' => $patron['firstname'], 'lastname' => $patron['lastname'], 'address1' => $row['ADDR1'], @@ -343,7 +343,7 @@ class Koha extends AbstractBase 'zip' => $row['ZIP'], 'phone' => $row['PHONE'], 'group' => $row['GRP'] - ); + ]; return $profile; } return null; @@ -368,7 +368,7 @@ class Koha extends AbstractBase public function getMyTransactions($patron) { $id = 0; - $transactionLst = array(); + $transactionLst = []; $row = $sql = $sqlStmt = ''; try { $id = $patron['id']; @@ -377,14 +377,14 @@ class Koha extends AbstractBase "from issues join items on issues.itemnumber = items.itemnumber " . "where issues.borrowernumber = :id"; $sqlStmt = $this->db->prepare($sql); - $sqlStmt->execute(array(':id' => $id)); + $sqlStmt->execute([':id' => $id]); foreach ($sqlStmt->fetchAll() as $row) { - $transactionLst[] = array( + $transactionLst[] = [ 'duedate' => $row['DUEDATE'], 'id' => $row['BIBNO'], 'barcode' => $row['BARCODE'], 'renew' => $row['RENEWALS'] - ); + ]; } return $transactionLst; } @@ -409,7 +409,7 @@ class Koha extends AbstractBase public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -442,7 +442,7 @@ class Koha extends AbstractBase */ public function getStatuses($idLst) { - $statusLst = array(); + $statusLst = []; foreach ($idLst as $id) { $statusLst[] = $this->getStatus($id); } @@ -461,7 +461,7 @@ class Koha extends AbstractBase public function getSuppressedRecords() { // TODO - return array(); + return []; } /** @@ -478,7 +478,7 @@ class Koha extends AbstractBase */ public function patronLogin($username, $password) { - $patron = array(); + $patron = []; $row = ''; // Koha uses MD5_BASE64 encoding to save borrowers' passwords, function @@ -492,14 +492,14 @@ class Koha extends AbstractBase try { $sqlStmt = $this->db->prepare($sql); - $sqlStmt->execute(array(':username' => $username, ':db_pwd' => $db_pwd)); + $sqlStmt->execute([':username' => $username, ':db_pwd' => $db_pwd]); $row = $sqlStmt->fetch(); if ($row) { // NOTE: Here, 'cat_password' => $password is used, password is // saved in a clear text as user provided. If 'cat_password' => // $db_pwd was used, then password will be saved encrypted as in // 'borrowers' table of 'koha' database - $patron = array( + $patron = [ 'id' => $row['ID'], 'firstname' => $row['FNAME'], 'lastname' => $row['LNAME'], @@ -508,7 +508,7 @@ class Koha extends AbstractBase 'email' => $row['EMAIL'], 'major' => null, 'college' => null - ); + ]; return $patron; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/LBS4.php b/module/VuFind/src/VuFind/ILS/Driver/LBS4.php index 28e70d2e215..eb46d9fabf9 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/LBS4.php +++ b/module/VuFind/src/VuFind/ILS/Driver/LBS4.php @@ -167,14 +167,14 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface $available = false; } - $holding[] = array( + $holding[] = [ 'id' => $ppn, 'availability' => $available, 'status' => $status, 'location' => $location, 'reserve' => $reserve, 'callnumber' => $label, - ); + ]; } } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -238,7 +238,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface . " order by o.signature"; try { $sqlStmt = sybase_query($sql); - $holding = array(); + $holding = []; while ($row = sybase_fetch_row($sqlStmt)) { $epn = $row[0]; $loan_indi = (string)$row[1]; @@ -256,7 +256,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface $location = $this->opaciln . "/" . $locid; } if ($row[6] != '') { - $summary = array($row[6]); + $summary = [$row[6]]; } $material = $row[7]; @@ -288,7 +288,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface $available = false; } - $holding[] = array( + $holding[] = [ 'id' => $ppn, 'availability' => $available, 'status' => $status, @@ -298,7 +298,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface 'duedate' => $duedate, 'number' => $volbar, 'barcode' => $volbar, - 'notes' => array($note), + 'notes' => [$note], 'summary' => $summary, 'is_holdable' => $is_holdable, 'item_id' => $epn, @@ -306,7 +306,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface 'storageRetrievalRequestLink' => $storage, 'checkStorageRetrievalRequest' => !empty($storage), 'material' => $material, - ); + ]; } } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -458,7 +458,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface */ public function getStatuses($ids) { - $items = array(); + $items = []; foreach ($ids as $id) { $items[] = $this->getStatus($id); } @@ -503,11 +503,11 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface . " + 7*ascii(substring(convert(char(12),'" . $pin . "',104),7,1))" . " + 8*ascii(substring(convert(char(12),'" . $pin . "',104),8,1))"; try { - $result = array(); + $result = []; $sqlStmt = sybase_query($sql); $row = sybase_fetch_row($sqlStmt); if ($row) { - $result = array('id' => $barcode, + $result = ['id' => $barcode, 'firstname' => $row[1], 'lastname' => $row[2], 'cat_username' => $barcode, @@ -517,7 +517,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface 'college' => $row[5], // borrower_type 'address_id_nr' => $row[7], 'iln' => $row[8], - 'lang' => $row[9]); + 'lang' => $row[9]]; return $result; } else { return null; @@ -558,11 +558,11 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface . " and b.borrower_bar='" . $user['id'] . "'" . " order by a.address_code asc"; try { - $result = array(); + $result = []; $sqlStmt = sybase_query($sql); $row = sybase_fetch_row($sqlStmt); if ($row) { - $result = array( + $result = [ 'firstname' => $row[1], 'lastname' => $row[2], 'address1' => $row[10] . ', ' . $row[9] . ' ' . $row[11], @@ -570,7 +570,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface 'email' => $row[3], 'phone' => $row[12], 'group' => $row[6], - ); + ]; if ($row[6] == '81') { $result['group'] = $this->translate('Staff'); } else if ($row[6] == '1') { @@ -617,11 +617,11 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface $lang = $patron['lang']; $sql = "exec loans_requests_rm_003 " . $aid . ", " . $iln . ", " . $lang; try { - $result = array(); + $result = []; $count = 0; $sqlStmt = sybase_query($sql); while ($row = sybase_fetch_row($sqlStmt)) { - $result[$count] = array( + $result[$count] = [ 'id' => $row[0] ,'duedate' => substr($row[13], 0, 12) ,'barcode' => $row[31] @@ -631,14 +631,14 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface ,'message' => $row[60] ,'title' => $this->picaRecode($row[44]) ,'item_id' => $row[7] - ); + ]; $count++; } return $result; } catch (\Exception $e) { throw new ILSException($e->getMessage()); } - return array(); + return []; } /** @@ -673,24 +673,24 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface . " and l.iln=" . $iln . ""; try { - $result = array(); + $result = []; $sqlStmt = sybase_query($sql); $expire = $row[3]; // empty ? while ($row = sybase_fetch_row($sqlStmt)) { $title = $this->picaRecode($row[1]); - $result[] = array( + $result[] = [ 'id' => $this->prfz($row[0]), 'create' => $row[2], 'expire' => $expire, //'location' => $row[4], 'title' => $title - ); + ]; } return $result; } catch (\Exception $e) { throw new ILSException($e->getMessage()); } - return array(); + return []; } /** @@ -707,7 +707,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -752,7 +752,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface . " and r.costs_code not in (1, 2, 3, 4, 8)" . ""; try { - $result = array(); + $result = []; $sqlStmt = sybase_query($sql); while ($row = sybase_fetch_row($sqlStmt)) { //$fine = $this->translate(('3'==$row[1])?'Overdue':'Dues'); @@ -762,7 +762,7 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface $checkout = substr($row[3], 0, 12); $duedate = substr($row[4], 0, 12); $title = $this->picaRecode(substr($row[6], 0, 12)); - $result[] = array( + $result[] = [ 'id' => $this->prfz($row[0]), 'amount' => $amount, 'balance' => $amount, //wtf @@ -770,13 +770,13 @@ class LBS4 extends AbstractBase implements TranslatorAwareInterface 'duedate' => $duedate, 'fine' => $fine, 'title' => $title, - ); + ]; } return $result; } catch (\Exception $e) { throw new ILSException($e->getMessage()); } - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php index d274556700e..93f35937c58 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php +++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php @@ -57,7 +57,7 @@ class MultiBackend extends AbstractBase * * @var string[] */ - protected $drivers = array(); + protected $drivers = []; /** * The default driver to use @@ -71,7 +71,7 @@ class MultiBackend extends AbstractBase * * @var object[] */ - protected $cache = array(); + protected $cache = []; /** * The array of booleans letting us know if a @@ -79,21 +79,21 @@ class MultiBackend extends AbstractBase * * @var boolean[] */ - protected $isInitialized = array(); + protected $isInitialized = []; /** * The array of driver configuration options. * * @var string[] */ - protected $config = array(); + protected $config = []; /** * The separating values to be used for each ILS. * Not yet implemented * @var object */ - protected $delimiters = array(); + protected $delimiters = []; /** * Configuration loader @@ -177,7 +177,7 @@ class MultiBackend extends AbstractBase $status = $driver->getStatus($this->getLocalId($id)); return $this->addIdPrefixes($status, $source); } - return array(); + return []; } /** @@ -193,7 +193,7 @@ class MultiBackend extends AbstractBase */ public function getStatuses($ids) { - $items = array(); + $items = []; foreach ($ids as $id) { $items[] = $this->getStatus($id); } @@ -224,7 +224,7 @@ class MultiBackend extends AbstractBase ); return $this->addIdPrefixes($holdings, $source); } - return array(); + return []; } /** @@ -245,7 +245,7 @@ class MultiBackend extends AbstractBase if ($driver) { return $driver->getPurchaseHistory($this->getLocalId($id)); } - return array(); + return []; } /** @@ -257,7 +257,7 @@ class MultiBackend extends AbstractBase { return isset($this->config['Login']['drivers']) ? $this->config['Login']['drivers'] - : array(); + : []; } /** @@ -300,7 +300,7 @@ class MultiBackend extends AbstractBase if ($driver) { return $driver->getNewItems($page, $limit, $daysOld, $fundId); } - return array(); + return []; } /** @@ -320,7 +320,7 @@ class MultiBackend extends AbstractBase if ($driver) { return $driver->findReserves($course, $inst, $dept); } - return array(); + return []; } /** @@ -341,7 +341,7 @@ class MultiBackend extends AbstractBase ->getMyProfile($this->stripIdPrefixes($patron, $source)); return $this->addIdPrefixes($profile, $source); } - return array(); + return []; } /** @@ -480,7 +480,7 @@ class MultiBackend extends AbstractBase if ($driver) { $holds = $driver->getMyHolds($this->stripIdPrefixes($patron, $source)); return $this->addIdPrefixes( - $holds, $source, array('id', 'item_id', 'cat_username') + $holds, $source, ['id', 'item_id', 'cat_username'] ); } throw new ILSException('No suitable backend driver found'); @@ -504,7 +504,7 @@ class MultiBackend extends AbstractBase $driver, 'getMyStorageRetrievalRequests', compact('patron') )) { // Return empty array if not supported by the driver - return array(); + return []; } $requests = $driver->getMyStorageRetrievalRequests( $this->stripIdPrefixes($patron, $source) @@ -563,7 +563,7 @@ class MultiBackend extends AbstractBase if ($driver) { if ($this->getSource($id) != $source || !is_callable( - array($driver, 'checkStorageRetrievalRequestIsValid') + [$driver, 'checkStorageRetrievalRequestIsValid'] ) ) { return false; @@ -602,7 +602,7 @@ class MultiBackend extends AbstractBase if ($holdDetails) { if ($this->getSource($holdDetails['id']) != $source) { // Return empty array since the sources don't match - return array(); + return []; } } $locations = $driver->getPickUpLocations( @@ -670,7 +670,7 @@ class MultiBackend extends AbstractBase ) { // Return empty array since the sources don't match or the method // isn't supported by the driver - return array(); + return []; } $groups = $driver->getRequestGroups( $this->stripIdPrefixes($id, $source), @@ -738,10 +738,10 @@ class MultiBackend extends AbstractBase $driver = $this->getDriver($source); if ($driver) { if ($this->getSource($holdDetails['id']) != $source) { - return array( + return [ "success" => false, "sysMessage" => 'hold_wrong_user_institution' - ); + ]; } $holdDetails = $this->stripIdPrefixes($holdDetails, $source); return $driver->placeHold($holdDetails); @@ -815,13 +815,13 @@ class MultiBackend extends AbstractBase $source = $this->getSource($details['patron']['cat_username'], 'login'); $driver = $this->getDriver($source); if ($driver - && is_callable(array($driver, 'placeStorageRetrievalRequest')) + && is_callable([$driver, 'placeStorageRetrievalRequest']) ) { if ($this->getSource($details['id']) != $source) { - return array( + return [ "success" => false, "sysMessage" => 'hold_wrong_user_institution' - ); + ]; } $details = $this->stripIdPrefixes($details, $source); return $driver->placeStorageRetrievalRequest($details); @@ -939,7 +939,7 @@ class MultiBackend extends AbstractBase ) { // Patron is not stripped so that the correct library can be determined return $driver->getILLPickupLibraries( - $this->stripIdPrefixes($id, $source, array('id')), + $this->stripIdPrefixes($id, $source, ['id']), $patron ); } @@ -971,7 +971,7 @@ class MultiBackend extends AbstractBase ) { // Patron is not stripped so that the correct library can be determined return $driver->getILLPickupLocations( - $this->stripIdPrefixes($id, $source, array('id')), + $this->stripIdPrefixes($id, $source, ['id']), $pickupLib, $patron ); @@ -998,7 +998,7 @@ class MultiBackend extends AbstractBase if ($driver && $this->methodSupported($driver, 'placeILLRequest', compact($details)) ) { - $details = $this->stripIdPrefixes($details, $source, array('id')); + $details = $this->stripIdPrefixes($details, $source, ['id']); return $driver->placeILLRequest($details); } throw new ILSException('No suitable backend driver found'); @@ -1022,13 +1022,13 @@ class MultiBackend extends AbstractBase $driver, 'getMyILLRequests', compact('patron') )) { // Return empty array if not supported by the driver - return array(); + return []; } $requests = $driver->getMyILLRequests( $this->stripIdPrefixes($patron, $source) ); return $this->addIdPrefixes( - $requests, $source, array('id', 'item_id', 'cat_username') + $requests, $source, ['id', 'item_id', 'cat_username'] ); } throw new ILSException('No suitable backend driver found'); @@ -1149,7 +1149,7 @@ class MultiBackend extends AbstractBase } // If driver not available, return an empty array - return array(); + return []; } /** @@ -1376,7 +1376,7 @@ class MultiBackend extends AbstractBase // Configuration loading failed; probably means file does not // exist -- just return an empty array in that case: $this->error("Could not load config for $source"); - return array(); + return []; } return $config->toArray(); } @@ -1393,7 +1393,7 @@ class MultiBackend extends AbstractBase * empty/null */ protected function addIdPrefixes($data, $source, - $modifyFields = array('id', 'cat_username') + $modifyFields = ['id', 'cat_username'] ) { if (!isset($data) || empty($data) || !is_array($data)) { return $data; @@ -1431,12 +1431,12 @@ class MultiBackend extends AbstractBase * empty/null */ protected function stripIdPrefixes($data, $source, - $modifyFields = array('id', 'cat_username') + $modifyFields = ['id', 'cat_username'] ) { if (!isset($data) || empty($data)) { return $data; } - $array = is_array($data) ? $data : array($data); + $array = is_array($data) ? $data : [$data]; foreach ($array as $key => $value) { if (is_array($value)) { @@ -1469,9 +1469,9 @@ class MultiBackend extends AbstractBase */ protected function methodSupported($driver, $method, $params = null) { - if (is_callable(array($driver, $method))) { + if (is_callable([$driver, $method])) { if (method_exists($driver, 'supportsMethod')) { - return $driver->supportsMethod($method, $params ?: array()); + return $driver->supportsMethod($method, $params ?: []); } return true; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php b/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php index 6e84b92ea61..11850d4ebe0 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php @@ -132,7 +132,7 @@ class NewGenLib extends AbstractBase */ public function getMyFines($patron) { - $MyFines = array(); + $MyFines = []; $pid = $patron['cat_username']; $fine = 'Overdue'; $LibId = 1; @@ -176,12 +176,12 @@ class NewGenLib extends AbstractBase $balance = $amount-$paidamt; } - $MyFines[] = array('amount' => $amount, + $MyFines[] = ['amount' => $amount, 'checkout' => $checkout, 'fine' => $fine, 'balance' => $balance, 'duedate' => $duedate, - 'id' => $id); + 'id' => $id]; } return $MyFines; @@ -200,7 +200,7 @@ class NewGenLib extends AbstractBase */ public function getMyHolds($patron) { - $holds = array(); + $holds = []; $PatId = $patron['cat_username']; $LibId = 1; //SQL Statement @@ -236,12 +236,12 @@ class NewGenLib extends AbstractBase $duedate = $rowDD['due_date']; $tadate = $rowDD['ta_date']; } - $holds[] = array('type' => $type, + $holds[] = ['type' => $type, 'id' => $RecordId, 'location' => null, 'reqnum' => null, 'expire' => $duedate . " " . $type, - 'create' => $tadate); + 'create' => $tadate]; } //SQL Statement 2 $mainsql2 = "select v.cataloguerecordid as cataloguerecordid, " . @@ -272,12 +272,12 @@ class NewGenLib extends AbstractBase } $RecordId2 = $row2['cataloguerecordid'] . "_" . $row2['owner_library_id']; - $holds[] = array('type' => $type2, + $holds[] = ['type' => $type2, 'id' => $RecordId2, 'location' => $location, 'reqnum' => $row2['queue_no'], 'expire' => null . " " . $type2, - 'create' => $row2['reservation_date']); + 'create' => $row2['reservation_date']]; } return $holds; } @@ -311,13 +311,13 @@ class NewGenLib extends AbstractBase if ($catusr != $row['patron_id'] || $catpswd != $row['user_password']) { return null; } else { - $profile = array('firstname' => $row['fname'], + $profile = ['firstname' => $row['fname'], 'lastname' => $row['lname'], 'address1' => $row['address1'], 'address2' => $row['address2'], 'zip' => $row['pin'], 'phone' => $row['phone1'], - 'group' => null); + 'group' => null]; } } return $profile; @@ -337,7 +337,7 @@ class NewGenLib extends AbstractBase */ public function getMyTransactions($patron) { - $transactions = array(); + $transactions = []; $PatId = $patron['cat_username']; $mainsql = "select c.due_date as due_date, c.status as status, c.ta_id " . "as ta_id, c.library_id as library_id, c.accession_number as " . @@ -370,11 +370,11 @@ class NewGenLib extends AbstractBase while ($srow = $sql->fetch(PDO::FETCH_ASSOC)) { $count = "Renewed = " . $srow['total']; } - $transactions[] = array('duedate' => $row['due_date'] . " " . $count, + $transactions[] = ['duedate' => $row['due_date'] . " " . $count, 'id' => $RecordId, 'barcode' => $row['accession_number'], 'renew' => $count, - 'reqnum' => null); + 'reqnum' => null]; } return $transactions; } @@ -419,7 +419,7 @@ class NewGenLib extends AbstractBase */ public function getStatuses($StatusResult) { - $status = array(); + $status = []; foreach ($StatusResult as $id) { $status[] = $this->getStatus($id); } @@ -440,7 +440,7 @@ class NewGenLib extends AbstractBase */ public function patronLogin($username, $password) { - $patron = array(); + $patron = []; $PatId = $username; $psswrd = $password; //SQL Statement @@ -462,14 +462,14 @@ class NewGenLib extends AbstractBase if ($PatId != $row['patron_id'] || $psswrd != $row['user_password']) { return null; } else { - $patron = array("id" => $PatId, + $patron = ["id" => $PatId, "firstname" => $row['fname'], 'lastname' => $row['lname'], 'cat_username' => $PatId, 'cat_password' => $psswrd, 'email' => $row['email'], 'major' => null, - 'college' => null); + 'college' => null]; } } return $patron; @@ -498,7 +498,7 @@ class NewGenLib extends AbstractBase public function getNewItems($page, $limit, $daysOld, $fundId = null) { // Do some initial work in solr so we aren't repeating it inside this loop. - $retVal[][] = array(); + $retVal[][] = []; $offset = ($page - 1) * $limit; $sql = "select cataloguerecordid,owner_library_id from cataloguerecord " . @@ -512,14 +512,14 @@ class NewGenLib extends AbstractBase throw new ILSException($e->getMessage()); } - $results = array(); + $results = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { $id = $row['cataloguerecordid'] . "_" . $row['owner_library_id']; $results[] = $id; } - $retVal = array('count' => count($results), 'results' => array()); + $retVal = ['count' => count($results), 'results' => []]; foreach ($results as $result) { - $retVal['results'][] = array('id' => $result); + $retVal['results'][] = ['id' => $result]; } return $retVal; } @@ -540,7 +540,7 @@ class NewGenLib extends AbstractBase public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -552,7 +552,7 @@ class NewGenLib extends AbstractBase */ protected function getItemStatus($RecordID) { - $StatusResult = array(); + $StatusResult = []; $pieces = explode("_", $RecordID); $CatId = $pieces[0]; $LibId = $pieces[1]; @@ -605,7 +605,7 @@ class NewGenLib extends AbstractBase while ($rowLoc = $sqlSmt1->fetch(PDO::FETCH_ASSOC)) { $location = $rowLoc['location']; } - $StatusResult[] = array('id' => $RecordID, + $StatusResult[] = ['id' => $RecordID, 'status' => $status, 'location' => $location, 'reserve' => $reserve, @@ -613,7 +613,7 @@ class NewGenLib extends AbstractBase 'availability' => $available, 'number' => $row['accession_number'], 'barcode' => $row['barcode'], - 'library_id' => $row['library_id']); + 'library_id' => $row['library_id']]; } return $StatusResult; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php index d4b96452e66..9c916023224 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php @@ -121,14 +121,14 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ? $this->config['settings']['useStatus'] : 'none'; if ($useStatus == "custom") { $status = $this->translate($this->config['Status']['status']); - return array( - array( + return [ + [ 'id' => $id, 'availability' => $this->config['Status']['availability'], 'status' => $status, 'use_unknown_message' => $this->config['Status']['use_unknown_message'], - 'status_array' => array($status), + 'status_array' => [$status], 'location' => $this->translate( $this->config['Status']['location'] ), @@ -136,14 +136,14 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface 'callnumber' => $this->translate( $this->config['Status']['callnumber'] ) - ) - ); + ] + ]; } else if ($useStatus == "marc") { // Retrieve record from index: $recordDriver = $this->getSolrRecord($id); return $this->getFormattedMarcDetails($recordDriver, 'MarcStatus'); } - return array(); + return []; } /** @@ -162,13 +162,13 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface $useStatus = isset($this->config['settings']['useStatus']) ? $this->config['settings']['useStatus'] : 'none'; if ($useStatus == "custom" || $useStatus == "marc") { - $status = array(); + $status = []; foreach ($idList as $id) { $status[] = $this->getStatus($id); } return $status; } - return array(); + return []; } /** @@ -191,8 +191,8 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ? $this->config['settings']['useHoldings'] : 'none'; if ($useHoldings == "custom") { - return array( - array( + return [ + [ 'id' => $id, 'number' => $this->translate( $this->config['Holdings']['number'] @@ -212,18 +212,18 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ), 'barcode' => $this->config['Holdings']['barcode'], 'notes' => isset($this->config['Holdings']['notes']) - ? $this->config['Holdings']['notes'] : array(), + ? $this->config['Holdings']['notes'] : [], 'summary' => isset($this->config['Holdings']['summary']) - ? $this->config['Holdings']['summary'] : array() - ) - ); + ? $this->config['Holdings']['summary'] : [] + ] + ]; } elseif ($useHoldings == "marc") { // Retrieve record from index: $recordDriver = $this->getSolrRecord($id); return $this->getFormattedMarcDetails($recordDriver, 'MarcHoldings'); } - return array(); + return []; } /** @@ -244,11 +244,11 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface $field = $marcStatus['marcField']; unset($marcStatus['marcField']); $result = $recordDriver->tryMethod( - 'getFormattedMarcDetails', array($field, $marcStatus) + 'getFormattedMarcDetails', [$field, $marcStatus] ); - return empty($result) ? array() : $result; + return empty($result) ? [] : $result; } - return array(); + return []; } /** @@ -285,7 +285,7 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -309,7 +309,7 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/PICA.php b/module/VuFind/src/VuFind/ILS/Driver/PICA.php index ecd871e98cb..33e72f325e6 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/PICA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/PICA.php @@ -106,7 +106,7 @@ class PICA extends DAIA } $_SESSION['picauser'] = $user; - return array( + return [ 'id' => $user->id, 'firstname' => $user->firstname, 'lastname' => $user->lastname, @@ -115,7 +115,7 @@ class PICA extends DAIA 'password' => $password, 'cat_username' => $barcode, 'cat_password' => $password - ); + ]; } /** @@ -167,12 +167,12 @@ class PICA extends DAIA $recordList['status'] = $userinfo->borrowerStatus; // Get the LOANS-Page to extract a message for the user $URL = "/loan/DB={$this->dbsid}/USERINFO"; - $POST = array( + $POST = [ "ACT" => "UI_DATA", "LNG" => "DU", "BOR_U" => $_SESSION['picauser']->username, "BOR_PW" => $_SESSION['picauser']->getCatPassword() - ); + ]; $postit = $this->postit($URL, $POST); // How many messages are there? $messages = substr_count($postit, '<strong class="alert">'); @@ -208,22 +208,22 @@ class PICA extends DAIA public function getMyTransactions($patron) { $URL = "/loan/DB={$this->dbsid}/USERINFO"; - $POST = array( + $POST = [ "ACT" => "UI_LOL", "LNG" => "DU", "BOR_U" => $_SESSION['picauser']->username, "BOR_PW" => $_SESSION['picauser']->getCatPassword() - ); + ]; $postit = $this->postit($URL, $POST); // How many items are there? $holds = substr_count($postit, 'input type="checkbox" name="VB"'); $iframes = $holdsByIframe = substr_count($postit, '<iframe'); - $ppns = array(); - $expiration = array(); - $transList = array(); - $barcode = array(); - $reservations = array(); - $titles = array(); + $ppns = []; + $expiration = []; + $transList = []; + $barcode = []; + $reservations = []; + $titles = []; if ($holdsByIframe >= $holds) { $position = strpos($postit, '<iframe'); for ($i = 0; $i < $iframes; $i++) { @@ -295,25 +295,25 @@ class PICA extends DAIA } for ($i = 0; $i < $holds; $i++) { if ($ppns[$i] !== false) { - $transList[] = array( + $transList[] = [ 'id' => $ppns[$i], 'duedate' => $expiration[$i], 'renewals' => $renewals[$i], 'reservations' => $reservations[$i], 'vb' => $barcode[$i], 'title' => $titles[$i] - ); + ]; } else { // There is a problem: no PPN found for this item... lets take id 0 // to avoid serious error (that will just return an empty title) - $transList[] = array( + $transList[] = [ 'id' => 0, 'duedate' => $expiration[$i], 'renewals' => $renewals[$i], 'reservations' => $reservations[$i], 'vb' => $barcode[$i], 'title' => $titles[$i] - ); + ]; } } return $transList; @@ -357,11 +357,11 @@ class PICA extends DAIA { $renewals = false; if (isset($this->renewalsScript) === true) { - $POST = array( + $POST = [ "DB" => '1', "VBAR" => $barcode, "U" => $_SESSION['picauser']->username - ); + ]; $URL = $this->renewalsScript; $postit = $this->postit($URL, $POST); @@ -419,18 +419,18 @@ class PICA extends DAIA public function getMyFines($patron) { $URL = "/loan/DB={$this->dbsid}/LNG=DU/USERINFO"; - $POST = array( + $POST = [ "ACT" => "UI_LOC", "BOR_U" => $_SESSION['picauser']->username, "BOR_PW" => $_SESSION['picauser']->getCatPassword() - ); + ]; $postit = $this->postit($URL, $POST); // How many items are there? $holds = substr_count($postit, '<td class="plain"')/3; - $fineDate = array(); - $description = array(); - $fine = array(); + $fineDate = []; + $description = []; + $fine = []; $position = strpos($postit, '<td class="infotab2" align="left">Betrag<td>'); for ($i = 0; $i < $holds; $i++) { $pos = strpos($postit, '<td class="plain"', $position); @@ -454,15 +454,15 @@ class PICA extends DAIA $position = $pos + 1; } - $fineList = array(); + $fineList = []; for ($i = 0; $i < $holds; $i++) { - $fineList[] = array( + $fineList[] = [ "amount" => $fine[$i], "checkout" => "", "fine" => $fineDate[$i] . ': ' . utf8_encode(html_entity_decode($description[$i])), "duedate" => "" - ); + ]; // id should be the ppn of the book resulting the fine but there's // currently no way to find out the PPN (we have neither barcode nor // signature...) @@ -486,17 +486,17 @@ class PICA extends DAIA public function getMyHolds($patron) { $URL = "/loan/DB={$this->dbsid}/LNG=DU/USERINFO"; - $POST = array( + $POST = [ "ACT" => "UI_LOR", "BOR_U" => $_SESSION['picauser']->username, "BOR_PW" => $_SESSION['picauser']->getCatPassword() - ); + ]; $postit = $this->postit($URL, $POST); // How many items are there? $holds = substr_count($postit, 'input type="checkbox" name="VB"'); - $ppns = array(); - $creation = array(); + $ppns = []; + $creation = []; $position = strpos($postit, 'input type="checkbox" name="VB"'); for ($i = 0; $i < $holds; $i++) { $pos = strpos($postit, 'value=', $position); @@ -552,11 +552,11 @@ class PICA extends DAIA * requested above... we need to do another request and filter the * UI_LOL-page for requests */ - $POST_LOL = array( + $POST_LOL = [ "ACT" => "UI_LOL", "BOR_U" => $_SESSION['picauser']->username, "BOR_PW" => $_SESSION['picauser']->getCatPassword() - ); + ]; $postit_lol = $this->postit($URL, $POST_LOL); $requests = substr_count( @@ -575,10 +575,10 @@ class PICA extends DAIA } for ($i = 0; $i < ($holds+$moreholds+$requests); $i++) { - $holdList[] = array( + $holdList[] = [ "id" => $ppns[$i], "create" => $creation[$i] - ); + ]; } return $holdList; } @@ -613,7 +613,7 @@ class PICA extends DAIA public function getFunds() { // TODO - return array(); + return []; } // protected functions to connect to PICA @@ -698,7 +698,7 @@ class PICA extends DAIA $doc = new DOMDocument(); $doc->load($searchUrl); $itemlist = $doc->getElementsByTagName('SHORTTITLE'); - $ppn = array(); + $ppn = []; for ($n = 0; $itemlist->item($n); $n++) { if (count($itemlist->item($n)->attributes) > 0) { $ppn[] = $itemlist->item($n)->attributes->getNamedItem('PPN') diff --git a/module/VuFind/src/VuFind/ILS/Driver/Polaris.php b/module/VuFind/src/VuFind/ILS/Driver/Polaris.php index 2a64497f0cd..ca12a0dba11 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Polaris.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Polaris.php @@ -132,12 +132,12 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); $auth_token = "PWS {$this->ws_api_id}:$signature"; - $http_headers = array( + $http_headers = [ "Content-type: application/json", "Accept: application/json", "PolarisDate: $date", "Authorization: $auth_token" - ); + ]; try { $client = $this->httpService->createClient($url); @@ -189,7 +189,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyHolds($patron) { - $holds = array(); + $holds = []; $response = $this->makeRequest( "patron/{$patron['cat_username']}/holdrequests/active", 'GET', $patron['cat_password'] @@ -199,7 +199,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $create = $this->formatJSONTime($holds_response->ActivationDate); $expire = $this->formatJSONTime($holds_response->ExpirationDate); - $holds[] = array( + $holds[] = [ 'id' => $holds_response->BibID, 'location' => $holds_response->PickupBranchName, 'reqnum' => $holds_response->HoldRequestID, @@ -207,7 +207,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'create' => $create, 'position' => $holds_response->QueuePosition, 'title' => $holds_response->Title, - ); + ]; } return $holds; @@ -226,7 +226,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getStatus($id) { - $holding = array(); + $holding = []; $response = $this->makeRequest("bib/$id/holdings"); $holdings_response_array = $response->BibHoldingsGetRows; @@ -248,7 +248,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $duedate = date("n-j-Y", strtotime($holdings_response->DueDate)); } - $holding[] = array( + $holding[] = [ 'availability' => $availability, 'id' => $id, 'status' => $holdings_response->CircStatus, @@ -259,7 +259,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf //'number' => $holdings_response->ItemsIn, 'number' => $copy_count, 'barcode' => $holdings_response->Barcode, - ); + ]; } return $holding; @@ -277,7 +277,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getStatuses($ids) { - $items = array(); + $items = []; $count = 0; foreach ($ids as $id) { $items[$count] = $this->getStatus($id); @@ -346,7 +346,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // microtime is msec or sec?? seems to have changed $activationdate = '/Date(' . intval(microtime(true) * 1000) . ')/'; - $jsonrequest = array( + $jsonrequest = [ 'PatronID' => $holdDetails['patron']['id'], 'BibID' => $holdDetails['id'], 'ItemBarcode' => '', @@ -360,14 +360,14 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'UserID' => $userid, 'RequestingOrgID' => $this->ws_requestingorgid, 'TargetGUID' => '', - ); + ]; $response = $this->makeRequest('holdrequest', 'POST', '', $jsonrequest); if ($response->StatusValue == 1) { - return array('success' => true, 'sysMessage' => $response->Message); + return ['success' => true, 'sysMessage' => $response->Message]; } else { - return array('success' => false, 'sysMessage' => $response->Message); + return ['success' => false, 'sysMessage' => $response->Message]; } } @@ -397,20 +397,20 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf if (isset($this->ws_pickUpLocations)) { // hardcoded pickup locations in the .ini file? or... foreach ($this->ws_pickUpLocations as $code => $library) { - $locations[] = array( + $locations[] = [ 'locationID' => $code, 'locationDisplay' => $library - ); + ]; } } else { // we get them from the API $response = $this->makeRequest("organizations/branch"); $locations_response_array = $response->OrganizationsGetRows; foreach ($locations_response_array as $location_response) { - $locations[] = array( + $locations[] = [ 'locationID' => $location_response->OrganizationID, 'locationDisplay' => $location_response->Name, - ); + ]; } } return $locations; @@ -449,7 +449,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -473,7 +473,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - return array('count' => 0, 'results' => array()); + return ['count' => 0, 'results' => []]; } /** @@ -491,7 +491,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function findReserves($course, $inst, $dept) { - return array(); + return []; } /** @@ -514,7 +514,7 @@ class Polaris extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf return null; } - $user = array(); + $user = []; $user['id'] = $response->PatronID; $user['firstname'] = null; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Sample.php b/module/VuFind/src/VuFind/ILS/Driver/Sample.php index 87ebada9018..0e02b3ef39a 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Sample.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Sample.php @@ -67,8 +67,8 @@ class Sample extends AbstractBase */ public function getStatus($id) { - return array( - array( + return [ + [ 'id' => $id, 'availability' => 1, 'status' => 'Available', @@ -78,8 +78,8 @@ class Sample extends AbstractBase 'duedate' => '', 'number' => 1, 'barcode' => '1234567890', - ) - ); + ] + ]; } /** @@ -94,7 +94,7 @@ class Sample extends AbstractBase */ public function getStatuses($ids) { - $items = array(); + $items = []; foreach ($ids as $id) { $items[] = $this->getStatus($id); } @@ -135,7 +135,7 @@ class Sample extends AbstractBase */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -159,7 +159,7 @@ class Sample extends AbstractBase */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - return array('count' => 0, 'results' => array()); + return ['count' => 0, 'results' => []]; } /** @@ -177,7 +177,7 @@ class Sample extends AbstractBase */ public function findReserves($course, $inst, $dept) { - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/Sierra.php b/module/VuFind/src/VuFind/ILS/Driver/Sierra.php index f197fd9d489..093c4fdab74 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Sierra.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Sierra.php @@ -106,7 +106,7 @@ class Sierra extends AbstractBase . "(bib_view.id = bib_record_item_record_link.bib_record_id) " . "WHERE bib_view.record_num = $1;"; $record_ids = pg_query_params( - $this->db, $get_record_ids_query, array($this->idStrip($id)) + $this->db, $get_record_ids_query, [$this->idStrip($id)] ); while ($record = pg_fetch_row($record_ids)) { $itemRecords[] = $record[0]; @@ -133,7 +133,7 @@ class Sierra extends AbstractBase . "varfield_view.varfield_type_code = 'c' and " . "varfield_view.record_num = $1;"; $results = pg_query_params( - $this->db, $query, array($this->idStrip($id)) + $this->db, $query, [$this->idStrip($id)] ); $callnumberarray = pg_fetch_array($results, 0, PGSQL_NUM); $callnumber = $callnumberarray[0]; @@ -212,7 +212,7 @@ class Sierra extends AbstractBase { try { // Sierra does not allow for searching for reserves by departments. - $departments = array(); + $departments = []; return $departments; } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -247,7 +247,7 @@ class Sierra extends AbstractBase . "t2.record_type_code = 'r' AND t2.varfield_type_code = 'r' AND " . "t2.occ_num = '0' ORDER BY t1.field_content;"; $results = pg_query($query); - $instructors = array(); + $instructors = []; $j = 0; while ($row = pg_fetch_row($results)) { if ($instructors[$row[2]] != null) { @@ -300,7 +300,7 @@ class Sierra extends AbstractBase . "ON (course_record_item_record_link.course_record_id = " . "varfield_view.record_id) " . "WHERE varfield_view.record_num = $1;"; - $results = pg_query_params($this->db, $query, array($coursenum)); + $results = pg_query_params($this->db, $query, [$coursenum]); while ($resultArray = pg_fetch_row($results)) { $bareNumber = $resultArray[0]; $fullNumber = $this->createFullId($bareNumber); @@ -324,7 +324,7 @@ class Sierra extends AbstractBase public function getFunds() { try { - $funds = array(); + $funds = []; $query = "SELECT DISTINCT fund_master.code_num, fund_master.code FROM sierra_view.fund_master;"; $results = pg_query($this->db, $query); @@ -352,7 +352,7 @@ class Sierra extends AbstractBase public function getStatus($id) { try { - $status = array(); + $status = []; $itemIds = $this->getIds($id); // Use the database ids to get the item-level information (status, // location, and potentially call number) associated with that bib record @@ -376,7 +376,7 @@ class Sierra extends AbstractBase pg_prepare($this->db, "prep_query", $query1); foreach ($itemIds as $item) { $callnumber = null; - $results1 = pg_execute($this->db, "prep_query", array($item)); + $results1 = pg_execute($this->db, "prep_query", [$item]); while ($resultArray = pg_fetch_row($results1)) { if ($resultArray[3] == "c") { $callnumber = $resultArray[2]; @@ -395,14 +395,14 @@ class Sierra extends AbstractBase $availability = false; } - $itemInfo = array( + $itemInfo = [ "id" => $id, "status" => $resultArray[0], "location" => $resultArray[1], "reserve" => "N", "callnumber" => $finalcallnumber, "availability" => $availability - ); + ]; $status[] = $itemInfo; } @@ -430,7 +430,7 @@ class Sierra extends AbstractBase public function getHolding($id, array $patron = null) { try { - $holdings = array(); + $holdings = []; $itemIds = $this->getIds($id); // Use the database ids to get the item-level information (status, // location, and potentially call number) associated with that bib record @@ -456,7 +456,7 @@ class Sierra extends AbstractBase pg_prepare($this->db, "prep_query", $query1); foreach ($itemIds as $item) { $callnumber = null; - $results1 = pg_execute($this->db, "prep_query", array($item)); + $results1 = pg_execute($this->db, "prep_query", [$item]); while ($row1 = pg_fetch_row($results1)) { if ($row1[4] == "b") { $barcode = $row1[3]; @@ -479,7 +479,7 @@ class Sierra extends AbstractBase $availability = false; } - $itemInfo = array( + $itemInfo = [ "id" => $id, "availability" => $availability, "status" => $resultArray[0], @@ -490,7 +490,7 @@ class Sierra extends AbstractBase "returnDate" => false, "number" => $number, "barcode" => $barcode - ); + ]; $holdings[] = $itemInfo; } @@ -521,7 +521,7 @@ class Sierra extends AbstractBase public function getNewItems($page, $limit, $daysOld, $fundID) { try { - $newItems = array(); + $newItems = []; $offset = $limit * ($page - 1); $daysOld = (int) $daysOld; if (is_int($daysOld) == false || $daysOld > 30) { @@ -554,11 +554,11 @@ class Sierra extends AbstractBase . "OFFSET CAST ($2 AS integer);"; if ($fundID != null) { $results = pg_query_params( - $this->db, $query, array($limit, $offset, $fundID) + $this->db, $query, [$limit, $offset, $fundID] ); } else { $results = pg_query_params( - $this->db, $query, array($limit, $offset) + $this->db, $query, [$limit, $offset] ); } $newItems['count'] = (string) pg_num_rows($results); @@ -569,7 +569,7 @@ class Sierra extends AbstractBase $newItems['results'][]['id'] = $fullNumber; } } else { - $newItems['results'] = array(); + $newItems['results'] = []; $newItems['results'][0]['id'] = null; } return $newItems; @@ -595,7 +595,7 @@ class Sierra extends AbstractBase { try { // TODO - $history = array(); + $history = []; return $history; } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -616,7 +616,7 @@ class Sierra extends AbstractBase public function getStatuses($ids) { try { - $statuses = array(); + $statuses = []; foreach ($ids as $id) { $statuses[] = $this->getStatus($id); } @@ -634,7 +634,7 @@ class Sierra extends AbstractBase public function getSuppressedAuthorityRecords() { try { - $authRecords = array(); + $authRecords = []; $query = "SELECT record_metadata.record_num FROM " . "sierra_view.authority_record LEFT JOIN " . "sierra_view.record_metadata ON " @@ -659,7 +659,7 @@ class Sierra extends AbstractBase public function getSuppressedRecords() { try { - $suppRecords = array(); + $suppRecords = []; $query = "SELECT record_metadata.record_num FROM " . "sierra_view.bib_record LEFT JOIN sierra_view.record_metadata " . "ON (bib_record.record_id = record_metadata.id) " diff --git a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php index 90ab240ffbb..d95a72ffeb5 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php @@ -74,50 +74,50 @@ class Symphony extends AbstractBase public function init() { // Merge in defaults. - $this->config += array( - 'WebServices' => array(), - 'PolicyCache' => array(), - 'LibraryFilter' => array(), - 'MarcHoldings' => array(), - '999Holdings' => array(), - 'Behaviors' => array(), - ); - - $this->config['WebServices'] += array( + $this->config += [ + 'WebServices' => [], + 'PolicyCache' => [], + 'LibraryFilter' => [], + 'MarcHoldings' => [], + '999Holdings' => [], + 'Behaviors' => [], + ]; + + $this->config['WebServices'] += [ 'clientID' => 'VuFind', 'baseURL' => 'http://localhost:8080/symws', - 'soapOptions' => array(), - ); + 'soapOptions' => [], + ]; - $this->config['PolicyCache'] += array( + $this->config['PolicyCache'] += [ 'backend' => 'file', - 'backendOptions' => array(), - 'frontendOptions' => array(), - ); + 'backendOptions' => [], + 'frontendOptions' => [], + ]; - $this->config['PolicyCache']['frontendOptions'] += array( + $this->config['PolicyCache']['frontendOptions'] += [ 'automatic_serialization' => true, 'lifetime' => null, - ); + ]; - $this->config['LibraryFilter'] += array( - 'include_only' => array(), - 'exclude' => array(), - ); + $this->config['LibraryFilter'] += [ + 'include_only' => [], + 'exclude' => [], + ]; - $this->config['999Holdings'] += array( + $this->config['999Holdings'] += [ 'entry_number' => 999, 'mode' => 'off', // also off, failover - ); + ]; - $this->config['Behaviors'] += array( + $this->config['Behaviors'] += [ 'showBaseCallNumber' => true, 'showAccountLogin' => true, 'showStaffNotes' => true, 'showFeeType' => 'ALL_FEES', 'usernameField' => 'userID', 'userProfileGroupField' => 'USER_PROFILE_ID' - ); + ]; // Initialize cache manager. if (isset($configArray['PolicyCache']['type'])) { @@ -143,7 +143,7 @@ class Symphony extends AbstractBase */ protected function getSoapClient($service) { - static $soapClients = array(); + static $soapClients = []; if (!isset($soapClients[$service])) { try { @@ -180,7 +180,7 @@ class Symphony extends AbstractBase protected function getSoapHeader($login = null, $password = null, $reset = false ) { - $data = array('clientID' => $this->config['WebServices']['clientID']); + $data = ['clientID' => $this->config['WebServices']['clientID']]; if (!is_null($login)) { $data['sessionToken'] = $this->getSessionToken($login, $password, $reset); @@ -208,7 +208,7 @@ class Symphony extends AbstractBase */ protected function getSessionToken($login, $password, $reset = false) { - static $sessionTokens = array(); + static $sessionTokens = []; // If we keyed only by $login, we might mistakenly retrieve a valid // session token when provided with an invalid password. @@ -223,7 +223,7 @@ class Symphony extends AbstractBase if (!$reset && $token = $_SESSION['symws']['session'][$key]) { $sessionTokens[$key] = $token; } else { - $params = array('login' => $login); + $params = ['login' => $login]; if (isset($password)) { $params['password'] = $password; } @@ -254,8 +254,8 @@ class Symphony extends AbstractBase * * @return mixed the result of the SOAP call */ - protected function makeRequest($service, $operation, $parameters = array(), - $options = array() + protected function makeRequest($service, $operation, $parameters = [], + $options = [] ) { // If provided, use the SoapHeader and skip the rest of makeRequest(). if (isset($options['header'])) { @@ -263,7 +263,7 @@ class Symphony extends AbstractBase $operation, $parameters, null, - array($options['header']) + [$options['header']] ); } @@ -282,7 +282,7 @@ class Symphony extends AbstractBase } elseif (isset($options['WebServices']['login']) && !in_array( $operation, - array('isRestrictedAccess', 'license', 'loginUser', 'version') + ['isRestrictedAccess', 'license', 'loginUser', 'version'] ) ) { $login = $this->config['WebServices']['login']; @@ -336,7 +336,7 @@ class Symphony extends AbstractBase */ protected function checkSymwsVersion() { - $resp = $this->makeRequest('standard', 'version', array()); + $resp = $this->makeRequest('standard', 'version', []); foreach ($resp->version as $v) { if ($v->product == 'SYM-WS') { if (version_compare($v->version, 'v3.2', '<')) { @@ -361,8 +361,8 @@ class Symphony extends AbstractBase */ protected function getStatuses999Holdings($ids) { - $items = array(); - $marcMap = array( + $items = []; + $marcMap = [ 'call number' => 'marc|a', 'copy number' => 'marc|c', 'barcode number' => 'marc|i', @@ -371,7 +371,7 @@ class Symphony extends AbstractBase 'home location' => 'marc|l', 'item type' => 'marc|t', 'circulate flag' => 'marc|r' - ); + ]; $entryNumber = $this->config['999Holdings']['entry_number']; @@ -396,7 +396,7 @@ class Symphony extends AbstractBase $material = $this->translatePolicyID('ITYP', $result['item type']); - $items[$result['id']][] = array( + $items[$result['id']][] = [ 'id' => $result['id'], 'availability' => $available, 'status' => $curr_loc, @@ -410,7 +410,7 @@ class Symphony extends AbstractBase 'item_id' => $result['barcode number'], 'library' => $library, 'material' => $material - ); + ]; } } return $items; @@ -427,7 +427,7 @@ class Symphony extends AbstractBase */ protected function lookupTitleInfo($ids) { - $ids = is_array($ids) ? $ids : array($ids); + $ids = is_array($ids) ? $ids : [$ids]; // SymWS ignores invalid titleIDs instead of rejecting them, so // checking ahead of time for obviously invalid titleIDs is a useful @@ -441,13 +441,13 @@ class Symphony extends AbstractBase } // Prepare $params array for makeRequest(). - $params = array( + $params = [ 'titleID' => $ids, 'includeAvailabilityInfo' => 'true', 'includeItemInfo' => 'true', 'includeBoundTogether' => 'true', 'includeOrderInfo' => 'true', - ); + ]; // If the driver is configured to populate holdings_text_fields // with MFHD, also request MARC holdings information from SymWS. @@ -505,9 +505,9 @@ class Symphony extends AbstractBase protected function parseCallInfo($callInfos, $titleID, $is_holdable = false, $bound_in = null ) { - $items = array(); + $items = []; - $callInfos = is_array($callInfos) ? $callInfos : array($callInfos); + $callInfos = is_array($callInfos) ? $callInfos : [$callInfos]; foreach ($callInfos as $callInfo) { $libraryID = $callInfo->libraryID; @@ -527,7 +527,7 @@ class Symphony extends AbstractBase $itemInfos = is_array($callInfo->ItemInfo) ? $callInfo->ItemInfo - : array($callInfo->ItemInfo); + : [$callInfo->ItemInfo]; foreach ($itemInfos as $itemInfo) { $in_transit = isset($itemInfo->transitReason); $currentLocation = $this->translatePolicyID( @@ -599,7 +599,7 @@ class Symphony extends AbstractBase $itemInfo->numberOfHolds : 0; // Handle item notes - $notes = array(); + $notes = []; if (isset($itemInfo->publicNote)) { $notes[] = $itemInfo->publicNote; @@ -633,7 +633,7 @@ class Symphony extends AbstractBase $holdtype = $available ? 'hold' : 'recall'; - $items[] = array( + $items[] = [ 'id' => $titleID, 'availability' => $available, 'status' => $status, @@ -647,7 +647,7 @@ class Symphony extends AbstractBase 'requests_placed' => $requests_placed, 'barcode' => $itemInfo->itemID, 'notes' => $notes, - 'summary' => array(), + 'summary' => [], 'is_holdable' => $is_holdable, 'holdtype' => $holdtype, 'addLink' => $is_holdable, @@ -666,7 +666,7 @@ class Symphony extends AbstractBase $transitDestinationLibrary, 'transit_reason' => $transitReason, 'transit_date' => $transitDate - ); + ]; } } return $items; @@ -685,11 +685,11 @@ class Symphony extends AbstractBase */ protected function parseBoundwithLinkInfo($boundwithLinkInfos, $ckey) { - $items = array(); + $items = []; $boundwithLinkInfos = is_array($boundwithLinkInfos) ? $boundwithLinkInfos - : array($boundwithLinkInfos); + : [$boundwithLinkInfos]; foreach ($boundwithLinkInfos as $boundwithLinkInfo) { // Ignore BoundwithLinkInfos which do not refer to parents @@ -710,12 +710,12 @@ class Symphony extends AbstractBase $callInfos = is_array($resp->TitleInfo->CallInfo) ? $resp->TitleInfo->CallInfo - : array($resp->TitleInfo->CallInfo); + : [$resp->TitleInfo->CallInfo]; foreach ($callInfos as $callInfo) { $itemInfos = is_array($callInfo->ItemInfo) ? $callInfo->ItemInfo - : array($callInfo->ItemInfo); + : [$callInfo->ItemInfo]; foreach ($itemInfos as $itemInfo) { if ($itemInfo->itemID == $linked_itemID) { $items += $this->parseCallInfo( @@ -744,10 +744,10 @@ class Symphony extends AbstractBase */ protected function parseTitleOrderInfo($titleOrderInfos, $titleID) { - $items = array(); + $items = []; $titleOrderInfos = is_array($titleOrderInfos) - ? $titleOrderInfos : array($titleOrderInfos); + ? $titleOrderInfos : [$titleOrderInfos]; foreach ($titleOrderInfos as $titleOrderInfo) { $library_id = $titleOrderInfo->orderLibraryID; @@ -789,7 +789,7 @@ class Symphony extends AbstractBase } for ($i = 1; $i <= $nr_copies; ++$i) { - $items[] = array( + $items[] = [ 'id' => $titleID, 'availability' => false, 'status' => implode('; ', $statuses), @@ -800,7 +800,7 @@ class Symphony extends AbstractBase 'number' => $i, 'barcode' => true, 'offsite' => $library_id == 'OFFSITE', - ); + ]; } } return $items; @@ -816,10 +816,10 @@ class Symphony extends AbstractBase */ protected function parseMarcHoldingsInfo($marcHoldingsInfos, $titleID) { - $items = array(); + $items = []; $marcHoldingsInfos = is_array($marcHoldingsInfos) ? $marcHoldingsInfos - : array($marcHoldingsInfos); + : [$marcHoldingsInfos]; foreach ($marcHoldingsInfos as $marcHoldingsInfo) { $libraryID = $marcHoldingsInfo->holdingLibraryID; @@ -829,8 +829,8 @@ class Symphony extends AbstractBase $marcEntryInfos = is_array($marcHoldingsInfo->MarcEntryInfo) ? $marcHoldingsInfo->MarcEntryInfo - : array($marcHoldingsInfo->MarcEntryInfo); - $item = array(); + : [$marcHoldingsInfo->MarcEntryInfo]; + $item = []; foreach ($marcEntryInfos as $marcEntryInfo) { foreach ($this->config['MarcHoldings'] as $textfield => $spec) { @@ -841,10 +841,10 @@ class Symphony extends AbstractBase } if (!empty($item)) { - $items[] = $item + array( + $items[] = $item + [ 'id' => $titleID, 'location' => $this->translatePolicyID('LIBR', $libraryID), - ); + ]; } } @@ -864,7 +864,7 @@ class Symphony extends AbstractBase protected function getLiveStatuses($ids) { foreach ($ids as $id) { - $items[$id] = array(); + $items[$id] = []; } /* In Symphony, a title record has at least one "callnum" record, @@ -876,7 +876,7 @@ class Symphony extends AbstractBase $response = $this->lookupTitleInfo($ids); $titleInfos = is_array($response->TitleInfo) ? $response->TitleInfo - : array($response->TitleInfo); + : [$response->TitleInfo]; foreach ($titleInfos as $titleInfo) { $ckey = $titleInfo->titleID; @@ -971,8 +971,8 @@ class Symphony extends AbstractBase */ public function getStatus($id) { - $statuses = $this->getStatuses(array($id)); - return isset($statuses[$id]) ? $statuses[$id] : array(); + $statuses = $this->getStatuses([$id]); + return isset($statuses[$id]) ? $statuses[$id] : []; } /** @@ -1027,7 +1027,7 @@ class Symphony extends AbstractBase */ public function getPurchaseHistory($id) { - return array(); + return []; } /** @@ -1046,23 +1046,23 @@ class Symphony extends AbstractBase { $usernameField = $this->config['Behaviors']['usernameField']; - $patron = array( + $patron = [ 'cat_username' => $username, 'cat_password' => $password, - ); + ]; try { $resp = $this->makeRequest( 'patron', 'lookupMyAccountInfo', - array( + [ 'includePatronInfo' => 'true', 'includePatronAddressInfo' => 'true' - ), - array( + ], + [ 'login' => $username, 'password' => $password, - ) + ] ); } catch (SoapFault $e) { $unableToLogin = 'ns0:com.sirsidynix.symws.service.' @@ -1086,7 +1086,7 @@ class Symphony extends AbstractBase // There may be an email address in any of three numbered addresses, // so we search each one until we find an email address, // starting with the one marked primary. - $addrinfo_check_order = array('1','2','3'); + $addrinfo_check_order = ['1','2','3']; if (isset($resp->patronAddressInfo->primaryAddress)) { $primary_addr_n = $resp->patronAddressInfo->primaryAddress; array_unshift($addrinfo_check_order, $primary_addr_n); @@ -1096,7 +1096,7 @@ class Symphony extends AbstractBase if (isset($resp->patronAddressInfo->$AddressNInfo)) { $addrinfos = is_array($resp->patronAddressInfo->$AddressNInfo) ? $resp->patronAddressInfo->$AddressNInfo - : array($resp->patronAddressInfo->$AddressNInfo); + : [$resp->patronAddressInfo->$AddressNInfo]; foreach ($addrinfos as $addrinfo) { if ($addrinfo->addressPolicyID == 'EMAIL' && !empty($addrinfo->addressValue) @@ -1130,21 +1130,21 @@ class Symphony extends AbstractBase $userProfileGroupField = $this->config['Behaviors']['userProfileGroupField']; - $options = array( + $options = [ 'includePatronInfo' => 'true', 'includePatronAddressInfo' => 'true', 'includePatronStatusInfo' => 'true', 'includeUserGroupInfo' => 'true' - ); + ]; $result = $this->makeRequest( 'patron', 'lookupMyAccountInfo', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); $primaryAddress = $result->patronAddressInfo->primaryAddress; @@ -1164,10 +1164,10 @@ class Symphony extends AbstractBase 'security', 'lookupSessionInfo', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] )->userProfileID; } elseif (strcmp($userProfileGroupField, 'PATRON_LIBRARY_ID') == 0) { $group = $result->patronInfo->patronLibraryID; @@ -1180,7 +1180,7 @@ class Symphony extends AbstractBase list($lastname,$firstname) = explode(', ', $result->patronInfo->displayName); - $profile = array( + $profile = [ 'lastname' => $lastname, 'firstname' => $firstname, 'address1' => $address1, @@ -1188,7 +1188,7 @@ class Symphony extends AbstractBase 'zip' => $zip, 'phone' => $phone, 'group' => $group - ); + ]; return $profile; } catch (\Exception $e) { @@ -1210,22 +1210,22 @@ class Symphony extends AbstractBase public function getMyTransactions($patron) { try { - $transList = array(); - $options = array('includePatronCheckoutInfo' => 'ALL'); + $transList = []; + $options = ['includePatronCheckoutInfo' => 'ALL']; $result = $this->makeRequest( 'patron', 'lookupMyAccountInfo', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); if (isset($result->patronCheckoutInfo)) { $transactions = $result->patronCheckoutInfo; - $transactions = !is_array($transactions) ? array($transactions) : + $transactions = !is_array($transactions) ? [$transactions] : $transactions; foreach ($transactions as $transaction) { @@ -1235,7 +1235,7 @@ class Symphony extends AbstractBase || !empty($transaction->renewalsRemainingUnlimited); $renewable = ($urr && $rr); - $transList[] = array( + $transList[] = [ 'duedate' => date('F j, Y', strtotime($transaction->dueDate)), 'id' => $transaction->titleKey, @@ -1248,7 +1248,7 @@ class Symphony extends AbstractBase //'message' => null, 'title' => $transaction->title, 'item_id' => $transaction->itemID - ); + ]; } } return $transList; @@ -1270,17 +1270,17 @@ class Symphony extends AbstractBase public function getMyHolds($patron) { try { - $holdList = array(); - $options = array('includePatronHoldInfo' => 'ACTIVE'); + $holdList = []; + $options = ['includePatronHoldInfo' => 'ACTIVE']; $result = $this->makeRequest( 'patron', 'lookupMyAccountInfo', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); if (!property_exists($result, 'patronHoldInfo')) { @@ -1288,10 +1288,10 @@ class Symphony extends AbstractBase } $holds = $result->patronHoldInfo; - $holds = !is_array($holds) ? array($holds) : $holds; + $holds = !is_array($holds) ? [$holds] : $holds; foreach ($holds as $hold) { - $holdList[] = array( + $holdList[] = [ 'id' => $hold->titleKey, //'type' => , 'location' => $hold->pickupLibraryID, @@ -1304,7 +1304,7 @@ class Symphony extends AbstractBase //'volume' => null, //'publication_year' => null, 'title' => $hold->title - ); + ]; } return $holdList; } catch(SoapFault $e) { @@ -1327,26 +1327,26 @@ class Symphony extends AbstractBase public function getMyFines($patron) { try { - $fineList = array(); + $fineList = []; $feeType = $this->config['Behaviors']['showFeeType']; - $options = array('includeFeeInfo' => $feeType); + $options = ['includeFeeInfo' => $feeType]; $result = $this->makeRequest( 'patron', 'lookupMyAccountInfo', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); if (isset($result->feeInfo)) { $fees = $result->feeInfo; - $fees = !is_array($fees) ? array($fees) : $fees; + $fees = !is_array($fees) ? [$fees] : $fees; foreach ($fees as $fee) { - $fineList[] = array( + $fineList[] = [ 'amount' => $fee->amount->_ * 100, 'checkout' => isset($fee->feeItemInfo->checkoutDate) ? @@ -1361,7 +1361,7 @@ class Symphony extends AbstractBase $fee->feeItemInfo->dueDate : null, 'id' => isset($fee->feeItemInfo->titleKey) ? $fee->feeItemInfo->titleKey : null - ); + ]; } } @@ -1401,37 +1401,37 @@ class Symphony extends AbstractBase public function cancelHolds($cancelDetails) { $count = 0; - $items = array(); + $items = []; $patron = $cancelDetails['patron']; foreach ($cancelDetails['details'] as $holdKey) { try { - $options = array('holdKey' => $holdKey); + $options = ['holdKey' => $holdKey]; $this->makeRequest( 'patron', 'cancelMyHold', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); $count++; - $items[$holdKey] = array( + $items[$holdKey] = [ 'success' => true, 'status' => 'hold_cancel_success' - ); + ]; } catch (\Exception $e) { - $items[$holdKey] = array( + $items[$holdKey] = [ 'success' => false, 'status' => 'hold_cancel_fail', 'sysMessage' => $e->getMessage() - ); + ]; } } - $result = array('count' => $count, 'items' => $items); + $result = ['count' => $count, 'items' => $items]; return $result; } @@ -1487,42 +1487,42 @@ class Symphony extends AbstractBase */ public function renewMyItems($renewDetails) { - $details = array(); + $details = []; $patron = $renewDetails['patron']; foreach ($renewDetails['details'] as $barcode) { try { - $options = array('itemID' => $barcode); + $options = ['itemID' => $barcode]; $renewal = $this->makeRequest( 'patron', 'renewMyCheckout', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'], - ) + ] ); - $details[$barcode] = array( + $details[$barcode] = [ 'success' => true, 'new_date' => date('j-M-y', strtotime($renewal->dueDate)), 'new_time' => date('g:i a', strtotime($renewal->dueDate)), 'item_id' => $renewal->itemID, 'sysMessage' => $renewal->message - ); + ]; } catch (\Exception $e) { - $details[$barcode] = array( + $details[$barcode] = [ 'success' => false, 'new_date' => false, 'new_time' => false, 'sysMessage' => 'We could not renew this item: ' . $e->getMessage() - ); + ]; } } - $result = array('details' => $details); + $result = ['details' => $details]; return $result; } @@ -1539,7 +1539,7 @@ class Symphony extends AbstractBase public function placeHold($holdDetails) { try { - $options = array(); + $options = []; $patron = $holdDetails['patron']; if ($holdDetails['item_id'] != null) { @@ -1566,23 +1566,23 @@ class Symphony extends AbstractBase 'patron', 'createMyHold', $options, - array( + [ 'login' => $patron['cat_username'], 'password' => $patron['cat_password'] - ) + ] ); - $result = array( + $result = [ 'success' => true, 'sysMessage' => 'Your hold has been placed.' - ); + ]; return $result; } catch (SoapFault $e) { - $result = array( + $result = [ 'success' => false, 'sysMessage' => 'We could not place the hold: ' . $e->getMessage() - ); + ]; return $result; } } @@ -1609,8 +1609,8 @@ class Symphony extends AbstractBase $this->policies[$policyType] = $policyList; return $policyList; } else { - $policyList = array(); - $options = array('policyType' => $policyType); + $policyList = []; + $options = ['policyType' => $policyType]; $policies = $this->makeRequest( 'admin', 'lookupPolicyList', $options ); @@ -1627,7 +1627,7 @@ class Symphony extends AbstractBase return $policyList; } } catch (\Exception $e) { - return array(); + return []; } } @@ -1652,13 +1652,13 @@ class Symphony extends AbstractBase */ public function getPickUpLocations($patron = false, $holdDetails = null) { - $libraries = array(); + $libraries = []; foreach ($this->getPolicyList('LIBR') as $key => $library) { - $libraries[] = array( + $libraries[] = [ 'locationID' => $key, 'locationDisplay' => $library - ); + ]; } return $libraries; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php index 5243c93c61b..462d71b3185 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php @@ -163,18 +163,18 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getPickUpLocations($patron = false, $holdDetails = null) { - $params = array('query' => 'libraries'); + $params = ['query' => 'libraries']; $response = $this->querySirsi($params); $response = rtrim($response); $lines = explode("\n", $response); - $libraries = array(); + $libraries = []; foreach ($lines as $line) { list($code, $name) = explode('|', $line); - $libraries[] = array( + $libraries[] = [ 'locationID' => $code, 'locationDisplay' => empty($name) ? $code : $name - ); + ]; } return $libraries; } @@ -237,24 +237,24 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $details = $renewDetails['details']; $chargeKeys = implode(',', $details); - $params = array( + $params = [ 'query' => 'renew_items', 'chargeKeys' => $chargeKeys, 'patronId' => $patron['cat_username'], 'pin' => $patron['cat_password'], 'library' => $patron['library'] - ); + ]; $response = $this->querySirsi($params); // process the API response if ($response == 'invalid_login') { - return array('blocks' => array("authentication_error_admin")); + return ['blocks' => ["authentication_error_admin"]]; } - $results = array(); + $results = []; $lines = explode("\n", $response); foreach ($lines as $line) { list($chargeKey, $result) = explode('-----API_RESULT-----', $line); - $results[$chargeKey] = array('item_id' => $chargeKey); - $matches = array(); + $results[$chargeKey] = ['item_id' => $chargeKey]; + $matches = []; preg_match('/\^MN([0-9][0-9][0-9])/', $result, $matches); if (isset($matches[1])) { $status = $matches[1]; @@ -273,7 +273,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $results[$chargeKey]['new_time'] = $newTime; } } - return array('details' => $results); + return ['details' => $results]; } /** @@ -290,10 +290,10 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getStatus($id) { - $params = array('query' => 'single', 'id' => $id); + $params = ['query' => 'single', 'id' => $id]; $response = $this->querySirsi($params); if (empty($response)) { - return array(); + return []; } // separate the item lines and the MARC holdings records @@ -343,13 +343,13 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getStatuses($idList) { - $statuses = array(); - $params = array( + $statuses = []; + $params = [ 'query' => 'multiple', 'ids' => implode("|", array_unique($idList)) - ); + ]; $response = $this->querySirsi($params); if (empty($response)) { - return array(); + return []; } $lines = explode("\n", $response); @@ -359,7 +359,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $item = $this->parseStatusLine($line); if ($item['id'] != $currentId) { $currentId = $item['id']; - $statuses[] = array(); + $statuses[] = []; $group++; } $statuses[$group][] = $item; @@ -383,7 +383,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -432,7 +432,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); // query sirsi - $params = array( + $params = [ 'query' => 'hold', 'itemId' => $holdDetails['item_id'], 'patronId' => $patron['cat_username'], @@ -443,30 +443,30 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'holdType' => $holdDetails['level'], 'callnumber' => $holdDetails['callnumber'], 'override' => $holdDetails['override'] - ); + ]; $response = $this->querySirsi($params); // process the API response if ($response == 'invalid_login') { - return array( + return [ 'success' => false, - 'sysMessage' => "authentication_error_admin"); + 'sysMessage' => "authentication_error_admin"]; } - $matches = array(); + $matches = []; preg_match('/\^MN([0-9][0-9][0-9])/', $response, $matches); if (isset($matches[1])) { $status = $matches[1]; if ($status == '209') { - return array('success' => true); + return ['success' => true]; } else { - return array( + return [ 'success' => false, - 'sysMessage' => $this->config['ApiMessages'][$status]); + 'sysMessage' => $this->config['ApiMessages'][$status]]; } } - return array('success' => false); + return ['success' => false]; } /** @@ -484,9 +484,9 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function patronLogin($username, $password) { //query sirsi - $params = array( + $params = [ 'query' => 'login', 'patronId' => $username, 'pin' => $password - ); + ]; $response = $this->querySirsi($params); if (empty($response)) { @@ -504,7 +504,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $expiry = $this->parseDateTime(trim($expiry)); } $expired = ($expiry == '0') ? false : $expiry < time(); - return array( + return [ 'id' => $username, 'firstname' => $first, 'lastname' => $last, @@ -527,7 +527,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'number_of_holds' => $holds, 'status' => $status, 'user_key' => $user_key - ); + ]; } /** @@ -546,15 +546,15 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $password = $patron['cat_password']; //query sirsi - $params = array( + $params = [ 'query' => 'profile', 'patronId' => $username, 'pin' => $password - ); + ]; $response = $this->querySirsi($params); list(, , , , $library, $profile, , , , , , , , $email, $address1, $zip, $phone, $address2) = explode('|', $response); - return array( + return [ 'firstname' => $patron['firstname'], 'lastname' => $patron['lastname'], 'address1' => $address1, @@ -564,7 +564,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'email' => $email, 'group' => $profile, 'library' => $library - ); + ]; } /** @@ -583,15 +583,15 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $username = $patron['cat_username']; $password = $patron['cat_password']; - $params = array( + $params = [ 'query' => 'fines', 'patronId' => $username, 'pin' => $password - ); + ]; $response = $this->querySirsi($params); if (empty($response)) { - return array(); + return []; } $lines = explode("\n", $response); - $items = array(); + $items = []; foreach ($lines as $item) { list($catkey, $amount, $balance, $date_billed, $number_of_payments, $with_items, $reason, $date_charged, $duedate, $date_recalled) @@ -608,7 +608,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $date_charged = $this->parseDateTime($date_charged); $duedate = $this->parseDateTime($duedate); $date_recalled = $this->parseDateTime($date_recalled); - $items[] = array( + $items[] = [ 'id' => $catkey, 'amount' => $amount, 'balance' => $balance, @@ -619,7 +619,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'checkout' => $this->formatDateTime($date_charged), 'duedate' => $this->formatDateTime($duedate), 'date_recalled' => $this->formatDateTime($date_recalled) - ); + ]; } return $items; @@ -641,15 +641,15 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $username = $patron['cat_username']; $password = $patron['cat_password']; - $params = array( + $params = [ 'query' => 'getholds', 'patronId' => $username, 'pin' => $password - ); + ]; $response = $this->querySirsi($params); if (empty($response)) { - return array(); + return []; } $lines = explode("\n", $response); - $items = array(); + $items = []; foreach ($lines as $item) { list($catkey, $holdkey, $available, , $date_expires, , $date_created, , $type, $pickup_library, , , , , , , $barcode) @@ -657,7 +657,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $date_created = $this->parseDateTime($date_created); $date_expires = $this->parseDateTime($date_expires); - $items[] = array( + $items[] = [ 'id' => $catkey, 'reqnum' => $holdkey, 'available' => ($available == 'Y') ? true : false, @@ -667,7 +667,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'location' => $pickup_library, 'item_id' => $holdkey, 'barcode' => trim($barcode) - ); + ]; } return $items; @@ -705,11 +705,11 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $patron = $cancelDetails['patron']; $details = $cancelDetails['details']; - $params = array( + $params = [ 'query' => 'cancelHolds', 'patronId' => $patron['cat_username'], 'pin' => $patron['cat_password'], 'holdId' => implode('|', $details) - ); + ]; $response = $this->querySirsi($params); // process response @@ -721,7 +721,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $lines = explode("\n", $response); // if there are more than 1 lines, then there is at least 1 failure - $failures = array(); + $failures = []; if (count($lines) > 1) { // extract the failed IDs. foreach ($lines as $line) { @@ -734,20 +734,20 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } $count = 0; - $items = array(); + $items = []; foreach ($details as $holdKey) { if (in_array($holdKey, $failures)) { - $items[$holdKey] = array( + $items[$holdKey] = [ 'success' => false, 'status' => "hold_cancel_fail" - ); + ]; } else { $count++; - $items[$holdKey] = array( + $items[$holdKey] = [ 'success' => true, 'status' => "hold_cancel_success" - ); + ]; } } - $result = array('count' => $count, 'items' => $items); + $result = ['count' => $count, 'items' => $items]; return $result; } @@ -768,15 +768,15 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $username = $patron['cat_username']; $password = $patron['cat_password']; - $params = array( + $params = [ 'query' => 'transactions', 'patronId' => $username, 'pin' => $password - ); + ]; $response = $this->querySirsi($params); if (empty($response)) { - return array(); + return []; } $item_lines = explode("\n", $response); - $items = array(); + $items = []; foreach ($item_lines as $item) { list($catkey, $date_charged, $duedate, $date_renewed, $accrued_fine, $overdue, $number_of_renewals, $date_recalled, @@ -793,7 +793,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); } $charge_key = "$charge_key1|$charge_key2|$charge_key3|$charge_key4"; - $items[] = array( + $items[] = [ 'id' => $catkey, 'date_charged' => $this->formatDateTime($this->parseDateTime($date_charged)), @@ -812,7 +812,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'item_id' => $charge_key, 'callnum' => $callnum, 'dueStatus' => $overdue == 'Y' ? 'overdue' : '' - ); + ]; } if (!empty($items)) { @@ -842,12 +842,12 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getCourses() { //query sirsi - $params = array('query' => 'courses'); + $params = ['query' => 'courses']; $response = $this->querySirsi($params); $response = rtrim($response); $course_lines = explode("\n", $response); - $courses = array(); + $courses = []; foreach ($course_lines as $course) { list($id, $code, $name) = explode('|', $course); @@ -869,12 +869,12 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getInstructors() { //query sirsi - $params = array('query' => 'instructors'); + $params = ['query' => 'instructors']; $response = $this->querySirsi($params); $response = rtrim($response); $user_lines = explode("\n", $response); - $users = array(); + $users = []; foreach ($user_lines as $user) { list($id, $name) = explode('|', $user); @@ -895,12 +895,12 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getDepartments() { //query sirsi - $params = array('query' => 'desks'); + $params = ['query' => 'desks']; $response = $this->querySirsi($params); $response = rtrim($response); $dept_lines = explode("\n", $response); - $depts = array(); + $depts = []; foreach ($dept_lines as $dept) { list($id, $name) = explode('|', $dept); @@ -927,31 +927,31 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { //query sirsi if ($courseId) { - $params = array( + $params = [ 'query' => 'reserves', 'course' => $courseId, 'instructor' => '', 'desk' => '' - ); + ]; } elseif ($instructorId) { - $params = array( + $params = [ 'query' => 'reserves', 'course' => '', 'instructor' => $instructorId, 'desk' => '' - ); + ]; } elseif ($departmentId) { - $params = array( + $params = [ 'query' => 'reserves', 'course' => '', 'instructor' => '', 'desk' => $departmentId - ); + ]; } else { - $params = array( + $params = [ 'query' => 'reserves', 'course' => '', 'instructor' => '', 'desk' => '' - ); + ]; } $response = $this->querySirsi($params); $item_lines = explode("\n", $response); - $items = array(); + $items = []; foreach ($item_lines as $item) { list($instructor_id, $course_id, $dept_id, $bib_id) = explode('|', $item); @@ -959,12 +959,12 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf && (empty($courseId) || $courseId == $course_id) && (empty($departmentId) || $departmentId == $dept_id) ) { - $items[] = array( + $items[] = [ 'BIB_ID' => $bib_id, 'INSTRUCTOR_ID' => $instructor_id, 'COURSE_ID' => $course_id, 'DEPARTMENT_ID' => $dept_id - ); + ]; } } return $items; @@ -997,7 +997,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // ? $params = array('query' => 'newItems', // 'lib' => array_search($lib, $config['Libraries'])) // : $params = array('query' => 'newItems'); - $params = array('query' => 'newitems', 'lib' => 'PPL'); + $params = ['query' => 'newitems', 'lib' => 'PPL']; $response = $this->querySirsi($params); $item_lines = explode("\n", rtrim($response)); @@ -1005,14 +1005,14 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $rescount = 0; foreach ($item_lines as $item) { $item = rtrim($item, '|'); - $items[$item] = array( + $items[$item] = [ 'id' => $item - ); + ]; $rescount++; } $results = array_slice($items, ($page - 1) * $limit, ($page * $limit)-1); - return array('count' => $rescount, 'results' => $results); + return ['count' => $rescount, 'results' => $results]; } /** @@ -1023,11 +1023,11 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getSuppressedRecords() { - $params = array('query' => 'shadowed'); + $params = ['query' => 'shadowed']; $response = $this->querySirsi($params); $record_lines = explode("\n", rtrim($response)); - $records = array(); + $records = []; foreach ($record_lines as $record) { $record = rtrim($record, '|'); $records[] = $record; @@ -1088,7 +1088,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $status = $this->config['UnavailableLocations'][$currLocCode]; } - $item = array( + $item = [ 'status' => $status, 'availability' => $availability, 'id' => $catkey, @@ -1115,7 +1115,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'date_recalled' => $this->formatDateTime($date_recalled), 'item_key' => $itemkey1 . '|' . $itemkey2 . '|' . $itemkey3 . '|', 'format' => $format - ); + ]; return $item; } @@ -1293,14 +1293,14 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf { $library_code = $field->getSubfield('b')->getData(); $location_code = $field->getSubfield('c')->getData(); - $location = array( + $location = [ 'library_code' => $library_code, 'library' => $this->mapLibrary($library_code), 'location_code' => $location_code, 'location' => $this->mapLocation($location_code), - 'notes' => array(), + 'notes' => [], 'marc852' => $field - ); + ]; foreach ($field->getSubfields('z') as $note) { $location['notes'][] = $note->getData(); } @@ -1321,15 +1321,15 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ protected function decodeMarcHoldingRecord($record) { - $locations = array(); - $holdings = array(); + $locations = []; + $holdings = []; // First pass: // - process locations // // - collect textual holdings indexed by linking number to be // able to easily check later what fields from enumeration // and chronology they override. - $textuals = array(); + $textuals = []; foreach ($record->getFields('852|866', true) as $field) { switch ($field->getTag()) { case '852': @@ -1361,7 +1361,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $link_digits = floor(strlen((string)PHP_INT_MAX) / 2); foreach ((array_key_exists(0, $textuals) - ? array() + ? [] : $record->getFields('863')) as $field) { $linking_field = $field->getSubfield('8'); @@ -1410,7 +1410,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $holdings[$ndx] = trim($textual_holding); } - return array($locations, $holdings); + return [$locations, $holdings]; } /** @@ -1423,7 +1423,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ protected function getMarcHoldings($marc) { - $holdings = array(); + $holdings = []; $file = new File_MARC($marc, File_MARC::SOURCE_STRING); while ($marc = $file->next()) { list($locations, $record_holdings) @@ -1433,7 +1433,7 @@ class Unicorn extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf foreach ($locations as $location) { $holdings[] = array_merge_recursive( $location, - array('summary' => $record_holdings) + ['summary' => $record_holdings] ); } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php index d47b9597762..871d4812416 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php @@ -96,7 +96,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getStatus($id) { - $holding = array(); + $holding = []; // Strip off the prefix from vtls exports $db_id = str_replace("vtls", "", $id); @@ -133,7 +133,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND d.bibid = :bib_id"; // Bind our bib_id and execute - $fields = array("bib_id:string" => $db_id); + $fields = ["bib_id:string" => $db_id]; $result = $this->db->simpleSelect($sql, $fields); // If there are no results, lets try again because it has no items @@ -144,7 +144,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { - $new_holding = array( + $new_holding = [ 'id' => $id, 'availability' => false, 'reserve' => "Y", @@ -152,7 +152,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa 'location' => "Toowoomba", 'campus' => "Toowoomba", 'callnumber' => $result[0]['CALL_NUMBER'] - ); + ]; switch ($result[0]['CALL_NUMBER']) { case 'ELECTRONIC RESOURCE' : @@ -282,7 +282,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa } } - $holding[] = array( + $holding[] = [ 'id' => $id, 'availability' => $available, 'status' => $row['STATUS'], @@ -290,7 +290,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa 'reserve' => $row['RESERVE'], 'campus' => $campus, 'callnumber' => $row['BIB_CALL_NUM'] - ); + ]; } return $holding; @@ -309,7 +309,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getStatuses($idList) { - $status = array(); + $status = []; foreach ($idList as $id) { $status[] = $this->getStatus($id); } @@ -335,7 +335,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa { // Strip off the prefix from vtls exports $db_id = str_replace("vtls", "", $id); - $fields = array("bib_id:string" => $db_id); + $fields = ["bib_id:string" => $db_id]; $holds = "SELECT d1.itemid, MAX(h1.request_control_number) AS req_num " . "FROM dbadmin.itemdetl2 d1, dbadmin.hlrcdetl h1 " . @@ -436,7 +436,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $call_num = $row['BIB_CALL_NUM']; } - $temp = array( + $temp = [ "id" => $id, "availability" => $available, "status" => $row['STATUS'], @@ -451,7 +451,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "itemclass" => $row['ITEM_CLASS'], "units" => $row['UNITS'], "resitemclass" => $row['RESERVE_ITEM_CLASS'] - ); + ]; // Add to the holdings array $holding[] = $temp; @@ -484,7 +484,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "FROM patron_type_patron p, patron_barcode b " . "WHERE b.patron_id = p.patron_id " . "AND b.barcode = :patron"; - $fields = array("patron:string" => $patron_id); + $fields = ["patron:string" => $patron_id]; $result = $this->db->simpleSelect($sql, $fields); // We should have 1 row and only 1 row. @@ -495,19 +495,19 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // A matrix of patron types and locations // TODO: Make this configurable through Virtua.ini. - $type_list = array( - 'Externals' => array('AX', 'AD', 'BX', 'BD', 'EX', 'ED', 'GX', 'GD', - 'RX', 'SX', 'SD', 'XS', 'CC', 'RD'), - 'Super User' => array('LP', 'OC'), + $type_list = [ + 'Externals' => ['AX', 'AD', 'BX', 'BD', 'EX', 'ED', 'GX', 'GD', + 'RX', 'SX', 'SD', 'XS', 'CC', 'RD'], + 'Super User' => ['LP', 'OC'], // 1 => Toowoomba - '1' => array('AU', 'AM', 'BU', 'BM', 'EU', 'EM', 'GU', 'GM', 'RI', 'SU', - 'SM', 'SC', 'RB', 'OT', 'ST', 'FC', 'LS'), + '1' => ['AU', 'AM', 'BU', 'BM', 'EU', 'EM', 'GU', 'GM', 'RI', 'SU', + 'SM', 'SC', 'RB', 'OT', 'ST', 'FC', 'LS'], // 5 => Springfield - '5' => array('US', 'ES', 'PS', 'AS', 'GS', 'TS', 'TAS', 'EPS', 'XVS', - 'XPS'), + '5' => ['US', 'ES', 'PS', 'AS', 'GS', 'TS', 'TAS', 'EPS', 'XVS', + 'XPS'], // 4 => Fraser Coast - '4' => array('UF', 'PF', 'AF') - ); + '4' => ['UF', 'PF', 'AF'] + ]; // Where is the patron from? $location = ""; foreach ($type_list as $loc => $patron_types) { @@ -517,32 +517,32 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa } // Requestable Statuses // TODO: Make this configurable through Virtua.ini. - $status_list = array( + $status_list = [ "4401", // At Repair "4705", // ON HOLD "5400", // Being Processed "5401", // On Display "5402", // 24 Hour Hold "5700" // IN TRANSIT - ); + ]; // Who can place reservations on available items - $available_locs = array( - '1' => array('5', '4'), - '4' => array(), - '5' => array() - ); + $available_locs = [ + '1' => ['5', '4'], + '4' => [], + '5' => [] + ]; // Who can place reservations on UNavailable items - $unavailable_locs = array( - '1' => array('1', '5', '4'), - '4' => array(), - '5' => array('5') - ); + $unavailable_locs = [ + '1' => ['1', '5', '4'], + '4' => [], + '5' => ['5'] + ]; // Who can place reservations on STATUS items - $status_locs = array( - '1' => array('1', '5', '4'), - '4' => array(), - '5' => array('5') - ); + $status_locs = [ + '1' => ['1', '5', '4'], + '4' => [], + '5' => ['5'] + ]; // Set a flag for super users, better then // the full function call inside the loop @@ -559,8 +559,8 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa /* * Finished our basic tests, the real logic starts here */ - $sorted = array(); // We'll put items from the patron's location in here - $return = array(); // Everything else in here + $sorted = []; // We'll put items from the patron's location in here + $return = []; // Everything else in here foreach ($holdings as $h) { // Super Users (eg. Off-Camp, and Lending) can request anything if ($super_user) { @@ -842,7 +842,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa protected function renderSubPattern($data) { $return_string = ""; - $sub_pattern = array(); + $sub_pattern = []; $i = 0; foreach ($data['pattern'] as $p) { // Is this chrono pattern element? @@ -852,7 +852,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // and clear the array if ($is_ch_pattern === false) { $return_string .= $this->renderPartSubPattern($sub_pattern); - $sub_pattern = array(); + $sub_pattern = []; } // Add the current element to the array @@ -864,7 +864,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // on it's own and clear the array again if ($is_ch_pattern === false) { $return_string .= $this->renderPartSubPattern($sub_pattern); - $sub_pattern = array(); + $sub_pattern = []; } $i++; } @@ -885,7 +885,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ protected function renderOtherPattern($data) { - $return = array(); + $return = []; $i = 0; foreach ($data['data'] as $d) { switch ($data['pattern_code'][$i]) { @@ -913,15 +913,15 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ protected function renderPattern($patterns, $field) { - $return = array(); + $return = []; // Check we have a pattern and the pattern exists if (isset($field['pattern']) && isset($patterns[$field['pattern']])) { // Enumeration, Chonology and Other fields - $enum_chrono = array( + $enum_chrono = [ 'a', 'b', 'c', 'd', 'e', 'f', 'i', 'j', 'k', 'l', 'm' - ); - $this_en_ch = array('pattern' => array(), 'data' => array()); - $this_other = array('pattern' => array(), 'data' => array()); + ]; + $this_en_ch = ['pattern' => [], 'data' => []]; + $this_other = ['pattern' => [], 'data' => []]; $pattern = $patterns[$field['pattern']]; // Foreach subfield @@ -961,26 +961,26 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa protected function renderSerialHoldings($holdings_marc) { // Convert to one line per tag - $data_set = array(); + $data_set = []; foreach ($holdings_marc as $row) { if ($row['SUBFIELD_DATA'] != null && trim($row['SUBFIELD_DATA']) != "" ) { - $data_set[$row['FIELD_SEQUENCE']][] = array( + $data_set[$row['FIELD_SEQUENCE']][] = [ 'tag' => trim($row['FIELD_TAG']), 'code' => trim($row['SUBFIELD_CODE']), 'data' => trim($row['SUBFIELD_DATA']) - ); + ]; } } // Prepare the set for sorting on '8' subfields, also move the tag data out - $sort_set = array(); + $sort_set = []; // Loop through each sequence foreach ($data_set as $row) { $sort = ''; $tag = ''; - $data = array(); + $data = []; // And each subfield foreach ($row as $subfield) { @@ -994,17 +994,17 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $sort_order = sprintf("%05d", $sort_order); } else { // Everything else goes in the data bucket - $data[] = array( + $data[] = [ 'code' => $subfield['code'], 'data' => $subfield['data'] - ); + ]; } } - $sort_set[$sort_rule . "." . $sort_order] = array( + $sort_set[$sort_rule . "." . $sort_order] = [ 'tag' => $tag, 'data' => $data - ); + ]; } // Sort the float array @@ -1012,22 +1012,22 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // Remove the prediction patterns from the list // and drop sort orders or holdings. - $patterns = array(); - $holdings_data = array(); + $patterns = []; + $holdings_data = []; foreach ($sort_set as $sort => $row) { $rule = explode('.', $sort); if ($row['tag'] == 853) { $patterns[$rule[0]] = $row['data']; } else { - $holdings_data[] = array( + $holdings_data[] = [ 'pattern' => $rule[0], 'data' => $row['data'] - ); + ]; } } // Render all the holdings now - $rendered_list = array(); + $rendered_list = []; foreach ($holdings_data as $row) { $rendered_list[] = $this->renderPattern($patterns, $row); } @@ -1050,7 +1050,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa { // Strip off the prefix from vtls exports $db_id = str_replace("vtls", "", $id); - $fields = array("bib_id:string" => $db_id); + $fields = ["bib_id:string" => $db_id]; // Let's go check if this bib id is for a serial $sql = "SELECT h.holdingsid, l.name " . @@ -1063,7 +1063,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // Results indicate serial holdings if (count($result) == 0) { - return array(); + return []; } $sql = "SELECT * " . @@ -1073,9 +1073,9 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND i.field_tag in ('853', '863', '866') " . "ORDER BY i.field_sequence, i.subfield_sequence"; - $data = array(); + $data = []; foreach ($result as $row) { - $fields = array("hid:string" => $row['HOLDINGSID']); + $fields = ["hid:string" => $row['HOLDINGSID']]; $hresult = $this->db->simpleSelect($sql, $fields); $data[$row['NAME']] = $this->renderSerialHoldings($hresult); } @@ -1101,16 +1101,16 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa return null; } - $data_set = array(); + $data_set = []; foreach ($hresult as $row) { if ($row['SUBFIELD_DATA'] != null && trim($row['SUBFIELD_DATA']) != "" ) { - $data_set[$row['ID'] . "_" . $row['FIELD_SEQUENCE']][] = array( + $data_set[$row['ID'] . "_" . $row['FIELD_SEQUENCE']][] = [ 'id' => trim($row['ID']), 'code' => trim($row['SUBFIELD_CODE']), 'data' => trim($row['SUBFIELD_DATA']) - ); + ]; } } return $data_set; @@ -1146,13 +1146,13 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa " WHERE UPPER(p.barcode) = UPPER(:barcode) " . ")"; - $fields = array("barcode:string" => $barcode); + $fields = ["barcode:string" => $barcode]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { // Valid Password if ($result[0]['PASSWORD'] == $password) { - $user = array(); + $user = []; $split = strpos($result[0]['NAME'], ','); $last_name = trim(substr($result[0]['NAME'], 0, $split)); $first_name = trim(substr($result[0]['NAME'], $split + 1)); @@ -1201,7 +1201,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND t.patron_type_id = pt.patron_type_id " . "AND p.patron_id = :patron_id"; - $fields = array("patron_id:string" => $patron['id']); + $fields = ["patron_id:string" => $patron['id']]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { @@ -1213,7 +1213,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $first_name = substr($first_name, 0, $split); } - $patron = array( + $patron = [ 'firstname' => trim($first_name), 'lastname' => trim($last_name), 'address1' => trim($result[0]['STREET_ADDRESS_1']), @@ -1221,7 +1221,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa 'zip' => trim($result[0]['POSTAL_CODE']), 'phone' => trim($result[0]['TELEPHONE_PRIMARY']), 'group' => trim($result[0]['PATRON_TYPE']) - ); + ]; if ($result[0]['CITY'] != null) { if (strlen($patron['address2']) > 0) { @@ -1250,7 +1250,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getMyFines($patron) { - $fineList = array(); + $fineList = []; $sql = "SELECT a.assessment_amount fine_amount, f.description, " . "a.balance, a.item_due_date due_date, i.bibid bib_id " . @@ -1261,18 +1261,18 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND a.fine_code_id = f.fine_code_id " . "AND a.patron_id = :patron_id"; - $fields = array("patron_id:string" => $patron['id']); + $fields = ["patron_id:string" => $patron['id']]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { foreach ($result as $row) { - $fineList[] = array( + $fineList[] = [ "amount" => $row['FINE_AMOUNT'] * 100, "fine" => $row['DESCRIPTION'], "balance" => $row['BALANCE'] * 100, "duedate" => $row['DUE_DATE'], "id" => "vtls" . sprintf("%09d", (int)$row['BIB_ID']) - ); + ]; } } return $fineList; @@ -1291,7 +1291,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getMyHolds($patron) { - $holdList = array(); + $holdList = []; $sql = "SELECT h.bibid, l.name pickup_location, h.pickup_any_location, " . "h.date_last_needed, h.date_placed, h.request_control_number " . @@ -1299,18 +1299,18 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "WHERE h.pickup_location = l.location_id " . "AND h.patron_id = :patron_id"; - $fields = array("patron_id:string" => $patron['id']); + $fields = ["patron_id:string" => $patron['id']]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { foreach ($result as $row) { - $holdList[] = array( + $holdList[] = [ "id" => "vtls" . sprintf("%09d", (int)$row['BIBID']), "location" => $row['PICKUP_LOCATION'], "expire" => $row['DATE_LAST_NEEDED'], "create" => $row['DATE_PLACED'], "reqnum" => $row['REQUEST_CONTROL_NUMBER'] - ); + ]; } } return $holdList; @@ -1330,7 +1330,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getMyTransactions($patron) { - $transList = array(); + $transList = []; $bib_reqs = "SELECT h.bibid, count(*) as bib_req " . "FROM hlrcdetl h " . @@ -1350,19 +1350,19 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND c.patron_id = :patron_id " . "ORDER BY c.due_date"; - $fields = array("patron_id:string" => $patron['id']); + $fields = ["patron_id:string" => $patron['id']]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { foreach ($result as $row) { - $transList[] = array( + $transList[] = [ 'duedate' => $row['DUE_DATE'], 'barcode' => $row['BARCODE'], 'renew' => $row['RENEW_COUNT'], 'request' => $row['REQ_COUNT'], // IDs need to show as 'vtls000589589' 'id' => "vtls" . sprintf("%09d", (int)$row['BIBID']) - ); + ]; } } return $transList; @@ -1378,7 +1378,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getCourses() { - $courseList = array(); + $courseList = []; $sql = "SELECT DISTINCT l.course_id " . "FROM reserve_list_v l, reserve_item_v i " . @@ -1412,7 +1412,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function findReserves($course, $inst = false, $dept = false) { - $recordList = array(); + $recordList = []; $sql = "SELECT DISTINCT d.bibid " . "FROM reserve_item_v i, reserve_list_v l, itemdetl2 d " . @@ -1420,7 +1420,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND SYSDATE BETWEEN i.Begin_date AND i.End_date " . "AND i.Item_id = d.itemid " . "AND l.Course_id = :course"; - $fields = array("course:string" => $course); + $fields = ["course:string" => $course]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) > 0) { @@ -1461,23 +1461,23 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $sql = "SELECT campus, open_time, close_time, status " . "FROM usq_sr_open_normal n " . "WHERE UPPER(dayofweek) = UPPER(:dow)"; - $fields = array("dow:string" => date("l", $time)); + $fields = ["dow:string" => date("l", $time)]; $result = $this->db->simpleSelect($sql, $fields); if (count($result) == 0) { - return array(); + return []; } // Create our return data structure - $times = array(); + $times = []; foreach ($result as $row) { // Remember times come out with no date, add in today. - $times[$row['CAMPUS']] = array( + $times[$row['CAMPUS']] = [ 'open' => "$today " . date($time_format, strtotime($row['OPEN_TIME'])), 'close' => "$today " . date($time_format, strtotime($row['CLOSE_TIME'])), 'status' => $row['STATUS'] - ); + ]; } // Opening hours exceptions @@ -1497,11 +1497,11 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "AND to_date(:today,'dd/mm/yyyy') " . "BETWEEN e.except_date_from AND e.except_date_to " . "AND app_$day = 1"; - $fields = array("today:string" => date("d/m/Y", $time)); + $fields = ["today:string" => date("d/m/Y", $time)]; $exceptions = $this->db->simpleSelect($sql, $fields); foreach ($exceptions as $row) { - $times[$row['CAMPUS']] = array( + $times[$row['CAMPUS']] = [ // Remember times come out with no date, add in today. 'open' => "$today " . date($time_format, strtotime($row['OPEN_TIME'])), @@ -1509,7 +1509,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa . date($time_format, strtotime($row['CLOSE_TIME'])), 'status' => $row['STATUS'], 'reason' => $row['REASON'] - ); + ]; } return $times; } @@ -1537,27 +1537,27 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $last_date = $holdDetails['requiredBy']; // Assume an error response: - $response = array('success' => false, 'status' => "hold_error_fail"); + $response = ['success' => false, 'status' => "hold_error_fail"]; // Get the iPortal server $web_server = $this->config['Catalog']['webhost']; // Validate input // * Request level - $allowed_req_levels = array( + $allowed_req_levels = [ 'item' => 0, 'bib' => 1, 'volume' => 2 - ); + ]; if (!in_array($req_level, array_keys($allowed_req_levels))) { return $response; } // * Pickup Location - $allowed_pickup_locs = array( + $allowed_pickup_locs = [ 'Toowoomba' => '10000', 'Fraser Coast' => '40000', 'Springfield' => '50000' - ); + ]; if (!in_array($pickup_loc, array_keys($allowed_pickup_locs))) { return $response; } @@ -1693,7 +1693,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $web_server = $this->config['Catalog']['webhost']; $virtua_url = "http://$web_server/cgi-bin/chameleon"; - $postParams = array( + $postParams = [ "SourceScreen" => "INITREQ", "conf" => "./chameleon.conf", "elementcount" => "1", @@ -1708,7 +1708,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa "patronid" => $patron['cat_username'], "patronpassword" => $patron['cat_password'], "patronhost" => $this->config['Catalog']['patron_host'] - ); + ]; // Get the response $result = $this->httpRequest($virtua_url, $postParams); @@ -1761,7 +1761,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa // Get items out on loan at the moment $result = $this->getMyTransactions($patron); // Make it more accessible - by barcode - $initial = array(); + $initial = []; foreach ($result as $row) { $initial[$row['barcode']] = $row; } @@ -1801,7 +1801,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa $result = $this->getMyTransactions($patron); // Foreach item currently on loan - $return = array(); + $return = []; foreach ($result as $row) { // Did we even attempt to renew? if (in_array($row['barcode'], $item_list)) { @@ -1829,7 +1829,7 @@ class Virtua extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterfa */ public function getSuppressedAuthorityRecords() { - $list = array(); + $list = []; $sql = "select auth_id " . "from state_record_authority " . diff --git a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php index 939b9d0f250..438b73a70d3 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php @@ -196,7 +196,7 @@ class Voyager extends AbstractBase $sqlString .= (!empty($sql['order'])) ? ' ORDER BY ' . implode(', ', $sql['order']) : ''; - return array('string' => $sqlString, 'bind' => $sql['bind']); + return ['string' => $sqlString, 'bind' => $sql['bind']]; } /** @@ -278,7 +278,7 @@ class Voyager extends AbstractBase // shelf) status, collecting any other statuses we find along the // way... $notCharged = false; - $otherStatuses = array(); + $otherStatuses = []; foreach ($statusArray as $status) { switch ($status) { case 'Not Charged': @@ -294,7 +294,7 @@ class Voyager extends AbstractBase // the item is not available! $available = (count($otherStatuses) == 0 && $notCharged); - return array('available' => $available, 'otherStatuses' => $otherStatuses); + return ['available' => $available, 'otherStatuses' => $otherStatuses]; } /** @@ -329,7 +329,7 @@ class Voyager extends AbstractBase protected function getStatusSQL($id) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "BIB_ITEM.BIB_ID", "ITEM.ITEM_ID", "ITEM.ON_RESERVE", "ITEM_STATUS_DESC as status", "NVL(LOCATION.LOCATION_DISPLAY_NAME, " . @@ -338,19 +338,19 @@ class Voyager extends AbstractBase "ITEM.TEMP_LOCATION", "ITEM.ITEM_TYPE_ID", "ITEM.ITEM_SEQUENCE_NUMBER", $this->getItemSortSequenceSQL('ITEM.PERM_LOCATION') - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".BIB_ITEM", $this->dbName . ".ITEM", $this->dbName . ".ITEM_STATUS_TYPE", $this->dbName . ".ITEM_STATUS", $this->dbName . ".LOCATION", $this->dbName . ".MFHD_ITEM", $this->dbName . ".MFHD_MASTER" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "BIB_ITEM.BIB_ID = :id", "BIB_ITEM.ITEM_ID = ITEM.ITEM_ID", "ITEM.ITEM_ID = ITEM_STATUS.ITEM_ID", @@ -359,17 +359,17 @@ class Voyager extends AbstractBase "MFHD_ITEM.ITEM_ID = ITEM.ITEM_ID", "MFHD_MASTER.MFHD_ID = MFHD_ITEM.MFHD_ID", "MFHD_MASTER.SUPPRESS_IN_OPAC='N'" - ); + ]; // Bind - $sqlBind = array(':id' => $id); + $sqlBind = [':id' => $id]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind, - ); + ]; return $sqlArray; } @@ -385,7 +385,7 @@ class Voyager extends AbstractBase protected function getStatusNoItemsSQL($id) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "BIB_MFHD.BIB_ID", "1 as ITEM_ID", "'N' as ON_RESERVE", "'No information available' as status", @@ -395,33 +395,33 @@ class Voyager extends AbstractBase "0 AS TEMP_LOCATION", "0 as ITEM_SEQUENCE_NUMBER", $this->getItemSortSequenceSQL('LOCATION.LOCATION_ID'), - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".BIB_MFHD", $this->dbName . ".LOCATION", $this->dbName . ".MFHD_MASTER" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "BIB_MFHD.BIB_ID = :id", "LOCATION.LOCATION_ID = MFHD_MASTER.LOCATION_ID", "MFHD_MASTER.MFHD_ID = BIB_MFHD.MFHD_ID", "MFHD_MASTER.SUPPRESS_IN_OPAC='N'", "NOT EXISTS (SELECT MFHD_ID FROM {$this->dbName}.MFHD_ITEM " . "WHERE MFHD_ITEM.MFHD_ID=MFHD_MASTER.MFHD_ID)" - ); + ]; // Bind - $sqlBind = array(':id' => $id); + $sqlBind = [':id' => $id]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind, - ); + ]; return $sqlArray; } @@ -436,14 +436,14 @@ class Voyager extends AbstractBase */ protected function getStatusData($sqlRows) { - $data = array(); + $data = []; foreach ($sqlRows as $row) { if (!isset($data[$row['ITEM_ID']])) { - $data[$row['ITEM_ID']] = array( + $data[$row['ITEM_ID']] = [ 'id' => $row['BIB_ID'], 'status' => $row['STATUS'], - 'status_array' => array($row['STATUS']), + 'status_array' => [$row['STATUS']], 'location' => $row['TEMP_LOCATION'] > 0 ? $this->getLocationName($row['TEMP_LOCATION']) : utf8_encode($row['LOCATION']), @@ -453,7 +453,7 @@ class Voyager extends AbstractBase 'sort_seq' => isset($row['SORT_SEQ']) ? $row['SORT_SEQ'] : PHP_INT_MAX - ); + ]; } else { if (!in_array( $row['STATUS'], $data[$row['ITEM_ID']]['status_array'] @@ -477,7 +477,7 @@ class Voyager extends AbstractBase protected function processStatusData($data) { // Process the raw data into final status information: - $status = array(); + $status = []; foreach ($data as $current) { // Get availability/status info based on the array of status codes: $availability = $this->determineAvailability($current['status_array']); @@ -526,13 +526,13 @@ class Voyager extends AbstractBase // information from the holdings record when no items are available. $sqlArrayItems = $this->getStatusSQL($id); $sqlArrayNoItems = $this->getStatusNoItemsSQL($id); - $possibleQueries = array( + $possibleQueries = [ $this->buildSqlFromArray($sqlArrayItems), $this->buildSqlFromArray($sqlArrayNoItems) - ); + ]; // Loop through the possible queries and merge results. - $data = array(); + $data = []; foreach ($possibleQueries as $sql) { // Execute SQL try { @@ -541,7 +541,7 @@ class Voyager extends AbstractBase throw new ILSException($e->getMessage()); } - $sqlRows = array(); + $sqlRows = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { $sqlRows[] = $row; } @@ -564,7 +564,7 @@ class Voyager extends AbstractBase */ public function getStatuses($idList) { - $status = array(); + $status = []; foreach ($idList as $id) { $status[] = $this->getStatus($id); } @@ -581,7 +581,7 @@ class Voyager extends AbstractBase protected function getHoldingItemsSQL($id) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "BIB_ITEM.BIB_ID", "MFHD_ITEM.MFHD_ID", "ITEM_BARCODE.ITEM_BARCODE", "ITEM.ITEM_ID", "ITEM.ON_RESERVE", "ITEM.ITEM_SEQUENCE_NUMBER", @@ -599,10 +599,10 @@ class Voyager extends AbstractBase "WHERE CIRC_TRANS_ARCHIVE.ITEM_ID = ITEM.ITEM_ID) RETURNDATE", "ITEM.ITEM_SEQUENCE_NUMBER", $this->getItemSortSequenceSQL('ITEM.PERM_LOCATION') - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".BIB_ITEM", $this->dbName . ".ITEM", $this->dbName . ".ITEM_STATUS_TYPE", $this->dbName . ".ITEM_STATUS", @@ -610,10 +610,10 @@ class Voyager extends AbstractBase $this->dbName . ".MFHD_MASTER", $this->dbName . ".MFHD_DATA", $this->dbName . ".CIRC_TRANSACTIONS", $this->dbName . ".ITEM_BARCODE" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "BIB_ITEM.BIB_ID = :id", "BIB_ITEM.ITEM_ID = ITEM.ITEM_ID", "ITEM.ITEM_ID = ITEM_STATUS.ITEM_ID", @@ -625,23 +625,23 @@ class Voyager extends AbstractBase "MFHD_MASTER.MFHD_ID = MFHD_ITEM.MFHD_ID", "MFHD_DATA.MFHD_ID = MFHD_ITEM.MFHD_ID", "MFHD_MASTER.SUPPRESS_IN_OPAC='N'" - ); + ]; // Order - $sqlOrder = array( + $sqlOrder = [ "ITEM.ITEM_SEQUENCE_NUMBER", "MFHD_DATA.MFHD_ID", "MFHD_DATA.SEQNUM" - ); + ]; // Bind - $sqlBind = array(':id' => $id); + $sqlBind = [':id' => $id]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'order' => $sqlOrder, 'bind' => $sqlBind, - ); + ]; return $sqlArray; } @@ -656,7 +656,7 @@ class Voyager extends AbstractBase protected function getHoldingNoItemsSQL($id) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "null as ITEM_BARCODE", "null as ITEM_ID", "MFHD_DATA.RECORD_SEGMENT", "null as ITEM_ENUM", "'N' as ON_RESERVE", "1 as ITEM_SEQUENCE_NUMBER", @@ -669,16 +669,16 @@ class Voyager extends AbstractBase "0 as PERM_LOCATION", "0 as ITEM_SEQUENCE_NUMBER", $this->getItemSortSequenceSQL('LOCATION.LOCATION_ID') - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".BIB_MFHD", $this->dbName . ".LOCATION", $this->dbName . ".MFHD_MASTER", $this->dbName . ".MFHD_DATA" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "BIB_MFHD.BIB_ID = :id", "LOCATION.LOCATION_ID = MFHD_MASTER.LOCATION_ID", "MFHD_MASTER.MFHD_ID = BIB_MFHD.MFHD_ID", @@ -686,21 +686,21 @@ class Voyager extends AbstractBase "MFHD_MASTER.SUPPRESS_IN_OPAC='N'", "NOT EXISTS (SELECT MFHD_ID FROM {$this->dbName}.MFHD_ITEM" . " WHERE MFHD_ITEM.MFHD_ID=MFHD_MASTER.MFHD_ID)" - ); + ]; // Order - $sqlOrder = array("MFHD_DATA.MFHD_ID", "MFHD_DATA.SEQNUM"); + $sqlOrder = ["MFHD_DATA.MFHD_ID", "MFHD_DATA.SEQNUM"]; // Bind - $sqlBind = array(':id' => $id); + $sqlBind = [':id' => $id]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'order' => $sqlOrder, 'bind' => $sqlBind, - ); + ]; return $sqlArray; } @@ -714,7 +714,7 @@ class Voyager extends AbstractBase */ protected function getHoldingData($sqlRows) { - $data = array(); + $data = []; foreach ($sqlRows as $row) { // Determine Copy Number (always use sequence number; append volume @@ -748,7 +748,7 @@ class Voyager extends AbstractBase // initialize the row and start an array of statuses. $data[$rowId][$number] = $row; $data[$rowId][$number]['STATUS_ARRAY'] - = array($row['STATUS']); + = [$row['STATUS']]; } } return $data; @@ -784,11 +784,11 @@ class Voyager extends AbstractBase "and LINE_ITEM.BIB_ID = :id " . "order by LINE_ITEM_COPY_STATUS.MFHD_ID, SERIAL_ISSUES.ISSUE_ID DESC"; try { - $sqlStmt = $this->executeSQL($sql, array(':id' => $id)); + $sqlStmt = $this->executeSQL($sql, [':id' => $id]); } catch (PDOException $e) { throw new ILSException($e->getMessage()); } - $raw = $processed = array(); + $raw = $processed = []; // Collect raw data: while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { $raw[] = $row['MFHD_ID'] . '||' . $row['ENUMCHRON']; @@ -838,7 +838,7 @@ class Voyager extends AbstractBase $results = $line; } else { if (!is_array($results)) { - $results = array($results); + $results = [$results]; } $results[] = $line; } @@ -859,11 +859,11 @@ class Voyager extends AbstractBase */ protected function processRecordSegment($recordSegment) { - $marcDetails = array(); + $marcDetails = []; try { $marc = new File_MARC( - str_replace(array("\n", "\r"), '', $recordSegment), + str_replace(["\n", "\r"], '', $recordSegment), File_MARC::SOURCE_STRING ); if ($record = $marc->next()) { @@ -928,13 +928,13 @@ class Voyager extends AbstractBase */ protected function getLocationName($id) { - static $cache = array(); + static $cache = []; // Fill cache if empty: if (!isset($cache[$id])) { $sql = "SELECT NVL(LOCATION_DISPLAY_NAME, LOCATION_NAME) as location " . "FROM {$this->dbName}.LOCATION WHERE LOCATION_ID=:id"; - $bind = array('id' => $id); + $bind = ['id' => $id]; $sqlStmt = $this->executeSQL($sql, $bind); $sqlRow = $sqlStmt->fetch(PDO::FETCH_ASSOC); $cache[$id] = utf8_encode($sqlRow['LOCATION']); @@ -952,7 +952,7 @@ class Voyager extends AbstractBase */ protected function processHoldingRow($sqlRow) { - return array( + return [ 'id' => $sqlRow['BIB_ID'], 'holdings_id' => $sqlRow['MFHD_ID'], 'item_id' => $sqlRow['ITEM_ID'], @@ -969,7 +969,7 @@ class Voyager extends AbstractBase 'sort_seq' => isset($sqlRow['SORT_SEQ']) ? $sqlRow['SORT_SEQ'] : PHP_INT_MAX - ); + ]; } /** @@ -987,10 +987,10 @@ class Voyager extends AbstractBase */ protected function processHoldingData($data, $id, $patron = false) { - $holding = array(); + $holding = []; // Build Holdings Array - $purchaseHistory = array(); + $purchaseHistory = []; if (isset($this->config['Holdings']['purchase_history']) && $this->config['Holdings']['purchase_history'] === 'split' ) { @@ -1037,20 +1037,20 @@ class Voyager extends AbstractBase } $holding[$i] = $this->processHoldingRow($row); - $purchases = array(); + $purchases = []; foreach ($purchaseHistory as $historyItem) { if ($holding[$i]['holdings_id'] == $historyItem['holdings_id']) { $purchases[] = $historyItem; } } - $holding[$i] += array( + $holding[$i] += [ 'availability' => $availability['available'], 'duedate' => $dueDate, 'number' => $number, 'requests_placed' => $requests_placed, 'returnDate' => $returnDate, 'purchase_history' => $purchases - ); + ]; // Parse Holding Record if ($row['RECORD_SEGMENT']) { @@ -1096,7 +1096,7 @@ class Voyager extends AbstractBase */ public function getHolding($id, array $patron = null) { - $possibleQueries = array(); + $possibleQueries = []; // There are two possible queries we can use to obtain status information. // The first (and most common) obtains information from a combination of @@ -1110,7 +1110,7 @@ class Voyager extends AbstractBase $possibleQueries[] = $this->buildSqlFromArray($sqlArrayNoItems); // Loop through the possible queries and merge results. - $data = array(); + $data = []; foreach ($possibleQueries as $sql) { // Execute SQL try { @@ -1119,7 +1119,7 @@ class Voyager extends AbstractBase throw new ILSException($e->getMessage()); } - $sqlRows = array(); + $sqlRows = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { $sqlRows[] = $row; } @@ -1147,7 +1147,7 @@ class Voyager extends AbstractBase $setting = isset($this->config['Holdings']['purchase_history']) ? $this->config['Holdings']['purchase_history'] : true; return (!$setting || $setting === 'split') - ? array() : $this->getPurchaseHistoryData($id); + ? [] : $this->getPurchaseHistoryData($id); } /** @@ -1196,7 +1196,7 @@ class Voyager extends AbstractBase $bindBarcode = strtolower(utf8_decode($barcode)); $compareLogin = mb_strtolower($login, 'UTF-8'); - $this->debugSQL(__FUNCTION__, $sql, array(':barcode' => $bindBarcode)); + $this->debugSQL(__FUNCTION__, $sql, [':barcode' => $bindBarcode]); $sqlStmt = $this->db->prepare($sql); $sqlStmt->bindParam(':barcode', $bindBarcode, PDO::PARAM_STR); $sqlStmt->execute(); @@ -1214,7 +1214,7 @@ class Voyager extends AbstractBase || ($fallback_login_field && is_null($primary) && $fallback == $compareLogin) ) { - return array( + return [ 'id' => utf8_encode($row['PATRON_ID']), 'firstname' => utf8_encode($row['FIRST_NAME']), 'lastname' => utf8_encode($row['LAST_NAME']), @@ -1225,7 +1225,7 @@ class Voyager extends AbstractBase // might be worth investigating further if needed later. 'email' => null, 'major' => null, - 'college' => null); + 'college' => null]; } } return null; @@ -1244,7 +1244,7 @@ class Voyager extends AbstractBase protected function getMyTransactionsSQL($patron) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "to_char(CIRC_TRANSACTIONS.CURRENT_DUE_DATE, 'MM-DD-YY HH24:MI')" . " as DUEDATE", "to_char(CURRENT_DUE_DATE, 'YYYYMMDD HH24:MI') as FULLDATE", @@ -1257,20 +1257,20 @@ class Voyager extends AbstractBase "CIRC_TRANSACTIONS.RENEWAL_COUNT", "CIRC_POLICY_MATRIX.RENEWAL_COUNT as RENEWAL_LIMIT", "LOCATION.LOCATION_DISPLAY_NAME as BORROWING_LOCATION" - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".CIRC_TRANSACTIONS", $this->dbName . ".BIB_ITEM", $this->dbName . ".MFHD_ITEM", $this->dbName . ".BIB_TEXT", $this->dbName . ".CIRC_POLICY_MATRIX", $this->dbName . ".LOCATION" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "CIRC_TRANSACTIONS.PATRON_ID = :id", "BIB_ITEM.ITEM_ID = CIRC_TRANSACTIONS.ITEM_ID", "CIRC_TRANSACTIONS.ITEM_ID = MFHD_ITEM.ITEM_ID(+)", @@ -1278,21 +1278,21 @@ class Voyager extends AbstractBase "CIRC_TRANSACTIONS.CIRC_POLICY_MATRIX_ID = " . "CIRC_POLICY_MATRIX.CIRC_POLICY_MATRIX_ID", "CIRC_TRANSACTIONS.CHARGE_LOCATION = LOCATION.LOCATION_ID" - ); + ]; // Order - $sqlOrder = array("FULLDATE ASC"); + $sqlOrder = ["FULLDATE ASC"]; // Bind - $sqlBind = array(':id' => $patron['id']); + $sqlBind = [':id' => $patron['id']]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'order' => $sqlOrder, 'bind' => $sqlBind - ); + ]; return $sqlArray; } @@ -1333,7 +1333,7 @@ class Voyager extends AbstractBase } } - $transaction = array( + $transaction = [ 'id' => $sqlRow['BIB_ID'], 'item_id' => $sqlRow['ITEM_ID'], 'duedate' => $dueDate, @@ -1345,7 +1345,7 @@ class Voyager extends AbstractBase ? $sqlRow['TITLE'] : $sqlRow['TITLE_BRIEF'], 'renew' => $sqlRow['RENEWAL_COUNT'], 'renewLimit' => $sqlRow['RENEWAL_LIMIT'] - ); + ]; if (isset($this->config['Loans']['display_borrowing_location']) && $this->config['Loans']['display_borrowing_location'] ) { @@ -1370,7 +1370,7 @@ class Voyager extends AbstractBase */ public function getMyTransactions($patron) { - $transList = array(); + $transList = []; $sqlArray = $this->getMyTransactionsSQL($patron); @@ -1398,7 +1398,7 @@ class Voyager extends AbstractBase protected function getFineSQL($patron) { // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "FINE_FEE_TYPE.FINE_FEE_DESC", "PATRON.PATRON_ID", "FINE_FEE.FINE_FEE_AMOUNT", "FINE_FEE.FINE_FEE_BALANCE", @@ -1406,32 +1406,32 @@ class Voyager extends AbstractBase "to_char(FINE_FEE.ORIG_CHARGE_DATE, 'MM-DD-YY') as CHARGEDATE", "to_char(FINE_FEE.DUE_DATE, 'MM-DD-YY') as DUEDATE", "BIB_ITEM.BIB_ID" - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".FINE_FEE", $this->dbName . ".FINE_FEE_TYPE", $this->dbName . ".PATRON", $this->dbName . ".BIB_ITEM" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "PATRON.PATRON_ID = :id", "FINE_FEE.FINE_FEE_TYPE = FINE_FEE_TYPE.FINE_FEE_TYPE", "FINE_FEE.PATRON_ID = PATRON.PATRON_ID", "FINE_FEE.ITEM_ID = BIB_ITEM.ITEM_ID(+)", "FINE_FEE.FINE_FEE_BALANCE > 0" - ); + ]; // Bind - $sqlBind = array(':id' => $patron['id']); + $sqlBind = [':id' => $patron['id']]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind - ); + ]; return $sqlArray; } @@ -1470,13 +1470,13 @@ class Voyager extends AbstractBase ); } - return array('amount' => $sqlRow['FINE_FEE_AMOUNT'], + return ['amount' => $sqlRow['FINE_FEE_AMOUNT'], 'fine' => $sqlRow['FINE_FEE_DESC'], 'balance' => $sqlRow['FINE_FEE_BALANCE'], 'createdate' => $createDate, 'checkout' => $chargeDate, 'duedate' => $dueDate, - 'id' => $sqlRow['BIB_ID']); + 'id' => $sqlRow['BIB_ID']]; } /** @@ -1492,7 +1492,7 @@ class Voyager extends AbstractBase */ public function getMyFines($patron) { - $fineList = array(); + $fineList = []; $sqlArray = $this->getFineSQL($patron); @@ -1523,7 +1523,7 @@ class Voyager extends AbstractBase $sqlSelectModifier = "distinct"; // Expressions - $sqlExpressions = array( + $sqlExpressions = [ "HOLD_RECALL.HOLD_RECALL_ID", "HOLD_RECALL.BIB_ID", "HOLD_RECALL.PICKUP_LOCATION", "HOLD_RECALL.HOLD_RECALL_TYPE", @@ -1537,20 +1537,20 @@ class Voyager extends AbstractBase "BIB_TEXT.TITLE_BRIEF", "BIB_TEXT.TITLE", "REQUEST_GROUP.GROUP_NAME as REQUEST_GROUP_NAME" - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . ".HOLD_RECALL", $this->dbName . ".HOLD_RECALL_ITEMS", $this->dbName . ".MFHD_ITEM", $this->dbName . ".BIB_TEXT", $this->dbName . ".VOYAGER_DATABASES", $this->dbName . ".REQUEST_GROUP" - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ "HOLD_RECALL.PATRON_ID = :id", "HOLD_RECALL.HOLD_RECALL_ID = HOLD_RECALL_ITEMS.HOLD_RECALL_ID(+)", "HOLD_RECALL_ITEMS.ITEM_ID = MFHD_ITEM.ITEM_ID(+)", @@ -1560,18 +1560,18 @@ class Voyager extends AbstractBase "(HOLD_RECALL.HOLDING_DB_ID IS NULL OR (HOLD_RECALL.HOLDING_DB_ID = " . "VOYAGER_DATABASES.DB_ID AND VOYAGER_DATABASES.DB_CODE = 'LOCAL'))", "HOLD_RECALL.REQUEST_GROUP_ID = REQUEST_GROUP.GROUP_ID(+)" - ); + ]; // Bind - $sqlBind = array(':id' => $patron['id']); + $sqlBind = [':id' => $patron['id']]; - $sqlArray = array( + $sqlArray = [ 'modifier' => $sqlSelectModifier, 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind - ); + ]; return $sqlArray; } @@ -1603,7 +1603,7 @@ class Voyager extends AbstractBase ); } - return array( + return [ 'id' => $sqlRow['BIB_ID'], 'type' => $sqlRow['HOLD_RECALL_TYPE'], 'location' => $sqlRow['PICKUP_LOCATION'], @@ -1618,7 +1618,7 @@ class Voyager extends AbstractBase 'publication_year' => $sqlRow['YEAR'], 'title' => empty($sqlRow['TITLE_BRIEF']) ? $sqlRow['TITLE'] : $sqlRow['TITLE_BRIEF'] - ); + ]; } /** @@ -1633,11 +1633,11 @@ class Voyager extends AbstractBase */ protected function processHoldsList($holdList) { - $returnList = array(); + $returnList = []; if (!empty($holdList)) { - $sortHoldList = array(); + $sortHoldList = []; // Get a unique List of Bib Ids foreach ($holdList as $holdItem) { $sortHoldList[$holdItem['id']][] = $holdItem; @@ -1664,8 +1664,8 @@ class Voyager extends AbstractBase */ public function getMyHolds($patron) { - $holdList = array(); - $returnList = array(); + $holdList = []; + $returnList = []; $sqlArray = $this->getMyHoldsSQL($patron); @@ -1697,7 +1697,7 @@ class Voyager extends AbstractBase $sqlSelectModifier = "distinct"; // Expressions - $sqlExpressions = array( + $sqlExpressions = [ 'CALL_SLIP.CALL_SLIP_ID', 'CALL_SLIP.BIB_ID', 'CALL_SLIP.PICKUP_LOCATION_ID', "to_char(CALL_SLIP.DATE_REQUESTED, 'YYYY-MM-DD HH24:MI:SS')" @@ -1719,40 +1719,40 @@ class Voyager extends AbstractBase 'MFHD_ITEM.YEAR', 'BIB_TEXT.TITLE_BRIEF', 'BIB_TEXT.TITLE' - ); + ]; // From - $sqlFrom = array( + $sqlFrom = [ $this->dbName . '.CALL_SLIP', $this->dbName . '.CALL_SLIP_STATUS_TYPE', $this->dbName . '.MFHD_ITEM', $this->dbName . '.BIB_TEXT' - ); + ]; // Where - $sqlWhere = array( + $sqlWhere = [ 'CALL_SLIP.PATRON_ID = :id', 'CALL_SLIP.STATUS = CALL_SLIP_STATUS_TYPE.STATUS_TYPE(+)', 'CALL_SLIP.ITEM_ID = MFHD_ITEM.ITEM_ID(+)', 'BIB_TEXT.BIB_ID = CALL_SLIP.BIB_ID' - ); + ]; // Order by - $sqlOrderBy = array( + $sqlOrderBy = [ "to_char(CALL_SLIP.DATE_REQUESTED, 'YYYY-MM-DD HH24:MI:SS')" - ); + ]; // Bind - $sqlBind = array(':id' => $patron['id']); + $sqlBind = [':id' => $patron['id']]; - $sqlArray = array( + $sqlArray = [ 'modifier' => $sqlSelectModifier, 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'order' => $sqlOrderBy, 'bind' => $sqlBind - ); + ]; return $sqlArray; } @@ -1790,7 +1790,7 @@ class Voyager extends AbstractBase ); } - return array( + return [ 'id' => $sqlRow['BIB_ID'], 'status' => utf8_encode($sqlRow['STATUS_DESC']), 'statusDate' => $statusDate, @@ -1810,7 +1810,7 @@ class Voyager extends AbstractBase 'year' => utf8_encode($sqlRow['ITEM_YEAR']), 'title' => empty($sqlRow['TITLE_BRIEF']) ? $sqlRow['TITLE'] : $sqlRow['TITLE_BRIEF'] - ); + ]; } /** @@ -1824,7 +1824,7 @@ class Voyager extends AbstractBase */ public function getMyStorageRetrievalRequests($patron) { - $list = array(); + $list = []; $sqlArray = $this->getMyStorageRetrievalRequestsSQL($patron); @@ -1869,8 +1869,8 @@ class Voyager extends AbstractBase "PATRON_GROUP.PATRON_GROUP_ID (+) " . "AND PATRON.PATRON_ID = :id"; try { - $sqlStmt = $this->executeSQL($sql, array(':id' => $patron['id'])); - $patron = array(); + $sqlStmt = $this->executeSQL($sql, [':id' => $patron['id']]); + $patron = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { if (!empty($row['FIRST_NAME'])) { $patron['firstname'] = utf8_encode($row['FIRST_NAME']); @@ -1954,12 +1954,12 @@ class Voyager extends AbstractBase */ public function getNewItems($page, $limit, $daysOld, $fundId = null) { - $items = array(); + $items = []; - $bindParams = array( + $bindParams = [ ':enddate' => date('d-m-Y', strtotime('now')), ':startdate' => date('d-m-Y', strtotime("-$daysOld day")) - ); + ]; $sql = "select count(distinct LINE_ITEM.BIB_ID) as count " . "from $this->dbName.LINE_ITEM, " . @@ -2047,7 +2047,7 @@ class Voyager extends AbstractBase */ public function getFunds() { - $list = array(); + $list = []; // Are funds disabled? If so, do no work! if (isset($this->config['Funds']['disabled']) @@ -2060,7 +2060,7 @@ class Voyager extends AbstractBase if (isset($this->config['Funds']['whitelist']) && is_array($this->config['Funds']['whitelist']) ) { - $whitelist = array(); + $whitelist = []; foreach ($this->config['Funds']['whitelist'] as $current) { $whitelist[] = strtolower($current); } @@ -2070,7 +2070,7 @@ class Voyager extends AbstractBase if (isset($this->config['Funds']['blacklist']) && is_array($this->config['Funds']['blacklist']) ) { - $blacklist = array(); + $blacklist = []; foreach ($this->config['Funds']['blacklist'] as $current) { $blacklist[] = strtolower($current); } @@ -2081,10 +2081,10 @@ class Voyager extends AbstractBase // Retrieve the data from Voyager; if we're limiting to a parent fund, we // need to apply a special WHERE clause and bind parameter. if (isset($this->config['Funds']['parent_fund'])) { - $bindParams = array(':parent' => $this->config['Funds']['parent_fund']); + $bindParams = [':parent' => $this->config['Funds']['parent_fund']]; $whereClause = 'WHERE FUND.PARENT_FUND = :parent'; } else { - $bindParams = array(); + $bindParams = []; $whereClause = ''; } $sql = "select distinct lower(FUND.FUND_NAME) as name " . @@ -2133,7 +2133,7 @@ class Voyager extends AbstractBase */ public function getDepartments() { - $deptList = array(); + $deptList = []; $sql = "select DEPARTMENT.DEPARTMENT_ID, DEPARTMENT.DEPARTMENT_NAME " . "from $this->dbName.RESERVE_LIST, " . @@ -2166,7 +2166,7 @@ class Voyager extends AbstractBase */ public function getInstructors() { - $instList = array(); + $instList = []; $sql = "select INSTRUCTOR.INSTRUCTOR_ID, " . "INSTRUCTOR.LAST_NAME || ', ' || INSTRUCTOR.FIRST_NAME as NAME " . @@ -2199,7 +2199,7 @@ class Voyager extends AbstractBase */ public function getCourses() { - $courseList = array(); + $courseList = []; $sql = "select COURSE.COURSE_NUMBER || ': ' || COURSE.COURSE_NAME as NAME," . " COURSE.COURSE_ID " . @@ -2240,9 +2240,9 @@ class Voyager extends AbstractBase */ public function findReserves($course, $inst, $dept) { - $recordList = array(); - $reserveWhere = array(); - $bindParams = array(); + $recordList = []; + $reserveWhere = []; + $bindParams = []; if ($course != '') { $reserveWhere[] = "RESERVE_LIST_COURSES.COURSE_ID = :course"; @@ -2346,7 +2346,7 @@ class Voyager extends AbstractBase */ public function getSuppressedRecords() { - $list = array(); + $list = []; $sql = "select BIB_MASTER.BIB_ID " . "from $this->dbName.BIB_MASTER " . @@ -2372,7 +2372,7 @@ class Voyager extends AbstractBase * * @return PDOStatement */ - protected function executeSQL($sql, $bind = array()) + protected function executeSQL($sql, $bind = []) { if (is_array($sql)) { $bind = $sql['bind']; diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index c2dec899886..f2b8dfe2388 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -355,12 +355,12 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte protected function putCachedData($id, $entry) { if (!isset($this->session->cache)) { - $this->session->cache = array(); + $this->session->cache = []; } - $this->session->cache[$id] = array( + $this->session->cache[$id] = [ 'time' => time(), 'entry' => $entry - ); + ]; } /** @@ -486,7 +486,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte protected function processHoldingRow($sqlRow) { $row = parent::processHoldingRow($sqlRow); - $row += array('item_id' => $sqlRow['ITEM_ID'], '_fullRow' => $sqlRow); + $row += ['item_id' => $sqlRow['ITEM_ID'], '_fullRow' => $sqlRow]; return $row; } @@ -572,7 +572,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte $addILLRequestLink = 'check'; } - $holding[$i] += array( + $holding[$i] += [ 'is_holdable' => $is_holdable, 'holdtype' => $holdType, 'addLink' => $addLink, @@ -581,7 +581,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte 'addStorageRetrievalRequestLink' => $addStorageRetrievalLink, 'ILLRequest' => $ILLRequest, 'addILLRequestLink' => $addILLRequestLink - ); + ]; unset($holding[$i]['_fullRow']); } return $holding; @@ -716,13 +716,13 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte */ public function getPickUpLocations($patron = false, $holdDetails = null) { - $params = array(); + $params = []; if ($this->ws_pickUpLocations) { foreach ($this->ws_pickUpLocations as $code => $library) { - $pickResponse[] = array( + $pickResponse[] = [ 'locationID' => $code, 'locationDisplay' => $library - ); + ]; } } else { if ($this->requestGroupsEnabled @@ -757,10 +757,10 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte // Read results while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { - $pickResponse[] = array( + $pickResponse[] = [ "locationID" => $row['LOCATION_ID'], "locationDisplay" => utf8_encode($row['LOCATION_NAME']) - ); + ]; } } return $pickResponse; @@ -822,7 +822,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte { $requestGroupOrder = isset($this->config['Holds']['requestGroupOrder']) ? explode(':', $this->config['Holds']['requestGroupOrder']) - : array(); + : []; $requestGroupOrder = array_flip($requestGroupOrder); if (isset($requestGroupOrder[$a['id']])) { if (isset($requestGroupOrder[$b['id']])) { @@ -860,18 +860,18 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte return false; } - $hierarchy = array(); + $hierarchy = []; // Build Hierarchy $hierarchy['record'] = $bibId; $hierarchy[$request] = false; // Add Required Params - $params = array( + $params = [ "patron" => $patron['id'], "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; $results = $this->makeRequest($hierarchy, $params, "GET", false); @@ -879,7 +879,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte throw new ILSException('Could not fetch hold information'); } - $items = array(); + $items = []; foreach ($results->hold as $hold) { foreach ($hold->items->item as $item) { $items[(string)$item->item_id] = 1; @@ -889,48 +889,48 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte // Find request groups (with items if item check is enabled) if ($this->checkItemsExist) { - $sqlExpressions = array( + $sqlExpressions = [ 'rg.GROUP_ID', 'rg.GROUP_NAME', 'bi.ITEM_ID' - ); + ]; - $sqlFrom = array( + $sqlFrom = [ "$this->dbName.BIB_ITEM bi", "$this->dbName.MFHD_ITEM mi", "$this->dbName.MFHD_MASTER mm", "$this->dbName.REQUEST_GROUP rg", "$this->dbName.REQUEST_GROUP_LOCATION rgl", - ); + ]; - $sqlWhere = array( + $sqlWhere = [ 'bi.BIB_ID=:bibId', 'mi.ITEM_ID=bi.ITEM_ID', 'mm.MFHD_ID=mi.MFHD_ID', 'rgl.LOCATION_ID=mm.LOCATION_ID', 'rg.GROUP_ID=rgl.GROUP_ID' - ); + ]; - $sqlBind = array( + $sqlBind = [ 'bibId' => $bibId - ); + ]; } else { - $sqlExpressions = array( + $sqlExpressions = [ 'rg.GROUP_ID', 'rg.GROUP_NAME', - ); + ]; - $sqlFrom = array( + $sqlFrom = [ "$this->dbName.REQUEST_GROUP rg", "$this->dbName.REQUEST_GROUP_LOCATION rgl" - ); + ]; - $sqlWhere = array( + $sqlWhere = [ 'rg.GROUP_ID=rgl.GROUP_ID' - ); + ]; - $sqlBind = array( - ); + $sqlBind = [ + ]; if ($this->pickupLocationsInRequestGroup) { // Limit to request groups that have valid pickup locations @@ -946,44 +946,44 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte if ($this->checkItemsNotAvailable) { // Build inner query first - $subExpressions = array( + $subExpressions = [ 'sub_rgl.GROUP_ID', 'sub_i.ITEM_ID', 'max(sub_ist.ITEM_STATUS) as STATUS' - ); + ]; - $subFrom = array( + $subFrom = [ "$this->dbName.ITEM_STATUS sub_ist", "$this->dbName.BIB_ITEM sub_bi", "$this->dbName.ITEM sub_i", "$this->dbName.REQUEST_GROUP_LOCATION sub_rgl", "$this->dbName.MFHD_ITEM sub_mi", "$this->dbName.MFHD_MASTER sub_mm" - ); + ]; - $subWhere = array( + $subWhere = [ 'sub_bi.BIB_ID=:subBibId', 'sub_i.ITEM_ID=sub_bi.ITEM_ID', 'sub_ist.ITEM_ID=sub_i.ITEM_ID', 'sub_mi.ITEM_ID=sub_i.ITEM_ID', 'sub_mm.MFHD_ID=sub_mi.MFHD_ID', 'sub_rgl.LOCATION_ID=sub_mm.LOCATION_ID' - ); + ]; - $subGroup = array( + $subGroup = [ 'sub_rgl.GROUP_ID', 'sub_i.ITEM_ID' - ); + ]; $sqlBind['subBibId'] = $bibId; - $subArray = array( + $subArray = [ 'expressions' => $subExpressions, 'from' => $subFrom, 'where' => $subWhere, 'group' => $subGroup, - 'bind' => array() - ); + 'bind' => [] + ]; $subSql = $this->buildSqlFromArray($subArray); @@ -992,12 +992,12 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte "and status.GROUP_ID = rgl.GROUP_ID)"; } - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); @@ -1009,20 +1009,20 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte return new PEAR_Error($e->getMessage()); } - $groups = array(); + $groups = []; while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) { if (!$this->checkItemsExist || isset($items[$row['ITEM_ID']])) { $groups[$row['GROUP_ID']] = utf8_encode($row['GROUP_NAME']); } } - $results = array(); + $results = []; foreach ($groups as $groupId => $groupName) { - $results[] = array('id' => $groupId, 'name' => $groupName); + $results[] = ['id' => $groupId, 'name' => $groupName]; } // Sort request groups - usort($results, array($this, 'requestGroupSortFunction')); + usort($results, [$this, 'requestGroupSortFunction']); return $results; } @@ -1054,7 +1054,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte } // Add Params - $queryString = array(); + $queryString = []; foreach ($params as $key => $param) { $queryString[] = urlencode($key) . "=" . urlencode($param); } @@ -1076,7 +1076,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte // Set timeout value $timeout = isset($this->config['Catalog']['http_timeout']) ? $this->config['Catalog']['http_timeout'] : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); // Attach XML if necessary if ($xml !== false) { @@ -1183,18 +1183,18 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte $blockReason = $this->getCachedData($cacheId); if (null === $blockReason) { // Build Hierarchy - $hierarchy = array( + $hierarchy = [ "patron" => $patronId, "patronStatus" => "blocks" - ); + ]; // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; - $blockReason = array(); + $blockReason = []; $blocks = $this->makeRequest($hierarchy, $params); if ($blocks) { @@ -1240,7 +1240,7 @@ class VoyagerRestful extends Voyager implements \VuFindHttp\HttpServiceAwareInte public function renewMyItems($renewDetails) { $patron = $renewDetails['patron']; - $finalResult = array('details' => array()); + $finalResult = ['details' => []]; // Get Account Blocks $finalResult['blocks'] = $this->checkAccountBlocks($patron['id']); @@ -1288,7 +1288,7 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $response = $this->makeRequest( - array('AuthenticatePatronService' => false), array(), 'POST', $xml + ['AuthenticatePatronService' => false], [], 'POST', $xml ); if ($response === false) { throw new ILSException('renew_error'); @@ -1312,7 +1312,7 @@ $itemIdentifiers EOT; $response = $this->makeRequest( - array('RenewService' => false), array(), 'POST', $xml + ['RenewService' => false], [], 'POST', $xml ); if ($response === false) { throw new ILSException('renew_error'); @@ -1349,7 +1349,7 @@ EOT; } } - $result = array(); + $result = []; $result['item_id'] = (string)$chargedItem->itemId; $result['sysMessage'] = (string)$renewStatus->status; @@ -1400,7 +1400,7 @@ EOT; ) { if (!empty($bibId) && !empty($patronId) && !empty($request)) { - $hierarchy = array(); + $hierarchy = []; // Build Hierarchy $hierarchy['record'] = $bibId; @@ -1412,11 +1412,11 @@ EOT; $hierarchy[$request] = false; // Add Required Params - $params = array( + $params = [ "patron" => $patronId, "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; $check = $this->makeRequest($hierarchy, $params, "GET", false); @@ -1457,7 +1457,7 @@ EOT; if (empty($patron) || empty($requestData) || empty($requestData['bibId']) || empty($type) ) { - return array('success' => false, 'status' => "hold_error_fail"); + return ['success' => false, 'status' => "hold_error_fail"]; } // Build request @@ -1512,7 +1512,7 @@ EOT; EOT; $response = $this->makeRequest( - array('SendPatronRequestService' => false), array(), 'POST', $xml + ['SendPatronRequestService' => false], [], 'POST', $xml ); if ($response === false) { @@ -1527,10 +1527,10 @@ EOT; ); foreach ($response->xpath('//ser:message') as $message) { if ($message->attributes()->type == 'success') { - return array( + return [ 'success' => true, 'status' => 'hold_request_success' - ); + ]; } if ($message->attributes()->type == 'system') { return $this->holdError('hold_error_system'); @@ -1589,10 +1589,10 @@ EOT; */ protected function holdError($msg) { - return array( + return [ "success" => false, "sysMessage" => $msg - ); + ]; } /** @@ -1605,20 +1605,20 @@ EOT; */ protected function isRecordOnLoan($patronId, $bibId) { - $sqlExpressions = array( + $sqlExpressions = [ 'count(cta.ITEM_ID) CNT' - ); + ]; - $sqlFrom = array( + $sqlFrom = [ "$this->dbName.BIB_ITEM bi", "$this->dbName.CIRC_TRANSACTIONS cta" - ); + ]; - $sqlWhere = array( + $sqlWhere = [ 'cta.PATRON_ID=:patronId', 'bi.BIB_ID=:bibId', 'bi.ITEM_ID=cta.ITEM_ID' - ); + ]; if ($this->requestGroupsEnabled) { $sqlFrom[] = "$this->dbName.REQUEST_GROUP_LOCATION rgl"; @@ -1630,14 +1630,14 @@ EOT; $sqlWhere[] = 'rgl.LOCATION_ID=mm.LOCATION_ID'; } - $sqlBind = array('patronId' => $patronId, 'bibId' => $bibId); + $sqlBind = ['patronId' => $patronId, 'bibId' => $bibId]; - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); @@ -1662,30 +1662,30 @@ EOT; */ protected function itemsExist($bibId, $requestGroupId) { - $sqlExpressions = array( + $sqlExpressions = [ 'count(i.ITEM_ID) CNT' - ); + ]; - $sqlFrom = array( + $sqlFrom = [ "$this->dbName.BIB_ITEM bi", "$this->dbName.ITEM i", "$this->dbName.MFHD_ITEM mi", "$this->dbName.MFHD_MASTER mm" - ); + ]; - $sqlWhere = array( + $sqlWhere = [ 'bi.BIB_ID=:bibId', 'i.ITEM_ID=bi.ITEM_ID', 'mi.ITEM_ID=i.ITEM_ID', 'mm.MFHD_ID=mi.MFHD_ID' - ); + ]; if ($this->excludedItemLocations) { $sqlWhere[] = 'mm.LOCATION_ID not in (' . $this->excludedItemLocations . ')'; } - $sqlBind = array('bibId' => $bibId); + $sqlBind = ['bibId' => $bibId]; if ($this->requestGroupsEnabled && isset($requestGroupId)) { $sqlFrom[] = "$this->dbName.REQUEST_GROUP_LOCATION rgl"; @@ -1696,12 +1696,12 @@ EOT; $sqlBind['requestGroupId'] = $requestGroupId; } - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'bind' => $sqlBind - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); try { @@ -1726,37 +1726,37 @@ EOT; protected function itemsAvailable($bibId, $requestGroupId) { // Build inner query first - $sqlExpressions = array( + $sqlExpressions = [ 'i.ITEM_ID', 'max(ist.ITEM_STATUS) as STATUS' - ); + ]; - $sqlFrom = array( + $sqlFrom = [ "$this->dbName.ITEM_STATUS ist", "$this->dbName.BIB_ITEM bi", "$this->dbName.ITEM i", "$this->dbName.MFHD_ITEM mi", "$this->dbName.MFHD_MASTER mm" - ); + ]; - $sqlWhere = array( + $sqlWhere = [ 'bi.BIB_ID=:bibId', 'i.ITEM_ID=bi.ITEM_ID', 'ist.ITEM_ID=i.ITEM_ID', 'mi.ITEM_ID=i.ITEM_ID', 'mm.MFHD_ID=mi.MFHD_ID' - ); + ]; if ($this->excludedItemLocations) { $sqlWhere[] = 'mm.LOCATION_ID not in (' . $this->excludedItemLocations . ')'; } - $sqlGroup = array( + $sqlGroup = [ 'i.ITEM_ID' - ); + ]; - $sqlBind = array('bibId' => $bibId); + $sqlBind = ['bibId' => $bibId]; if ($this->requestGroupsEnabled && isset($requestGroupId)) { $sqlFrom[] = "$this->dbName.REQUEST_GROUP_LOCATION rgl"; @@ -1767,13 +1767,13 @@ EOT; $sqlBind['requestGroupId'] = $requestGroupId; } - $sqlArray = array( + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, 'where' => $sqlWhere, 'group' => $sqlGroup, 'bind' => $sqlBind - ); + ]; $sql = $this->buildSqlFromArray($sqlArray); $outersql = "select count(avail.item_id) CNT from (${sql['string']}) avail" . @@ -1876,7 +1876,7 @@ EOT; // Optional check that the bib has no available items if ($this->checkItemsNotAvailable) { - $disabledGroups = array(); + $disabledGroups = []; $key = 'disableAvailabilityCheckForRequestGroups'; if (isset($this->config['Holds'][$key])) { $disabledGroups = explode(':', $this->config['Holds'][$key]); @@ -1903,12 +1903,12 @@ EOT; } // Build Request Data - $requestData = array( + $requestData = [ 'bibId' => $bibId, 'PICK' => $pickUpLocation, 'REQNNA' => $lastInterestDate, 'REQCOMMENTS' => $comment - ); + ]; if ($level == 'copy' && $itemId) { $requestData['itemId'] = $itemId; } elseif (isset($holdDetails['requestGroupId'])) { @@ -1940,7 +1940,7 @@ EOT; $details = $cancelDetails['details']; $patron = $cancelDetails['patron']; $count = 0; - $response = array(); + $response = []; foreach ($details as $cancelDetails) { list($itemId, $cancelCode) = explode("|", $cancelDetails); @@ -1949,17 +1949,17 @@ EOT; $cancelID = $this->ws_dbKey . "|" . $cancelCode; // Build Hierarchy - $hierarchy = array( + $hierarchy = [ "patron" => $patron['id'], "circulationActions" => "requests", "holds" => $cancelID - ); + ]; // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; // Get Data $cancel = $this->makeRequest($hierarchy, $params, "DELETE"); @@ -1971,20 +1971,20 @@ EOT; $reply = (string)$cancel->$node; $count = ($reply == "ok") ? $count+1 : $count; - $response[$itemId] = array( + $response[$itemId] = [ 'success' => ($reply == "ok") ? true : false, 'status' => ($reply == "ok") ? "hold_cancel_success" : "hold_cancel_fail", 'sysMessage' => ($reply == "ok") ? false : $reply, - ); + ]; } else { - $response[$itemId] = array( + $response[$itemId] = [ 'success' => false, 'status' => "hold_cancel_fail" - ); + ]; } } - $result = array('count' => $count, 'items' => $response); + $result = ['count' => $count, 'items' => $response]; return $result; } @@ -2047,16 +2047,16 @@ EOT; // Get remote loans and renewability for local loans via the API // Build Hierarchy - $hierarchy = array( + $hierarchy = [ 'patron' => $patron['id'], 'circulationActions' => 'loans' - ); + ]; // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; $results = $this->makeRequest($hierarchy, $params); @@ -2116,7 +2116,7 @@ EOT; $dueTime = false; } - $transactions[] = array( + $transactions[] = [ // This is bogus, but we need something.. 'id' => (string)$institution->attributes()->id . '_' . (string)$loan->itemId, @@ -2129,7 +2129,7 @@ EOT; 'institution_id' => (string)$institution->attributes()->id, 'institution_name' => (string)$loan->dbName, 'institution_dbkey' => (string)$loan->dbKey, - ); + ]; } } } @@ -2150,17 +2150,17 @@ EOT; protected function getRemoteHolds($patron) { // Build Hierarchy - $hierarchy = array( + $hierarchy = [ 'patron' => $patron['id'], 'circulationActions' => 'requests', 'holds' => false - ); + ]; // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; $results = $this->makeRequest($hierarchy, $params); @@ -2172,7 +2172,7 @@ EOT; if ($replyCode != 0 && $replyCode != 8) { throw new ILSException('System error fetching remote holds'); } - $holds = array(); + $holds = []; if (isset($results->holds->institution)) { foreach ($results->holds->institution as $institution) { // Only take remote holds @@ -2183,7 +2183,7 @@ EOT; foreach ($institution->hold as $hold) { $item = $hold->requestItem; - $holds[] = array( + $holds[] = [ 'id' => '', 'type' => (string)$item->holdType, 'location' => (string)$item->pickupLocation, @@ -2213,7 +2213,7 @@ EOT; == 'In transit to') ? substr((string)$item->statusText, 14) : '' - ); + ]; } } } @@ -2231,17 +2231,17 @@ EOT; protected function getRemoteCallSlips($patron) { // Build Hierarchy - $hierarchy = array( + $hierarchy = [ 'patron' => $patron['id'], 'circulationActions' => 'requests', 'callslips' => false - ); + ]; // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; $results = $this->makeRequest($hierarchy, $params); @@ -2249,7 +2249,7 @@ EOT; if ($replyCode != 0 && $replyCode != 8) { throw new Exception('System error fetching call slips'); } - $requests = array(); + $requests = []; if (isset($results->callslips->institution)) { foreach ($results->callslips->institution as $institution) { if ($this->isLocalInst((string)$institution->attributes()->id)) { @@ -2258,7 +2258,7 @@ EOT; } foreach ($institution->callslip as $callslip) { $item = $callslip->requestItem; - $requests[] = array( + $requests[] = [ 'id' => '', 'type' => (string)$item->holdType, 'location' => (string)$item->pickupLocation, @@ -2296,7 +2296,7 @@ EOT; 'Y-m-d', substr((string)$item->statusText, 9) ) : '' - ); + ]; } } } @@ -2334,7 +2334,7 @@ EOT; } // Attempt Request - $hierarchy = array(); + $hierarchy = []; // Build Hierarchy $hierarchy['record'] = $bibId; @@ -2346,30 +2346,30 @@ EOT; $hierarchy['callslip'] = false; // Add Required Params - $params = array( + $params = [ 'patron' => $patron['id'], 'patron_homedb' => $this->ws_patronHomeUbId, 'view' => 'full' - ); + ]; if ('title' == $level) { - $xml['call-slip-title-parameters'] = array( + $xml['call-slip-title-parameters'] = [ 'comment' => $comment, 'reqinput field="1"' => $details['volume'], 'reqinput field="2"' => $details['issue'], 'reqinput field="3"' => $details['year'], 'dbkey' => $this->ws_dbKey, 'mfhdId' => $mfhdId - ); + ]; if (isset($details['pickUpLocation'])) { $xml['call-slip-title-parameters']['pickup-location'] = $details['pickUpLocation']; } } else { - $xml['call-slip-parameters'] = array( + $xml['call-slip-parameters'] = [ 'comment' => $comment, 'dbkey' => $this->ws_dbKey - ); + ]; if (isset($details['pickUpLocation'])) { $xml['call-slip-parameters']['pickup-location'] = $details['pickUpLocation']; @@ -2424,7 +2424,7 @@ EOT; $details = $cancelDetails['details']; $patron = $cancelDetails['patron']; $count = 0; - $response = array(); + $response = []; foreach ($details as $cancelDetails) { list($dbKey, $itemId, $cancelCode) = explode("|", $cancelDetails); @@ -2433,17 +2433,17 @@ EOT; $cancelID = ($dbKey ? $dbKey : $this->ws_dbKey) . "|" . $cancelCode; // Build Hierarchy - $hierarchy = array( + $hierarchy = [ 'patron' => $patron['id'], 'circulationActions' => 'requests', 'callslips' => $cancelID - ); + ]; // Add Required Params - $params = array( + $params = [ 'patron_homedb' => $this->ws_patronHomeUbId, 'view' => 'full' - ); + ]; // Get Data $cancel = $this->makeRequest($hierarchy, $params, 'DELETE'); @@ -2454,22 +2454,22 @@ EOT; $reply = (string)$cancel->{'reply-text'}; $count = ($reply == 'ok') ? $count + 1 : $count; - $response[$itemId] = array( + $response[$itemId] = [ 'success' => ($reply == 'ok') ? true : false, 'status' => ($reply == 'ok') ? 'storage_retrieval_request_cancel_success' : 'storage_retrieval_request_cancel_fail', 'sysMessage' => ($reply == 'ok') ? false : $reply, - ); + ]; } else { - $response[$itemId] = array( + $response[$itemId] = [ 'success' => false, 'status' => 'storage_retrieval_request_cancel_fail' - ); + ]; } } - $result = array('count' => $count, 'items' => $response); + $result = ['count' => $count, 'items' => $response]; return $result; } @@ -2563,14 +2563,14 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $response = $this->makeRequest( - array('PatronRequestsService' => false), array(), 'POST', $xml + ['PatronRequestsService' => false], [], 'POST', $xml ); if ($response === false) { - $this->session->UBDetails[$requestId] = array( + $this->session->UBDetails[$requestId] = [ 'time' => time(), 'data' => false - ); + ]; $this->putCachedData($requestId, false); return false; } @@ -2624,7 +2624,7 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $response = $this->makeRequest( - array('PatronRequestService' => false), array(), 'POST', $xml + ['PatronRequestService' => false], [], 'POST', $xml ); if ($response === false) { @@ -2643,36 +2643,36 @@ EOT; $this->putCachedData($requestId, false); return false; } - $items = array(); - $libraries = array(); - $locations = array(); + $items = []; + $libraries = []; + $locations = []; $requiredByDate = ''; foreach ($response->xpath('//req:field') as $field) { switch ($field->attributes()->labelKey) { case 'selectItem': foreach ($field->xpath('./req:select/req:option') as $option) { - $items[] = array( + $items[] = [ 'id' => (string)$option->attributes()->id, 'name' => (string)$option - ); + ]; } break; case 'pickupLib': foreach ($field->xpath('./req:select/req:option') as $option) { - $libraries[] = array( + $libraries[] = [ 'id' => (string)$option->attributes()->id, 'name' => (string)$option, 'isDefault' => $option->attributes()->isDefault == 'Y' - ); + ]; } break; case 'pickUpAt': foreach ($field->xpath('./req:select/req:option') as $option) { - $locations[] = array( + $locations[] = [ 'id' => (string)$option->attributes()->id, 'name' => (string)$option, 'isDefault' => $option->attributes()->isDefault == 'Y' - ); + ]; } break; case 'notNeededAfter': @@ -2683,12 +2683,12 @@ EOT; break; } } - $results = array( + $results = [ 'items' => $items, 'libraries' => $libraries, 'locations' => $locations, 'requiredBy' => $requiredByDate - ); + ]; $this->putCachedData($requestId, $results); return $results; } @@ -2821,7 +2821,7 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $response = $this->makeRequest( - array('UBPickupLibService' => false), array(), 'POST', $xml + ['UBPickupLibService' => false], [], 'POST', $xml ); if ($response === false) { @@ -2838,13 +2838,13 @@ EOT; // Any message means a problem, right? throw new ILSException('ill_request_error_technical'); } - $locations = array(); + $locations = []; foreach ($response->xpath('//req:location') as $location) { - $locations[] = array( + $locations[] = [ 'id' => (string)$location->attributes()->id, 'name' => (string)$location, 'isDefault' => $location->attributes()->isDefault == 'Y' - ); + ]; } return $locations; } @@ -2910,10 +2910,10 @@ EOT; } } if (!$pickupLocationValid) { - return array( + return [ 'success' => false, 'sysMessage' => 'ill_request_place_fail_missing' - ); + ]; } // Attempt Request @@ -2964,7 +2964,7 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $response = $this->makeRequest( - array('SendPatronRequestService' => false), array(), 'POST', $xml + ['SendPatronRequestService' => false], [], 'POST', $xml ); if ($response === false) { @@ -2979,10 +2979,10 @@ EOT; ); foreach ($response->xpath('//ser:message') as $message) { if ($message->attributes()->type == 'success') { - return array( + return [ 'success' => true, 'status' => 'ill_request_success' - ); + ]; } if ($message->attributes()->type == 'system') { return $this->holdError('ill_request_error_technical'); @@ -3027,7 +3027,7 @@ EOT; $details = $cancelDetails['details']; $patron = $cancelDetails['patron']; $count = 0; - $response = array(); + $response = []; foreach ($details as $cancelDetails) { list($dbKey, $itemId, $type, $cancelCode) = explode("|", $cancelDetails); @@ -3036,10 +3036,10 @@ EOT; $cancelID = ($dbKey ? $dbKey : $this->ws_dbKey) . "|" . $cancelCode; // Build Hierarchy - $hierarchy = array( + $hierarchy = [ "patron" => $patron['id'], "circulationActions" => 'requests' - ); + ]; // An UB request is if ($type == 'C') { $hierarchy['callslips'] = $cancelID; @@ -3048,10 +3048,10 @@ EOT; } // Add Required Params - $params = array( + $params = [ "patron_homedb" => $this->ws_patronHomeUbId, "view" => "full" - ); + ]; // Get Data $cancel = $this->makeRequest($hierarchy, $params, "DELETE"); @@ -3064,21 +3064,21 @@ EOT; $reply = (string)$cancel->$node; $count = ($reply == "ok") ? $count+1 : $count; - $response[$itemId] = array( + $response[$itemId] = [ 'success' => ($reply == "ok") ? true : false, 'status' => ($reply == "ok") ? "ill_request_cancel_success" : "ill_request_cancel_fail", 'sysMessage' => ($reply == "ok") ? false : $reply, - ); + ]; } else { - $response[$itemId] = array( + $response[$itemId] = [ 'success' => false, 'status' => "ill_request_cancel_fail" - ); + ]; } } - $result = array('count' => $count, 'items' => $response); + $result = ['count' => $count, 'items' => $response]; return $result; } @@ -3173,7 +3173,7 @@ xmlns:ser="http://www.endinfosys.com/Voyager/serviceParameters"> EOT; $result = $this->makeRequest( - array('ChangePINService' => false), array(), 'POST', $xml + ['ChangePINService' => false], [], 'POST', $xml ); $result->registerXPathNamespace( @@ -3185,14 +3185,14 @@ EOT; $code = $error->attributes()->errorCode; $exceptionNamespace = 'com.endinfosys.voyager.patronpin.PatronPIN.'; if ($code == $exceptionNamespace . 'ValidateException') { - return array( + return [ 'success' => false, 'status' => 'authentication_error_invalid' - ); + ]; } if ($code == $exceptionNamespace . 'ValidateUniqueException') { - return array( + return [ 'success' => false, 'status' => 'password_error_not_unique' - ); + ]; } if ($code == $exceptionNamespace . 'ValidateLengthException') { // This issue should not be encountered if the settings are correct. @@ -3204,7 +3204,7 @@ EOT; } throw new ILSException((string)$error); } - return array('success' => true, 'status' => 'change_password_ok'); + return ['success' => true, 'status' => 'change_password_ok']; } /** @@ -3225,6 +3225,6 @@ EOT; if ($method == 'changePassword') { return isset($this->config['changePassword']); } - return is_callable(array($this, $method)); + return is_callable([$this, $method]); } } diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php index ef2842f8f56..e1255026279 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php @@ -54,7 +54,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * * @var array */ - protected $agency = array(); + protected $agency = []; /** * NCIP server URL @@ -68,7 +68,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * * @var array */ - protected $pickupLocations = array(); + protected $pickupLocations = []; /** * Initialize the driver. @@ -123,10 +123,10 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } if (($handle = fopen($pickupLocationsFile, "r")) !== false) { while (($data = fgetcsv($handle)) !== false) { - $this->pickupLocations[$data[0]][] = array( + $this->pickupLocations[$data[0]][] = [ 'locationID' => $data[1], 'locationDisplay' => $data[2] - ); + ]; } fclose($handle); } @@ -147,7 +147,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // Set timeout value $timeout = isset($this->config['Catalog']['http_timeout']) ? $this->config['Catalog']['http_timeout'] : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); $client->setRawBody($xml); $client->setEncType('application/xml; "charset=utf-8"'); $result = $client->setMethod('POST')->send(); @@ -203,14 +203,14 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); $location = (string)$location[0]; - return array( + return [ //'id' => ... 'status' => $status, 'location' => $location, 'callnumber' => $itemCallNo, 'availability' => ($status == "Not Charged"), 'reserve' => 'N', // not supported - ); + ]; } /** @@ -281,7 +281,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } // Build return array: - return array( + return [ 'id' => empty($aggregate_id) ? (empty($bib_id) ? '' : $bib_id) : $aggregate_id, 'availability' => ($status == 'Not Charged'), @@ -304,7 +304,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'holdtype' => $holdType, 'storageRetrievalRequest' => 'auto', 'addStorageRetrievalRequestLink' => 'true', - ); + ]; } /** @@ -349,7 +349,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } // Build a list of the types of information we want to retrieve: - $desiredParts = array( + $desiredParts = [ 'Bibliographic Description', 'Circulation Status', 'Electronic Resource', @@ -357,7 +357,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'Item Description', 'Item Use Restriction Type', 'Location' - ); + ]; // Start the XML: $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . @@ -411,7 +411,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getStatuses($idList) { - $status = array(); + $status = []; if ($this->consortium) { return $status; // (empty) TODO: add support for consortial statuses. @@ -454,7 +454,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // and then add the current chunk to the right place: $chunk['id'] = $bib_id; if (!isset($status[$id])) { - $status[$id] = array(); + $status[$id] = []; } $status[$bib_id][] = $chunk; } @@ -493,7 +493,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ) { $aggregate_id = $id; - $item_agency_id = array(); + $item_agency_id = []; if (! is_null($ids)) { foreach ($ids as $_id) { // Need to parse out the 035$a format, e.g., "(Agency) 123" @@ -507,9 +507,9 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } } - $holdings = array(); + $holdings = []; foreach ($item_agency_id as $_agency => $_id) { - $request = $this->getStatusRequest(array($_id), null, $_agency); + $request = $this->getStatusRequest([$_id], null, $_agency); $response = $this->sendRequest($request); $bib_id = $response->xpath( @@ -567,7 +567,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $sourceRecord = '(' . $_agency . ') '; } $sourceRecord .= $id; - $ids = array($sourceRecord); + $ids = [$sourceRecord]; } return $this->getConsortialHoldings($id, $patron, $ids); @@ -589,7 +589,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getPurchaseHistory($id) { // TODO - return array(); + return []; } /** @@ -621,7 +621,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); if (!empty($id)) { // Fill in basic patron details: - $patron = array( + $patron = [ 'id' => (string)$id[0], 'patron_agency_id' => (string)$patron_agency_id[0], 'cat_username' => $username, @@ -629,7 +629,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'email' => null, 'major' => null, 'college' => null - ); + ]; // Look up additional details: $details = $this->getMyProfile($patron); @@ -657,14 +657,14 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyTransactions($patron) { - $extras = array('<ns1:LoanedItemsDesired/>'); + $extras = ['<ns1:LoanedItemsDesired/>']; $request = $this->getLookupUserRequest( $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); - $retVal = array(); + $retVal = []; $list = $response->xpath('ns1:LookupUserResponse/ns1:LoanedItem'); foreach ($list as $current) { @@ -685,13 +685,13 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf } else { $tmp = "1"; } - $retVal[] = array( + $retVal[] = [ 'id' => $tmp, 'duedate' => $due, 'title' => (string)$title[0], 'item_id' => (string)$item_id[0], 'renewable' => true, - ); + ]; } return $retVal; @@ -710,7 +710,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyFines($patron) { - $extras = array('<ns1:UserFiscalAccountDesired/>'); + $extras = ['<ns1:UserFiscalAccountDesired/>']; $request = $this->getLookupUserRequest( $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras @@ -721,7 +721,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'ns1:LookupUserResponse/ns1:UserFiscalAccount/ns1:AccountDetails' ); - $fines = array(); + $fines = []; $balance = 0; foreach ($list as $current) { @@ -746,7 +746,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ $id = ''; $balance += $amount; - $fines[] = array( + $fines[] = [ 'amount' => $amount, 'balance' => $balance, 'checkout' => '', @@ -754,7 +754,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'duedate' => '', 'createdate' => $date, 'id' => $id - ); + ]; } return $fines; } @@ -772,14 +772,14 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyHolds($patron) { - $extras = array('<ns1:RequestedItemsDesired/>'); + $extras = ['<ns1:RequestedItemsDesired/>']; $request = $this->getLookupUserRequest( $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); - $retVal = array(); + $retVal = []; $list = $response->xpath('ns1:LookupUserResponse/ns1:RequestedItem'); foreach ($list as $current) { $id = $current->xpath( @@ -800,7 +800,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // Only return requests of type Hold or Recall. Callslips/Stack // Retrieval requests are fetched using getMyStorageRetrievalRequests if ($requestType === "Hold" or $requestType === "Recall") { - $retVal[] = array( + $retVal[] = [ 'id' => (string)$id[0], 'create' => '', 'expire' => $expireDate, @@ -809,7 +809,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'requestId' => (string)$requestId[0], 'item_id' => (string)$itemId[0], 'location' => (string)$pickupLocation[0], - ); + ]; } } @@ -828,7 +828,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyProfile($patron) { - $extras = array( + $extras = [ '<ns1:UserElementType ns1:Scheme="http://www.niso.org/ncip/v1_0/' . 'schemes/userelementtype/userelementtype.scm">' . 'User Address Information' . @@ -837,7 +837,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'schemes/userelementtype/userelementtype.scm">' . 'Name Information' . '</ns1:UserElementType>' - ); + ]; $request = $this->getLookupUserRequest( $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras @@ -863,7 +863,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'ns1:UnstructuredAddress/ns1:UnstructuredAddressData' ); $address = explode("\n", trim((string)$address[0])); - return array( + return [ 'firstname' => (string)$first[0], 'lastname' => (string)$last[0], 'address1' => isset($address[0]) ? $address[0] : '', @@ -872,7 +872,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'zip' => isset($address[3]) ? $address[3] : '', 'phone' => '', // TODO: phone number support 'group' => '' - ); + ]; } /** @@ -898,7 +898,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getNewItems($page, $limit, $daysOld, $fundId = null) { // TODO - return array(); + return []; } /** @@ -912,7 +912,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getFunds() { // TODO - return array(); + return []; } /** @@ -926,7 +926,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getDepartments() { // TODO - return array(); + return []; } /** @@ -940,7 +940,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getInstructors() { // TODO - return array(); + return []; } /** @@ -954,7 +954,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getCourses() { // TODO - return array(); + return []; } /** @@ -974,7 +974,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function findReserves($course, $inst, $dept) { // TODO - return array(); + return []; } /** @@ -986,7 +986,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getSuppressedRecords() { // TODO - return array(); + return []; } /** @@ -1003,23 +1003,23 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf public function getConfig($function, $params = null) { if ($function == 'Holds') { - return array( + return [ 'HMACKeys' => 'item_id:holdtype:item_agency_id:aggregate_id:bib_id', 'extraHoldFields' => 'comments:pickUpLocation:requiredByDate', 'defaultRequiredDate' => '0:2:0', 'consortium' => $this->consortium, - ); + ]; } if ($function == 'StorageRetrievalRequests') { - return array( + return [ 'HMACKeys' => 'id:item_id:item_agency_id:aggregate_id:bib_id', 'extraFields' => 'comments:pickUpLocation:requiredByDate:item-issue', 'helpText' => 'This is a storage retrieval request help text' . ' with some <span style="color: red">styling</span>.', 'defaultRequiredDate' => '0:2:0', - ); + ]; } - return array(); + return []; } /** @@ -1064,14 +1064,14 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getPickUpLocations($patron, $holdDetails = null) { - $locations = array(); + $locations = []; foreach (array_keys($this->agency) as $agency) { foreach ($this->pickupLocations[$agency] as $thisAgency) { $locations[] - = array( + = [ 'locationID' => $thisAgency['locationID'], 'locationDisplay' => $thisAgency['locationDisplay'], - ); + ]; } } return $locations; @@ -1088,14 +1088,14 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function getMyStorageRetrievalRequests($patron) { - $extras = array('<ns1:RequestedItemsDesired/>'); + $extras = ['<ns1:RequestedItemsDesired/>']; $request = $this->getLookupUserRequest( $patron['cat_username'], $patron['cat_password'], $patron['patron_agency_id'], $extras ); $response = $this->sendRequest($request); - $retVal = array(); + $retVal = []; $list = $response->xpath('ns1:LookupUserResponse/ns1:RequestedItem'); foreach ($list as $current) { $cancelled = true; @@ -1118,7 +1118,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf // Only return requests of type Stack Retrieval/Callslip. Hold // and Recall requests are fetched using getMyHolds if ($requestType === 'Stack Retrieval') { - $retVal[] = array( + $retVal[] = [ 'id' => (string)$id[0], 'create' => $created, 'expire' => '', @@ -1129,7 +1129,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf 'canceled' => $cancelled, 'location' => (string)$pickupLocation[0], 'processed' => false, - ); + ]; } } @@ -1191,15 +1191,15 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); if ($success) { - return array( + return [ 'success' => true, "sysMessage" => 'Storage Retrieval Request Successful.' - ); + ]; } else { - return array( + return [ 'success' => false, "sysMessage" => 'Storage Retrieval Request Not Successful.' - ); + ]; } } @@ -1259,15 +1259,15 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf ); if ($success) { - return array( + return [ 'success' => true, "sysMessage" => 'Request Successful.' - ); + ]; } else { - return array( + return [ 'success' => false, "sysMessage" => 'Request Not Successful.' - ); + ]; } } @@ -1288,7 +1288,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $username = $cancelDetails['patron']['cat_username']; $password = $cancelDetails['patron']['cat_password']; $details = $cancelDetails['details']; - $response = array(); + $response = []; foreach ($details as $cancelDetails) { list($itemId, $requestId) = explode("|", $cancelDetails); @@ -1303,18 +1303,18 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $itemId = (string)$itemId; if ($userId) { $count++; - $response[$itemId] = array( + $response[$itemId] = [ 'success' => true, 'status' => 'hold_cancel_success', - ); + ]; } else { - $response[$itemId] = array( + $response[$itemId] = [ 'success' => false, 'status' => 'hold_cancel_fail', - ); + ]; } } - $result = array('count' => $count, 'items' => $response); + $result = ['count' => $count, 'items' => $response]; return $result; } @@ -1354,7 +1354,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $username = $cancelDetails['patron']['cat_username']; $password = $cancelDetails['patron']['cat_password']; $details = $cancelDetails['details']; - $response = array(); + $response = []; foreach ($details as $cancelDetails) { list($itemId, $requestId) = explode("|", $cancelDetails); @@ -1369,18 +1369,18 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $itemId = (string)$itemId; if ($userId) { $count++; - $response[$itemId] = array( + $response[$itemId] = [ 'success' => true, 'status' => 'storage_retrieval_request_cancel_success', - ); + ]; } else { - $response[$itemId] = array( + $response[$itemId] = [ 'success' => false, 'status' => 'storage_retrieval_request_cancel_fail', - ); + ]; } } - $result = array('count' => $count, 'items' => $response); + $result = ['count' => $count, 'items' => $response]; return $result; } @@ -1414,7 +1414,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf */ public function renewMyItems($renewDetails) { - $details = array(); + $details = []; foreach ($renewDetails['details'] as $renewId) { $request = $this->getRenewRequest( $renewDetails['patron']['cat_username'], @@ -1428,22 +1428,22 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf $tmp = split("T", $newDueDate); $splitDate = $tmp[0]; $splitTime = $tmp[1]; - $details[$renewId] = array( + $details[$renewId] = [ "success" => true, "new_date" => $splitDate, "new_time" => rtrim($splitTime, "Z"), "item_id" => $renewId, - ); + ]; } else { - $details[$renewId] = array( + $details[$renewId] = [ "success" => false, "item_id" => $renewId, - ); + ]; } } - return array(null, "details" => $details); + return [null, "details" => $details]; } /** @@ -1650,7 +1650,7 @@ class XCNCIP2 extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterf * @return string NCIP request XML */ protected function getLookupUserRequest($username, $password, - $patron_agency_id = null, $extras = array() + $patron_agency_id = null, $extras = [] ) { $ret = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . '<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ' . diff --git a/module/VuFind/src/VuFind/ILS/Logic/Holds.php b/module/VuFind/src/VuFind/ILS/Logic/Holds.php index 60475226280..fbb4d82cd14 100644 --- a/module/VuFind/src/VuFind/ILS/Logic/Holds.php +++ b/module/VuFind/src/VuFind/ILS/Logic/Holds.php @@ -74,7 +74,7 @@ class Holds * * @var array */ - protected $hideHoldings = array(); + protected $hideHoldings = []; /** * Constructor @@ -112,26 +112,26 @@ class Holds */ protected function formatHoldings($holdings) { - $retVal = array(); + $retVal = []; // Handle purchase history alongside other textual fields $textFieldNames = $this->catalog->getHoldingsTextFieldNames(); $textFieldNames[] = 'purchase_history'; foreach ($holdings as $groupKey => $items) { - $retVal[$groupKey] = array( + $retVal[$groupKey] = [ 'items' => $items, 'location' => isset($items[0]['location']) ? $items[0]['location'] : '' - ); + ]; // Copy all text fields from the item to the holdings level foreach ($items as $item) { foreach ($textFieldNames as $fieldName) { if (!empty($item[$fieldName])) { $fields = is_array($item[$fieldName]) ? $item[$fieldName] - : array($item[$fieldName]); + : [$item[$fieldName]]; foreach ($fields as $field) { if (empty($retVal[$groupKey][$fieldName]) @@ -159,7 +159,7 @@ class Holds */ public function getHoldings($id, $ids = null) { - $holdings = array(); + $holdings = []; // Get Holdings Data if ($this->catalog) { @@ -207,7 +207,7 @@ class Holds */ protected function standardHoldings($result) { - $holdings = array(); + $holdings = []; if (count($result)) { foreach ($result as $copy) { $show = !in_array($copy['location'], $this->hideHoldings); @@ -230,7 +230,7 @@ class Holds */ protected function driverHoldings($result, $holdConfig) { - $holdings = array(); + $holdings = []; if (count($result)) { foreach ($result as $copy) { @@ -272,7 +272,7 @@ class Holds */ protected function generateHoldings($result, $type, $holdConfig) { - $holdings = array(); + $holdings = []; $any_available = false; $holds_override = isset($this->config->Catalog->allow_holds_override) @@ -487,11 +487,11 @@ class Holds $queryString = implode('&', $queryString); // Build Params - return array( + return [ 'action' => $action, 'record' => $details['id'], 'source' => isset($details['source']) ? $details['source'] : 'VuFind', 'query' => $queryString, 'anchor' => "#tabnav" - ); + ]; } /** @@ -504,9 +504,9 @@ class Holds protected function getBlockedDetails($holdDetails) { // Build Params - return array( + return [ 'action' => 'BlockedHold', 'record' => $holdDetails['id'] - ); + ]; } /** @@ -519,10 +519,10 @@ class Holds protected function getBlockedStorageRetrievalRequestDetails($details) { // Build Params - return array( + return [ 'action' => 'BlockedStorageRetrievalRequest', 'record' => $details['id'] - ); + ]; } /** @@ -535,10 +535,10 @@ class Holds protected function getBlockedILLRequestDetails($details) { // Build Params - return array( + return [ 'action' => 'BlockedILLRequest', 'record' => $details['id'] - ); + ]; } /** diff --git a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php index 13d88fc789a..3b5e071ac3a 100644 --- a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php +++ b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php @@ -74,7 +74,7 @@ class TitleHolds * * @var array */ - protected $hideHoldings = array(); + protected $hideHoldings = []; /** * Constructor @@ -140,7 +140,7 @@ class TitleHolds { // Cache results in a static array since the same holdings may be requested // multiple times during a run through the class: - static $holdings = array(); + static $holdings = []; if (!isset($holdings[$id])) { $holdings[$id] = $this->catalog->getHolding($id); @@ -194,10 +194,10 @@ class TitleHolds $checkHolds = $this->catalog->checkFunction( 'Holds', compact('id', 'patron') ); - $data = array( + $data = [ 'id' => $id, 'level' => 'title' - ); + ]; if ($checkHolds != false) { $valid = $this->catalog->checkRequestIsValid($id, $data, $patron); @@ -223,10 +223,10 @@ class TitleHolds $any_available = false; $addlink = false; - $data = array( + $data = [ 'id' => $id, 'level' => 'title' - ); + ]; // Are holds allows? $checkHolds = $this->catalog->checkFunction( @@ -290,9 +290,9 @@ class TitleHolds $queryString = implode('&', $queryString); // Build Params - return array( + return [ 'action' => 'Hold', 'record' => $data['id'], 'query' => $queryString, 'anchor' => '#tabnav' - ); + ]; } } diff --git a/module/VuFind/src/VuFind/ImageLoader.php b/module/VuFind/src/VuFind/ImageLoader.php index 0bcafdd42cc..e0b04cbfbd5 100644 --- a/module/VuFind/src/VuFind/ImageLoader.php +++ b/module/VuFind/src/VuFind/ImageLoader.php @@ -83,12 +83,12 @@ class ImageLoader implements \Zend\Log\LoggerAwareInterface * * @var array */ - protected $allowedFileExtensions = array( + protected $allowedFileExtensions = [ "gif" => "image/gif", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "tiff" => "image/tiff", "tif" => "image/tiff" - ); + ]; /** * Setter for dependency @@ -140,10 +140,10 @@ class ImageLoader implements \Zend\Log\LoggerAwareInterface * * @return string|bool */ - protected function searchTheme($path, $formats = array('')) + protected function searchTheme($path, $formats = ['']) { // Check all supported image formats: - $filenames = array(); + $filenames = []; foreach ($formats as $format) { $filenames[] = $path . $format; } diff --git a/module/VuFind/src/VuFind/Log/Logger.php b/module/VuFind/src/VuFind/Log/Logger.php index dc1c29f335a..7ae2ea04c31 100644 --- a/module/VuFind/src/VuFind/Log/Logger.php +++ b/module/VuFind/src/VuFind/Log/Logger.php @@ -79,12 +79,12 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface $table_name = $parts[0]; $error_types = isset($parts[1]) ? $parts[1] : ''; - $columnMapping = array( + $columnMapping = [ 'priority' => 'priority', 'message' => 'message', 'logtime' => 'timestamp', 'ident' => 'ident' - ); + ]; // Make Writers $filters = explode(',', $error_types); @@ -232,7 +232,7 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface * * @return Logger */ - public function log($priority, $message, $extra = array()) + public function log($priority, $message, $extra = []) { // Special case to handle arrays of messages (for multi-verbosity-level // logging, not supported by base class): @@ -240,13 +240,13 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface $timestamp = new \DateTime(); foreach ($this->writers->toArray() as $writer) { $writer->write( - array( + [ 'timestamp' => $timestamp, 'priority' => (int) $priority, 'priorityName' => $this->priorities[$priority], 'message' => $message, 'extra' => $extra - ) + ] ); } return $this; @@ -292,7 +292,7 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface . 'function = ' . $line['function']; $basicBacktrace .= "{$basicBacktraceLine}\n"; if (!empty($line['args'])) { - $args = array(); + $args = []; foreach ($line['args'] as $i => $arg) { $args[] = $i . ' = ' . $this->argumentToString($arg); } @@ -304,13 +304,13 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface } } - $errorDetails = array( + $errorDetails = [ 1 => $baseError, 2 => $baseError . $basicServer, 3 => $baseError . $basicServer . $basicBacktrace, 4 => $baseError . $detailedServer . $basicBacktrace, 5 => $baseError . $detailedServer . $detailedBacktrace - ); + ]; $this->log(BaseLogger::CRIT, $errorDetails); } @@ -329,7 +329,7 @@ class Logger extends BaseLogger implements ServiceLocatorAwareInterface return get_class($arg) . ' Object'; } if (is_array($arg)) { - $args = array(); + $args = []; foreach ($arg as $key => $item) { $args[] = "$key => " . $this->argumentToString($item); } diff --git a/module/VuFind/src/VuFind/Mailer/Factory.php b/module/VuFind/src/VuFind/Mailer/Factory.php index 97cbbf8d34d..f47a9a7c92f 100644 --- a/module/VuFind/src/VuFind/Mailer/Factory.php +++ b/module/VuFind/src/VuFind/Mailer/Factory.php @@ -55,15 +55,15 @@ class Factory implements \Zend\ServiceManager\FactoryInterface $config = $sm->get('VuFind\Config')->get('config'); // Create mail transport: - $settings = array( + $settings = [ 'host' => $config->Mail->host, 'port' => $config->Mail->port - ); + ]; if (isset($config->Mail->username) && isset($config->Mail->password)) { $settings['connection_class'] = 'login'; - $settings['connection_config'] = array( + $settings['connection_config'] = [ 'username' => $config->Mail->username, 'password' => $config->Mail->password - ); + ]; } $transport = new Smtp(); $transport->setOptions(new SmtpOptions($settings)); diff --git a/module/VuFind/src/VuFind/Mailer/Mailer.php b/module/VuFind/src/VuFind/Mailer/Mailer.php index d618fb5afba..5c2c87eae76 100644 --- a/module/VuFind/src/VuFind/Mailer/Mailer.php +++ b/module/VuFind/src/VuFind/Mailer/Mailer.php @@ -204,9 +204,9 @@ class Mailer implements \VuFind\I18n\Translator\TranslatorAwareInterface } $body = $view->partial( 'Email/share-link.phtml', - array( + [ 'msgUrl' => $url, 'to' => $to, 'from' => $from, 'message' => $msg - ) + ] ); return $this->send($to, $from, $subject, $body, $cc); } @@ -245,9 +245,9 @@ class Mailer implements \VuFind\I18n\Translator\TranslatorAwareInterface } $body = $view->partial( 'Email/record.phtml', - array( + [ 'driver' => $record, 'to' => $to, 'from' => $from, 'message' => $msg - ) + ] ); return $this->send($to, $from, $subject, $body, $cc); } diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index 9260e6f1913..f01b3e5ef01 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -103,7 +103,7 @@ class Server * * @var array */ - protected $metadataFormats = array(); + protected $metadataFormats = []; /** * Namespace used for ID prefixing (if any) @@ -166,7 +166,7 @@ class Server * * @var array */ - protected $setQueries = array(); + protected $setQueries = []; /** * Constructor @@ -194,7 +194,7 @@ class Server if (isset($parts['port'])) { $this->baseHostURL .= $parts['port']; } - $this->params = isset($params) && is_array($params) ? $params : array(); + $this->params = isset($params) && is_array($params) ? $params : []; $this->initializeMetadataFormats(); // Load details on supported formats $this->initializeSettings($config); // Load config.ini settings } @@ -258,7 +258,7 @@ class Server $this->attachRecordHeader( $record, $this->prefixID($tracker['id']), date($this->iso8601, $this->normalizeDate($tracker['deleted'])), - array(), + [], 'deleted' ); } @@ -274,7 +274,7 @@ class Server * * @return void */ - protected function attachRecordHeader($xml, $id, $date, $sets = array(), + protected function attachRecordHeader($xml, $id, $date, $sets = [], $status = '' ) { $header = $xml->addChild('header'); @@ -317,7 +317,7 @@ class Server if (!is_null($this->setField) && !empty($fields[$this->setField])) { $sets = $fields[$this->setField]; } else { - $sets = array(); + $sets = []; } // Get modification date: @@ -441,12 +441,12 @@ class Server */ protected function initializeMetadataFormats() { - $this->metadataFormats['oai_dc'] = array( + $this->metadataFormats['oai_dc'] = [ 'schema' => 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd', - 'namespace' => 'http://www.openarchives.org/OAI/2.0/oai_dc/'); - $this->metadataFormats['marc21'] = array( + 'namespace' => 'http://www.openarchives.org/OAI/2.0/oai_dc/']; + $this->metadataFormats['marc21'] = [ 'schema' => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', - 'namespace' => 'http://www.loc.gov/MARC21/slim'); + 'namespace' => 'http://www.loc.gov/MARC21/slim']; } /** @@ -645,7 +645,7 @@ class Server // proves not to be the case: $results = $this->resultsManager->get($this->searchClassId); try { - $facets = $results->getFullFieldFacets(array($this->setField)); + $facets = $results->getFullFieldFacets([$this->setField]); } catch (\Exception $e) { $facets = null; } @@ -933,7 +933,7 @@ class Server if (strlen($date) == 10) { $date .= ' ' . $time; } else { - $date = str_replace(array('T', 'Z'), array(' ', ''), $date); + $date = str_replace(['T', 'Z'], [' ', ''], $date); } // Translate to a timestamp: diff --git a/module/VuFind/src/VuFind/QRCode/Loader.php b/module/VuFind/src/VuFind/QRCode/Loader.php index 594ec5edf8a..4c786252bba 100644 --- a/module/VuFind/src/VuFind/QRCode/Loader.php +++ b/module/VuFind/src/VuFind/QRCode/Loader.php @@ -62,9 +62,9 @@ class Loader extends \VuFind\ImageLoader * * @var string */ - protected $params = array( + protected $params = [ 'level' => "L", 'size' => "3", 'margin' => "4" - ); + ]; /** * Constructor @@ -91,7 +91,7 @@ class Loader extends \VuFind\ImageLoader * @return void */ public function loadQRCode($text, - $params = array('level' => "L", 'size' => "3", 'margin' => "4") + $params = ['level' => "L", 'size' => "3", 'margin' => "4"] ) { // Sanitize parameters: $this->text = $text; diff --git a/module/VuFind/src/VuFind/Recommend/AbstractFacets.php b/module/VuFind/src/VuFind/Recommend/AbstractFacets.php index 110fb8a6178..7caeb48524b 100644 --- a/module/VuFind/src/VuFind/Recommend/AbstractFacets.php +++ b/module/VuFind/src/VuFind/Recommend/AbstractFacets.php @@ -46,14 +46,14 @@ abstract class AbstractFacets implements RecommendInterface * * @var array */ - protected $excludableFacets = array(); + protected $excludableFacets = []; /** * Facets that are "ORed" instead of "ANDed." * * @var array */ - protected $orFacets = array(); + protected $orFacets = []; /** * Search results diff --git a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php index 5fc5b5a5ee6..0331acb8676 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php @@ -151,27 +151,27 @@ class AuthorFacets implements RecommendInterface // Do not provide recommendations for blank searches: $lookfor = $this->getSearchTerm(); if (empty($lookfor)) { - return array('count' => 0, 'list' => array()); + return ['count' => 0, 'list' => []]; } // Start configuring the results object: $results = $this->resultsManager->get('SolrAuthorFacets'); // Set up a special limit for the AuthorFacets search object: - $results->getOptions()->setLimitOptions(array(10)); + $results->getOptions()->setLimitOptions([10]); // Initialize object using parameters from the current Solr search object. $results->getParams() - ->initFromRequest(new Parameters(array('lookfor' => $lookfor))); + ->initFromRequest(new Parameters(['lookfor' => $lookfor])); // Send back the results: - return array( + return [ // Total authors (currently there is no way to calculate this without // risking out-of-memory errors or slow results, so we set this to // false; if we are able to find this information out in the future, // we can fill it in here and the templates will display it). 'count' => false, 'list' => $results->getResults() - ); + ]; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php index 5931d1e2efb..7d068c068f4 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php @@ -61,7 +61,7 @@ class AuthorityRecommend implements RecommendInterface * * @var array */ - protected $filters = array(); + protected $filters = []; /** * Maximum number of results that will be accompanied by recommendations (set @@ -83,7 +83,7 @@ class AuthorityRecommend implements RecommendInterface * * @var array */ - protected $recommendations = array(); + protected $recommendations = []; /** * Results plugin manager @@ -172,15 +172,15 @@ class AuthorityRecommend implements RecommendInterface // "Heading" search and IS NOT found in the "MainHeading" search defined // in authsearchspecs.yaml. $request = new Parameters( - array( + [ 'join' => 'AND', - 'bool0' => array('AND'), - 'lookfor0' => array($this->lookfor), - 'type0' => array('Heading'), - 'bool1' => array('NOT'), - 'lookfor1' => array($this->lookfor), - 'type1' => array('MainHeading') - ) + 'bool0' => ['AND'], + 'lookfor0' => [$this->lookfor], + 'type0' => ['Heading'], + 'bool1' => ['NOT'], + 'lookfor1' => [$this->lookfor], + 'type1' => ['MainHeading'] + ] ); // Initialise and process search (ignore Solr errors -- no reason to fail @@ -201,10 +201,10 @@ class AuthorityRecommend implements RecommendInterface // above foreach ($results as $result) { // Extract relevant details: - $recordArray = array( + $recordArray = [ 'id' => $result->getUniqueID(), 'heading' => $result->getBreadcrumb() - ); + ]; // check for duplicates before adding record to recordSet if (!$this->inArrayR($recordArray['heading'], $this->recommendations)) { diff --git a/module/VuFind/src/VuFind/Recommend/DPLATerms.php b/module/VuFind/src/VuFind/Recommend/DPLATerms.php index 22f64136a89..47e745d80b1 100644 --- a/module/VuFind/src/VuFind/Recommend/DPLATerms.php +++ b/module/VuFind/src/VuFind/Recommend/DPLATerms.php @@ -75,7 +75,7 @@ class DPLATerms implements RecommendInterface * * @var array */ - protected $formatMap = array( + protected $formatMap = [ 'authorStr' => 'sourceResource.creator', 'building' => 'provider.name', 'format' => 'sourceResource.format', @@ -83,19 +83,19 @@ class DPLATerms implements RecommendInterface 'institution' => 'provider.name', 'language' => 'sourceResource.language.name', 'publishDate' => 'sourceResource.date.begin', - ); + ]; /** * List of fields to retrieve from the API * * @var array */ - protected $returnFields = array( + protected $returnFields = [ 'id', 'dataProvider', 'sourceResource.title', 'sourceResource.description', - ); + ]; /** * Constructor @@ -165,10 +165,10 @@ class DPLATerms implements RecommendInterface $response = $this->client->send(); } catch (TimeoutException $e) { error_log('DPLA API timeout -- skipping recommendations.'); - return array(); + return []; } if (!$response->isSuccess()) { - return array(); + return []; } return $this->processResults($response->getBody()); } @@ -187,11 +187,11 @@ class DPLATerms implements RecommendInterface ? $search->getString() : ''; - $params = array( + $params = [ 'q' => $lookfor, 'fields' => implode(',', $this->returnFields), 'api_key' => $this->apiKey - ); + ]; foreach ($filters as $field => $filter) { if (isset($this->formatMap[$field])) { $params[$this->formatMap[$field]] = implode(',', $filter); @@ -210,12 +210,12 @@ class DPLATerms implements RecommendInterface protected function processResults($response) { $body = json_decode($response); - $results = array(); + $results = []; if ($body->count > 0) { $title = 'sourceResource.title'; $desc = 'sourceResource.description'; foreach ($body->docs as $i => $doc) { - $results[$i] = array( + $results[$i] = [ 'title' => is_array($doc->$title) ? current($doc->$title) : $doc->$title, @@ -223,7 +223,7 @@ class DPLATerms implements RecommendInterface ? current($doc->dataProvider) : $doc->dataProvider, 'link' => 'http://dp.la/item/' . $doc->id - ); + ]; if (isset($doc->$desc)) { $results[$i]['desc'] = is_array($doc->$desc) ? current($doc->$desc) diff --git a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php index c148c5ae4fc..b5f27db358f 100644 --- a/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php +++ b/module/VuFind/src/VuFind/Recommend/EuropeanaResults.php @@ -145,7 +145,7 @@ class EuropeanaResults implements RecommendInterface, $this->limit = isset($params[2]) && is_numeric($params[2]) && $params[2] > 0 ? intval($params[2]) : 5; $this->excludeProviders = (isset($params[3]) && !empty($params[3])) - ? $params[3] : array(); + ? $params[3] : []; //make array if (!empty($this->excludeProviders)) { $this->excludeProviders = explode(',', $this->excludeProviders); @@ -225,15 +225,15 @@ class EuropeanaResults implements RecommendInterface, ); } $parsedFeed = FeedReader::import($this->targetUrl); - $resultsProcessed = array(); + $resultsProcessed = []; foreach ($parsedFeed as $value) { $link = (string)$value->link; if (!empty($link)) { - $resultsProcessed[] = array( + $resultsProcessed[] = [ 'title' => (string)$value->title, 'link' => substr($link, 0, strpos($link, '.srw')) . '.html', 'enclosure' => (string)$value->enclosure['url'] - ); + ]; } if (count($resultsProcessed) == $this->limit) { break; @@ -241,11 +241,11 @@ class EuropeanaResults implements RecommendInterface, } if (!empty($resultsProcessed)) { - $this->results = array( + $this->results = [ 'worksArray' => $resultsProcessed, 'feedTitle' => $this->searchSite, 'sourceLink' => $this->sitePath - ); + ]; } else { $this->results = false; } diff --git a/module/VuFind/src/VuFind/Recommend/ExpandFacets.php b/module/VuFind/src/VuFind/Recommend/ExpandFacets.php index 67814486e9b..f5eacd4504e 100644 --- a/module/VuFind/src/VuFind/Recommend/ExpandFacets.php +++ b/module/VuFind/src/VuFind/Recommend/ExpandFacets.php @@ -109,7 +109,7 @@ class ExpandFacets implements RecommendInterface // All standard facets to display: $this->facets = isset($config->$mainSection) ? - $config->$mainSection->toArray() : array(); + $config->$mainSection->toArray() : []; } /** diff --git a/module/VuFind/src/VuFind/Recommend/FacetCloud.php b/module/VuFind/src/VuFind/Recommend/FacetCloud.php index 9239c2f074b..73fced93a9a 100644 --- a/module/VuFind/src/VuFind/Recommend/FacetCloud.php +++ b/module/VuFind/src/VuFind/Recommend/FacetCloud.php @@ -48,8 +48,8 @@ class FacetCloud extends ExpandFacets public function getFacetLimit() { $params = $this->searchObject->getParams(); - $settings = is_callable(array($params, 'getFacetSettings')) - ? $params->getFacetSettings() : array(); + $settings = is_callable([$params, 'getFacetSettings']) + ? $params->getFacetSettings() : []; // Figure out the facet limit -- if available, we can use this to display // "..." when more facets are available than are currently being displayed, diff --git a/module/VuFind/src/VuFind/Recommend/FavoriteFacets.php b/module/VuFind/src/VuFind/Recommend/FavoriteFacets.php index 5bab380e81e..23b414e279e 100644 --- a/module/VuFind/src/VuFind/Recommend/FavoriteFacets.php +++ b/module/VuFind/src/VuFind/Recommend/FavoriteFacets.php @@ -55,6 +55,6 @@ class FavoriteFacets extends SideFacets // Only display tags when enabled: $this->mainFacets = ($tagSetting && $tagSetting !== 'disabled') - ? array('tags' => 'Your Tags') : array(); + ? ['tags' => 'Your Tags'] : []; } } diff --git a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php index b6f3617e368..d87558d0bc6 100644 --- a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php +++ b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjects.php @@ -119,7 +119,7 @@ class OpenLibrarySubjects implements RecommendInterface, if (isset($params[3])) { $this->subjectTypes = explode(',', $params[3]); } else { - $this->subjectTypes = array("topic"); + $this->subjectTypes = ["topic"]; } // A 4th parameter is not specified in searches.ini, if it exists @@ -168,7 +168,7 @@ class OpenLibrarySubjects implements RecommendInterface, { // Only proceed if we have a request parameter value if (!empty($this->subject)) { - $result = array(); + $result = []; $ol = new OpenLibrary($this->httpService->createClient()); $result = $ol->getSubjects( $this->subject, $this->publishedIn, $this->subjectTypes, true, false, @@ -176,9 +176,9 @@ class OpenLibrarySubjects implements RecommendInterface, ); if (!empty($result)) { - $this->result = array( + $this->result = [ 'worksArray' => $result, 'subject' => $this->subject - ); + ]; } } } @@ -201,7 +201,7 @@ class OpenLibrarySubjects implements RecommendInterface, $from = $request->get($field . 'from'); $to = $request->get($field . 'to'); if (!is_null($from) && !is_null($to)) { - $range = array('from' => $from, 'to' => $to); + $range = ['from' => $from, 'to' => $to]; } else if (is_object($params)) { $currentFilters = $params->getFilters(); if (isset($currentFilters[$field][0])) { diff --git a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjectsDeferred.php b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjectsDeferred.php index a0ae22c0f0c..afe2d2a40c6 100644 --- a/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjectsDeferred.php +++ b/module/VuFind/src/VuFind/Recommend/OpenLibrarySubjectsDeferred.php @@ -100,7 +100,7 @@ class OpenLibrarySubjectsDeferred extends OpenLibrarySubjects $settings[2] = 'publishDate'; } $pubDateRange = strtolower($settings[2]) == 'false' ? - array() : $this->getPublishedDates($settings[2], $params, $request); + [] : $this->getPublishedDates($settings[2], $params, $request); if (!empty($pubDateRange)) { // Check if [Subject types] parameter has been supplied in searches.ini if (!isset($settings[3])) { diff --git a/module/VuFind/src/VuFind/Recommend/PubDateVisAjax.php b/module/VuFind/src/VuFind/Recommend/PubDateVisAjax.php index a92b127e3c2..4c25b5f1e39 100644 --- a/module/VuFind/src/VuFind/Recommend/PubDateVisAjax.php +++ b/module/VuFind/src/VuFind/Recommend/PubDateVisAjax.php @@ -66,7 +66,7 @@ class PubDateVisAjax implements RecommendInterface * * @var array */ - protected $dateFacets = array(); + protected $dateFacets = []; /** * Store the configuration of the recommendation module. @@ -131,7 +131,7 @@ class PubDateVisAjax implements RecommendInterface { // Don't bother processing if the result set is empty: if ($this->searchObject->getResultTotal() == 0) { - return array(); + return []; } return $this->processDateFacets( $this->searchObject->getParams()->getFilters() @@ -173,7 +173,7 @@ class PubDateVisAjax implements RecommendInterface // Pass through hidden filters: $options = $this->searchObject->getOptions(); - if (is_callable(array($options, 'getHiddenFilters'))) { + if (is_callable([$options, 'getHiddenFilters'])) { foreach ($options->getHiddenFilters() as $hf) { $str .= '&' . urlencode('hf[]') . '=' . urlencode($hf); } @@ -190,7 +190,7 @@ class PubDateVisAjax implements RecommendInterface */ protected function processDateFacets($filters) { - $result = array(); + $result = []; foreach ($this->dateFacets as $current) { $from = $to = ''; if (isset($filters[$current])) { @@ -203,7 +203,7 @@ class PubDateVisAjax implements RecommendInterface } } } - $result[$current] = array($from, $to); + $result[$current] = [$from, $to]; $result[$current]['label'] = $this->searchObject->getParams()->getFacetLabel($current); } diff --git a/module/VuFind/src/VuFind/Recommend/RandomRecommend.php b/module/VuFind/src/VuFind/Recommend/RandomRecommend.php index 1ae33f76a50..6ce5d177128 100644 --- a/module/VuFind/src/VuFind/Recommend/RandomRecommend.php +++ b/module/VuFind/src/VuFind/Recommend/RandomRecommend.php @@ -92,7 +92,7 @@ class RandomRecommend implements RecommendInterface * * @var array */ - protected $filters = array(); + protected $filters = []; /** * Settings from configuration @@ -141,7 +141,7 @@ class RandomRecommend implements RecommendInterface $this->settings = $settings; // Apply any settings that override the defaults by being non-empty: - $properties = array('backend', 'limit', 'displayMode', 'mode', 'minimum'); + $properties = ['backend', 'limit', 'displayMode', 'mode', 'minimum']; $settings = explode(':', $settings); foreach ($properties as $i => $property) { if (!empty($settings[$i])) { @@ -207,7 +207,7 @@ class RandomRecommend implements RecommendInterface public function getResults() { if (count($this->results) < $this->minimum) { - return array(); + return []; } return $this->results; } diff --git a/module/VuFind/src/VuFind/Recommend/SideFacets.php b/module/VuFind/src/VuFind/Recommend/SideFacets.php index dfa0ed4f021..398b56aa3f7 100644 --- a/module/VuFind/src/VuFind/Recommend/SideFacets.php +++ b/module/VuFind/src/VuFind/Recommend/SideFacets.php @@ -47,42 +47,42 @@ class SideFacets extends AbstractFacets * * @var array */ - protected $dateFacets = array(); + protected $dateFacets = []; /** * Day/month/year date facet configuration * * @var array */ - protected $fullDateFacets = array(); + protected $fullDateFacets = []; /** * Generic range facet configuration * * @var array */ - protected $genericRangeFacets = array(); + protected $genericRangeFacets = []; /** * Numeric range facet configuration * * @var array */ - protected $numericRangeFacets = array(); + protected $numericRangeFacets = []; /** * Main facet configuration * * @var array */ - protected $mainFacets = array(); + protected $mainFacets = []; /** * Checkbox facet configuration * * @var array */ - protected $checkboxFacets = array(); + protected $checkboxFacets = []; /** * Collapsed facet setting @@ -96,14 +96,14 @@ class SideFacets extends AbstractFacets * * @var array */ - protected $hierarchicalFacets = array(); + protected $hierarchicalFacets = []; /** * Hierarchical facet sort options * * @var array */ - protected $hierarchicalFacetSortOptions = array(); + protected $hierarchicalFacetSortOptions = []; /** * Hierarchical facet helper @@ -147,7 +147,7 @@ class SideFacets extends AbstractFacets // All standard facets to display: $this->mainFacets = isset($config->$mainSection) ? - $config->$mainSection->toArray() : array(); + $config->$mainSection->toArray() : []; // Load boolean configurations: $this->loadBooleanConfigs($config, array_keys($this->mainFacets)); @@ -176,7 +176,7 @@ class SideFacets extends AbstractFacets } $this->checkboxFacets = ($checkboxSection && isset($config->$checkboxSection)) - ? $config->$checkboxSection->toArray() : array(); + ? $config->$checkboxSection->toArray() : []; if (isset($flipCheckboxes) && $flipCheckboxes) { $this->checkboxFacets = array_flip($this->checkboxFacets); } @@ -303,16 +303,16 @@ class SideFacets extends AbstractFacets */ public function getAllRangeFacets() { - $raw = array( + $raw = [ 'date' => $this->getDateFacets(), 'fulldate' => $this->getFullDateFacets(), 'generic' => $this->getGenericRangeFacets(), 'numeric' => $this->getNumericRangeFacets() - ); - $processed = array(); + ]; + $processed = []; foreach ($raw as $type => $values) { foreach ($values as $field => $range) { - $processed[$field] = array('type' => $type, 'values' => $range); + $processed[$field] = ['type' => $type, 'values' => $range]; } } return $processed; @@ -326,7 +326,7 @@ class SideFacets extends AbstractFacets public function getCollapsedFacets() { if (empty($this->collapsedFacets)) { - return array(); + return []; } elseif ($this->collapsedFacets == '*') { return array_keys($this->getFacetSet()); } @@ -340,7 +340,7 @@ class SideFacets extends AbstractFacets * * @return array */ - public function getVisibleFilters($extraFilters = array()) + public function getVisibleFilters($extraFilters = []) { // Merge extras into main list: $filterList = array_merge( @@ -348,9 +348,9 @@ class SideFacets extends AbstractFacets ); // Filter out suppressed values: - $final = array(); + $final = []; foreach ($filterList as $field => $filters) { - $current = array(); + $current = []; foreach ($filters as $filter) { if (!isset($filter['suppressDisplay']) || !$filter['suppressDisplay'] @@ -376,7 +376,7 @@ class SideFacets extends AbstractFacets protected function getRangeFacets($property) { $filters = $this->results->getParams()->getFilters(); - $result = array(); + $result = []; if (isset($this->$property) && is_array($this->$property)) { foreach ($this->$property as $current) { $from = $to = ''; @@ -389,7 +389,7 @@ class SideFacets extends AbstractFacets } } } - $result[$current] = array($from, $to); + $result[$current] = [$from, $to]; } } return $result; diff --git a/module/VuFind/src/VuFind/Recommend/SwitchQuery.php b/module/VuFind/src/VuFind/Recommend/SwitchQuery.php index cea5f163aa5..7b6491bd304 100644 --- a/module/VuFind/src/VuFind/Recommend/SwitchQuery.php +++ b/module/VuFind/src/VuFind/Recommend/SwitchQuery.php @@ -62,7 +62,7 @@ class SwitchQuery implements RecommendInterface * * @var array */ - protected $suggestions = array(); + protected $suggestions = []; /** * Names of checks that should be skipped. These should correspond @@ -71,7 +71,7 @@ class SwitchQuery implements RecommendInterface * * @var array */ - protected $skipChecks = array(); + protected $skipChecks = []; /** * Names of transforms to apply. These should correspond @@ -80,7 +80,7 @@ class SwitchQuery implements RecommendInterface * * @var array */ - protected $transforms = array(); + protected $transforms = []; /** * Search results object. @@ -114,9 +114,9 @@ class SwitchQuery implements RecommendInterface return trim(strtolower($i)); }; $this->skipChecks = !empty($params[1]) - ? array_map($callback, explode(',', $params[1])) : array(); + ? array_map($callback, explode(',', $params[1])) : []; $this->transforms = !empty($params[2]) - ? explode(',', $params[2]) : array(); + ? explode(',', $params[2]) : []; } /** @@ -304,9 +304,9 @@ class SwitchQuery implements RecommendInterface protected function getLuceneHelper() { $backend = $this->backendManager->get($this->backend); - $qb = is_callable(array($backend, 'getQueryBuilder')) + $qb = is_callable([$backend, 'getQueryBuilder']) ? $backend->getQueryBuilder() : false; - return $qb && is_callable(array($qb, 'getLuceneHelper')) + return $qb && is_callable([$qb, 'getLuceneHelper']) ? $qb->getLuceneHelper() : false; } diff --git a/module/VuFind/src/VuFind/Recommend/TopFacets.php b/module/VuFind/src/VuFind/Recommend/TopFacets.php index 7170ee41589..c9ccb1038c9 100644 --- a/module/VuFind/src/VuFind/Recommend/TopFacets.php +++ b/module/VuFind/src/VuFind/Recommend/TopFacets.php @@ -76,13 +76,13 @@ class TopFacets extends AbstractFacets // Load the desired facet information: $config = $this->configLoader->get($iniName); $this->facets = isset($config->$mainSection) - ? $config->$mainSection->toArray() : array(); + ? $config->$mainSection->toArray() : []; // Load other relevant settings: - $this->baseSettings = array( + $this->baseSettings = [ 'rows' => $config->Results_Settings->top_rows, 'cols' => $config->Results_Settings->top_cols - ); + ]; // Load boolean configurations: $this->loadBooleanConfigs($config, array_keys($this->facets)); diff --git a/module/VuFind/src/VuFind/Recommend/VisualFacets.php b/module/VuFind/src/VuFind/Recommend/VisualFacets.php index edb2cbf9dd0..141e95f98ac 100644 --- a/module/VuFind/src/VuFind/Recommend/VisualFacets.php +++ b/module/VuFind/src/VuFind/Recommend/VisualFacets.php @@ -100,7 +100,7 @@ class VisualFacets extends AbstractFacets public function getPivotFacetSet() { // Avoid fatal error in case of unexpected results object (e.g. EmptySet): - return is_callable(array($this->results, 'getPivotFacetList')) - ? $this->results->getPivotFacetList() : array(); + return is_callable([$this->results, 'getPivotFacetList']) + ? $this->results->getPivotFacetList() : []; } } diff --git a/module/VuFind/src/VuFind/Recommend/WorldCatTerms.php b/module/VuFind/src/VuFind/Recommend/WorldCatTerms.php index 1273aa4d247..556adda3a1f 100644 --- a/module/VuFind/src/VuFind/Recommend/WorldCatTerms.php +++ b/module/VuFind/src/VuFind/Recommend/WorldCatTerms.php @@ -136,7 +136,7 @@ class WorldCatTerms implements RecommendInterface // this will make it easier to only display content in the template if // we have something worth displaying. if (is_array($terms)) { - $desiredKeys = array('exact', 'broader', 'narrower'); + $desiredKeys = ['exact', 'broader', 'narrower']; foreach ($terms as $key => $value) { if (empty($value) || !in_array($key, $desiredKeys)) { unset($terms[$key]); diff --git a/module/VuFind/src/VuFind/Record/Loader.php b/module/VuFind/src/VuFind/Record/Loader.php index 44600370568..accb5179c5c 100644 --- a/module/VuFind/src/VuFind/Record/Loader.php +++ b/module/VuFind/src/VuFind/Record/Loader.php @@ -87,7 +87,7 @@ class Loader } if ($tolerateMissing) { $record = $this->recordFactory->get('Missing'); - $record->setRawData(array('id' => $id)); + $record->setRawData(['id' => $id]); $record->setSourceIdentifier($source); return $record; } @@ -130,20 +130,20 @@ class Loader // Sort the IDs by source -- we'll create an associative array indexed by // source and record ID which points to the desired position of the indexed // record in the final return array: - $idBySource = array(); + $idBySource = []; foreach ($ids as $i => $details) { // Convert source|id string to array if necessary: if (!is_array($details)) { $parts = explode('|', $details, 2); - $ids[$i] = $details = array( + $ids[$i] = $details = [ 'source' => $parts[0], 'id' => $parts[1] - ); + ]; } $idBySource[$details['source']][$details['id']] = $i; } // Retrieve the records and put them back in order: - $retVal = array(); + $retVal = []; foreach ($idBySource as $source => $details) { $records = $this->loadBatchForSource(array_keys($details), $source); foreach ($records as $current) { @@ -157,7 +157,7 @@ class Loader foreach ($ids as $i => $details) { if (!isset($retVal[$i]) || !is_object($retVal[$i])) { $fields = isset($details['extra_fields']) - ? $details['extra_fields'] : array(); + ? $details['extra_fields'] : []; $fields['id'] = $details['id']; $retVal[$i] = $this->recordFactory->get('Missing'); $retVal[$i]->setRawData($fields); diff --git a/module/VuFind/src/VuFind/Record/Router.php b/module/VuFind/src/VuFind/Record/Router.php index 73f0e391b31..8867121db96 100644 --- a/module/VuFind/src/VuFind/Record/Router.php +++ b/module/VuFind/src/VuFind/Record/Router.php @@ -91,7 +91,7 @@ class Router public function getTabRouteDetails($driver, $tab = null) { $route = $this->getRouteDetails( - $driver, '', empty($tab) ? array() : array('tab' => $tab) + $driver, '', empty($tab) ? [] : ['tab' => $tab] ); // If collections are active and the record route was selected, we need @@ -126,7 +126,7 @@ class Router * @return array */ public function getRouteDetails($driver, $routeSuffix = '', - $extraParams = array() + $extraParams = [] ) { // Extract source and ID from driver or string: if (is_object($driver)) { @@ -145,9 +145,9 @@ class Router $routeBase = ($source == 'VuFind') ? 'record' : strtolower($source . 'record'); - return array( + return [ 'params' => $params, 'route' => $routeBase . $routeSuffix - ); + ]; } /** @@ -168,6 +168,6 @@ class Router $source = $parts[0]; $id = $parts[1]; } - return array($source, $id); + return [$source, $id]; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index dd05b3ea869..a077a7dd54c 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -59,7 +59,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, * * @var array */ - protected $extraDetails = array(); + protected $extraDetails = []; /** * Main VuFind configuration @@ -80,7 +80,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, * * @var array */ - protected $fields = array(); + protected $fields = []; /** * Constructor @@ -243,7 +243,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, // Add the information to the user's account: $user->saveResource( $resource, $list, - isset($params['mytags']) ? $params['mytags'] : array(), + isset($params['mytags']) ? $params['mytags'] : [], isset($params['notes']) ? $params['notes'] : '' ); } @@ -262,7 +262,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, $data = $db->getSavedData( $this->getUniqueId(), $this->getResourceSource(), $list_id, $user_id ); - $notes = array(); + $notes = []; foreach ($data as $current) { if (!empty($current->notes)) { $notes[] = $current->notes; @@ -339,9 +339,9 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, { if (is_null($types)) { $types = isset($this->recordConfig->Record->related) ? - $this->recordConfig->Record->related : array(); + $this->recordConfig->Record->related : []; } - $retVal = array(); + $retVal = []; foreach ($types as $current) { $parts = explode(':', $current); $type = $parts[0]; @@ -436,7 +436,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, if ($this->mainConfig->Record->citation_formats === false || $this->mainConfig->Record->citation_formats === 'false' ) { - return array(); + return []; } // Whitelist: @@ -455,7 +455,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, */ protected function getSupportedCitationFormats() { - return array(); + return []; } /** @@ -480,10 +480,10 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, * * @return mixed */ - public function tryMethod($method, $params = array()) + public function tryMethod($method, $params = []) { - return is_callable(array($this, $method)) - ? call_user_func_array(array($this, $method), $params) + return is_callable([$this, $method]) + ? call_user_func_array([$this, $method], $params) : null; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/EDS.php b/module/VuFind/src/VuFind/RecordDriver/EDS.php index 54354b14487..78c3e34627c 100644 --- a/module/VuFind/src/VuFind/RecordDriver/EDS.php +++ b/module/VuFind/src/VuFind/RecordDriver/EDS.php @@ -115,7 +115,7 @@ class EDS extends SolrDefault */ protected function getItemsAuthorsArray() { - $authors = array(); + $authors = []; if (isset($this->fields['Items'])) { foreach ($this->fields['Items'] as $item) { if ('Au' == $item['Group']) { @@ -134,7 +134,7 @@ class EDS extends SolrDefault public function getCustomLinks() { return isset($this->fields['CustomLinks']) ? - $this->fields['CustomLinks'] : array(); + $this->fields['CustomLinks'] : []; } /** @@ -182,15 +182,15 @@ class EDS extends SolrDefault */ public function getItems() { - $items = array(); + $items = []; if (isset($this->fields['Items']) && !empty($this->fields['Items'])) { foreach ($this->fields['Items'] as $item) { - $items[] = array( + $items[] = [ 'Label' => isset($item['Label']) ? $item['Label'] : '', 'Group' => isset($item['Group']) ? $item['Group'] : '', 'Data' => isset($item['Data']) ? $this->toHTML($item['Data'], $item['Group']) : '' - ); + ]; } } return $items; @@ -273,7 +273,7 @@ class EDS extends SolrDefault */ public function getItemsSubjects() { - $subjects = array(); + $subjects = []; if (isset($this->fields['Items'])) { foreach ($this->fields['Items'] as $item) { if ('Su' == $item['Group']) { @@ -348,7 +348,7 @@ class EDS extends SolrDefault */ public function getAuthors() { - $authors = array(); + $authors = []; if (isset($this->fields['RecordInfo']['BibRecord']['BibRelationships'])) { $bibRels = & $this->fields['RecordInfo']['BibRecord']['BibRelationships']; @@ -432,9 +432,9 @@ class EDS extends SolrDefault // Any group can be added here, but we only use Au (Author) // Other groups, not present here, won't be transformed to HTML links - $allowed_searchlink_groups = array('au','su'); + $allowed_searchlink_groups = ['au','su']; - $xml_to_html_tags = array( + $xml_to_html_tags = [ '<jsection' => '<section', '</jsection' => '</section', '<highlight' => '<span class="highlight"', @@ -471,7 +471,7 @@ class EDS extends SolrDefault '</superscript' => '</sup', '<relatesTo' => '<sup', '</relatesTo' => '</sup' - ); + ]; // The XML data is escaped, let's unescape html entities (e.g. < => <) $data = html_entity_decode($data, ENT_QUOTES, "utf-8"); @@ -533,7 +533,7 @@ class EDS extends SolrDefault */ protected function replaceBRWithCommas($data, $group) { - $groupsToReplace = array('au','su'); + $groupsToReplace = ['au','su']; if (in_array($group, $groupsToReplace)) { $br = '/<br \/>/'; $comma = ', '; @@ -552,7 +552,7 @@ class EDS extends SolrDefault */ protected function getSupportedCitationFormats() { - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/EIT.php b/module/VuFind/src/VuFind/RecordDriver/EIT.php index 40108eccf2f..99c601d5b1f 100644 --- a/module/VuFind/src/VuFind/RecordDriver/EIT.php +++ b/module/VuFind/src/VuFind/RecordDriver/EIT.php @@ -88,13 +88,13 @@ class EIT extends SolrDefault public function getAllSubjectHeadings() { $su = isset($this->controlInfo['artinfo']['su']) - ? $this->controlInfo['artinfo']['su'] : array(); + ? $this->controlInfo['artinfo']['su'] : []; // The EIT index doesn't currently subject headings in a broken-down // format, so we'll just send each value as a single chunk. - $retval = array(); + $retval = []; foreach ($su as $s) { - $retval[] = array($s); + $retval[] = [$s]; } return $retval; } @@ -151,7 +151,7 @@ class EIT extends SolrDefault */ public function getDateSpan() { - return array(); + return []; } /** @@ -162,14 +162,14 @@ class EIT extends SolrDefault */ public function getDeduplicatedAuthors() { - $authors = array( + $authors = [ 'main' => $this->getPrimaryAuthor(), 'secondary' => $this->getSecondaryAuthors() - ); + ]; // The secondary author array may contain a corporate or primary author; // let's be sure we filter out duplicate values. - $duplicates = array(); + $duplicates = []; if (!empty($authors['main'])) { $duplicates[] = $authors['main']; } @@ -202,7 +202,7 @@ class EIT extends SolrDefault return $this->controlInfo['artinfo']['doctype']; } return isset($this->controlInfo['artinfo']['doctype']) - ? array($this->controlInfo['artinfo']['doctype']) : array(); + ? [$this->controlInfo['artinfo']['doctype']] : []; } /** @@ -231,13 +231,13 @@ class EIT extends SolrDefault public function getPublicationDates() { if (isset($this->controlInfo['pubinfo']['dt']['@attributes']['year'])) { - return array( + return [ $this->controlInfo['pubinfo']['dt']['@attributes']['year'] - ); + ]; } else if (isset($this->controlInfo['pubinfo']['dt'])) { - return array($this->controlInfo['pubinfo']['dt']); + return [$this->controlInfo['pubinfo']['dt']]; } else { - return array(); + return []; } } @@ -249,7 +249,7 @@ class EIT extends SolrDefault public function getPublishers() { return isset($this->controlInfo['pubinfo']['pub']) - ? array($this->controlInfo['pubinfo']['pub']) : array(); + ? [$this->controlInfo['pubinfo']['pub']] : []; } /** @@ -260,7 +260,7 @@ class EIT extends SolrDefault public function getSecondaryAuthors() { return is_array($this->controlInfo['artinfo']['aug']['au']) - ? $this->controlInfo['artinfo']['aug']['au'] : array(); + ? $this->controlInfo['artinfo']['aug']['au'] : []; } /** @@ -290,11 +290,11 @@ class EIT extends SolrDefault ) { return is_array($this->controlInfo['artinfo']['ab']) ? $this->controlInfo['artinfo']['ab'] - : array($this->controlInfo['artinfo']['ab']); + : [$this->controlInfo['artinfo']['ab']]; } // If we got this far, no description was found: - return array(); + return []; } /** @@ -327,14 +327,14 @@ class EIT extends SolrDefault // If non-empty, map internal URL array to expected return format; // otherwise, return empty array: if (isset($this->fields['fields']['plink'])) { - $links = array($this->fields['fields']['plink']); + $links = [$this->fields['fields']['plink']]; $desc = $this->translate('View this record in EBSCOhost'); $filter = function ($url) use ($desc) { return compact('url', 'desc'); }; return array_map($filter, $links); } else { - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/Pazpar2.php b/module/VuFind/src/VuFind/RecordDriver/Pazpar2.php index 3c03ac8964d..aeb91312d89 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Pazpar2.php +++ b/module/VuFind/src/VuFind/RecordDriver/Pazpar2.php @@ -43,7 +43,7 @@ class Pazpar2 extends SolrDefault * * @var array */ - protected $pz2fields = array(); + protected $pz2fields = []; /** * Set raw data to initialize the object. @@ -70,12 +70,12 @@ class Pazpar2 extends SolrDefault */ protected function xmlToArray($xml) { - $array = array(); + $array = []; foreach ($xml as $key => $data) { - $children = array(); + $children = []; // Attributes if (count($data->attributes()) > 0) { - $children['_attr_'] = array(); + $children['_attr_'] = []; foreach ($data->attributes() as $name => $attr) { $children['_attr_'][$name] = (string) $attr; } @@ -101,16 +101,16 @@ class Pazpar2 extends SolrDefault $array[$key][] = $children; } else { // Convert for multiple children - $array[$key] = array( + $array[$key] = [ $array[$key], $children - ); + ]; } } } // Top-level Attributes if (count($xml->attributes()) > 0) { - $array['_attr_'] = array(); + $array['_attr_'] = []; foreach ($xml->attributes() as $key => $attr) { $array['_attr_'][$key] = (string) $attr; } @@ -153,12 +153,12 @@ class Pazpar2 extends SolrDefault public function getProviders() { if (!$this->pz2fields['location']) { - return array(); + return []; } if (isset($this->pz2fields['location']['_attr_'])) { - return array($this->pz2fields['location']['_attr_']['name']); + return [$this->pz2fields['location']['_attr_']['name']]; } - $providers = array(); + $providers = []; foreach ($this->pz2fields['location'] as $location) { if (isset($location['_attr_']['name']) && !in_array($location['_attr_']['name'], $providers) @@ -177,7 +177,7 @@ class Pazpar2 extends SolrDefault public function getPublicationDates() { return isset($this->pz2fields['md-date']) ? - array($this->pz2fields['md-date']) : array(); + [$this->pz2fields['md-date']] : []; } /** @@ -190,7 +190,7 @@ class Pazpar2 extends SolrDefault $authors = isset($this->pz2fields['md-author']) ? $this->pz2fields['md-author'] : ''; - return is_array($authors) ? array_slice($authors, 1) : array(); + return is_array($authors) ? array_slice($authors, 1) : []; } /** @@ -233,12 +233,12 @@ class Pazpar2 extends SolrDefault if (isset($this->pz2fields['location']['md-electronic-url'])) { return array_map( function ($url) { - return array('url' => $url); + return ['url' => $url]; }, (array) $this->pz2fields['location']['md-electronic-url'] ); } - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php index cdd994f8e3c..aa0ea820d77 100644 --- a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php +++ b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php @@ -54,9 +54,9 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager // Add an initializer for setting up hierarchies $initializer = function ($instance, $manager) { - $hasHierarchyType = is_callable(array($instance, 'getHierarchyType')); + $hasHierarchyType = is_callable([$instance, 'getHierarchyType']); if ($hasHierarchyType - && is_callable(array($instance, 'setHierarchyDriverManager')) + && is_callable([$instance, 'setHierarchyDriverManager']) ) { $sm = $manager->getServiceLocator(); if ($sm && $sm->has('VuFind\HierarchyDriverPluginManager')) { diff --git a/module/VuFind/src/VuFind/RecordDriver/Primo.php b/module/VuFind/src/VuFind/RecordDriver/Primo.php index 8d96ed41207..a7a8e9cce11 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Primo.php +++ b/module/VuFind/src/VuFind/RecordDriver/Primo.php @@ -84,7 +84,7 @@ class Primo extends SolrDefault */ public function getSecondaryAuthors() { - $authors = array(); + $authors = []; if (isset($this->fields['creator'])) { for ($i = 1; $i < count($this->fields['creator']); $i++) { if (isset($this->fields['creator'][$i])) { @@ -103,7 +103,7 @@ class Primo extends SolrDefault public function getCreators() { return isset($this->fields['creator']) - ? $this->fields['creator'] : array(); + ? $this->fields['creator'] : []; } /** @@ -115,7 +115,7 @@ class Primo extends SolrDefault public function getAllSubjectHeadings() { $base = isset($this->fields['subjects']) - ? $this->fields['subjects'] : array(); + ? $this->fields['subjects'] : []; $callback = function ($str) { return array_map('trim', explode(' -- ', $str)); }; @@ -154,7 +154,7 @@ class Primo extends SolrDefault public function getFormats() { return isset($this->fields['format']) - ? (array)$this->fields['format'] : array(); + ? (array)$this->fields['format'] : []; } /** @@ -176,7 +176,7 @@ class Primo extends SolrDefault public function getDescription() { return isset($this->fields['description']) - ? $this->fields['description'] : array(); + ? $this->fields['description'] : []; } /** @@ -199,7 +199,7 @@ class Primo extends SolrDefault */ public function getISSNs() { - $issns = array(); + $issns = []; if (isset($this->fields['issn'])) { $issns = $this->fields['issn']; } @@ -214,7 +214,7 @@ class Primo extends SolrDefault public function getLanguages() { return isset($this->fields['language']) - ? (array)$this->fields['language'] : array(); + ? (array)$this->fields['language'] : []; } /** @@ -231,9 +231,9 @@ class Primo extends SolrDefault public function getThumbnail($size = 'small') { if ($isbn = $this->getCleanISBN()) { - return array('size' => $size, 'isn' => $isbn); + return ['size' => $size, 'isn' => $isbn]; } - return array('size' => $size, 'contenttype' => 'JournalArticle'); + return ['size' => $size, 'contenttype' => 'JournalArticle']; } /** @@ -252,10 +252,10 @@ class Primo extends SolrDefault */ public function getURLs() { - $retVal = array(); + $retVal = []; if (isset($this->fields['url'])) { - $retVal[] = array(); + $retVal[] = []; $retVal[0]['url'] = $this->fields['url']; if (isset($this->fields['fulltext'])) { $desc = $this->fields['fulltext'] == 'fulltext' @@ -289,7 +289,7 @@ class Primo extends SolrDefault */ protected function getSupportedCitationFormats() { - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/Response/PublicationDetails.php b/module/VuFind/src/VuFind/RecordDriver/Response/PublicationDetails.php index d2476d83be0..11e4bb2673d 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Response/PublicationDetails.php +++ b/module/VuFind/src/VuFind/RecordDriver/Response/PublicationDetails.php @@ -113,7 +113,7 @@ class PublicationDetails return trim( preg_replace( '/\s+/', ' ', - implode(' ', array($this->place, $this->name, $this->date)) + implode(' ', [$this->place, $this->name, $this->date]) ) ); } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php b/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php index 1c406340838..2a885aaa7f3 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrAuth.php @@ -75,7 +75,7 @@ class SolrAuth extends SolrMarc { return isset($this->fields['see_also']) && is_array($this->fields['see_also']) - ? $this->fields['see_also'] : array(); + ? $this->fields['see_also'] : []; } /** @@ -87,7 +87,7 @@ class SolrAuth extends SolrMarc { return isset($this->fields['use_for']) && is_array($this->fields['use_for']) - ? $this->fields['use_for'] : array(); + ? $this->fields['use_for'] : []; } /** @@ -101,7 +101,7 @@ class SolrAuth extends SolrMarc if (!empty($lccn)) { return $lccn; } - $lccns = $this->getFieldArray('700', array('0')); + $lccns = $this->getFieldArray('700', ['0']); foreach ($lccns as $lccn) { if (substr($lccn, 0, '5') == '(DLC)') { return substr($lccn, 5); diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php index 81b8d070fe9..e0347a3ec85 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php @@ -51,9 +51,9 @@ class SolrDefault extends AbstractBase * * @var array */ - protected $preferredSnippetFields = array( + protected $preferredSnippetFields = [ 'contents', 'topic' - ); + ]; /** * These Solr fields should NEVER be used for snippets. (We exclude author @@ -63,11 +63,11 @@ class SolrDefault extends AbstractBase * * @var array */ - protected $forbiddenSnippetFields = array( + protected $forbiddenSnippetFields = [ 'author', 'author-letter', 'title', 'title_short', 'title_full', 'title_full_unstemmed', 'title_auth', 'title_sub', 'spelling', 'id', 'ctrlnum' - ); + ]; /** * These are captions corresponding with Solr fields for use when displaying @@ -75,7 +75,7 @@ class SolrDefault extends AbstractBase * * @var array */ - protected $snippetCaptions = array(); + protected $snippetCaptions = []; /** * Should we highlight fields in search results? @@ -110,7 +110,7 @@ class SolrDefault extends AbstractBase * * @var array */ - protected $highlightDetails = array(); + protected $highlightDetails = []; /** * Search results plugin manager @@ -181,7 +181,7 @@ class SolrDefault extends AbstractBase public function getAccessRestrictions() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -204,7 +204,7 @@ class SolrDefault extends AbstractBase // format, so we'll just send each value as a single chunk. Other record // drivers (i.e. MARC) can offer this data in a more granular format. $callback = function ($i) { - return array($i); + return [$i]; }; return array_map($callback, array_unique($headings)); } @@ -240,7 +240,7 @@ class SolrDefault extends AbstractBase public function getAwards() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -251,7 +251,7 @@ class SolrDefault extends AbstractBase public function getBibliographyNotes() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -371,7 +371,7 @@ class SolrDefault extends AbstractBase public function getDateSpan() { return isset($this->fields['dateSpan']) ? - $this->fields['dateSpan'] : array(); + $this->fields['dateSpan'] : []; } /** @@ -382,15 +382,15 @@ class SolrDefault extends AbstractBase */ public function getDeduplicatedAuthors() { - $authors = array( + $authors = [ 'main' => $this->getPrimaryAuthor(), 'corporate' => $this->getCorporateAuthor(), 'secondary' => $this->getSecondaryAuthors() - ); + ]; // The secondary author array may contain a corporate or primary author; // let's be sure we filter out duplicate values. - $duplicates = array(); + $duplicates = []; if (!empty($authors['main'])) { $duplicates[] = $authors['main']; } @@ -423,7 +423,7 @@ class SolrDefault extends AbstractBase public function getFindingAids() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -433,7 +433,7 @@ class SolrDefault extends AbstractBase */ public function getFormats() { - return isset($this->fields['format']) ? $this->fields['format'] : array(); + return isset($this->fields['format']) ? $this->fields['format'] : []; } /** @@ -444,7 +444,7 @@ class SolrDefault extends AbstractBase public function getGeneralNotes() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -499,10 +499,10 @@ class SolrDefault extends AbstractBase // First check for preferred fields: foreach ($this->preferredSnippetFields as $current) { if (isset($this->highlightDetails[$current][0])) { - return array( + return [ 'snippet' => $this->highlightDetails[$current][0], 'caption' => $this->getSnippetCaption($current) - ); + ]; } } @@ -512,10 +512,10 @@ class SolrDefault extends AbstractBase ) { foreach ($this->highlightDetails as $key => $value) { if (!in_array($key, $this->forbiddenSnippetFields)) { - return array( + return [ 'snippet' => $value[0], 'caption' => $this->getSnippetCaption($key) - ); + ]; } } } @@ -548,7 +548,7 @@ class SolrDefault extends AbstractBase public function getInstitutions() { return isset($this->fields['institution']) - ? $this->fields['institution'] : array(); + ? $this->fields['institution'] : []; } /** @@ -561,7 +561,7 @@ class SolrDefault extends AbstractBase // If ISBN is in the index, it should automatically be an array... but if // it's not set at all, we should normalize the value to an empty array. return isset($this->fields['isbn']) && is_array($this->fields['isbn']) ? - $this->fields['isbn'] : array(); + $this->fields['isbn'] : []; } /** @@ -574,7 +574,7 @@ class SolrDefault extends AbstractBase // If ISSN is in the index, it should automatically be an array... but if // it's not set at all, we should normalize the value to an empty array. return isset($this->fields['issn']) && is_array($this->fields['issn']) ? - $this->fields['issn'] : array(); + $this->fields['issn'] : []; } /** @@ -585,7 +585,7 @@ class SolrDefault extends AbstractBase public function getLanguages() { return isset($this->fields['language']) ? - $this->fields['language'] : array(); + $this->fields['language'] : []; } /** @@ -633,7 +633,7 @@ class SolrDefault extends AbstractBase public function getNewerTitles() { return isset($this->fields['title_new']) ? - $this->fields['title_new'] : array(); + $this->fields['title_new'] : []; } /** @@ -644,7 +644,7 @@ class SolrDefault extends AbstractBase public function getOCLC() { return isset($this->fields['oclc_num']) ? - $this->fields['oclc_num'] : array(); + $this->fields['oclc_num'] : []; } /** @@ -706,13 +706,13 @@ class SolrDefault extends AbstractBase $pubDate = empty($pubDate) ? '' : $pubDate[0]; // Start an array of OpenURL parameters: - return array( + return [ 'ctx_ver' => 'Z39.88-2004', 'ctx_enc' => 'info:ofi/enc:UTF-8', 'rfr_id' => 'info:sid/' . $this->getCoinsID() . ':generator', 'rft.title' => $this->getTitle(), 'rft.date' => $pubDate - ); + ]; } /** @@ -868,7 +868,7 @@ class SolrDefault extends AbstractBase public function getPhysicalDescriptions() { return isset($this->fields['physical']) ? - $this->fields['physical'] : array(); + $this->fields['physical'] : []; } /** @@ -879,7 +879,7 @@ class SolrDefault extends AbstractBase public function getPlacesOfPublication() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -890,7 +890,7 @@ class SolrDefault extends AbstractBase public function getPlayingTimes() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -901,7 +901,7 @@ class SolrDefault extends AbstractBase public function getPreviousTitles() { return isset($this->fields['title_old']) ? - $this->fields['title_old'] : array(); + $this->fields['title_old'] : []; } /** @@ -923,7 +923,7 @@ class SolrDefault extends AbstractBase public function getProductionCredits() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -934,7 +934,7 @@ class SolrDefault extends AbstractBase public function getPublicationDates() { return isset($this->fields['publishDate']) ? - $this->fields['publishDate'] : array(); + $this->fields['publishDate'] : []; } /** @@ -961,7 +961,7 @@ class SolrDefault extends AbstractBase $dates = $this->getHumanReadablePublicationDates(); $i = 0; - $retval = array(); + $retval = []; while (isset($places[$i]) || isset($names[$i]) || isset($dates[$i])) { // Build objects to represent each set of data; these will // transform seamlessly into strings in the view layer. @@ -984,7 +984,7 @@ class SolrDefault extends AbstractBase public function getPublicationFrequency() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -995,7 +995,7 @@ class SolrDefault extends AbstractBase public function getPublishers() { return isset($this->fields['publisher']) ? - $this->fields['publisher'] : array(); + $this->fields['publisher'] : []; } /** @@ -1007,7 +1007,7 @@ class SolrDefault extends AbstractBase public function getRealTimeHistory() { // Not supported by the Solr index -- implement in child classes. - return array(); + return []; } /** @@ -1019,7 +1019,7 @@ class SolrDefault extends AbstractBase public function getRealTimeHoldings() { // Not supported by the Solr index -- implement in child classes. - return array(); + return []; } /** @@ -1030,7 +1030,7 @@ class SolrDefault extends AbstractBase public function getRelationshipNotes() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -1041,7 +1041,7 @@ class SolrDefault extends AbstractBase public function getSecondaryAuthors() { return isset($this->fields['author2']) ? - $this->fields['author2'] : array(); + $this->fields['author2'] : []; } /** @@ -1058,7 +1058,7 @@ class SolrDefault extends AbstractBase return $this->fields['series']; } return isset($this->fields['series2']) ? - $this->fields['series2'] : array(); + $this->fields['series2'] : []; } /** @@ -1102,7 +1102,7 @@ class SolrDefault extends AbstractBase public function getSystemDetails() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -1120,11 +1120,11 @@ class SolrDefault extends AbstractBase && !empty($this->fields['description']) ) { return is_array($this->fields['description']) - ? $this->fields['description'] : array($this->fields['description']); + ? $this->fields['description'] : [$this->fields['description']]; } // If we got this far, no description was found: - return array(); + return []; } /** @@ -1135,7 +1135,7 @@ class SolrDefault extends AbstractBase public function getTargetAudienceNotes() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -1154,12 +1154,12 @@ class SolrDefault extends AbstractBase if (isset($this->fields['thumbnail']) && $this->fields['thumbnail']) { return $this->fields['thumbnail']; } - $arr = array( + $arr = [ 'author' => mb_substr($this->getPrimaryAuthor(), 0, 300, 'utf-8'), 'callnumber' => $this->getCallNumber(), 'size' => $size, 'title' => mb_substr($this->getTitle(), 0, 300, 'utf-8') - ); + ]; if ($isbn = $this->getCleanISBN()) { $arr['isbn'] = $isbn; } @@ -1175,7 +1175,7 @@ class SolrDefault extends AbstractBase // If an ILS driver has injected extra details, check for IDs in there // to fill gaps: if ($ilsDetails = $this->getExtraDetail('ils_details')) { - foreach (array('isbn', 'issn', 'oclc', 'upc') as $key) { + foreach (['isbn', 'issn', 'oclc', 'upc'] as $key) { if (!isset($arr[$key]) && isset($ilsDetails[$key])) { $arr[$key] = $ilsDetails[$key]; } @@ -1226,7 +1226,7 @@ class SolrDefault extends AbstractBase public function getTOC() { return isset($this->fields['contents']) - ? $this->fields['contents'] : array(); + ? $this->fields['contents'] : []; } /** @@ -1237,7 +1237,7 @@ class SolrDefault extends AbstractBase public function getHierarchicalPlaceNames() { // Not currently stored in the Solr index - return array(); + return []; } /** @@ -1248,7 +1248,7 @@ class SolrDefault extends AbstractBase public function getUPC() { return isset($this->fields['upc_str_mv']) ? - $this->fields['upc_str_mv'] : array(); + $this->fields['upc_str_mv'] : []; } /** @@ -1271,11 +1271,11 @@ class SolrDefault extends AbstractBase // otherwise, return empty array: if (isset($this->fields['url']) && is_array($this->fields['url'])) { $filter = function ($url) { - return array('url' => $url); + return ['url' => $url]; }; return array_map($filter, $this->fields['url']); } - return array(); + return []; } /** @@ -1318,7 +1318,7 @@ class SolrDefault extends AbstractBase public function getHierarchyTopID() { return isset($this->fields['hierarchy_top_id']) - ? $this->fields['hierarchy_top_id'] : array(); + ? $this->fields['hierarchy_top_id'] : []; } /** @@ -1329,7 +1329,7 @@ class SolrDefault extends AbstractBase public function getHierarchyTopTitle() { return isset($this->fields['hierarchy_top_title']) - ? $this->fields['hierarchy_top_title'] : array(); + ? $this->fields['hierarchy_top_title'] : []; } /** @@ -1350,7 +1350,7 @@ class SolrDefault extends AbstractBase // Initialize some variables needed within the switch below: $isCollection = $this->isCollection(); - $titles = $ids = array(); + $titles = $ids = []; // Check config setting for what constitutes a collection, act accordingly: switch ($hierarchyDriver->getCollectionLinkType()) { @@ -1382,7 +1382,7 @@ class SolrDefault extends AbstractBase // Map the titles and IDs to a useful format: $c = count($ids); - $retVal = array(); + $retVal = []; for ($i = 0; $i < $c; $i++) { $retVal[$ids[$i]] = $titles[$i]; } @@ -1426,7 +1426,7 @@ class SolrDefault extends AbstractBase */ public function getHierarchyPositionsInParents() { - $retVal = array(); + $retVal = []; if (isset($this->fields['hierarchy_parent_id']) && isset($this->fields['hierarchy_sequence']) ) { @@ -1445,7 +1445,7 @@ class SolrDefault extends AbstractBase */ public function getTitlesInHierarchy() { - $retVal = array(); + $retVal = []; if (isset($this->fields['title_in_hierarchy']) && is_array($this->fields['title_in_hierarchy']) ) { @@ -1604,7 +1604,7 @@ class SolrDefault extends AbstractBase */ protected function getSupportedCitationFormats() { - return array('APA', 'Chicago', 'MLA'); + return ['APA', 'Chicago', 'MLA']; } /** @@ -1709,7 +1709,7 @@ class SolrDefault extends AbstractBase */ public function getSchemaOrgFormatsArray() { - $types = array(); + $types = []; foreach ($this->getFormats() as $format) { switch ($format) { case 'Book': @@ -1757,7 +1757,7 @@ class SolrDefault extends AbstractBase { return isset($this->fields['dedup_data']) ? $this->fields['dedup_data'] - : array(); + : []; } /** diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index c67f0ba91a3..e03500f4cb1 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -94,7 +94,7 @@ class SolrMarc extends SolrDefault // When indexing over HTTP, SolrMarc may use entities instead of certain // control characters; we should normalize these: $marc = str_replace( - array('#29;', '#30;', '#31;'), array("\x1D", "\x1E", "\x1F"), $marc + ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc ); $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); } @@ -125,12 +125,12 @@ class SolrMarc extends SolrDefault public function getAllSubjectHeadings() { // These are the fields that may contain subject headings: - $fields = array( + $fields = [ '600', '610', '611', '630', '648', '650', '651', '653', '655', '656' - ); + ]; // This is all the collected data: - $retval = array(); + $retval = []; // Try each MARC field one at a time: foreach ($fields as $field) { @@ -143,7 +143,7 @@ class SolrMarc extends SolrDefault // If we got here, we found results -- let's loop through them. foreach ($results as $result) { // Start an array for holding the chunks of the current heading: - $current = array(); + $current = []; // Get all the chunks and collect them together: $subfields = $result->getSubfields(); @@ -223,11 +223,11 @@ class SolrMarc extends SolrDefault public function getCorporateAuthor() { // Try 110 first -- if none found, try 710 next. - $main = $this->getFirstFieldValue('110', array('a', 'b')); + $main = $this->getFirstFieldValue('110', ['a', 'b']); if (!empty($main)) { return $main; } - return $this->getFirstFieldValue('710', array('a', 'b')); + return $this->getFirstFieldValue('710', ['a', 'b']); } /** @@ -247,11 +247,11 @@ class SolrMarc extends SolrDefault { // Default to subfield a if nothing is specified. if (!is_array($subfields)) { - $subfields = array('a'); + $subfields = ['a']; } // Initialize return array - $matches = array(); + $matches = []; // Try to look up the specified field, return empty array if it doesn't // exist. @@ -326,8 +326,8 @@ class SolrMarc extends SolrDefault // If the MARC links are being used, return blank array $fieldsNames = isset($this->mainConfig->Record->marc_links) ? array_map('trim', explode(',', $this->mainConfig->Record->marc_links)) - : array(); - return in_array('785', $fieldsNames) ? array() : parent::getNewerTitles(); + : []; + return in_array('785', $fieldsNames) ? [] : parent::getNewerTitles(); } /** @@ -340,13 +340,13 @@ class SolrMarc extends SolrDefault protected function getPublicationInfo($subfield = 'a') { // First check old-style 260 field: - $results = $this->getFieldArray('260', array($subfield)); + $results = $this->getFieldArray('260', [$subfield]); // Now track down relevant RDA-style 264 fields; we only care about // copyright and publication places (and ignore copyright places if // publication places are present). This behavior is designed to be // consistent with default SolrMarc handling of names/dates. - $pubResults = $copyResults = array(); + $pubResults = $copyResults = []; $fields = $this->marcRecord->getFields('264'); if (is_array($fields)) { @@ -392,7 +392,7 @@ class SolrMarc extends SolrDefault */ public function getPlayingTimes() { - $times = $this->getFieldArray('306', array('a'), false); + $times = $this->getFieldArray('306', ['a'], false); // Format the times to include colons ("HH:MM:SS" format). for ($x = 0; $x < count($times); $x++) { @@ -414,8 +414,8 @@ class SolrMarc extends SolrDefault // If the MARC links are being used, return blank array $fieldsNames = isset($this->mainConfig->Record->marc_links) ? array_map('trim', explode(',', $this->mainConfig->Record->marc_links)) - : array(); - return in_array('780', $fieldsNames) ? array() : parent::getPreviousTitles(); + : []; + return in_array('780', $fieldsNames) ? [] : parent::getPreviousTitles(); } /** @@ -435,7 +435,7 @@ class SolrMarc extends SolrDefault */ public function getPublicationFrequency() { - return $this->getFieldArray('310', array('a', 'b')); + return $this->getFieldArray('310', ['a', 'b']); } /** @@ -457,20 +457,20 @@ class SolrMarc extends SolrDefault */ public function getSeries() { - $matches = array(); + $matches = []; // First check the 440, 800 and 830 fields for series information: - $primaryFields = array( - '440' => array('a', 'p'), - '800' => array('a', 'b', 'c', 'd', 'f', 'p', 'q', 't'), - '830' => array('a', 'p')); + $primaryFields = [ + '440' => ['a', 'p'], + '800' => ['a', 'b', 'c', 'd', 'f', 'p', 'q', 't'], + '830' => ['a', 'p']]; $matches = $this->getSeriesFromMARC($primaryFields); if (!empty($matches)) { return $matches; } // Now check 490 and display it only if 440/800/830 were empty: - $secondaryFields = array('490' => array('a')); + $secondaryFields = ['490' => ['a']]; $matches = $this->getSeriesFromMARC($secondaryFields); if (!empty($matches)) { return $matches; @@ -491,7 +491,7 @@ class SolrMarc extends SolrDefault */ protected function getSeriesFromMARC($fieldInfo) { - $matches = array(); + $matches = []; // Loop through the field specification.... foreach ($fieldInfo as $field => $subfields) { @@ -502,14 +502,14 @@ class SolrMarc extends SolrDefault // Can we find a name using the specified subfield list? $name = $this->getSubfieldArray($currentField, $subfields); if (isset($name[0])) { - $currentArray = array('name' => $name[0]); + $currentArray = ['name' => $name[0]]; // Can we find a number in subfield v? (Note that number is // always in subfield v regardless of whether we are dealing // with 440, 490, 800 or 830 -- hence the hard-coded array // rather than another parameter in $fieldInfo). $number - = $this->getSubfieldArray($currentField, array('v')); + = $this->getSubfieldArray($currentField, ['v']); if (isset($number[0])) { $currentArray['number'] = $number[0]; } @@ -540,7 +540,7 @@ class SolrMarc extends SolrDefault protected function getSubfieldArray($currentField, $subfields, $concat = true) { // Start building a line of text for the current field - $matches = array(); + $matches = []; $currentLine = ''; // Loop through all subfields, collecting results that match the whitelist; @@ -612,7 +612,7 @@ class SolrMarc extends SolrDefault */ public function getTitleSection() { - return $this->getFirstFieldValue('245', array('n', 'p')); + return $this->getFirstFieldValue('245', ['n', 'p']); } /** @@ -623,7 +623,7 @@ class SolrMarc extends SolrDefault */ public function getTitleStatement() { - return $this->getFirstFieldValue('245', array('c')); + return $this->getFirstFieldValue('245', ['c']); } /** @@ -636,11 +636,11 @@ class SolrMarc extends SolrDefault // Return empty array if we have no table of contents: $fields = $this->marcRecord->getFields('505'); if (!$fields) { - return array(); + return []; } // If we got this far, we have a table -- collect it as a string: - $toc = array(); + $toc = []; foreach ($fields as $field) { $subfields = $field->getSubfields(); foreach ($subfields as $subfield) { @@ -662,11 +662,11 @@ class SolrMarc extends SolrDefault */ public function getHierarchicalPlaceNames() { - $placeNames = array(); + $placeNames = []; if ($fields = $this->marcRecord->getFields('752')) { foreach ($fields as $field) { $subfields = $field->getSubfields(); - $current = array(); + $current = []; foreach ($subfields as $subfield) { if (!is_numeric($subfield->getCode())) { $current[] = $subfield->getData(); @@ -694,13 +694,13 @@ class SolrMarc extends SolrDefault */ public function getURLs() { - $retVal = array(); + $retVal = []; // Which fields/subfields should we check for URLs? - $fieldsToCheck = array( - '856' => array('y', 'z'), // Standard URL - '555' => array('a') // Cumulative index/finding aids - ); + $fieldsToCheck = [ + '856' => ['y', 'z'], // Standard URL + '555' => ['a'] // Cumulative index/finding aids + ]; foreach ($fieldsToCheck as $field => $subfields) { $urls = $this->marcRecord->getFields($field); @@ -724,7 +724,7 @@ class SolrMarc extends SolrDefault $desc = $address; } - $retVal[] = array('url' => $address, 'desc' => $desc); + $retVal[] = ['url' => $address, 'desc' => $desc]; } } } @@ -752,12 +752,12 @@ class SolrMarc extends SolrDefault { // Load configurations: $fieldsNames = isset($this->mainConfig->Record->marc_links) - ? explode(',', $this->mainConfig->Record->marc_links) : array(); + ? explode(',', $this->mainConfig->Record->marc_links) : []; $useVisibilityIndicator = isset($this->mainConfig->Record->marc_links_use_visibility_indicator) ? $this->mainConfig->Record->marc_links_use_visibility_indicator : true; - $retVal = array(); + $retVal = []; foreach ($fieldsNames as $value) { $value = trim($value); $fields = $this->marcRecord->getFields($value); @@ -849,42 +849,42 @@ class SolrMarc extends SolrDefault case 'oclc': foreach ($linkFields as $current) { if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) { - $link = array('type' => 'oclc', 'value' => $oclc); + $link = ['type' => 'oclc', 'value' => $oclc]; } } break; case 'dlc': foreach ($linkFields as $current) { if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) { - $link = array('type' => 'dlc', 'value' => $dlc); + $link = ['type' => 'dlc', 'value' => $dlc]; } } break; case 'id': foreach ($linkFields as $current) { if ($bibLink = $this->getIdFromLinkingField($current)) { - $link = array('type' => 'bib', 'value' => $bibLink); + $link = ['type' => 'bib', 'value' => $bibLink]; } } break; case 'isbn': if ($isbn = $field->getSubfield('z')) { - $link = array( + $link = [ 'type' => 'isn', 'value' => trim($isbn->getData()), 'exclude' => $this->getUniqueId() - ); + ]; } break; case 'issn': if ($issn = $field->getSubfield('x')) { - $link = array( + $link = [ 'type' => 'isn', 'value' => trim($issn->getData()), 'exclude' => $this->getUniqueId() - ); + ]; } break; case 'title': - $link = array('type' => 'title', 'value' => $title); + $link = ['type' => 'title', 'value' => $title]; break; } // Exit loop if we have a link @@ -893,11 +893,11 @@ class SolrMarc extends SolrDefault } } // Make sure we have something to display: - return !isset($link) ? false : array( + return !isset($link) ? false : [ 'title' => $this->getRecordLinkNote($field), 'value' => $title, 'link' => $link - ); + ]; } /** @@ -939,7 +939,7 @@ class SolrMarc extends SolrDefault public function getFormattedMarcDetails($field, $data) { // Initialize return array - $matches = array(); + $matches = []; $i = 0; // Try to look up the specified field, return empty array if it doesn't @@ -965,7 +965,7 @@ class SolrMarc extends SolrDefault } else { // Default to subfield a if nothing is specified. if (count($split) < 2) { - $subfields = array('a'); + $subfields = ['a']; } else { $subfields = str_split($split[1]); } @@ -1001,7 +1001,7 @@ class SolrMarc extends SolrDefault if ($format == 'marc21') { $xml = $this->marcRecord->toXML(); $xml = str_replace( - array(chr(27), chr(28), chr(29), chr(30), chr(31)), ' ', $xml + [chr(27), chr(28), chr(29), chr(30), chr(31)], ' ', $xml ); $xml = simplexml_load_string($xml); if (!$xml || !isset($xml->record)) { @@ -1062,7 +1062,7 @@ class SolrMarc extends SolrDefault { return $this->hasILS() ? $this->holdLogic->getHoldings( $this->getUniqueID(), $this->getConsortialIDs() - ) : array(); + ) : []; } /** @@ -1075,12 +1075,12 @@ class SolrMarc extends SolrDefault { // Get Acquisitions Data if (!$this->hasILS()) { - return array(); + return []; } try { return $this->ils->getPurchaseHistory($this->getUniqueID()); } catch (ILSException $e) { - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrReserves.php b/module/VuFind/src/VuFind/RecordDriver/SolrReserves.php index 2017c8f25c7..f07a266f787 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrReserves.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrReserves.php @@ -119,6 +119,6 @@ class SolrReserves extends SolrDefault public function getItemIds() { return isset($this->fields['bib_id']) - ? $this->fields['bib_id'] : array(); + ? $this->fields['bib_id'] : []; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrWeb.php b/module/VuFind/src/VuFind/RecordDriver/SolrWeb.php index 168efc0af40..491c3d726b9 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrWeb.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrWeb.php @@ -50,7 +50,7 @@ class SolrWeb extends SolrDefault public function __construct($mainConfig = null, $recordConfig = null, $searchSettings = null ) { - $this->preferredSnippetFields = array('description', 'fulltext'); + $this->preferredSnippetFields = ['description', 'fulltext']; parent::__construct($mainConfig, $recordConfig, $searchSettings); } diff --git a/module/VuFind/src/VuFind/RecordDriver/Summon.php b/module/VuFind/src/VuFind/RecordDriver/Summon.php index 312b9d7a20a..ff61954a91d 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Summon.php +++ b/module/VuFind/src/VuFind/RecordDriver/Summon.php @@ -54,28 +54,28 @@ class Summon extends SolrDefault */ public function getAllSubjectHeadings() { - $retval = array(); + $retval = []; $topic = isset($this->fields['SubjectTerms']) ? - $this->fields['SubjectTerms'] : array(); + $this->fields['SubjectTerms'] : []; $temporal = isset($this->fields['TemporalSubjectTerms']) ? - $this->fields['TemporalSubjectTerms'] : array(); + $this->fields['TemporalSubjectTerms'] : []; $geo = isset($this->fields['GeographicLocations']) ? - $this->fields['GeographicLocations'] : array(); + $this->fields['GeographicLocations'] : []; $key = isset($this->fields['Keywords']) ? - $this->fields['Keywords'] : array(); + $this->fields['Keywords'] : []; - $retval = array(); + $retval = []; foreach ($topic as $t) { - $retval[] = array(trim($t)); + $retval[] = [trim($t)]; } foreach ($temporal as $t) { - $retval[] = array(trim($t)); + $retval[] = [trim($t)]; } foreach ($geo as $g) { - $retval[] = array(trim($g)); + $retval[] = [trim($g)]; } foreach ($key as $k) { - $retval[] = array(trim($k)); + $retval[] = [trim($k)]; } return $retval; } @@ -88,7 +88,7 @@ class Summon extends SolrDefault public function getBibliographyNotes() { return isset($this->fields['Notes']) ? - $this->fields['Notes'] : array(); + $this->fields['Notes'] : []; } /** @@ -134,7 +134,7 @@ class Summon extends SolrDefault public function getFormats() { return isset($this->fields['ContentType']) - ? $this->fields['ContentType'] : array(); + ? $this->fields['ContentType'] : []; } /** @@ -164,10 +164,10 @@ class Summon extends SolrDefault public function getHighlightedSnippet() { return isset($this->fields['Snippet'][0]) - ? array( + ? [ 'snippet' => trim($this->fields['Snippet'][0], '.'), 'caption' => '' - ) + ] : false; } @@ -197,7 +197,7 @@ class Summon extends SolrDefault if (isset($this->fields['ISBN']) && is_array($this->fields['ISBN'])) { return $this->fields['ISBN']; } - return array(); + return []; } /** @@ -207,7 +207,7 @@ class Summon extends SolrDefault */ public function getISSNs() { - $issns = array(); + $issns = []; if (isset($this->fields['ISSN'])) { $issns = $this->fields['ISSN']; } @@ -225,7 +225,7 @@ class Summon extends SolrDefault public function getLanguages() { return isset($this->fields['Language']) ? - $this->fields['Language'] : array(); + $this->fields['Language'] : []; } /** @@ -236,7 +236,7 @@ class Summon extends SolrDefault public function getOCLC() { return isset($this->fields['OCLC']) ? - $this->fields['OCLC'] : array(); + $this->fields['OCLC'] : []; } /** @@ -259,7 +259,7 @@ class Summon extends SolrDefault public function getPlacesOfPublication() { return isset($this->fields['PublicationPlace']) ? - $this->fields['PublicationPlace'] : array(); + $this->fields['PublicationPlace'] : []; } /** @@ -309,7 +309,7 @@ class Summon extends SolrDefault if (isset($this->fields['PublicationDate_xml']) && is_array($this->fields['PublicationDate_xml']) ) { - $dates = array(); + $dates = []; $converter = $this->getDateConverter(); foreach ($this->fields['PublicationDate_xml'] as $current) { if (isset($current['month']) && isset($current['year'])) { @@ -329,7 +329,7 @@ class Summon extends SolrDefault } } return isset($this->fields['PublicationDate']) ? - $this->fields['PublicationDate'] : array(); + $this->fields['PublicationDate'] : []; } /** @@ -340,7 +340,7 @@ class Summon extends SolrDefault public function getPublishers() { return isset($this->fields['Publisher']) ? - $this->fields['Publisher'] : array(); + $this->fields['Publisher'] : []; } /** @@ -350,7 +350,7 @@ class Summon extends SolrDefault */ public function getSecondaryAuthors() { - $authors = array(); + $authors = []; if (isset($this->fields['Author_xml'])) { for ($i = 1; $i < count($this->fields['Author_xml']); $i++) { if (isset($this->fields['Author_xml'][$i]['fullname'])) { @@ -371,7 +371,7 @@ class Summon extends SolrDefault public function getSeries() { return isset($this->fields['PublicationSeriesTitle']) - ? $this->fields['PublicationSeriesTitle'] : array(); + ? $this->fields['PublicationSeriesTitle'] : []; } /** @@ -404,7 +404,7 @@ class Summon extends SolrDefault public function getSummary() { return isset($this->fields['Abstract']) ? - $this->fields['Abstract'] : array(); + $this->fields['Abstract'] : []; } /** @@ -429,9 +429,9 @@ class Summon extends SolrDefault && !isset($params['isbn']) && !isset($params['upc']) ) { if ($size === 'small' && isset($this->fields['thumbnail_s'][0])) { - return array('proxy' => $this->fields['thumbnail_s'][0]); + return ['proxy' => $this->fields['thumbnail_s'][0]]; } else if (isset($this->fields['thumbnail_m'][0])) { - return array('proxy' => $this->fields['thumbnail_m'][0]); + return ['proxy' => $this->fields['thumbnail_m'][0]]; } } @@ -453,7 +453,7 @@ class Summon extends SolrDefault $sub = $this->getSubtitle(); $title = empty($sub) ? $title : "{$title}: {$sub}"; return str_replace( - array('{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'), '', $title + ['{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'], '', $title ); } @@ -465,7 +465,7 @@ class Summon extends SolrDefault public function getTOC() { return isset($this->fields['TableOfContents']) - ? $this->fields['TableOfContents'] : array(); + ? $this->fields['TableOfContents'] : []; } /** @@ -485,17 +485,17 @@ class Summon extends SolrDefault public function getURLs() { if (isset($this->fields['link'])) { - return array( - array( + return [ + [ 'url' => $this->fields['link'], 'desc' => $this->translate('Get full text') - ) - ); + ] + ]; } - $retVal = array(); + $retVal = []; if (isset($this->fields['url']) && is_array($this->fields['url'])) { foreach ($this->fields['url'] as $desc => $url) { - $retVal[] = array('url' => $url, 'desc' => $desc); + $retVal[] = ['url' => $url, 'desc' => $desc]; } } return $retVal; diff --git a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php index 5856a2ea6df..e923b9c4091 100644 --- a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php +++ b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php @@ -62,7 +62,7 @@ class WorldCat extends SolrMarc // Map the WorldCat response into a format that the parent Solr-based // record driver can understand. - parent::setRawData(array('fullrecord' => $data)); + parent::setRawData(['fullrecord' => $data]); } /** @@ -74,7 +74,7 @@ class WorldCat extends SolrMarc public function getRealTimeHoldings() { // Not supported here: - return array(); + return []; } /** @@ -86,7 +86,7 @@ class WorldCat extends SolrMarc public function getRealTimeHistory() { // Not supported here: - return array(); + return []; } /** @@ -126,7 +126,7 @@ class WorldCat extends SolrMarc */ public function getFormats() { - return $this->getFieldArray('245', array('h')); + return $this->getFieldArray('245', ['h']); } /** @@ -136,7 +136,7 @@ class WorldCat extends SolrMarc */ public function getOCLC() { - return array($this->getUniqueID()); + return [$this->getUniqueID()]; } /** @@ -159,9 +159,9 @@ class WorldCat extends SolrMarc */ public function getCallNumber() { - $callNo = $this->getFirstFieldValue('090', array('a', 'b')); + $callNo = $this->getFirstFieldValue('090', ['a', 'b']); if (empty($callNo)) { - $callNo = $this->getFirstFieldValue('050', array('a', 'b')); + $callNo = $this->getFirstFieldValue('050', ['a', 'b']); } return empty($callNo) ? $this->getDeweyCallNumber() : $callNo; } @@ -173,7 +173,7 @@ class WorldCat extends SolrMarc */ public function getDeweyCallNumber() { - return $this->getFirstFieldValue('082', array('a')); + return $this->getFirstFieldValue('082', ['a']); } /** @@ -183,7 +183,7 @@ class WorldCat extends SolrMarc */ public function getPrimaryAuthor() { - return $this->getFirstFieldValue('100', array('a')); + return $this->getFirstFieldValue('100', ['a']); } /** @@ -193,7 +193,7 @@ class WorldCat extends SolrMarc */ public function getLanguages() { - $retVal = array(); + $retVal = []; $field = $this->marcRecord->getField('008'); if ($field) { $content = $field->getData(); @@ -211,7 +211,7 @@ class WorldCat extends SolrMarc */ public function getTitle() { - return $this->getFirstFieldValue('245', array('a', 'b')); + return $this->getFirstFieldValue('245', ['a', 'b']); } /** @@ -239,7 +239,7 @@ class WorldCat extends SolrMarc */ public function getShortTitle() { - return $this->getFirstFieldValue('245', array('a')); + return $this->getFirstFieldValue('245', ['a']); } /** @@ -249,7 +249,7 @@ class WorldCat extends SolrMarc */ public function getSubtitle() { - return $this->getFirstFieldValue('245', array('b')); + return $this->getFirstFieldValue('245', ['b']); } /** @@ -279,7 +279,7 @@ class WorldCat extends SolrMarc */ public function getSecondaryAuthors() { - return $this->getFieldArray('700', array('a', 'b', 'c', 'd')); + return $this->getFieldArray('700', ['a', 'b', 'c', 'd']); } /** @@ -289,7 +289,7 @@ class WorldCat extends SolrMarc */ public function getNewerTitles() { - return $this->getFieldArray('785', array('a', 's', 't')); + return $this->getFieldArray('785', ['a', 's', 't']); } /** @@ -299,6 +299,6 @@ class WorldCat extends SolrMarc */ public function getPreviousTitles() { - return $this->getFieldArray('780', array('a', 's', 't')); + return $this->getFieldArray('780', ['a', 's', 't']); } } diff --git a/module/VuFind/src/VuFind/RecordTab/AbstractContent.php b/module/VuFind/src/VuFind/RecordTab/AbstractContent.php index 298fbc11054..adced66518c 100644 --- a/module/VuFind/src/VuFind/RecordTab/AbstractContent.php +++ b/module/VuFind/src/VuFind/RecordTab/AbstractContent.php @@ -100,7 +100,7 @@ abstract class AbstractContent extends AbstractBase if (null === $this->results) { $isbn = $this->getRecordDriver()->tryMethod('getCleanISBN'); $this->results = (null === $this->loader || empty($isbn)) - ? array() : $this->loader->loadByIsbn($isbn); + ? [] : $this->loader->loadByIsbn($isbn); } return $this->results; } diff --git a/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php b/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php index 00ad966e998..5791f08365d 100644 --- a/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php +++ b/module/VuFind/src/VuFind/RecordTab/HierarchyTree.php @@ -123,7 +123,7 @@ class HierarchyTree extends AbstractBase $this->treeList = $this->getRecordDriver()->tryMethod('getHierarchyTrees'); if (null === $this->treeList) { - $this->treeList = array(); + $this->treeList = []; } } return $this->treeList; diff --git a/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php index 321ad317bd5..bf7afb6b800 100644 --- a/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php +++ b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php @@ -77,7 +77,7 @@ class HoldingsILS extends AbstractBase */ public function getUniqueCallNumbers($items) { - $callNos = array(); + $callNos = []; foreach ($items as $item) { if (isset($item['callnumber']) && strlen($item['callnumber']) > 0) { $callNos[] = $item['callnumber']; diff --git a/module/VuFind/src/VuFind/RecordTab/Map.php b/module/VuFind/src/VuFind/RecordTab/Map.php index 823b4d0b5b1..efb7e0eed95 100644 --- a/module/VuFind/src/VuFind/RecordTab/Map.php +++ b/module/VuFind/src/VuFind/RecordTab/Map.php @@ -85,16 +85,16 @@ class Map extends AbstractBase { $longLat = $this->getRecordDriver()->tryMethod('getLongLat'); if (empty($longLat)) { - return json_encode(array()); + return json_encode([]); } $longLat = explode(',', $longLat); - $markers = array( - array( + $markers = [ + [ 'title' => (string) $this->getRecordDriver()->getBreadcrumb(), 'lon' => $longLat[0], 'lat' => $longLat[1] - ) - ); + ] + ]; return json_encode($markers); } diff --git a/module/VuFind/src/VuFind/RecordTab/PluginManager.php b/module/VuFind/src/VuFind/RecordTab/PluginManager.php index 56cb51171a8..a79162a7fc4 100644 --- a/module/VuFind/src/VuFind/RecordTab/PluginManager.php +++ b/module/VuFind/src/VuFind/RecordTab/PluginManager.php @@ -74,7 +74,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager $className = get_parent_class($className); if (empty($className)) { // No setting found... - return array(); + return []; } } } @@ -92,7 +92,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager public function getTabsForRecord(\VuFind\RecordDriver\AbstractBase $driver, array $config, $request = null ) { - $tabs = array(); + $tabs = []; foreach ($this->getTabServiceNames($driver, $config) as $tabKey => $svc) { if (!$this->has($svc)) { continue; diff --git a/module/VuFind/src/VuFind/RecordTab/SimilarItemsCarousel.php b/module/VuFind/src/VuFind/RecordTab/SimilarItemsCarousel.php index fa121641047..c475fdc8f50 100644 --- a/module/VuFind/src/VuFind/RecordTab/SimilarItemsCarousel.php +++ b/module/VuFind/src/VuFind/RecordTab/SimilarItemsCarousel.php @@ -81,7 +81,7 @@ class SimilarItemsCarousel extends AbstractBase public function getResults() { $record = $this->getRecordDriver(); - $params = new \VuFindSearch\ParamBag(array('rows' => 40)); + $params = new \VuFindSearch\ParamBag(['rows' => 40]); return $this->searchService->similar( $record->getSourceIdentifier(), $record->getUniqueId(), $params ); diff --git a/module/VuFind/src/VuFind/Related/Editions.php b/module/VuFind/src/VuFind/Related/Editions.php index 7ee8ae8ddf7..eeeaf989d1c 100644 --- a/module/VuFind/src/VuFind/Related/Editions.php +++ b/module/VuFind/src/VuFind/Related/Editions.php @@ -43,7 +43,7 @@ class Editions implements RelatedInterface * * @var array */ - protected $results = array(); + protected $results = []; /** * Results plugin manager @@ -143,7 +143,7 @@ class Editions implements RelatedInterface */ protected function getQueryParts($driver) { - $parts = array(); + $parts = []; $oclcNum = $driver->tryMethod('getCleanOCLCNum'); if (!empty($oclcNum)) { $oclcList = $this->wcUtils->getXOCLCNUM($oclcNum); diff --git a/module/VuFind/src/VuFind/Related/WorldCatEditions.php b/module/VuFind/src/VuFind/Related/WorldCatEditions.php index 8549babb41a..fa2e864a211 100644 --- a/module/VuFind/src/VuFind/Related/WorldCatEditions.php +++ b/module/VuFind/src/VuFind/Related/WorldCatEditions.php @@ -77,7 +77,7 @@ class WorldCatEditions extends Editions */ protected function getQueryParts($driver) { - $parts = array(); + $parts = []; $oclcNum = $driver->tryMethod('getCleanOCLCNum'); if (!empty($oclcNum)) { $oclcList = $this->wcUtils->getXOCLCNUM($oclcNum); diff --git a/module/VuFind/src/VuFind/Related/WorldCatSimilar.php b/module/VuFind/src/VuFind/Related/WorldCatSimilar.php index 3d637896d76..21285542ce1 100644 --- a/module/VuFind/src/VuFind/Related/WorldCatSimilar.php +++ b/module/VuFind/src/VuFind/Related/WorldCatSimilar.php @@ -49,7 +49,7 @@ class WorldCatSimilar extends Similar public function init($settings, $driver) { // Create array of query parts: - $parts = array(); + $parts = []; // Add Dewey class to query $deweyClass = $driver->tryMethod('getDeweyCallNumber'); diff --git a/module/VuFind/src/VuFind/Reserves/CsvReader.php b/module/VuFind/src/VuFind/Reserves/CsvReader.php index 1f79a5c70b7..03331f651ed 100644 --- a/module/VuFind/src/VuFind/Reserves/CsvReader.php +++ b/module/VuFind/src/VuFind/Reserves/CsvReader.php @@ -64,28 +64,28 @@ class CsvReader * * @var array */ - protected $instructors = array(); + protected $instructors = []; /** * Course data loaded from files * * @var array */ - protected $courses = array(); + protected $courses = []; /** * Department data loaded from files * * @var array */ - protected $departments = array(); + protected $departments = []; /** * Reserves data loaded from files * * @var array */ - protected $reserves = array(); + protected $reserves = []; /** * Flag indicating whether or not we have processed data yet. @@ -114,7 +114,7 @@ class CsvReader */ public function __construct($files, $delimiter = ',', $template = null) { - $this->files = is_array($files) ? $files : array($files); + $this->files = is_array($files) ? $files : [$files]; $this->delimiter = $delimiter; // Provide default template if none passed in: @@ -188,12 +188,12 @@ class CsvReader } $goodLines++; - $this->reserves[] = array( + $this->reserves[] = [ 'BIB_ID' => $bibId, 'INSTRUCTOR_ID' => $instructor, 'COURSE_ID' => $course, 'DEPARTMENT_ID' => $department, - ); + ]; } fclose($fh); if ($goodLines == 0) { diff --git a/module/VuFind/src/VuFind/Resolver/Connection.php b/module/VuFind/src/VuFind/Resolver/Connection.php index a1d404231a6..1f17d304aef 100644 --- a/module/VuFind/src/VuFind/Resolver/Connection.php +++ b/module/VuFind/src/VuFind/Resolver/Connection.php @@ -141,7 +141,7 @@ class Connection */ public function __call($methodName, $params) { - $method = array($this->driver, $methodName); + $method = [$this->driver, $methodName]; if (is_callable($method)) { return call_user_func_array($method, $params); } diff --git a/module/VuFind/src/VuFind/Resolver/Driver/Ezb.php b/module/VuFind/src/VuFind/Resolver/Driver/Ezb.php index e2551c4bc3e..344a3a5721d 100644 --- a/module/VuFind/src/VuFind/Resolver/Driver/Ezb.php +++ b/module/VuFind/src/VuFind/Resolver/Driver/Ezb.php @@ -88,7 +88,7 @@ class Ezb implements DriverInterface // Parse OpenURL into associative array: $tmp = explode('&', $openURL); - $parsed = array(); + $parsed = []; foreach ($tmp as $current) { $tmp2 = explode('=', $current, 2); @@ -123,7 +123,7 @@ class Ezb implements DriverInterface */ public function parseLinks($xmlstr) { - $records = array(); // array to return + $records = []; // array to return $xml = new DOMDocument(); if (!@$xml->loadXML($xmlstr)) { @@ -155,7 +155,7 @@ class Ezb implements DriverInterface */ protected function downgradeOpenUrl($parsed) { - $downgraded = array(); + $downgraded = []; // we need 'genre' but only the values // article or journal are allowed... @@ -210,7 +210,7 @@ class Ezb implements DriverInterface ); $i = 0; foreach ($results as $result) { - $record = array(); + $record = []; $titleXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" . "Result[@state={$state}]/Title"; $record['title'] = strip_tags( @@ -251,7 +251,7 @@ class Ezb implements DriverInterface ); $i = 0; foreach ($results as $result) { - $record = array(); + $record = []; $record['title'] = $coverage; $urlXP = "/OpenURLResponseXML/Full/PrintData/References/Reference/URL"; $record['href'] = $xpath->query($urlXP, $result)->item($i)->nodeValue; diff --git a/module/VuFind/src/VuFind/Resolver/Driver/Sfx.php b/module/VuFind/src/VuFind/Resolver/Driver/Sfx.php index 2bd6002cb05..bae6009f769 100644 --- a/module/VuFind/src/VuFind/Resolver/Driver/Sfx.php +++ b/module/VuFind/src/VuFind/Resolver/Driver/Sfx.php @@ -97,7 +97,7 @@ class Sfx implements DriverInterface */ public function parseLinks($xmlstr) { - $records = array(); // array to return + $records = []; // array to return try { $xml = new \SimpleXmlElement($xmlstr); } catch (\Exception $e) { @@ -107,7 +107,7 @@ class Sfx implements DriverInterface $root = $xml->xpath("//ctx_obj_targets"); $xml = $root[0]; foreach ($xml->children() as $target) { - $record = array(); + $record = []; $record['title'] = (string)$target->target_public_name; $record['href'] = (string)$target->target_url; $record['service_type'] = (string)$target->service_type; diff --git a/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php b/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php index 9d79a745c28..5a97866d34e 100644 --- a/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php +++ b/module/VuFind/src/VuFind/Resolver/Driver/Threesixtylink.php @@ -97,7 +97,7 @@ class Threesixtylink implements DriverInterface */ public function parseLinks($xmlstr) { - $records = array(); // array to return + $records = []; // array to return $xml = new DOMDocument(); if (!@$xml->loadXML($xmlstr)) { @@ -108,7 +108,7 @@ class Threesixtylink implements DriverInterface $linkGroups = $xpath->query("//ssopenurl:linkGroup[@type='holding']"); if (!is_null($linkGroups)) { foreach ($linkGroups as $linkGroup) { - $record = array(); + $record = []; // select the deepest link returned $elems = $xpath->query( ".//ssopenurl:url[@type='article']", $linkGroup diff --git a/module/VuFind/src/VuFind/Role/DynamicRoleProvider.php b/module/VuFind/src/VuFind/Role/DynamicRoleProvider.php index 727e469d962..d9b8ab10693 100644 --- a/module/VuFind/src/VuFind/Role/DynamicRoleProvider.php +++ b/module/VuFind/src/VuFind/Role/DynamicRoleProvider.php @@ -84,7 +84,7 @@ class DynamicRoleProvider implements RoleProviderInterface */ public function getRoles(array $roleNames) { - return array_map(array($this, 'getRole'), $roleNames); + return array_map([$this, 'getRole'], $roleNames); } /** @@ -117,7 +117,7 @@ class DynamicRoleProvider implements RoleProviderInterface protected function populateRoles() { // Reset internal role array: - $this->roles = array(); + $this->roles = []; // Map permission configuration to the expected output format. foreach ($this->getPermissionsArray() as $roleName => $permissionArr) { diff --git a/module/VuFind/src/VuFind/Role/PermissionProvider/IpRange.php b/module/VuFind/src/VuFind/Role/PermissionProvider/IpRange.php index 382ecbd6cec..bb910d1b794 100644 --- a/module/VuFind/src/VuFind/Role/PermissionProvider/IpRange.php +++ b/module/VuFind/src/VuFind/Role/PermissionProvider/IpRange.php @@ -91,7 +91,7 @@ class IpRange implements PermissionProviderInterface */ protected function checkIP($remoteIP, $rangeIP) { - $mylist = array(); + $mylist = []; $count = 0; $inList = false; foreach ((array)$rangeIP as $range) { diff --git a/module/VuFind/src/VuFind/SMS/AbstractBase.php b/module/VuFind/src/VuFind/SMS/AbstractBase.php index 1645e752866..369905210d8 100644 --- a/module/VuFind/src/VuFind/SMS/AbstractBase.php +++ b/module/VuFind/src/VuFind/SMS/AbstractBase.php @@ -53,7 +53,7 @@ abstract class AbstractBase implements SMSInterface * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function __construct(\Zend\Config\Config $config, $options = array()) + public function __construct(\Zend\Config\Config $config, $options = []) { $this->smsConfig = $config; } diff --git a/module/VuFind/src/VuFind/SMS/Clickatell.php b/module/VuFind/src/VuFind/SMS/Clickatell.php index c93daef7bb1..0a5169b720e 100644 --- a/module/VuFind/src/VuFind/SMS/Clickatell.php +++ b/module/VuFind/src/VuFind/SMS/Clickatell.php @@ -53,7 +53,7 @@ class Clickatell extends AbstractBase * @param array $options Additional options (client may be an HTTP * client object) */ - public function __construct(\Zend\Config\Config $config, $options = array()) + public function __construct(\Zend\Config\Config $config, $options = []) { parent::__construct($config, $options); $this->client = isset($options['client']) @@ -98,9 +98,9 @@ class Clickatell extends AbstractBase */ public function getCarriers() { - return array( - 'Clickatell' => array('name' => 'Clickatell', 'domain' => null) - ); + return [ + 'Clickatell' => ['name' => 'Clickatell', 'domain' => null] + ]; } /** diff --git a/module/VuFind/src/VuFind/SMS/Factory.php b/module/VuFind/src/VuFind/SMS/Factory.php index 14ca9e400b4..9c7626cb55b 100644 --- a/module/VuFind/src/VuFind/SMS/Factory.php +++ b/module/VuFind/src/VuFind/SMS/Factory.php @@ -62,9 +62,9 @@ class Factory implements \Zend\ServiceManager\FactoryInterface switch (strtolower($type)) { case 'clickatell': $client = $sm->get('VuFind\Http')->createClient(); - return new Clickatell($smsConfig, array('client' => $client)); + return new Clickatell($smsConfig, ['client' => $client]); case 'mailer': - $options = array('mailer' => $sm->get('VuFind\Mailer')); + $options = ['mailer' => $sm->get('VuFind\Mailer')]; if (isset($mainConfig->Site->email)) { $options['defaultFrom'] = $mainConfig->Site->email; } diff --git a/module/VuFind/src/VuFind/SMS/Mailer.php b/module/VuFind/src/VuFind/SMS/Mailer.php index a3289b77d98..a9345edfa10 100644 --- a/module/VuFind/src/VuFind/SMS/Mailer.php +++ b/module/VuFind/src/VuFind/SMS/Mailer.php @@ -44,16 +44,16 @@ class Mailer extends AbstractBase * * @var array */ - protected $carriers = array( - 'virgin' => array('name' => 'Virgin Mobile', 'domain' => 'vmobl.com'), - 'att' => array('name' => 'AT&T', 'domain' => 'mms.att.net'), - 'verizon' => array('name' => 'Verizon', 'domain' => 'vtext.com'), - 'nextel' => array('name' => 'Nextel', 'domain' => 'messaging.nextel.com'), - 'sprint' => array('name' => 'Sprint', 'domain' => 'messaging.sprintpcs.com'), - 'tmobile' => array('name' => 'T Mobile', 'domain' => 'tmomail.net'), - 'alltel' => array('name' => 'Alltel', 'domain' => 'message.alltel.com'), - 'Cricket' => array('name' => 'Cricket', 'domain' => 'mms.mycricket.com') - ); + protected $carriers = [ + 'virgin' => ['name' => 'Virgin Mobile', 'domain' => 'vmobl.com'], + 'att' => ['name' => 'AT&T', 'domain' => 'mms.att.net'], + 'verizon' => ['name' => 'Verizon', 'domain' => 'vtext.com'], + 'nextel' => ['name' => 'Nextel', 'domain' => 'messaging.nextel.com'], + 'sprint' => ['name' => 'Sprint', 'domain' => 'messaging.sprintpcs.com'], + 'tmobile' => ['name' => 'T Mobile', 'domain' => 'tmomail.net'], + 'alltel' => ['name' => 'Alltel', 'domain' => 'message.alltel.com'], + 'Cricket' => ['name' => 'Cricket', 'domain' => 'mms.mycricket.com'] + ]; /** * Default "from" address @@ -76,7 +76,7 @@ class Mailer extends AbstractBase * @param array $options Additional options: defaultFrom (optional) * and mailer (must be a \VuFind\Mailer\Mailer object) */ - public function __construct(\Zend\Config\Config $config, $options = array()) + public function __construct(\Zend\Config\Config $config, $options = []) { // Set up parent object first: parent::__construct($config, $options); @@ -84,10 +84,10 @@ class Mailer extends AbstractBase // If found, use carriers from SMS configuration; otherwise, fall back to the // default list of US carriers. if (isset($config->Carriers) && count($config->Carriers) > 0) { - $this->carriers = array(); + $this->carriers = []; foreach ($config->Carriers as $id => $settings) { list($domain, $name) = explode(':', $settings, 2); - $this->carriers[$id] = array('name' => $name, 'domain' => $domain); + $this->carriers[$id] = ['name' => $name, 'domain' => $domain]; } } diff --git a/module/VuFind/src/VuFind/Search/BackendManager.php b/module/VuFind/src/VuFind/Search/BackendManager.php index 96cad44c79e..909b1ed08b8 100644 --- a/module/VuFind/src/VuFind/Search/BackendManager.php +++ b/module/VuFind/src/VuFind/Search/BackendManager.php @@ -162,7 +162,7 @@ class BackendManager implements SharedListenerAggregateInterface $listener = $events->attach( 'VuFind\Search', 'resolve', - array($this, 'onResolve') + [$this, 'onResolve'] ); $this->listeners->attach($events, $listener); } diff --git a/module/VuFind/src/VuFind/Search/Base/Options.php b/module/VuFind/src/VuFind/Search/Base/Options.php index 5ff15a119c0..330dad11856 100644 --- a/module/VuFind/src/VuFind/Search/Base/Options.php +++ b/module/VuFind/src/VuFind/Search/Base/Options.php @@ -49,7 +49,7 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $sortOptions = array(); + protected $sortOptions = []; /** * Overall default sort option @@ -63,7 +63,7 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $defaultSortByHandler = array(); + protected $defaultSortByHandler = []; /** * RSS-specific sort option @@ -84,14 +84,14 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $advancedHandlers = array(); + protected $advancedHandlers = []; /** * Basic search handlers * * @var array */ - protected $basicHandlers = array(); + protected $basicHandlers = []; /** * Special advanced facet settings @@ -112,7 +112,7 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $defaultFilters = array(); + protected $defaultFilters = []; /** * Default limit option @@ -126,7 +126,7 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $limitOptions = array(); + protected $limitOptions = []; /** * Default view option @@ -140,14 +140,14 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $viewOptions = array(); + protected $viewOptions = []; /** * Facet settings * * @var array */ - protected $translatedFacets = array(); + protected $translatedFacets = []; /** * Spelling setting @@ -161,14 +161,14 @@ abstract class Options implements TranslatorAwareInterface * * @var array */ - protected $shards = array(); + protected $shards = []; /** * Default selected shards * * @var array */ - protected $defaultSelectedShards = array(); + protected $defaultSelectedShards = []; /** * Should we present shard checkboxes to the user? @@ -214,7 +214,7 @@ abstract class Options implements TranslatorAwareInterface */ public function __construct(\VuFind\Config\PluginManager $configLoader) { - $this->limitOptions = array($this->defaultLimit); + $this->limitOptions = [$this->defaultLimit]; } /** diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 6c6e5449b41..2069b63f5ba 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -95,7 +95,7 @@ class Params implements ServiceLocatorAwareInterface * * @var array */ - protected $selectedShards = array(); + protected $selectedShards = []; /** * View @@ -116,42 +116,42 @@ class Params implements ServiceLocatorAwareInterface * * @var array */ - protected $recommend = array(); + protected $recommend = []; /** * Are recommendations turned on? * * @var bool */ - protected $recommendationEnabled = array(); + protected $recommendationEnabled = []; /** * Main facet configuration * * @var array */ - protected $facetConfig = array(); + protected $facetConfig = []; /** * Checkbox facet configuration * * @var array */ - protected $checkboxFacets = array(); + protected $checkboxFacets = []; /** * Applied filters * * @var array */ - protected $filterList = array(); + protected $filterList = []; /** * Facets in "OR" mode * * @var array */ - protected $orFacets = array(); + protected $orFacets = []; /** * Override Query @@ -274,9 +274,9 @@ class Params implements ServiceLocatorAwareInterface protected function initShards($request) { $legalShards = array_keys($this->getOptions()->getShards()); - $requestShards = $request->get('shard', array()); + $requestShards = $request->get('shard', []); if (!is_array($requestShards)) { - $requestShards = array($requestShards); + $requestShards = [$requestShards]; } // If a shard selection list is found as an incoming parameter, @@ -650,8 +650,8 @@ class Params implements ServiceLocatorAwareInterface public function getDisplayQuery() { // Set up callbacks: - $translate = array($this, 'translate'); - $showField = array($this->getOptions(), 'getHumanReadableFieldName'); + $translate = [$this, 'translate']; + $showField = [$this->getOptions(), 'getHumanReadableFieldName']; // Build display query: return QueryAdapter::display($this->getQuery(), $translate, $showField); @@ -669,7 +669,7 @@ class Params implements ServiceLocatorAwareInterface { $enabled = $this->recommendationsEnabled(); if (null === $location) { - $active = array(); + $active = []; foreach ($enabled as $current) { if (isset($this->recommend[$current])) { $active[$current] = $this->recommend[$current]; @@ -678,7 +678,7 @@ class Params implements ServiceLocatorAwareInterface return $active; } return in_array($location, $enabled) && isset($this->recommend[$location]) - ? $this->recommend[$location] : array(); + ? $this->recommend[$location] : []; } /** @@ -694,9 +694,9 @@ class Params implements ServiceLocatorAwareInterface public function recommendationsEnabled($new = null) { if (true === $new) { - $this->recommendationEnabled = array('top', 'side', 'noresults'); + $this->recommendationEnabled = ['top', 'side', 'noresults']; } else if (false === $new) { - $this->recommendationEnabled = array(); + $this->recommendationEnabled = []; } else if (null !== $new) { $this->recommendationEnabled = $new; } @@ -716,7 +716,7 @@ class Params implements ServiceLocatorAwareInterface // Bypass settings if recommendations are disabled. $enabled = $this->recommendationsEnabled(); if (empty($enabled)) { - return array(); + return []; } // Load the necessary settings to determine the appropriate recommendations @@ -730,7 +730,7 @@ class Params implements ServiceLocatorAwareInterface // Load a type-specific recommendations setting if possible, or the default // otherwise: - $recommend = array(); + $recommend = []; if (in_array('top', $enabled)) { if (null !== $handler @@ -800,10 +800,10 @@ class Params implements ServiceLocatorAwareInterface $manager = $sm->get('VuFind\RecommendPluginManager'); // Process recommendations for each location: - $this->recommend = array( - 'top' => array(), 'side' => array(), 'noresults' => array(), - 'bottom' => array(), - ); + $this->recommend = [ + 'top' => [], 'side' => [], 'noresults' => [], + 'bottom' => [], + ]; foreach ($settings as $location => $currentSet) { // If the current location is disabled, skip processing! if (empty($currentSet)) { @@ -812,7 +812,7 @@ class Params implements ServiceLocatorAwareInterface // Make sure the current location's set of recommendations is an array; // if it's a single string, this normalization will simplify processing. if (!is_array($currentSet)) { - $currentSet = array($currentSet); + $currentSet = [$currentSet]; } // Now loop through all recommendation settings for the location. foreach ($currentSet as $current) { @@ -860,7 +860,7 @@ class Params implements ServiceLocatorAwareInterface $value = trim($value); // Send back the results: - return array($field, $value); + return [$field, $value]; } /** @@ -949,9 +949,9 @@ class Params implements ServiceLocatorAwareInterface public function removeAllFilters($field = null) { if ($field == null) { - $this->filterList = array(); + $this->filterList = []; } else { - $this->filterList[$field] = array(); + $this->filterList[$field] = []; } } @@ -1003,7 +1003,7 @@ class Params implements ServiceLocatorAwareInterface // relevant information to the array. list($fieldName) = explode(':', $filter); $this->checkboxFacets[$fieldName] - = array('desc' => $desc, 'filter' => $filter); + = ['desc' => $desc, 'filter' => $filter]; } /** @@ -1036,7 +1036,7 @@ class Params implements ServiceLocatorAwareInterface */ public function resetFacetConfig() { - $this->facetConfig = array(); + $this->facetConfig = []; } /** @@ -1061,9 +1061,9 @@ class Params implements ServiceLocatorAwareInterface { // Get a list of checkbox filters to skip if necessary: $skipList = $excludeCheckboxFilters - ? $this->getCheckboxFacetValues() : array(); + ? $this->getCheckboxFacetValues() : []; - $list = array(); + $list = []; // Loop through all the current filter fields foreach ($this->filterList as $field => $values) { list($operator, $field) = $this->parseOperatorAndFieldName($field); @@ -1097,12 +1097,12 @@ class Params implements ServiceLocatorAwareInterface */ protected function formatFilterListEntry($field, $value, $operator, $translate) { - return array( + return [ 'value' => $value, 'displayText' => $translate ? $this->translate($value) : $value, 'field' => $field, 'operator' => $operator, - ); + ]; } /** @@ -1124,7 +1124,7 @@ class Params implements ServiceLocatorAwareInterface } else { $operator = 'AND'; } - return array($operator, $field); + return [$operator, $field]; } /** @@ -1134,11 +1134,11 @@ class Params implements ServiceLocatorAwareInterface */ protected function getCheckboxFacetValues() { - $list = array(); + $list = []; foreach ($this->checkboxFacets as $current) { list($field, $value) = $this->parseFilter($current['filter']); if (!isset($list[$field])) { - $list[$field] = array(); + $list[$field] = []; } $list[$field][] = $value; } @@ -1154,7 +1154,7 @@ class Params implements ServiceLocatorAwareInterface { // Build up an array of checkbox facets with status booleans and // toggle URLs. - $facets = array(); + $facets = []; foreach ($this->checkboxFacets as $field => $details) { $facets[$field] = $details; if ($this->hasFilter($details['filter'])) { @@ -1293,7 +1293,7 @@ class Params implements ServiceLocatorAwareInterface ) { $rangeFacets = $request->get($requestParam); if (!empty($rangeFacets)) { - $ranges = is_array($rangeFacets) ? $rangeFacets : array($rangeFacets); + $ranges = is_array($rangeFacets) ? $rangeFacets : [$rangeFacets]; foreach ($ranges as $range) { // Load start and end of range: $from = $request->get($range . 'from'); @@ -1389,8 +1389,8 @@ class Params implements ServiceLocatorAwareInterface protected function initDateFilters($request) { return $this->initGenericRangeFilters( - $request, 'daterange', array($this, 'formatYearForDateRange'), - array($this, 'buildDateRangeFilter') + $request, 'daterange', [$this, 'formatYearForDateRange'], + [$this, 'buildDateRangeFilter'] ); } @@ -1407,8 +1407,8 @@ class Params implements ServiceLocatorAwareInterface protected function initFullDateFilters($request) { return $this->initGenericRangeFilters( - $request, 'fulldaterange', array($this, 'formatDateForFullDateRange'), - array($this, 'buildFullDateRangeFilter') + $request, 'fulldaterange', [$this, 'formatDateForFullDateRange'], + [$this, 'buildFullDateRangeFilter'] ); } @@ -1425,8 +1425,8 @@ class Params implements ServiceLocatorAwareInterface protected function initNumericRangeFilters($request) { return $this->initGenericRangeFilters( - $request, 'numericrange', array($this, 'formatValueForNumericRange'), - array($this, 'buildNumericRangeFilter') + $request, 'numericrange', [$this, 'formatValueForNumericRange'], + [$this, 'buildNumericRangeFilter'] ); } @@ -1499,12 +1499,12 @@ class Params implements ServiceLocatorAwareInterface */ public function getViewList() { - $list = array(); + $list = []; foreach ($this->getOptions()->getViewOptions() as $key => $value) { - $list[$key] = array( + $list[$key] = [ 'desc' => $value, 'selected' => ($key == $this->getView()) - ); + ]; } return $list; } @@ -1519,12 +1519,12 @@ class Params implements ServiceLocatorAwareInterface { // Loop through all the current limits $valid = $this->getOptions()->getLimitOptions(); - $list = array(); + $list = []; foreach ($valid as $limit) { - $list[$limit] = array( + $list[$limit] = [ 'desc' => $limit, 'selected' => ($limit == $this->getLimit()) - ); + ]; } return $list; } @@ -1539,12 +1539,12 @@ class Params implements ServiceLocatorAwareInterface { // Loop through all the current filter fields $valid = $this->getOptions()->getSortOptions(); - $list = array(); + $list = []; foreach ($valid as $sort => $desc) { - $list[$sort] = array( + $list[$sort] = [ 'desc' => $desc, 'selected' => ($sort == $this->getSort()) - ); + ]; } return $list; } @@ -1744,7 +1744,7 @@ class Params implements ServiceLocatorAwareInterface $orFields = array_map('trim', explode(',', $config->$facetSettings->orFacets)); } else { - $orFields = array(); + $orFields = []; } foreach ($config->$facetList as $key => $value) { $useOr = (isset($orFields[0]) && $orFields[0] == '*') diff --git a/module/VuFind/src/VuFind/Search/Base/Results.php b/module/VuFind/src/VuFind/Search/Base/Results.php index e7b73aa48ee..ead46d04ca0 100644 --- a/module/VuFind/src/VuFind/Search/Base/Results.php +++ b/module/VuFind/src/VuFind/Search/Base/Results.php @@ -117,7 +117,7 @@ abstract class Results implements ServiceLocatorAwareInterface * * @var array */ - protected $helpers = array(); + protected $helpers = []; /** * Spelling suggestions @@ -226,8 +226,8 @@ abstract class Results implements ServiceLocatorAwareInterface // Initialize variables to defaults (to ensure they don't stay null // and cause unnecessary repeat processing): $this->resultTotal = 0; - $this->results = array(); - $this->suggestions = array(); + $this->results = []; + $this->suggestions = []; // Run the search: $this->startQueryTimer(); @@ -272,7 +272,7 @@ abstract class Results implements ServiceLocatorAwareInterface public function getSpellingSuggestions() { // Not supported by default: - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/Search/Combined/Params.php b/module/VuFind/src/VuFind/Search/Combined/Params.php index 450f0f14888..8fa09345a39 100644 --- a/module/VuFind/src/VuFind/Search/Combined/Params.php +++ b/module/VuFind/src/VuFind/Search/Combined/Params.php @@ -49,10 +49,10 @@ class Params extends \VuFind\Search\Solr\Params protected function getRecommendationSettings() { $enabled = $this->recommendationsEnabled(); - $recommend = array(); + $recommend = []; $config = $this->getServiceLocator()->get('VuFind\Config') ->get('combined'); - foreach (array('top', 'bottom') as $location) { + foreach (['top', 'bottom'] as $location) { if (in_array($location, $enabled) && isset($config->RecommendationModules->$location) ) { diff --git a/module/VuFind/src/VuFind/Search/Combined/Results.php b/module/VuFind/src/VuFind/Search/Combined/Results.php index 7cf1e819949..dcb323f6491 100644 --- a/module/VuFind/src/VuFind/Search/Combined/Results.php +++ b/module/VuFind/src/VuFind/Search/Combined/Results.php @@ -49,7 +49,7 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // Not relevant: - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/Search/EDS/Options.php b/module/VuFind/src/VuFind/Search/EDS/Options.php index 1b090ec50ec..f1f1c149e90 100644 --- a/module/VuFind/src/VuFind/Search/EDS/Options.php +++ b/module/VuFind/src/VuFind/Search/EDS/Options.php @@ -50,7 +50,7 @@ class Options extends \VuFind\Search\Base\Options * * @var array */ - protected $modeOptions = array(); + protected $modeOptions = []; /** * Default search mode options @@ -68,19 +68,19 @@ class Options extends \VuFind\Search\Base\Options * Default expanders to apply * @var array */ - protected $defaultExpanders = array(); + protected $defaultExpanders = []; /** * Available expander options * @var unknown */ - protected $expanderOptions = array(); + protected $expanderOptions = []; /** * Available limiter options * @var unknown */ - protected $limiterOptions = array(); + protected $limiterOptions = []; /** * Wheither or not to return available facets with the search response @@ -99,21 +99,21 @@ class Options extends \VuFind\Search\Base\Options * * @var array */ - protected $commonLimiters = array(); + protected $commonLimiters = []; /** * Expanders to display on the basic search screen * * @var array */ - protected $commonExpanders = array(); + protected $commonExpanders = []; /** * Pre-assigned filters * * @var array */ - protected $hiddenFilters = array(); + protected $hiddenFilters = []; /** * Constructor @@ -127,10 +127,10 @@ class Options extends \VuFind\Search\Base\Options $this->searchIni = 'EDS'; $searchSettings = $configLoader->get($this->searchIni); parent::__construct($configLoader); - $this->viewOptions = array( + $this->viewOptions = [ 'list|title' => 'Title View', 'list|brief' => 'Brief View', 'list|detailed' => 'Detailed View' - ); + ]; $this->apiInfo = $apiInfo; $this->setOptionsFromApi($searchSettings); $this->setOptionsFromConfig($searchSettings); @@ -277,7 +277,7 @@ class Options extends \VuFind\Search\Base\Options // expression $this->$property[$key] below. $propertyRef = & $this->$property; - $newPropertyValues = array(); + $newPropertyValues = []; foreach ($searchSettings->$section as $key => $value) { if (isset($propertyRef[$key])) { $newPropertyValues[$key] = $value; @@ -436,7 +436,7 @@ class Options extends \VuFind\Search\Base\Options $availCriteria = & $this->apiInfo['AvailableSearchCriteria']; //Sort preferences - $this->sortOptions = array(); + $this->sortOptions = []; if (isset($availCriteria['AvailableSorts'])) { foreach ($availCriteria['AvailableSorts'] as $sort) { $this->sortOptions[$sort['Id']] @@ -446,7 +446,7 @@ class Options extends \VuFind\Search\Base\Options // By default, use all of the available search fields for both // advanced and basic. Use the values in the config files to filter. - $this->basicHandlers = array('AllFields' => 'All Fields'); + $this->basicHandlers = ['AllFields' => 'All Fields']; if (isset($availCriteria['AvailableSearchFields'])) { foreach ($availCriteria['AvailableSearchFields'] as $searchField) { $this->basicHandlers[$searchField['FieldCode']] @@ -456,12 +456,12 @@ class Options extends \VuFind\Search\Base\Options $this->advancedHandlers = $this->basicHandlers; // Search Mode preferences - $this->modeOptions = array(); + $this->modeOptions = []; if (isset($availCriteria['AvailableSearchModes'])) { foreach ($availCriteria['AvailableSearchModes'] as $mode) { - $this->modeOptions[$mode['Mode']] = array( + $this->modeOptions[$mode['Mode']] = [ 'Label' => $mode['Label'], 'Value' => $mode['Mode'] - ); + ]; if (isset($mode['DefaultOn']) && 'y' == $mode['DefaultOn'] ) { @@ -471,13 +471,13 @@ class Options extends \VuFind\Search\Base\Options } //expanders - $this->expanderOptions = array(); - $this->defaultExpanders = array(); + $this->expanderOptions = []; + $this->defaultExpanders = []; if (isset($availCriteria['AvailableExpanders'])) { foreach ($availCriteria['AvailableExpanders'] as $expander) { - $this->expanderOptions[$expander['Id']] = array( + $this->expanderOptions[$expander['Id']] = [ 'Label' => $expander['Label'], 'Value' => $expander['Id'] - ); + ]; if (isset($expander['DefaultOn']) && 'y' == $expander['DefaultOn'] ) { @@ -487,14 +487,14 @@ class Options extends \VuFind\Search\Base\Options } //Limiters - $this->limiterOptions = array(); + $this->limiterOptions = []; if (isset($availCriteria['AvailableLimiters'])) { foreach ($availCriteria['AvailableLimiters'] as $limiter) { $val = ''; if ('select' == $limiter['Type']) { $val = 'y'; } - $this->limiterOptions[$limiter['Id']] = array( + $this->limiterOptions[$limiter['Id']] = [ 'Id' => $limiter['Id'], 'Label' => $limiter['Label'], 'Type' => $limiter['Type'], @@ -502,10 +502,10 @@ class Options extends \VuFind\Search\Base\Options ? $this->populateLimiterValues( $limiter['LimiterValues'] ) - : array(array('Value' => $val)), + : [['Value' => $val]], 'DefaultOn' => isset($limiter['DefaultOn']) ? $limiter['DefaultOn'] : 'n', - ); + ]; } @@ -522,16 +522,16 @@ class Options extends \VuFind\Search\Base\Options */ protected function populateLimiterValues($limiterValues) { - $availableLimiterValues = array(); + $availableLimiterValues = []; if (isset($limiterValues)) { foreach ($limiterValues as $limiterValue) { - $availableLimiterValues[] = array( + $availableLimiterValues[] = [ 'Value' => $limiterValue['Value'], 'LimiterValues' => isset($limiterValue['LimiterValues']) ? $this ->populateLimiterValues($limiterValue['LimiterValues']) : null - ); + ]; } } return empty($availableLimiterValues) ? null : $availableLimiterValues; @@ -609,17 +609,17 @@ class Options extends \VuFind\Search\Base\Options */ public function getSearchScreenLimiters() { - $ssLimiterOptions = array(); + $ssLimiterOptions = []; if (isset($this->commonLimiters)) { foreach ($this->commonLimiters as $key) { $limiter = $this->limiterOptions[$key]; - $ssLimiterOptions[$key] = array( + $ssLimiterOptions[$key] = [ 'selectedvalue' => 'LIMIT|' . $key . ':y', 'description' => $this->getLabelForCheckboxFilter( 'eds_limiter_' . $key, $limiter['Label'] ), 'selected' => ('y' == $limiter['DefaultOn']) ? true : false - ); + ]; } } return $ssLimiterOptions; @@ -632,16 +632,16 @@ class Options extends \VuFind\Search\Base\Options */ public function getSearchScreenExpanders() { - $ssExpanderOptions = array(); + $ssExpanderOptions = []; if (isset($this->commonExpanders)) { foreach ($this->commonExpanders as $key) { $expander = $this->expanderOptions[$key]; - $ssExpanderOptions[$key] = array( + $ssExpanderOptions[$key] = [ 'selectedvalue' => 'EXPAND:' . $key, 'description' => $this->getLabelForCheckboxFilter( 'eds_expander_' . $key, $expander['Label'] ), - ); + ]; } } return $ssExpanderOptions; diff --git a/module/VuFind/src/VuFind/Search/EDS/Params.php b/module/VuFind/src/VuFind/Search/EDS/Params.php index 7c07d74a442..6b0dddb9e2c 100644 --- a/module/VuFind/src/VuFind/Search/EDS/Params.php +++ b/module/VuFind/src/VuFind/Search/EDS/Params.php @@ -45,14 +45,14 @@ class Params extends \VuFind\Search\Base\Params * * @var array */ - protected $dateFacetSettings = array(); + protected $dateFacetSettings = []; /** * Additional filters to display as side facets * * @var array */ - protected $extraFilterList = array(); + protected $extraFilterList = []; /** * Is the request using this parameters objects for setup only? @@ -135,7 +135,7 @@ class Params extends \VuFind\Search\Base\Params $defaultFacetLimit = isset($config->Facet_Settings->facet_limit) ? $config->Facet_Settings->facet_limit : 30; - $finalFacets = array(); + $finalFacets = []; foreach ($this->getFullFacetSettings() as $facet) { // See if parameters are included as part of the facet name; // if not, override them with defaults. @@ -210,7 +210,7 @@ class Params extends \VuFind\Search\Base\Params public function createBackendLimiterParameters(ParamBag $params) { //group limiters with same id together - $edsLimiters = array(); + $edsLimiters = []; foreach ($this->limiters as $limiter) { if (isset($limiter) && !empty($limiter)) { // split the id/value @@ -307,7 +307,7 @@ class Params extends \VuFind\Search\Base\Params */ public function getFullFacetSettings() { - return isset($this->fullFacetSettings) ? $this->fullFacetSettings : array(); + return isset($this->fullFacetSettings) ? $this->fullFacetSettings : []; } /** @@ -388,12 +388,12 @@ class Params extends \VuFind\Search\Base\Params */ public function getViewList() { - $list = array(); + $list = []; foreach ($this->getOptions()->getViewOptions() as $key => $value) { - $list[$key] = array( + $list[$key] = [ 'desc' => $value, 'selected' => ($key == $this->getView() . '|' . $this->getEdsView()) - ); + ]; } return $list; } @@ -408,8 +408,8 @@ class Params extends \VuFind\Search\Base\Params public function getDisplayQuery() { // Set up callbacks: - $translate = array($this, 'translate'); - $showField = array($this->getOptions(), 'getHumanReadableFieldName'); + $translate = [$this, 'translate']; + $showField = [$this->getOptions(), 'getHumanReadableFieldName']; // Build display query: return QueryAdapter::display($this->getQuery(), $translate, $showField); diff --git a/module/VuFind/src/VuFind/Search/EDS/QueryAdapter.php b/module/VuFind/src/VuFind/Search/EDS/QueryAdapter.php index 9136957100a..1521207c732 100644 --- a/module/VuFind/src/VuFind/Search/EDS/QueryAdapter.php +++ b/module/VuFind/src/VuFind/Search/EDS/QueryAdapter.php @@ -78,7 +78,7 @@ class QueryAdapter extends \VuFind\Search\QueryAdapter ) { $output = ''; //There should only ever be 1 group with EDS queries. - $all = array(); + $all = []; foreach ($query->getQueries() as $search) { if ($search instanceof QueryGroup) { // Process each search group. There should only be 1 with EDS queries diff --git a/module/VuFind/src/VuFind/Search/EDS/Results.php b/module/VuFind/src/VuFind/Search/EDS/Results.php index 473f5e7c347..ab88204f65a 100644 --- a/module/VuFind/src/VuFind/Search/EDS/Results.php +++ b/module/VuFind/src/VuFind/Search/EDS/Results.php @@ -77,12 +77,12 @@ class Results extends \VuFind\Search\Base\Results $this->resultTotal = $collection->getTotal(); //Add a publication date facet - $this->responseFacets[] = array( + $this->responseFacets[] = [ 'fieldName' => 'PublicationDate', 'displayName' => 'PublicationDate', 'displayText' => 'Publication Date', - 'counts' => array() - ); + 'counts' => [] + ]; // Construct record drivers for all the items in the response: $this->results = $collection->getRecords(); @@ -100,7 +100,7 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // Loop through the facets returned by EDS - $facetResult = array(); + $facetResult = []; if (is_array($this->responseFacets)) { // Get the filter list -- we'll need to check it below: $filterList = $this->getParams()->getFilters(); @@ -124,7 +124,7 @@ class Results extends \VuFind\Search\Base\Results // an active filter for the current field? $orField = '~' . $field; $itemsToCheck = isset($filterList[$field]) - ? $filterList[$field] : array(); + ? $filterList[$field] : []; if (isset($filterList[$orField])) { $itemsToCheck += $filterList[$orField]; } @@ -162,7 +162,7 @@ class Results extends \VuFind\Search\Base\Results ksort($facetResult); // Rewrite the sorted array with appropriate keys: - $finalResult = array(); + $finalResult = []; foreach ($facetResult as $current) { $finalResult[$current['displayName']] = $current; } diff --git a/module/VuFind/src/VuFind/Search/EIT/Results.php b/module/VuFind/src/VuFind/Search/EIT/Results.php index 3d283a9a7cb..f5f524da025 100644 --- a/module/VuFind/src/VuFind/Search/EIT/Results.php +++ b/module/VuFind/src/VuFind/Search/EIT/Results.php @@ -72,6 +72,6 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // No facets in EIT: - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/Search/EmptySet/Results.php b/module/VuFind/src/VuFind/Search/EmptySet/Results.php index 0fa94845a42..9a003f3eb95 100644 --- a/module/VuFind/src/VuFind/Search/EmptySet/Results.php +++ b/module/VuFind/src/VuFind/Search/EmptySet/Results.php @@ -61,6 +61,6 @@ class Results extends BaseResults */ public function getFacetList($filter = null) { - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php index a8e23bc68eb..c861f67bfd9 100644 --- a/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/AbstractSolrBackendFactory.php @@ -180,9 +180,9 @@ abstract class AbstractSolrBackendFactory implements FactoryInterface // Spellcheck if (isset($config->Spelling->enabled) && $config->Spelling->enabled) { if (isset($config->Spelling->simple) && $config->Spelling->simple) { - $dictionaries = array('basicSpell'); + $dictionaries = ['basicSpell']; } else { - $dictionaries = array('default', 'basicSpell'); + $dictionaries = ['default', 'basicSpell']; } $spellingListener = new InjectSpellingListener($backend, $dictionaries); $spellingListener->attach($events); @@ -249,7 +249,7 @@ abstract class AbstractSolrBackendFactory implements FactoryInterface protected function getHiddenFilters() { $search = $this->config->get($this->searchConfig); - $hf = array(); + $hf = []; // Hidden filters if (isset($search->HiddenFilters)) { @@ -277,16 +277,16 @@ abstract class AbstractSolrBackendFactory implements FactoryInterface { $config = $this->config->get('config'); - $handlers = array( - 'select' => array( + $handlers = [ + 'select' => [ 'fallback' => true, - 'defaults' => array('fl' => '*,score'), - 'appends' => array('fq' => array()), - ), - 'term' => array( - 'functions' => array('terms'), - ), - ); + 'defaults' => ['fl' => '*,score'], + 'appends' => ['fq' => []], + ], + 'term' => [ + 'functions' => ['terms'], + ], + ]; foreach ($this->getHiddenFilters() as $filter) { array_push($handlers['select']['appends']['fq'], $filter); diff --git a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php index b49d2044987..955cd455494 100644 --- a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php @@ -121,14 +121,14 @@ class EdsBackendFactory implements FactoryInterface */ protected function createConnector() { - $options = array(); + $options = []; $id = 'EDS'; $key = 'EDS'; // Build HTTP client: $client = $this->serviceLocator->get('VuFind\Http')->createClient(); $timeout = isset($this->edsConfig->General->timeout) ? $this->edsConfig->General->timeout : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); $connector = new Connector($id, $key, $options, $client); $connector->setLogger($this->logger); return $connector; diff --git a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php index 1dc18521af9..c899d0a1dc6 100644 --- a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php @@ -127,7 +127,7 @@ class LibGuidesBackendFactory implements FactoryInterface $client = $this->serviceLocator->get('VuFind\Http')->createClient(); $timeout = isset($this->libGuidesConfig->General->timeout) ? $this->libGuidesConfig->General->timeout : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); $connector = new Connector($iid, $client, $ver); $connector->setLogger($this->logger); return $connector; diff --git a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php index e1553a5a66e..1b5c3416eee 100644 --- a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php @@ -121,7 +121,7 @@ class PrimoBackendFactory implements FactoryInterface $client = $this->serviceLocator->get('VuFind\Http')->createClient(); $timeout = isset($this->primoConfig->General->timeout) ? $this->primoConfig->General->timeout : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); $connector = new Connector($id, $this->getInstCode(), $client, $port); $connector->setLogger($this->logger); @@ -136,9 +136,9 @@ class PrimoBackendFactory implements FactoryInterface protected function getInstCode() { $codes = isset($this->primoConfig->Institutions->code) - ? $this->primoConfig->Institutions->code : array(); + ? $this->primoConfig->Institutions->code : []; $regex = isset($this->primoConfig->Institutions->regex) - ? $this->primoConfig->Institutions->regex : array(); + ? $this->primoConfig->Institutions->regex : []; if (empty($codes) || empty($regex) || count($codes) != count($regex)) { throw new \Exception('Check [Institutions] settings in Primo.ini'); } diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php index 1a5a4d2d323..12a0c38c910 100644 --- a/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php @@ -77,7 +77,7 @@ class SolrDefaultBackendFactory extends AbstractSolrBackendFactory { $backend = parent::createBackend($connector); $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager'); - $factory = new RecordCollectionFactory(array($manager, 'getSolrRecord')); + $factory = new RecordCollectionFactory([$manager, 'getSolrRecord']); $backend->setRecordCollectionFactory($factory); return $backend; } diff --git a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php index ef939951ff3..3eb4a66e9c1 100644 --- a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php @@ -130,9 +130,9 @@ class SummonBackendFactory implements FactoryInterface $client = $this->serviceLocator->get('VuFind\Http')->createClient(); $timeout = isset($this->summonConfig->General->timeout) ? $this->summonConfig->General->timeout : 30; - $client->setOptions(array('timeout' => $timeout)); + $client->setOptions(['timeout' => $timeout]); - $options = array('authedUser' => $this->isAuthed()); + $options = ['authedUser' => $this->isAuthed()]; $connector = new Connector($id, $key, $options, $client); $connector->setLogger($this->logger); return $connector; diff --git a/module/VuFind/src/VuFind/Search/Favorites/Options.php b/module/VuFind/src/VuFind/Search/Favorites/Options.php index 494f30a1686..1bdd53f33cf 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Options.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Options.php @@ -48,10 +48,10 @@ class Options extends \VuFind\Search\Base\Options parent::__construct($configLoader); $this->defaultSort = 'title'; - $this->sortOptions = array( + $this->sortOptions = [ 'title' => 'sort_title', 'author' => 'sort_author', 'year DESC' => 'sort_year', 'year' => 'sort_year asc' - ); + ]; } /** diff --git a/module/VuFind/src/VuFind/Search/Favorites/Params.php b/module/VuFind/src/VuFind/Search/Favorites/Params.php index a6e6a429dca..90abd863104 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Params.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Params.php @@ -67,7 +67,7 @@ class Params extends \VuFind\Search\Base\Params */ protected function getRecommendationSettings() { - return array('side' => 'FavoriteFacets'); + return ['side' => 'FavoriteFacets']; } /** diff --git a/module/VuFind/src/VuFind/Search/Favorites/Results.php b/module/VuFind/src/VuFind/Search/Favorites/Results.php index ee48d5735a1..8dd48a49640 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Results.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Results.php @@ -75,31 +75,31 @@ class Results extends BaseResults } // Start building the facet list: - $retVal = array(); + $retVal = []; // Loop through every requested field: $validFields = array_keys($filter); foreach ($validFields as $field) { if (!isset($this->facets[$field])) { - $this->facets[$field] = array( + $this->facets[$field] = [ 'label' => $this->getParams()->getFacetLabel($field), - 'list' => array() - ); + 'list' => [] + ]; switch ($field) { case 'tags': if ($this->list) { $tags = $this->list->getTags(); } else { - $tags = $this->user ? $this->user->getTags() : array(); + $tags = $this->user ? $this->user->getTags() : []; } foreach ($tags as $tag) { - $this->facets[$field]['list'][] = array( + $this->facets[$field]['list'][] = [ 'value' => $tag->tag, 'displayText' => $tag->tag, 'count' => $tag->cnt, 'isApplied' => $this->getParams()->hasFilter("$field:" . $tag->tag) - ); + ]; } break; } @@ -158,14 +158,14 @@ class Results extends BaseResults } // Retrieve record drivers for the selected items. - $recordsToRequest = array(); + $recordsToRequest = []; foreach ($rawResults as $row) { - $recordsToRequest[] = array( + $recordsToRequest[] = [ 'id' => $row->record_id, 'source' => $row->source, - 'extra_fields' => array( + 'extra_fields' => [ 'title' => $row->title - ) - ); + ] + ]; } $this->results = $this->getServiceLocator()->get('VuFind\RecordLoader') ->loadBatch($recordsToRequest); @@ -179,7 +179,7 @@ class Results extends BaseResults protected function getTagFilters() { $filters = $this->getParams()->getFilters(); - return isset($filters['tags']) ? $filters['tags'] : array(); + return isset($filters['tags']) ? $filters['tags'] : []; } /** diff --git a/module/VuFind/src/VuFind/Search/LibGuides/Results.php b/module/VuFind/src/VuFind/Search/LibGuides/Results.php index fada022f50d..b8216c02189 100644 --- a/module/VuFind/src/VuFind/Search/LibGuides/Results.php +++ b/module/VuFind/src/VuFind/Search/LibGuides/Results.php @@ -70,6 +70,6 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // Facets not supported. - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Minified.php b/module/VuFind/src/VuFind/Search/Minified.php index eb75470c6b6..d82d0a3e7f5 100644 --- a/module/VuFind/src/VuFind/Search/Minified.php +++ b/module/VuFind/src/VuFind/Search/Minified.php @@ -57,14 +57,14 @@ class Minified * * @var array */ - public $t = array(); + public $t = []; /** * Filters * * @var array */ - public $f = array(); + public $f = []; /** * ID, start tIme, query Speed, Result total, search TYpe, search CLass id diff --git a/module/VuFind/src/VuFind/Search/MixedList/Params.php b/module/VuFind/src/VuFind/Search/MixedList/Params.php index 900456bf600..333c39c0cfe 100644 --- a/module/VuFind/src/VuFind/Search/MixedList/Params.php +++ b/module/VuFind/src/VuFind/Search/MixedList/Params.php @@ -55,7 +55,7 @@ class Params extends \VuFind\Search\Base\Params */ protected function initSearch($request) { - $this->recordsToRequest = $request->get('id', array()); + $this->recordsToRequest = $request->get('id', []); // We always want to display the entire list as one page: $this->setLimit(count($this->recordsToRequest)); @@ -82,6 +82,6 @@ class Params extends \VuFind\Search\Base\Params protected function getRecommendationSettings() { // No recommendation modules in mixed list view currently: - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/MixedList/Results.php b/module/VuFind/src/VuFind/Search/MixedList/Results.php index 0b06e65d382..b3b74af62e8 100644 --- a/module/VuFind/src/VuFind/Search/MixedList/Results.php +++ b/module/VuFind/src/VuFind/Search/MixedList/Results.php @@ -50,7 +50,7 @@ class Results extends BaseResults public function getFacetList($filter = null) { // Facets not supported here: - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/Search/Pazpar2/Options.php b/module/VuFind/src/VuFind/Search/Pazpar2/Options.php index b57c5f59376..e94e03597e4 100644 --- a/module/VuFind/src/VuFind/Search/Pazpar2/Options.php +++ b/module/VuFind/src/VuFind/Search/Pazpar2/Options.php @@ -48,7 +48,7 @@ class Options extends \VuFind\Search\Base\Options parent::__construct($configLoader); $this->searchIni = $this->facetsIni = 'Pazpar2'; - $this->limitOptions = array($this->defaultLimit); + $this->limitOptions = [$this->defaultLimit]; // Load source settings $searchSettings = $configLoader->get($this->searchIni); @@ -65,7 +65,7 @@ class Options extends \VuFind\Search\Base\Options $defaultChecked = is_object($searchSettings->SourcePreferences->defaultChecked) ? $searchSettings->SourcePreferences->defaultChecked->toArray() - : array($searchSettings->SourcePreferences->defaultChecked); + : [$searchSettings->SourcePreferences->defaultChecked]; foreach ($defaultChecked as $current) { $this->defaultSelectedShards[] = $current; } diff --git a/module/VuFind/src/VuFind/Search/Pazpar2/Results.php b/module/VuFind/src/VuFind/Search/Pazpar2/Results.php index 08de48def73..4b07c9fc0f2 100644 --- a/module/VuFind/src/VuFind/Search/Pazpar2/Results.php +++ b/module/VuFind/src/VuFind/Search/Pazpar2/Results.php @@ -68,6 +68,6 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // No facets in Pazpar2: - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Primo/Options.php b/module/VuFind/src/VuFind/Search/Primo/Options.php index 31fb5c6a82f..af7f763f49d 100644 --- a/module/VuFind/src/VuFind/Search/Primo/Options.php +++ b/module/VuFind/src/VuFind/Search/Primo/Options.php @@ -50,7 +50,7 @@ class Options extends \VuFind\Search\Base\Options * * @var array */ - protected $advancedOperators = array(); + protected $advancedOperators = []; /** * Constructor diff --git a/module/VuFind/src/VuFind/Search/Primo/Results.php b/module/VuFind/src/VuFind/Search/Primo/Results.php index 8ed5ff2a951..cf0fbdfd7e2 100644 --- a/module/VuFind/src/VuFind/Search/Primo/Results.php +++ b/module/VuFind/src/VuFind/Search/Primo/Results.php @@ -80,15 +80,15 @@ class Results extends \VuFind\Search\Base\Results // create a lookup array to determine order: $order = array_flip(array_keys($filter)); // Loop through the facets returned by Primo. - $facetResult = array(); + $facetResult = []; if (is_array($this->responseFacets)) { foreach ($this->responseFacets as $field => $current) { $translate = in_array($field, $this->getOptions()->getTranslatedFacets()); if (isset($filter[$field])) { - $new = array(); + $new = []; foreach ($current as $value => $count) { - $new[] = array( + $new[] = [ 'value' => $value, 'displayText' => $translate @@ -97,7 +97,7 @@ class Results extends \VuFind\Search\Base\Results 'isApplied' => $this->getParams()->hasFilter("$field:" . $value), 'operator' => 'AND', 'count' => $count - ); + ]; } $cmp = function ($x, $y) { @@ -107,7 +107,7 @@ class Results extends \VuFind\Search\Base\Results usort($new, $cmp); // Basic reformatting of the data: - $current = array('list' => $new); + $current = ['list' => $new]; // Inject label from configuration: $current['label'] = $filter[$field]; @@ -124,7 +124,7 @@ class Results extends \VuFind\Search\Base\Results ksort($facetResult); // Rewrite the sorted array with appropriate keys: - $finalResult = array(); + $finalResult = []; foreach ($facetResult as $current) { $finalResult[$current['field']] = $current; } diff --git a/module/VuFind/src/VuFind/Search/QueryAdapter.php b/module/VuFind/src/VuFind/Search/QueryAdapter.php index 64fdea86039..5f2a51cab4a 100644 --- a/module/VuFind/src/VuFind/Search/QueryAdapter.php +++ b/module/VuFind/src/VuFind/Search/QueryAdapter.php @@ -64,14 +64,14 @@ abstract class QueryAdapter } elseif (isset($search['g'])) { $operator = $search['g'][0]['b']; return new QueryGroup( - $operator, array_map(array('self', 'deminify'), $search['g']) + $operator, array_map(['self', 'deminify'], $search['g']) ); } else { // Special case: The outer-most group-of-groups. if (isset($search[0]['j'])) { $operator = $search[0]['j']; return new QueryGroup( - $operator, array_map(array('self', 'deminify'), $search) + $operator, array_map(['self', 'deminify'], $search) ); } else { // Simple query @@ -113,11 +113,11 @@ abstract class QueryAdapter $showName ) { // Groups and exclusions. - $groups = $excludes = array(); + $groups = $excludes = []; foreach ($query->getQueries() as $search) { if ($search instanceof QueryGroup) { - $thisGroup = array(); + $thisGroup = []; // Process each search group foreach ($search->getQueries() as $group) { if ($group instanceof Query) { @@ -170,11 +170,11 @@ abstract class QueryAdapter public static function fromRequest(Parameters $request, $defaultHandler) { $groupCount = 0; - $groups = array(); + $groups = []; // Loop through each search group while (!is_null($lookfor = $request->get("lookfor{$groupCount}"))) { - $group = array(); + $group = []; $lastBool = null; // Loop through each term inside the group @@ -224,31 +224,31 @@ abstract class QueryAdapter { // Simple query: if ($query instanceof Query) { - return array( - array( + return [ + [ 'l' => $query->getString(), 'i' => $query->getHandler() - ) - ); + ] + ]; } // Advanced query: - $retVal = array(); + $retVal = []; $operator = $query->isNegated() ? 'NOT' : $query->getOperator(); foreach ($query->getQueries() as $current) { if ($topLevel) { - $retVal[] = array( + $retVal[] = [ 'g' => self::minify($current, false), 'j' => $operator - ); + ]; } elseif ($current instanceof QueryGroup) { throw new \Exception('Not sure how to minify this query!'); } else { - $currentArr = array( + $currentArr = [ 'f' => $current->getHandler(), 'l' => $current->getString(), 'b' => $operator - ); + ]; if (null !== ($op = $current->getOperator())) { $currentArr['o'] = $op; } diff --git a/module/VuFind/src/VuFind/Search/Solr/AbstractErrorListener.php b/module/VuFind/src/VuFind/Search/Solr/AbstractErrorListener.php index 6e62c0d181a..b3a88aa39a2 100644 --- a/module/VuFind/src/VuFind/Search/Solr/AbstractErrorListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/AbstractErrorListener.php @@ -107,7 +107,7 @@ abstract class AbstractErrorListener */ public function attach(SharedEventManagerInterface $manager) { - $manager->attach('VuFind\Search', 'error', array($this, 'onSearchError')); + $manager->attach('VuFind\Search', 'error', [$this, 'onSearchError']); } /** diff --git a/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php b/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php index 0719788af5b..1f5b582ba55 100644 --- a/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/DeduplicationListener.php @@ -107,8 +107,8 @@ class DeduplicationListener public function attach( SharedEventManagerInterface $manager ) { - $manager->attach('VuFind\Search', 'pre', array($this, 'onSearchPre')); - $manager->attach('VuFind\Search', 'post', array($this, 'onSearchPost')); + $manager->attach('VuFind\Search', 'pre', [$this, 'onSearchPre']); + $manager->attach('VuFind\Search', 'post', [$this, 'onSearchPost']); } /** @@ -172,7 +172,7 @@ class DeduplicationListener $params = $event->getParam('params'); $buildingPriority = $this->determineBuildingPriority($params); - $idList = array(); + $idList = []; // Find out the best records and list their IDs: $result = $event->getTarget(); foreach ($result->getRecords() as $record) { @@ -186,7 +186,7 @@ class DeduplicationListener $priority = 99999; $undefPriority = 99999; // Find the document that matches the source priority best: - $dedupData = array(); + $dedupData = []; foreach ($localIds as $localId) { $localPriority = null; list($source) = explode('.', $localId, 2); @@ -211,10 +211,10 @@ class DeduplicationListener $dedupId = $localId; $priority = $localPriority; } - $dedupData[$source] = array( + $dedupData[$source] = [ 'id' => $localId, 'priority' => isset($localPriority) ? $localPriority : 99999 - ); + ]; } $fields['dedup_id'] = $dedupId; $idList[] = $dedupId; @@ -315,7 +315,7 @@ class DeduplicationListener */ protected function determineBuildingPriority($params) { - $result = array(); + $result = []; foreach ($params->get('fq') as $fq) { if (strncmp($fq, 'building:', 9) == 0) { if (preg_match( diff --git a/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetHelper.php b/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetHelper.php index df167da4473..013ecc81a4e 100644 --- a/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetHelper.php +++ b/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetHelper.php @@ -95,7 +95,7 @@ class HierarchicalFacetHelper // getParamArray() is expensive, so call it just once and pass it on $paramArray = $urlHelper !== false ? $urlHelper->getParamArray() : null; // Create a keyed (for conversion to hierarchical) array of facet data - $keyedList = array(); + $keyedList = []; foreach ($facetList as $item) { $keyedList[$item['value']] = $this->createFacetItem( $facet, $item, $urlHelper, $paramArray @@ -103,7 +103,7 @@ class HierarchicalFacetHelper } // Convert the keyed array to a hierarchical array - $result = array(); + $result = []; foreach ($keyedList as &$item) { if ($item['level'] > 0) { $keyedList[$item['parent']]['children'][] = &$item; @@ -127,11 +127,11 @@ class HierarchicalFacetHelper */ public function flattenFacetHierarchy($facetList) { - $results = array(); + $results = []; foreach ($facetList as $facetItem) { $children = !empty($facetItem['children']) ? $facetItem['children'] - : array(); + : []; unset($facetItem['children']); $results[] = $facetItem; if ($children) { @@ -229,7 +229,7 @@ class HierarchicalFacetHelper $item['hasAppliedChildren'] = false; $item['href'] = $href; $item['exclude'] = $exclude; - $item['children'] = array(); + $item['children'] = []; return $item; } diff --git a/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetListener.php b/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetListener.php index 213f1d7696b..b60d5036574 100644 --- a/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/HierarchicalFacetListener.php @@ -131,16 +131,16 @@ class HierarchicalFacetListener $this->translatedFacets = isset($this->facetConfig->Advanced_Settings->translated_facets) ? $this->facetConfig->Advanced_Settings->translated_facets->toArray() - : array(); + : []; $specialFacets = $this->facetConfig->SpecialFacets; $this->displayStyles = isset($specialFacets->hierarchicalFacetDisplayStyles) ? $specialFacets->hierarchicalFacetDisplayStyles->toArray() - : array(); + : []; $this->separators = isset($specialFacets->hierarchicalFacetSeparators) ? $specialFacets->hierarchicalFacetSeparators->toArray() - : array(); + : []; } /** @@ -153,7 +153,7 @@ class HierarchicalFacetListener public function attach( SharedEventManagerInterface $manager ) { - $manager->attach('VuFind\Search', 'post', array($this, 'onSearchPost')); + $manager->attach('VuFind\Search', 'post', [$this, 'onSearchPost']); } /** @@ -204,11 +204,11 @@ class HierarchicalFacetListener if (isset($this->displayStyles[$facetName]) && $this->displayStyles[$facetName] == 'full' ) { - $fields[$facetName] = array( + $fields[$facetName] = [ $this->formatFacetField( $facetName, end($fields[$facetName]) ) - ); + ]; } else { foreach ($fields[$facetName] as &$value) { $value = $this->formatFacetField($facetName, $value); diff --git a/module/VuFind/src/VuFind/Search/Solr/InjectHighlightingListener.php b/module/VuFind/src/VuFind/Search/Solr/InjectHighlightingListener.php index 1413de86d23..3652c9ffbbb 100644 --- a/module/VuFind/src/VuFind/Search/Solr/InjectHighlightingListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/InjectHighlightingListener.php @@ -88,8 +88,8 @@ class InjectHighlightingListener */ public function attach(SharedEventManagerInterface $manager) { - $manager->attach('VuFind\Search', 'pre', array($this, 'onSearchPre')); - $manager->attach('VuFind\Search', 'post', array($this, 'onSearchPost')); + $manager->attach('VuFind\Search', 'pre', [$this, 'onSearchPre']); + $manager->attach('VuFind\Search', 'post', [$this, 'onSearchPost']); } /** diff --git a/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php b/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php index bce71561936..7491b40cc04 100644 --- a/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php @@ -93,10 +93,10 @@ class InjectSpellingListener public function attach(SharedEventManagerInterface $manager) { $manager->attach( - 'VuFind\Search', Service::EVENT_PRE, array($this, 'onSearchPre') + 'VuFind\Search', Service::EVENT_PRE, [$this, 'onSearchPre'] ); $manager->attach( - 'VuFind\Search', Service::EVENT_POST, array($this, 'onSearchPost') + 'VuFind\Search', Service::EVENT_POST, [$this, 'onSearchPost'] ); } diff --git a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php index 14e3deea92c..150b91a96b5 100644 --- a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php @@ -86,7 +86,7 @@ class MultiIndexListener array $stripfields, array $specs ) { $this->specs = $specs; - $this->active = array(); + $this->active = []; $this->backend = $backend; $this->shards = $shards; $this->stripfields = $stripfields; @@ -101,7 +101,7 @@ class MultiIndexListener */ public function attach(SharedEventManagerInterface $manager) { - $manager->attach('VuFind\Search', 'pre', array($this, 'onSearchPre')); + $manager->attach('VuFind\Search', 'pre', [$this, 'onSearchPre']); } /** @@ -129,12 +129,12 @@ class MultiIndexListener // an array to prevent invalid argument warnings. $shards = $params->get('shards'); $shards = explode( - ',', implode(',', (is_array($shards) ? $shards : array())) + ',', implode(',', (is_array($shards) ? $shards : [])) ); $fields = $this->getFields($shards); $specs = $this->getSearchSpecs($fields); $backend->getQueryBuilder()->setSpecs($specs); - $facets = $params->get('facet.field') ?: array(); + $facets = $params->get('facet.field') ?: []; $params->set('facet.field', array_diff($facets, $fields)); } } @@ -152,7 +152,7 @@ class MultiIndexListener */ protected function getFields(array $shards) { - $fields = array(); + $fields = []; foreach ($this->stripfields as $name => $strip) { if (isset($this->shards[$name])) { $uri = $this->shards[$name]; @@ -173,7 +173,7 @@ class MultiIndexListener */ protected function getSearchSpecs(array $fields) { - $specs = array(); + $specs = []; $fields = array_merge( $fields, array_map( @@ -184,7 +184,7 @@ class MultiIndexListener ) ); foreach ($this->specs as $handler => $spec) { - $specs[$handler] = array(); + $specs[$handler] = []; foreach ($spec as $component => $settings) { switch ($component) { case 'QueryFields': @@ -210,10 +210,10 @@ class MultiIndexListener */ protected function stripSpecsQueryFields(array $settings, array $fields) { - $stripped = array(); + $stripped = []; foreach ($settings as $field => $rule) { if (is_numeric($field)) { - $group = array(); + $group = []; $type = reset($rule); while (next($rule) !== false) { if (!in_array(key($rule), $fields)) { diff --git a/module/VuFind/src/VuFind/Search/Solr/Options.php b/module/VuFind/src/VuFind/Search/Solr/Options.php index e30ca2dd28b..e9bc34b3847 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Options.php +++ b/module/VuFind/src/VuFind/Search/Solr/Options.php @@ -43,21 +43,21 @@ class Options extends \VuFind\Search\Base\Options * * @var array */ - protected $hiddenFilters = array(); + protected $hiddenFilters = []; /** * Hierarchical facets * * @var array */ - protected $hierarchicalFacets = array(); + protected $hierarchicalFacets = []; /** * Hierarchical facet separators * * @var array */ - protected $hierarchicalFacetSeparators = array(); + protected $hierarchicalFacetSeparators = []; /** * Constructor @@ -119,10 +119,10 @@ class Options extends \VuFind\Search\Base\Options $this->sortOptions[$key] = $value; } } else { - $this->sortOptions = array('relevance' => 'sort_relevance', + $this->sortOptions = ['relevance' => 'sort_relevance', 'year' => 'sort_year', 'year asc' => 'sort_year asc', 'callnumber' => 'sort_callnumber', 'author' => 'sort_author', - 'title' => 'sort_title'); + 'title' => 'sort_title']; } // Load view preferences (or defaults if none in .ini file): if (isset($searchSettings->Views)) { @@ -130,9 +130,9 @@ class Options extends \VuFind\Search\Base\Options $this->viewOptions[$key] = $value; } } elseif (isset($searchSettings->General->default_view)) { - $this->viewOptions = array($this->defaultView => $this->defaultView); + $this->viewOptions = [$this->defaultView => $this->defaultView]; } else { - $this->viewOptions = array('list' => 'List'); + $this->viewOptions = ['list' => 'List']; } // Load facet preferences @@ -193,7 +193,7 @@ class Options extends \VuFind\Search\Base\Options $defaultChecked = is_object($searchSettings->ShardPreferences->defaultChecked) ? $searchSettings->ShardPreferences->defaultChecked->toArray() - : array($searchSettings->ShardPreferences->defaultChecked); + : [$searchSettings->ShardPreferences->defaultChecked]; foreach ($defaultChecked as $current) { $this->defaultSelectedShards[] = $current; } diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 19c21557354..64ec0c036ea 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -102,7 +102,7 @@ class Params extends \VuFind\Search\Base\Params { // Define Filter Query $filterQuery = $this->getOptions()->getHiddenFilters(); - $orFilters = array(); + $orFilters = []; foreach ($this->filterList as $field => $filter) { if ($orFacet = (substr($field, 0, 1) == '~')) { $field = substr($field, 1); @@ -118,7 +118,7 @@ class Params extends \VuFind\Search\Base\Params } if ($orFacet) { $orFilters[$field] = isset($orFilters[$field]) - ? $orFilters[$field] : array(); + ? $orFilters[$field] : []; $orFilters[$field][] = $q; } else { $filterQuery[] = $q; @@ -140,7 +140,7 @@ class Params extends \VuFind\Search\Base\Params public function getFacetSettings() { // Build a list of facets we want from the index - $facetSet = array(); + $facetSet = []; if (!empty($this->facetConfig)) { $facetSet['limit'] = $this->facetLimit; foreach (array_keys($this->facetConfig) as $facetField) { @@ -395,16 +395,16 @@ class Params extends \VuFind\Search\Base\Params */ protected function normalizeSort($sort) { - static $table = array( - 'year' => array('field' => 'publishDateSort', 'order' => 'desc'), + static $table = [ + 'year' => ['field' => 'publishDateSort', 'order' => 'desc'], 'publishDateSort' => - array('field' => 'publishDateSort', 'order' => 'desc'), - 'author' => array('field' => 'authorStr', 'order' => 'asc'), - 'title' => array('field' => 'title_sort', 'order' => 'asc'), - 'relevance' => array('field' => 'score', 'order' => 'desc'), - 'callnumber' => array('field' => 'callnumber', 'order' => 'asc'), - ); - $normalized = array(); + ['field' => 'publishDateSort', 'order' => 'desc'], + 'author' => ['field' => 'authorStr', 'order' => 'asc'], + 'title' => ['field' => 'title_sort', 'order' => 'asc'], + 'relevance' => ['field' => 'score', 'order' => 'desc'], + 'callnumber' => ['field' => 'callnumber', 'order' => 'asc'], + ]; + $normalized = []; foreach (explode(',', $sort) as $component) { $parts = explode(' ', trim($component)); $field = reset($parts); @@ -465,7 +465,7 @@ class Params extends \VuFind\Search\Base\Params // If we have selected shards, we need to format them: if (!empty($shards)) { - $selectedShards = array(); + $selectedShards = []; foreach ($shards as $current) { $selectedShards[$current] = $allShards[$current]; } diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index d39d6901619..c61a0638452 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -176,7 +176,7 @@ class Results extends \VuFind\Search\Base\Results */ protected function fixBadQueryGroup(QueryGroup $query) { - $newQueries = array(); + $newQueries = []; $fixed = false; // Try to fix each query in the group; replace any query that needs to @@ -236,29 +236,29 @@ class Results extends \VuFind\Search\Base\Results } // Start building the facet list: - $list = array(); + $list = []; // Loop through every field returned by the result set $fieldFacets = $this->responseFacets->getFieldFacets(); foreach (array_keys($filter) as $field) { - $data = isset($fieldFacets[$field]) ? $fieldFacets[$field] : array(); + $data = isset($fieldFacets[$field]) ? $fieldFacets[$field] : []; // Skip empty arrays: if (count($data) < 1) { continue; } // Initialize the settings for the current field - $list[$field] = array(); + $list[$field] = []; // Add the on-screen label $list[$field]['label'] = $filter[$field]; // Build our array of values for this field - $list[$field]['list'] = array(); + $list[$field]['list'] = []; // Should we translate values for the current facet? $translate = in_array($field, $this->getOptions()->getTranslatedFacets()); // Loop through values: foreach ($data as $value => $count) { // Initialize the array of data about the current facet: - $currentSettings = array(); + $currentSettings = []; $currentSettings['value'] = $value; $currentSettings['displayText'] = $translate ? $this->translate($value) : $value; diff --git a/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php b/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php index ce45c94798b..ee34a4ef5ce 100644 --- a/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php +++ b/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php @@ -126,15 +126,15 @@ class SpellingProcessor public function tokenize($input) { // Blacklist of useless tokens: - $joins = array("AND", "OR", "NOT"); + $joins = ["AND", "OR", "NOT"]; // Strip out parentheses -- irrelevant for tokenization: - $paren = array("(" => " ", ")" => " "); + $paren = ["(" => " ", ")" => " "]; $input = trim(strtr($input, $paren)); // Base of this algorithm comes straight from PHP doc example by // benighted at gmail dot com: http://php.net/manual/en/function.strtok.php - $tokens = array(); + $tokens = []; $token = strtok($input, " \t"); while ($token !== false) { // find double quoted tokens @@ -169,15 +169,15 @@ class SpellingProcessor */ public function getSuggestions(Spellcheck $spellcheck, AbstractQuery $query) { - $allSuggestions = array(); + $allSuggestions = []; foreach ($spellcheck as $term => $info) { if (!$this->shouldSkipTerm($query, $term, false) && ($suggestions = $this->formatAndFilterSuggestions($query, $info)) ) { - $allSuggestions[$term] = array( + $allSuggestions[$term] = [ 'freq' => $info['origFreq'], 'suggestions' => $suggestions - ); + ]; } } // Fail over to secondary suggestions if primary failed: @@ -206,7 +206,7 @@ class SpellingProcessor ); } $limit = $this->getSpellingLimit(); - $suggestions = array(); + $suggestions = []; foreach ($info['suggestion'] as $suggestion) { if (count($suggestions) >= $limit) { break; @@ -251,7 +251,7 @@ class SpellingProcessor */ public function processSuggestions($suggestions, $query, Params $params) { - $returnArray = array(); + $returnArray = []; foreach ($suggestions as $term => $details) { // Find out if our suggestion is part of a token $inToken = false; @@ -314,10 +314,10 @@ class SpellingProcessor $label = $replacement; } // Basic spelling suggestion data - $returnArray[$targetTerm]['suggestions'][$label] = array( + $returnArray[$targetTerm]['suggestions'][$label] = [ 'freq' => $freq, 'new_term' => $replacement - ); + ]; // Only generate expansions if enabled in config if ($this->expand) { diff --git a/module/VuFind/src/VuFind/Search/Solr/V4/ErrorListener.php b/module/VuFind/src/VuFind/Search/Solr/V4/ErrorListener.php index f86c9d784a4..9e15ae91790 100644 --- a/module/VuFind/src/VuFind/Search/Solr/V4/ErrorListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/V4/ErrorListener.php @@ -98,7 +98,7 @@ class ErrorListener extends AbstractErrorListener */ protected function analyzeJsonErrorResponse($body) { - $tags = array(); + $tags = []; if (isset($body->error->msg)) { $reason = $body->error->msg; if (stristr($reason, 'org.apache.solr.search.SyntaxError') diff --git a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php index df3b1a5cd4d..5e4ea1fd388 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php @@ -94,15 +94,15 @@ class Params extends \VuFind\Search\Solr\Params // Load the AuthorModuleRecommendations configuration if available, use // standard defaults otherwise: if (isset($ss->AuthorModuleRecommendations)) { - $recommend = array(); + $recommend = []; foreach ($ss->AuthorModuleRecommendations as $section => $content) { - $recommend[$section] = array(); + $recommend[$section] = []; foreach ($content as $current) { $recommend[$section][] = $current; } } } else { - $recommend = array('side' => array('ExpandFacets:Author')); + $recommend = ['side' => ['ExpandFacets:Author']]; } return $recommend; diff --git a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Options.php b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Options.php index 8bb021f4cbc..541c114367f 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Options.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Options.php @@ -51,10 +51,10 @@ class Options extends \VuFind\Search\Solr\Options // It's important to remember here we are talking about on-screen // sort values, not what is sent to Solr, since this screen // is really using facet sorting. - $this->sortOptions = array( + $this->sortOptions = [ 'relevance' => 'sort_author_relevance', 'author' => 'sort_author_author' - ); + ]; // No spell check needed in author module: $this->spellcheck = false; diff --git a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php index 97c116a0430..ab635328cc3 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Params.php @@ -51,7 +51,7 @@ class Params extends \VuFind\Search\Solr\Params parent::initFromRequest($request); // Force custom facet settings: - $this->facetConfig = array(); + $this->facetConfig = []; $this->addFacet('authorStr'); $this->setFacetOffset(($this->getPage() - 1) * $this->getLimit()); $this->setFacetLimit($this->getLimit() * 10); @@ -96,7 +96,7 @@ class Params extends \VuFind\Search\Solr\Params protected function getRecommendationSettings() { // No recommendations here: - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php index a551d9b5f89..47659e42f29 100644 --- a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php +++ b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php @@ -55,7 +55,7 @@ class Results extends \VuFind\Search\Solr\Results $this->responseFacets = $collection->getFacets(); // Get the facets from which we will build our results: - $facets = $this->getFacetList(array('authorStr' => null)); + $facets = $this->getFacetList(['authorStr' => null]); if (isset($facets['authorStr'])) { $params = $this->getParams(); $this->resultTotal diff --git a/module/VuFind/src/VuFind/Search/SolrCollection/Options.php b/module/VuFind/src/VuFind/Search/SolrCollection/Options.php index fcce78c3f87..f952e6cecea 100644 --- a/module/VuFind/src/VuFind/Search/SolrCollection/Options.php +++ b/module/VuFind/src/VuFind/Search/SolrCollection/Options.php @@ -50,16 +50,16 @@ class Options extends \VuFind\Search\Solr\Options // Load sort preferences (or defaults if none in .ini file): $searchSettings = $configLoader->get('Collection'); if (isset($searchSettings->Sort)) { - $this->sortOptions = array(); + $this->sortOptions = []; foreach ($searchSettings->Sort as $key => $value) { $this->sortOptions[$key] = $value; } } else { - $this->sortOptions = array( + $this->sortOptions = [ 'title' => 'sort_title', 'year' => 'sort_year', 'year asc' => 'sort_year asc', 'author' => 'sort_author' - ); + ]; } $this->defaultSort = key($this->sortOptions); } diff --git a/module/VuFind/src/VuFind/Search/SolrCollection/Params.php b/module/VuFind/src/VuFind/Search/SolrCollection/Params.php index 8e8ec3a8701..e1858684bbc 100644 --- a/module/VuFind/src/VuFind/Search/SolrCollection/Params.php +++ b/module/VuFind/src/VuFind/Search/SolrCollection/Params.php @@ -123,7 +123,7 @@ class Params extends \VuFind\Search\Solr\Params ->get('Collection'); return isset($searchSettings->Recommend) ? $searchSettings->Recommend->toArray() - : array('side' => array('CollectionSideFacets:Facets::Collection:true')); + : ['side' => ['CollectionSideFacets:Facets::Collection:true']]; } /** diff --git a/module/VuFind/src/VuFind/Search/Summon/Options.php b/module/VuFind/src/VuFind/Search/Summon/Options.php index 05b6e122c68..72389f9a110 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Options.php +++ b/module/VuFind/src/VuFind/Search/Summon/Options.php @@ -149,9 +149,9 @@ class Options extends \VuFind\Search\Base\Options $this->viewOptions[$key] = $value; } } elseif (isset($searchSettings->General->default_view)) { - $this->viewOptions = array($this->defaultView => $this->defaultView); + $this->viewOptions = [$this->defaultView => $this->defaultView]; } else { - $this->viewOptions = array('list' => 'List'); + $this->viewOptions = ['list' => 'List']; } } diff --git a/module/VuFind/src/VuFind/Search/Summon/Params.php b/module/VuFind/src/VuFind/Search/Summon/Params.php index e01d32764a7..245f1b6c8be 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Params.php +++ b/module/VuFind/src/VuFind/Search/Summon/Params.php @@ -46,14 +46,14 @@ class Params extends \VuFind\Search\Base\Params * * @var array */ - protected $fullFacetSettings = array(); + protected $fullFacetSettings = []; /** * Settings for the date facet only * * @var array */ - protected $dateFacetSettings = array(); + protected $dateFacetSettings = []; /** * Add a field to facet on. @@ -191,7 +191,7 @@ class Params extends \VuFind\Search\Base\Params $defaultFacetLimit = isset($config->Facet_Settings->facet_limit) ? $config->Facet_Settings->facet_limit : 30; - $finalFacets = array(); + $finalFacets = []; foreach ($this->getFullFacetSettings() as $facet) { // See if parameters are included as part of the facet name; // if not, override them with defaults. @@ -219,7 +219,7 @@ class Params extends \VuFind\Search\Base\Params // Which filters should be applied to our query? $filterList = $this->getFilterList(); if (!empty($filterList)) { - $orFacets = array(); + $orFacets = []; // Loop through all filters and add appropriate values to request: foreach ($filterList as $filterArray) { @@ -251,7 +251,7 @@ class Params extends \VuFind\Search\Base\Params } else if ($filt['operator'] == 'OR') { // Special case -- OR facets: $orFacets[$filt['field']] = isset($orFacets[$filt['field']]) - ? $orFacets[$filt['field']] : array(); + ? $orFacets[$filt['field']] : []; $orFacets[$filt['field']][] = $safeValue; } else { // Standard case: diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php index 20f3d871ce5..844d97b320c 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Results.php +++ b/module/VuFind/src/VuFind/Search/Summon/Results.php @@ -103,11 +103,11 @@ class Results extends \VuFind\Search\Base\Results $dateFacets = $this->getParams()->getDateFacetSettings(); if (!empty($dateFacets)) { foreach ($dateFacets as $dateFacet) { - $this->responseFacets[] = array( + $this->responseFacets[] = [ 'fieldName' => $dateFacet, 'displayName' => $dateFacet, - 'counts' => array() - ); + 'counts' => [] + ]; } } @@ -135,7 +135,7 @@ class Results extends \VuFind\Search\Base\Results $order = array_flip(array_keys($filter)); // Loop through the facets returned by Summon. - $facetResult = array(); + $facetResult = []; if (is_array($this->responseFacets)) { foreach ($this->responseFacets as $current) { // The "displayName" value is actually the name of the field on @@ -161,7 +161,7 @@ class Results extends \VuFind\Search\Base\Results ksort($facetResult); // Rewrite the sorted array with appropriate keys: - $finalResult = array(); + $finalResult = []; foreach ($facetResult as $current) { $finalResult[$current['displayName']] = $current; } @@ -178,7 +178,7 @@ class Results extends \VuFind\Search\Base\Results */ protected function stripFilterParameters($rawFilter) { - $filter = array(); + $filter = []; foreach ($rawFilter as $key => $value) { $key = explode(',', $key); $key = trim($key[0]); @@ -221,7 +221,7 @@ class Results extends \VuFind\Search\Base\Results // an active filter for the current field? $orField = '~' . $field; $itemsToCheck = isset($filterList[$field]) - ? $filterList[$field] : array(); + ? $filterList[$field] : []; if (isset($filterList[$orField])) { $itemsToCheck += $filterList[$orField]; } @@ -257,12 +257,12 @@ class Results extends \VuFind\Search\Base\Results */ protected function processSpelling($spelling) { - $this->suggestions = array(); + $this->suggestions = []; foreach ($spelling as $current) { if (!isset($this->suggestions[$current['originalQuery']])) { - $this->suggestions[$current['originalQuery']] = array( - 'suggestions' => array() - ); + $this->suggestions[$current['originalQuery']] = [ + 'suggestions' => [] + ]; } $this->suggestions[$current['originalQuery']]['suggestions'][] = $current['suggestedQuery']; @@ -277,13 +277,13 @@ class Results extends \VuFind\Search\Base\Results */ public function getSpellingSuggestions() { - $retVal = array(); + $retVal = []; foreach ($this->getRawSuggestions() as $term => $details) { foreach ($details['suggestions'] as $word) { // Strip escaped characters in the search term (for example, "\:") $term = stripcslashes($term); $word = stripcslashes($word); - $retVal[$term]['suggestions'][$word] = array('new_term' => $word); + $retVal[$term]['suggestions'][$word] = ['new_term' => $word]; } } return $retVal; diff --git a/module/VuFind/src/VuFind/Search/Tags/Options.php b/module/VuFind/src/VuFind/Search/Tags/Options.php index 44770217580..6766014d7da 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Options.php +++ b/module/VuFind/src/VuFind/Search/Tags/Options.php @@ -46,12 +46,12 @@ class Options extends \VuFind\Search\Base\Options public function __construct(\VuFind\Config\PluginManager $configLoader) { parent::__construct($configLoader); - $this->basicHandlers = array('tags' => 'Tag'); + $this->basicHandlers = ['tags' => 'Tag']; $this->defaultSort = 'title'; - $this->sortOptions = array( + $this->sortOptions = [ 'title' => 'sort_title', 'author' => 'sort_author', 'year DESC' => 'sort_year', 'year' => 'sort_year asc' - ); + ]; } /** diff --git a/module/VuFind/src/VuFind/Search/Tags/Params.php b/module/VuFind/src/VuFind/Search/Tags/Params.php index be52762991e..a0141285c32 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Params.php +++ b/module/VuFind/src/VuFind/Search/Tags/Params.php @@ -49,6 +49,6 @@ class Params extends \VuFind\Search\Base\Params protected function getRecommendationSettings() { // No recommendation modules in tag view currently: - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Tags/Results.php b/module/VuFind/src/VuFind/Search/Tags/Results.php index 8cbdeed777e..ddae3e8b870 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Results.php +++ b/module/VuFind/src/VuFind/Search/Tags/Results.php @@ -52,7 +52,7 @@ class Results extends BaseResults if (!empty($tag)) { $rawResults = $tag->getResources(null, $this->getParams()->getSort()); } else { - $rawResults = array(); + $rawResults = []; } // How many results were there? @@ -68,10 +68,10 @@ class Results extends BaseResults } // Retrieve record drivers for the selected items. - $recordsToRequest = array(); + $recordsToRequest = []; foreach ($rawResults as $row) { $recordsToRequest[] - = array('id' => $row->record_id, 'source' => $row->source); + = ['id' => $row->record_id, 'source' => $row->source]; } $this->results = $this->getServiceLocator()->get('VuFind\RecordLoader') ->loadBatch($recordsToRequest); @@ -88,6 +88,6 @@ class Results extends BaseResults public function getFacetList($filter = null) { // Facets not supported: - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/UrlQueryHelper.php b/module/VuFind/src/VuFind/Search/UrlQueryHelper.php index ff6b5869f4d..f95317953ec 100644 --- a/module/VuFind/src/VuFind/Search/UrlQueryHelper.php +++ b/module/VuFind/src/VuFind/Search/UrlQueryHelper.php @@ -65,7 +65,7 @@ class UrlQueryHelper * * @var array */ - protected $defaultParams = array(); + protected $defaultParams = []; /** * Should we suppress the standard query parameter? @@ -151,13 +151,13 @@ class UrlQueryHelper if ($current instanceof QueryGroup) { $operator = $current->isNegated() ? 'NOT' : $current->getOperator(); - $params['bool' . $i] = array($operator); + $params['bool' . $i] = [$operator]; foreach ($current->getQueries() as $inner) { if (!isset($params['lookfor' . $i])) { - $params['lookfor' . $i] = array(); + $params['lookfor' . $i] = []; } if (!isset($params['type' . $i])) { - $params['type' . $i] = array(); + $params['type' . $i] = []; } $params['lookfor' . $i][] = $inner->getString(); $params['type' . $i][] = $inner->getHandler(); @@ -206,7 +206,7 @@ class UrlQueryHelper } $filters = $this->params->getFilters(); if (!empty($filters)) { - $params['filter'] = array(); + $params['filter'] = []; foreach ($filters as $field => $values) { foreach ($values as $current) { $params['filter'][] = $field . ':"' . $current . '"'; @@ -278,7 +278,7 @@ class UrlQueryHelper // Add the filter: if (!isset($params['filter'])) { - $params['filter'] = array(); + $params['filter'] = []; } $params['filter'][] = $filter; @@ -325,7 +325,7 @@ class UrlQueryHelper } // Remove the filter: - $newFilter = array(); + $newFilter = []; if (isset($params['filter']) && is_array($params['filter'])) { foreach ($params['filter'] as $current) { list($currentField, $currentValue) @@ -483,7 +483,7 @@ class UrlQueryHelper * * @return string */ - public function asHiddenFields($filter = array()) + public function asHiddenFields($filter = []) { $retVal = ''; foreach ($this->getParamArray() as $paramName => $paramValue) { @@ -561,7 +561,7 @@ class UrlQueryHelper */ protected function buildQueryString($a, $escape = true) { - $parts = array(); + $parts = []; foreach ($a as $key => $value) { if (is_array($value)) { foreach ($value as $current) { diff --git a/module/VuFind/src/VuFind/Search/WorldCat/Results.php b/module/VuFind/src/VuFind/Search/WorldCat/Results.php index 128d6f757b2..86416ef5b7b 100644 --- a/module/VuFind/src/VuFind/Search/WorldCat/Results.php +++ b/module/VuFind/src/VuFind/Search/WorldCat/Results.php @@ -68,6 +68,6 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // No facets in WorldCat: - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php index be0ff7ce434..8cf7fd106c4 100644 --- a/module/VuFind/src/VuFind/Service/Factory.php +++ b/module/VuFind/src/VuFind/Service/Factory.php @@ -310,7 +310,7 @@ class Factory public static function getHttp(ServiceManager $sm) { $config = $sm->get('VuFind\Config')->get('config'); - $options = array(); + $options = []; if (isset($config->Proxy->host)) { $options['proxy_host'] = $config->Proxy->host; if (isset($config->Proxy->port)) { @@ -318,7 +318,7 @@ class Factory } } $defaults = isset($config->Http) - ? $config->Http->toArray() : array(); + ? $config->Http->toArray() : []; return new \VuFindHttp\HttpService($options, $defaults); } @@ -444,7 +444,7 @@ class Factory $translator = $sm->get('VuFind\Translator'); $recaptcha->setOption( 'custom_translations', - array( + [ 'audio_challenge' => $translator->translate('recaptcha_audio_challenge'), 'cant_hear_this' => @@ -467,7 +467,7 @@ class Factory $translator->translate('recaptcha_refresh_btn'), 'visual_challenge' => $translator->translate('recaptcha_visual_challenge') - ) + ] ); } return $recaptcha; @@ -733,13 +733,13 @@ class Factory // Set up the ExtendedIni plugin: $config = $sm->get('VuFind\Config')->get('config'); - $pathStack = array( + $pathStack = [ APPLICATION_PATH . '/languages', LOCAL_OVERRIDE_DIR . '/languages' - ); + ]; $fallbackLocales = $config->Site->language == 'en' ? 'en' - : array($config->Site->language, 'en'); + : [$config->Site->language, 'en']; try { $pm = $translator->getPluginManager(); } catch (\Zend\Mvc\Exception\BadMethodCallException $ex) { diff --git a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php index ddd053993c2..d68fac408cb 100644 --- a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php +++ b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php @@ -54,7 +54,7 @@ abstract class AbstractPluginManager extends Base { parent::__construct($configuration); $this->addInitializer( - array('VuFind\ServiceManager\Initializer', 'initPlugin'), false + ['VuFind\ServiceManager\Initializer', 'initPlugin'], false ); } diff --git a/module/VuFind/src/VuFind/Sitemap/AbstractFile.php b/module/VuFind/src/VuFind/Sitemap/AbstractFile.php index eb64ad7d418..df76bfb5b80 100644 --- a/module/VuFind/src/VuFind/Sitemap/AbstractFile.php +++ b/module/VuFind/src/VuFind/Sitemap/AbstractFile.php @@ -50,7 +50,7 @@ abstract class AbstractFile * * @var array */ - protected $urls = array(); + protected $urls = []; /** * Add a URL to the map. diff --git a/module/VuFind/src/VuFind/Sitemap/Generator.php b/module/VuFind/src/VuFind/Sitemap/Generator.php index e1411d524b2..9b3987fbe7c 100644 --- a/module/VuFind/src/VuFind/Sitemap/Generator.php +++ b/module/VuFind/src/VuFind/Sitemap/Generator.php @@ -101,7 +101,7 @@ class Generator * * @var array */ - protected $warnings = array(); + protected $warnings = []; /** * Mode of retrieving IDs from the index (may be 'terms' or 'search') @@ -126,12 +126,12 @@ class Generator // Process backend configuration: $backendConfig = isset($this->config->Sitemap->index) - ? $this->config->Sitemap->index : array('Solr,/Record/'); - $backendConfig = is_callable(array($backendConfig, 'toArray')) + ? $this->config->Sitemap->index : ['Solr,/Record/']; + $backendConfig = is_callable([$backendConfig, 'toArray']) ? $backendConfig->toArray() : (array)$backendConfig; $callback = function ($n) { $parts = array_map('trim', explode(',', $n)); - return array('id' => $parts[0], 'url' => $parts[1]); + return ['id' => $parts[0], 'url' => $parts[1]]; }; $this->backendSettings = array_map($callback, $backendConfig); @@ -257,7 +257,7 @@ class Generator $key = $backend->getConnector()->getUniqueKey(); $info = $backend->terms($key, $lastTerm, $this->countPerPage) ->getFieldTerms($key); - return null === $info ? array() : array_keys($info->toArray()); + return null === $info ? [] : array_keys($info->toArray()); } /** @@ -273,18 +273,18 @@ class Generator $connector = $backend->getConnector(); $key = $connector->getUniqueKey(); $params = new ParamBag( - array( + [ 'q' => '*:*', 'fl' => $key, 'rows' => $this->countPerPage, 'start' => $offset, 'wt' => 'json', 'sort' => $key . ' asc', - ) + ] ); $raw = $connector->search($params); $result = json_decode($raw); - $ids = array(); + $ids = []; if (isset($result->response->docs)) { foreach ($result->response->docs as $doc) { $ids[] = $doc->$key; diff --git a/module/VuFind/src/VuFind/Solr/Utils.php b/module/VuFind/src/VuFind/Solr/Utils.php index aa9d099f8cd..70bb2302567 100644 --- a/module/VuFind/src/VuFind/Solr/Utils.php +++ b/module/VuFind/src/VuFind/Solr/Utils.php @@ -57,7 +57,7 @@ class Utils if (!preg_match($regEx, $query, $matches)) { return false; } - return array('from' => trim($matches[1]), 'to' => trim($matches[2])); + return ['from' => trim($matches[1]), 'to' => trim($matches[2])]; } /** @@ -71,7 +71,7 @@ class Utils public static function sanitizeDate($date) { // Strip brackets; we'll assume guesses are correct. - $date = str_replace(array('[', ']'), '', $date); + $date = str_replace(['[', ']'], '', $date); // Special case -- first four characters are not a year: if (!preg_match('/^[0-9]{4}/', $date)) { @@ -116,8 +116,8 @@ class Utils $year = substr($date, 0, 4); // Let's get rid of punctuation and normalize separators: - $date = str_replace(array('.', ' ', '?'), '', $date); - $date = str_replace(array('/', '--', '-0'), '-', $date); + $date = str_replace(['.', ' ', '?'], '', $date); + $date = str_replace(['/', '--', '-0'], '-', $date); // If multiple dates are &'ed together, take just the first: list($date) = explode('&', $date); diff --git a/module/VuFind/src/VuFind/Statistics/AbstractBase.php b/module/VuFind/src/VuFind/Statistics/AbstractBase.php index e41a8b926cd..87cab2bb66c 100644 --- a/module/VuFind/src/VuFind/Statistics/AbstractBase.php +++ b/module/VuFind/src/VuFind/Statistics/AbstractBase.php @@ -117,7 +117,7 @@ abstract class AbstractBase */ public function getDriversForSource($source, $getAll = false) { - $drivers = array(); + $drivers = []; // For each mode if (isset($this->config->Statistics->mode)) { @@ -199,7 +199,7 @@ abstract class AbstractBase $parts = explode(' ', $this->getBrowser($agent)); $browser = $parts[0]; $version = isset($parts[1]) ? $parts[1] : ''; - return array( + return [ 'id' => uniqid('', true), 'datestamp' => substr(date('c', strtotime('now')), 0, -6) . 'Z', 'browser' => $browser, @@ -210,7 +210,7 @@ abstract class AbstractBase : $server->get('HTTP_REFERER'), 'url' => $server->get('REQUEST_URI'), 'session' => $this->sessId - ); + ]; } /** diff --git a/module/VuFind/src/VuFind/Statistics/Driver/AbstractBase.php b/module/VuFind/src/VuFind/Statistics/Driver/AbstractBase.php index ab2a80ecd7b..b2a8d5568d4 100644 --- a/module/VuFind/src/VuFind/Statistics/Driver/AbstractBase.php +++ b/module/VuFind/src/VuFind/Statistics/Driver/AbstractBase.php @@ -87,10 +87,10 @@ abstract class AbstractBase * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function getFullList($field, $value = array()) + public function getFullList($field, $value = []) { // Assume no statistics - return array(); + return []; } /** @@ -106,6 +106,6 @@ abstract class AbstractBase public function getBrowserStats($version, $limit) { // Assume no statistics - return array(); + return []; } } diff --git a/module/VuFind/src/VuFind/Statistics/Driver/Db.php b/module/VuFind/src/VuFind/Statistics/Driver/Db.php index c06e0b0766e..36a7e427ebd 100644 --- a/module/VuFind/src/VuFind/Statistics/Driver/Db.php +++ b/module/VuFind/src/VuFind/Statistics/Driver/Db.php @@ -68,7 +68,7 @@ class Db extends AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface * * @return array */ - public function getFullList($field, $value = array()) + public function getFullList($field, $value = []) { // Use the model return $this->getDbTable('UserStatsFields')->getFields($field, $value) diff --git a/module/VuFind/src/VuFind/Statistics/Driver/Solr.php b/module/VuFind/src/VuFind/Statistics/Driver/Solr.php index e9ba0d980de..038a30733db 100644 --- a/module/VuFind/src/VuFind/Statistics/Driver/Solr.php +++ b/module/VuFind/src/VuFind/Statistics/Driver/Solr.php @@ -98,19 +98,19 @@ class Solr extends AbstractBase * * @return array */ - public function getFullList($field, $value = array('value' => '[* TO *]')) + public function getFullList($field, $value = ['value' => '[* TO *]']) { $query = new Query($field . ':' . $value['value']); $params = new ParamBag(); $params->add('fl', $field); $start = 0; $limit = 1000; - $data = array(); + $data = []; do { $response = $this->solrBackend->search($query, $start, $limit, $params); $records = $response->getRecords(); foreach ($records as $doc) { - $data[] = array($field => $doc->$field); + $data[] = [$field => $doc->$field]; } $start += $limit; } while (count($records) > 0); @@ -134,7 +134,7 @@ class Solr extends AbstractBase $params->add('group.field', 'session'); $start = 0; $limit = 1000; - $hashes = array(); + $hashes = []; do { $response = $this->solrBackend->search($query, $start, $limit, $params); $groups = $response->getGroups(); @@ -159,17 +159,17 @@ class Solr extends AbstractBase } $start += $limit; } while (count($groups['session']['groups']) > 0); - $solrBrowsers = array(); + $solrBrowsers = []; foreach ($hashes as $browser => $count) { - $newBrowser = array( + $newBrowser = [ 'browserName' => $browser, 'count' => $count - ); + ]; // Insert sort (limit to listLength) for ($i = 0;$i<$listLength-1 && $i<count($solrBrowsers);$i++) { if ($count > $solrBrowsers[$i]['count']) { // Insert in order - array_splice($solrBrowsers, $i, 0, array($newBrowser)); + array_splice($solrBrowsers, $i, 0, [$newBrowser]); continue 2; // Skip the append after this loop } } diff --git a/module/VuFind/src/VuFind/Statistics/Record.php b/module/VuFind/src/VuFind/Statistics/Record.php index aea6a83f3c8..8a06200aba8 100644 --- a/module/VuFind/src/VuFind/Statistics/Record.php +++ b/module/VuFind/src/VuFind/Statistics/Record.php @@ -49,10 +49,10 @@ class Record extends AbstractBase public function log($data, $request) { $this->save( - array( + [ 'recordId' => $data->getUniqueId(), 'recordSource' => $data->getResourceSource() - ), + ], $request ); } @@ -72,7 +72,7 @@ class Record extends AbstractBase $summary = $driver->getFullList('recordId'); if (!empty($summary)) { $sources = $driver->getFullList('recordSource'); - $hashes = array(); + $hashes = []; // Generate hashes (faster than grouping by looping) for ($i = 0;$i<count($summary);$i++) { $source = $sources[$i]['recordSource']; @@ -82,27 +82,27 @@ class Record extends AbstractBase ? $hashes[$source][$id] + 1 : 1; } - $top = array(); + $top = []; // For each source foreach ($hashes as $source => $records) { // Using a reference to consolidate code dramatically $reference = & $top; if ($bySource) { - $top[$source] = array(); + $top[$source] = []; $reference = & $top[$source]; } // For each record foreach ($records as $id => $count) { - $newRecord = array( + $newRecord = [ 'value' => $id, 'count' => $count, 'source' => $source - ); + ]; // Insert sort (limit to listLength) for ($i = 0;$i<$listLength-1 && $i<count($reference);$i++) { if ($count > $reference[$i]['count']) { // Insert in order - array_splice($reference, $i, 0, array($newRecord)); + array_splice($reference, $i, 0, [$newRecord]); continue 2; // Skip the append after this loop } } @@ -112,12 +112,12 @@ class Record extends AbstractBase } $reference = array_slice($reference, 0, $listLength); } - return array( + return [ 'top' => $top, 'total' => count($summary) - ); + ]; } } - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Statistics/Search.php b/module/VuFind/src/VuFind/Statistics/Search.php index bbc3eb9e29c..5d9acacb3ba 100644 --- a/module/VuFind/src/VuFind/Statistics/Search.php +++ b/module/VuFind/src/VuFind/Statistics/Search.php @@ -48,13 +48,13 @@ class Search extends AbstractBase */ public function log($data, $request) { - $stat = array( + $stat = [ 'phrase' => $data->getParams()->getDisplayQuery(), 'searchSource' => $data->getParams()->getSearchClassId(), 'type' => $data->getParams()->getSearchHandler(), 'resultCount' => $data->getResultTotal(), 'noresults' => $data->getResultTotal() == 0 - ); + ]; $this->save($stat, $request); } @@ -73,7 +73,7 @@ class Search extends AbstractBase $summary = $driver->getFullList('phrase'); if (!empty($summary)) { $sources = $driver->getFullList('searchSource'); - $hashes = array(); + $hashes = []; // Generate hashes (faster than grouping by looping) for ($i = 0;$i<count($summary);$i++) { if (!isset($sources[$i]['searchSource'])) { @@ -93,13 +93,13 @@ class Search extends AbstractBase ? $hashes[$source][$summary[$i]['phrase']] + 1 : 1; } - $top = array(); + $top = []; // For each source foreach ($hashes as $source => $records) { // Using a reference to consolidate code dramatically $reference = & $top; if ($bySource) { - $top[$source] = array(); + $top[$source] = []; $reference = & $top[$source]; } // For each record @@ -107,16 +107,16 @@ class Search extends AbstractBase $value = ($phrase == '' || $phrase == '*:*') ? '(empty)' : $phrase; - $newRecord = array( + $newRecord = [ 'value' => $value, 'count' => $count, 'source' => $source - ); + ]; // Insert sort (limit to listLength) for ($i = 0;$i<$listLength-1 && $i<count($reference);$i++) { if ($count > $reference[$i]['count']) { // Insert in order - array_splice($reference, $i, 0, array($newRecord)); + array_splice($reference, $i, 0, [$newRecord]); continue 2; // Skip the append after this loop } } @@ -126,15 +126,15 @@ class Search extends AbstractBase } $reference = array_slice($reference, 0, $listLength); } - return array( + return [ 'top' => $top, 'total' => count($summary), 'empty' => count( - $driver->getFullList('noresults', array('value' => 'true')) + $driver->getFullList('noresults', ['value' => 'true']) ) - ); + ]; } } - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Tags.php b/module/VuFind/src/VuFind/Tags.php index 62bfae20022..b87fee02f08 100644 --- a/module/VuFind/src/VuFind/Tags.php +++ b/module/VuFind/src/VuFind/Tags.php @@ -65,7 +65,7 @@ class Tags public function parse($tags) { preg_match_all('/"[^"]*"|[^ ]+/', trim($tags), $words); - $result = array(); + $result = []; foreach ($words[0] as $tag) { // Wipe out double-quotes and trim over-long tags: $result[] = substr(str_replace('"', '', $tag), 0, $this->maxLength); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AddEllipsis.php b/module/VuFind/src/VuFind/View/Helper/Root/AddEllipsis.php index 46cec4af51d..dace239c2a3 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AddEllipsis.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AddEllipsis.php @@ -53,7 +53,7 @@ class AddEllipsis extends AbstractHelper // Remove highlighting markers from the string so we can perform a clean // comparison: $dehighlighted = str_replace( - array('{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'), '', $highlighted + ['{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'], '', $highlighted ); // If the dehighlighted string is shorter than the full string, we need diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Auth.php b/module/VuFind/src/VuFind/View/Helper/Root/Auth.php index 588740ff582..4c951e37332 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Auth.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Auth.php @@ -64,7 +64,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - protected function renderTemplate($name, $context = array()) + protected function renderTemplate($name, $context = []) { // Set up the needed context in the view: $contextHelper = $this->getView()->plugin('context'); @@ -126,7 +126,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getCreateFields($context = array()) + public function getCreateFields($context = []) { return $this->renderTemplate('create.phtml', $context); } @@ -138,7 +138,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getLoginFields($context = array()) + public function getLoginFields($context = []) { return $this->renderTemplate('loginfields.phtml', $context); } @@ -150,7 +150,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getLogin($context = array()) + public function getLogin($context = []) { return $this->renderTemplate('login.phtml', $context); } @@ -162,7 +162,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getLoginDesc($context = array()) + public function getLoginDesc($context = []) { return $this->renderTemplate('logindesc.phtml', $context); } @@ -187,7 +187,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getNewPasswordForm($context = array()) + public function getNewPasswordForm($context = []) { return $this->renderTemplate('newpassword.phtml', $context); } @@ -199,7 +199,7 @@ class Auth extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function getPasswordRecoveryForm($context = array()) + public function getPasswordRecoveryForm($context = []) { return $this->renderTemplate('recovery.phtml', $context); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Citation.php b/module/VuFind/src/VuFind/View/Helper/Root/Citation.php index 544e95fd5f5..669b4c1906d 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Citation.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Citation.php @@ -44,7 +44,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper * * @var array */ - protected $details = array(); + protected $details = []; /** * Record driver @@ -81,7 +81,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper public function __invoke($driver) { // Build author list: - $authors = array(); + $authors = []; $primary = $driver->tryMethod('getPrimaryAuthor'); if (empty($primary)) { $primary = $driver->tryMethod('getCorporateAuthor'); @@ -116,15 +116,15 @@ class Citation extends \Zend\View\Helper\AbstractHelper // Store everything: $this->driver = $driver; - $this->details = array( + $this->details = [ 'authors' => $this->prepareAuthors($authors), 'title' => trim($title), 'subtitle' => trim($subtitle), 'pubPlace' => isset($pubPlaces[0]) ? $pubPlaces[0] : null, 'pubName' => isset($publishers[0]) ? $publishers[0] : null, 'pubDate' => isset($pubDates[0]) ? $pubDates[0] : null, - 'edition' => empty($edition) ? array() : array($edition), + 'edition' => empty($edition) ? [] : [$edition], 'journal' => $driver->tryMethod('getContainerTitle') - ); + ]; return $this; } @@ -149,7 +149,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper // If we got this far, it's worth trying to reverse names (for example, // this may be dirty data from Summon): - $processed = array(); + $processed = []; foreach ($authors as $name) { if (!strstr($name, ',')) { $parts = explode(' ', $name); @@ -197,11 +197,11 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ public function getCitationAPA() { - $apa = array( + $apa = [ 'title' => $this->getAPATitle(), 'authors' => $this->getAPAAuthors(), 'edition' => $this->getEdition() - ); + ]; // Show a period after the title if it does not already have punctuation // and is not followed by an edition statement: $apa['periodAfterTitle'] @@ -254,10 +254,10 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ public function getCitationMLA($etAlThreshold = 4, $volNumSeparator = '.') { - $mla = array( + $mla = [ 'title' => $this->getMLATitle(), 'authors' => $this->getMLAAuthors($etAlThreshold) - ); + ]; $mla['periodAfterTitle'] = !$this->isPunctuated($mla['title']); // Behave differently for books vs. journals: @@ -373,7 +373,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper $vol = $num; $num = ''; } - return array($vol, $num, $year); + return [$vol, $num, $year]; } else { // Right now, we'll assume if day == 1, this is a monthly publication; // that's probably going to result in some bad citations, but it's the @@ -381,7 +381,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper $finalDate = $year . (empty($month) ? '' : ', ' . $month) . (($day > 1) ? ' ' . $day : ''); - return array('', '', $finalDate); + return ['', '', $finalDate]; } } @@ -397,7 +397,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper $str = $this->stripPunctuation($str); // Is it a standard suffix? - $suffixes = array('Jr', 'Sr'); + $suffixes = ['Jr', 'Sr']; if (in_array($str, $suffixes)) { return true; } @@ -506,7 +506,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ protected function isPunctuated($string) { - $punctuation = array('.', '?', '!'); + $punctuation = ['.', '?', '!']; return (in_array(substr($string, -1), $punctuation)); } @@ -519,7 +519,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ protected function stripPunctuation($text) { - $punctuation = array('.', ',', ':', ';', '/'); + $punctuation = ['.', ',', ':', ';', '/']; $text = trim($text); if (in_array(substr($text, -1), $punctuation)) { $text = substr($text, 0, -1); @@ -559,11 +559,11 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ protected function capitalizeTitle($str) { - $exceptions = array('a', 'an', 'the', 'against', 'between', 'in', 'of', - 'to', 'and', 'but', 'for', 'nor', 'or', 'so', 'yet', 'to'); + $exceptions = ['a', 'an', 'the', 'against', 'between', 'in', 'of', + 'to', 'and', 'but', 'for', 'nor', 'or', 'so', 'yet', 'to']; $words = explode(' ', $str); - $newwords = array(); + $newwords = []; $followsColon = false; foreach ($words as $word) { // Capitalize words unless they are in the exception list... but even @@ -730,7 +730,7 @@ class Citation extends \Zend\View\Helper\AbstractHelper */ protected function getPublisher() { - $parts = array(); + $parts = []; if (isset($this->details['pubPlace']) && !empty($this->details['pubPlace']) ) { diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Context.php b/module/VuFind/src/VuFind/View/Helper/Root/Context.php index a166189040f..cf0dd466ecf 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Context.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Context.php @@ -55,7 +55,7 @@ class Context extends AbstractHelper { $view = $this->getView(); - $oldVars = array(); + $oldVars = []; foreach ($vars as $k => $v) { $oldVars[$k] = isset($view->$k) ? $view->$k : null; $view->$k = $v; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/DateTime.php b/module/VuFind/src/VuFind/View/Helper/Root/DateTime.php index 1fa135264a5..4432eeefb28 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/DateTime.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/DateTime.php @@ -82,12 +82,12 @@ class DateTime extends \Zend\View\Helper\AbstractHelper { $dueDateHelpString = $this->converter->convertToDisplayDate("m-d-y", "11-22-3333"); - $search = array("1", "2", "3"); - $replace = array( + $search = ["1", "2", "3"]; + $replace = [ $this->view->translate("date_month_placeholder"), $this->view->translate("date_day_placeholder"), $this->view->translate("date_year_placeholder") - ); + ]; return str_replace($search, $replace, $dueDateHelpString); } @@ -102,6 +102,6 @@ class DateTime extends \Zend\View\Helper\AbstractHelper */ public function __call($methodName, $params) { - return call_user_func_array(array($this->converter, $methodName), $params); + return call_user_func_array([$this->converter, $methodName], $params); } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php index fd3cef08bc1..39005a4b7f5 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php @@ -248,7 +248,7 @@ class Factory { $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); $config = isset($config->SearchHistoryLabels) - ? $config->SearchHistoryLabels->toArray() : array(); + ? $config->SearchHistoryLabels->toArray() : []; return new HistoryLabel($config, $sm->get('transesc')); } @@ -445,7 +445,7 @@ class Factory { $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); $config = isset($config->SearchTabs) - ? $config->SearchTabs->toArray() : array(); + ? $config->SearchTabs->toArray() : []; return new SearchTabs( $sm->getServiceLocator()->get('VuFind\SearchResultsPluginManager'), $config, $sm->get('url') @@ -497,7 +497,7 @@ class Factory if (!$setting) { $setting = 'disabled'; } - $whitelist = array('enabled', 'disabled', 'public_only', 'private_only'); + $whitelist = ['enabled', 'disabled', 'public_only', 'private_only']; if (!in_array($setting, $whitelist)) { $setting = 'enabled'; } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php index 1ec7cf97d73..4dfd203fac8 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php @@ -76,7 +76,7 @@ class Flashmessages extends AbstractHelper public function __invoke() { $html = ''; - $namespaces = array('error', 'info'); + $namespaces = ['error', 'info']; foreach ($namespaces as $ns) { $this->fm->setNamespace($ns); $messages = array_merge( @@ -97,7 +97,7 @@ class Flashmessages extends AbstractHelper } $helper = $helper ? $this->getView()->plugin($helper) : false; - $tokens = isset($msg['tokens']) ? $msg['tokens'] : array(); + $tokens = isset($msg['tokens']) ? $msg['tokens'] : []; $default = isset($msg['default']) ? $msg['default'] : null; $html .= $helper ? $helper($msg['msg'], $tokens, $default) : $msg['msg']; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/HelpText.php b/module/VuFind/src/VuFind/View/Helper/Root/HelpText.php index 24f320070fd..b2fc213ed4c 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/HelpText.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/HelpText.php @@ -66,7 +66,7 @@ class HelpText extends \Zend\View\Helper\AbstractHelper * * @var array */ - protected $warnings = array(); + protected $warnings = []; /** * Constructor @@ -107,14 +107,14 @@ class HelpText extends \Zend\View\Helper\AbstractHelper // Set up the needed context in the view: $this->contextHelper->__invoke($this->getView()); $oldContext = $this->contextHelper - ->apply(null === $context ? array() : $context); + ->apply(null === $context ? [] : $context); // Sanitize the template name to include only alphanumeric characters // or underscores. $safe_topic = preg_replace('/[^\w]/', '', $name); // Clear warnings - $this->warnings = array(); + $this->warnings = []; try { $tpl = "HelpTranslations/{$this->language}/{$safe_topic}.phtml"; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Highlight.php b/module/VuFind/src/VuFind/View/Helper/Root/Highlight.php index c98f06adbeb..2dcb2f89c06 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Highlight.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Highlight.php @@ -70,14 +70,14 @@ class Highlight extends AbstractHelper // if $haystack already has highlighting markers in it, we may want to send // in a blank needle. if (!is_array($needle)) { - $needle = empty($needle) ? array() : array($needle); + $needle = empty($needle) ? [] : [$needle]; } // Highlight search terms one phrase at a time; we just put in placeholders // for the start and end span tags at this point so we can do proper URL // encoding later. foreach ($needle as $phrase) { - $phrase = trim(str_replace(array('"', '*', '?'), '', $phrase)); + $phrase = trim(str_replace(['"', '*', '?'], '', $phrase)); if ($phrase != '') { $phrase = preg_quote($phrase, '/'); $haystack = preg_replace( @@ -89,8 +89,8 @@ class Highlight extends AbstractHelper // URL encode the string, then put in the highlight spans: $haystack = str_replace( - array('{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'), - array($this->startTag, $this->endTag), + ['{{{{START_HILITE}}}}', '{{{{END_HILITE}}}}'], + [$this->startTag, $this->endTag], htmlspecialchars($haystack) ); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/JqueryValidation.php b/module/VuFind/src/VuFind/View/Helper/Root/JqueryValidation.php index c293baadaf2..b9a20a5f79d 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/JqueryValidation.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/JqueryValidation.php @@ -52,10 +52,10 @@ class JqueryValidation extends AbstractHelper public function __invoke($params) { // jquery validation rules that this plugin currently supports - $supported_rules = array('required', 'email', 'digits', 'equalTo', - 'phoneUS', 'mobileUK'); - $messages = array(); - $rules = array(); + $supported_rules = ['required', 'email', 'digits', 'equalTo', + 'phoneUS', 'mobileUK']; + $messages = []; + $rules = []; foreach ($supported_rules as $rule) { if (isset($params[$rule])) { switch($rule) { diff --git a/module/VuFind/src/VuFind/View/Helper/Root/JsTranslations.php b/module/VuFind/src/VuFind/View/Helper/Root/JsTranslations.php index d7873423c98..bda2f1baced 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/JsTranslations.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/JsTranslations.php @@ -58,7 +58,7 @@ class JsTranslations extends AbstractHelper * * @var array */ - protected $strings = array(); + protected $strings = []; /** * Constructor @@ -93,7 +93,7 @@ class JsTranslations extends AbstractHelper */ public function getScript() { - $parts = array(); + $parts = []; foreach ($this->strings as $k => $v) { $parts[] = $k . ': "' . addslashes($this->transEsc->__invoke($v)) . '"'; } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/LocalizedNumber.php b/module/VuFind/src/VuFind/View/Helper/Root/LocalizedNumber.php index 65cb509dc78..4360dff6046 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/LocalizedNumber.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/LocalizedNumber.php @@ -68,10 +68,10 @@ class LocalizedNumber extends AbstractHelper $translator = $this->getView()->plugin('translate'); $decimalPoint = $translator( - 'number_decimal_point', array(), $this->defaultDecimalPoint + 'number_decimal_point', [], $this->defaultDecimalPoint ); $thousandSep = $translator( - 'number_thousands_separator', array(), $this->defaultThousandSep + 'number_thousands_separator', [], $this->defaultThousandSep ); $formattedNumber = number_format( $number, $decimals, $decimalPoint, $thousandSep diff --git a/module/VuFind/src/VuFind/View/Helper/Root/OpenUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/OpenUrl.php index bbf9e447e4e..b2f5a5ae85e 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/OpenUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/OpenUrl.php @@ -91,7 +91,7 @@ class OpenUrl extends \Zend\View\Helper\AbstractHelper } // Build parameters needed to display the control: - $params = array( + $params = [ 'openUrl' => $openUrl, 'openUrlBase' => empty($base) ? false : $base, 'openUrlWindow' => empty($this->config->window_settings) @@ -104,7 +104,7 @@ class OpenUrl extends \Zend\View\Helper\AbstractHelper ? false : $this->config->graphic_height, 'openUrlEmbed' => $embed, 'openUrlId' => $counter - ); + ]; // Render the subtemplate: return $this->context->__invoke($this->getView())->renderInContext( diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php index 1d257c4ef86..99ea13b4ded 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php @@ -206,11 +206,11 @@ class Piwik extends \Zend\View\Helper\AbstractHelper protected function getSearchCustomVars($results) { if (!$this->customVars) { - return array(); + return []; } - $facets = array(); - $facetTypes = array(); + $facets = []; + $facetTypes = []; $params = $results->getParams(); foreach ($params->getFilterList() as $filterType => $filters) { $facetTypes[] = $filterType; @@ -221,7 +221,7 @@ class Piwik extends \Zend\View\Helper\AbstractHelper $facets = implode("\t", $facets); $facetTypes = implode("\t", $facetTypes); - return array( + return [ 'Facets' => $facets, 'FacetTypes' => $facetTypes, 'SearchType' => $params->getSearchType(), @@ -230,7 +230,7 @@ class Piwik extends \Zend\View\Helper\AbstractHelper 'Page' => $params->getPage(), 'Limit' => $params->getLimit(), 'View' => $params->getView() - ); + ]; } /** @@ -263,11 +263,11 @@ class Piwik extends \Zend\View\Helper\AbstractHelper } $institutions = $institutions; - return array( + return [ 'RecordFormat' => $formats, 'RecordData' => "$id|$author|$title", 'RecordInstitution' => $institutions - ); + ]; } /** @@ -277,7 +277,7 @@ class Piwik extends \Zend\View\Helper\AbstractHelper */ protected function getGenericCustomVars() { - return array(); + return []; } /** diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php index 159a860a69e..be8789486f3 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php @@ -119,7 +119,7 @@ class Recaptcha extends AbstractHelper return $this->view->render( 'Service/recaptcha.phtml', - array( + [ 'challengeField' => $challengeField, 'errorPart' => $errorPart, 'host' => $host, @@ -128,7 +128,7 @@ class Recaptcha extends AbstractHelper 'responseField' => $responseField, 'theme' => $options['theme'], 'useRecaptcha' => $useRecaptcha, - ) + ] ); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Recommend.php b/module/VuFind/src/VuFind/View/Helper/Root/Recommend.php index eec701c558b..333452d5c6b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Recommend.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Recommend.php @@ -52,7 +52,7 @@ class Recommend extends AbstractHelper // Set up the rendering context: $contextHelper = $this->getView()->plugin('context'); $oldContext = $contextHelper($this->getView())->apply( - array('recommend' => $recommend) + ['recommend' => $recommend] ); // Get the current recommendation module's class name, then start a loop diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Record.php b/module/VuFind/src/VuFind/View/Helper/Root/Record.php index 4c1dd2bb535..bc6edf40660 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Record.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Record.php @@ -84,7 +84,7 @@ class Record extends AbstractHelper { // Set default context if none provided: if (is_null($context)) { - $context = array('driver' => $this->driver); + $context = ['driver' => $this->driver]; } // Set up the needed context in the view: @@ -192,7 +192,7 @@ class Record extends AbstractHelper public function getFormatClass($format) { return $this->renderTemplate( - 'format-class.phtml', array('format' => $format) + 'format-class.phtml', ['format' => $format] ); } @@ -224,12 +224,12 @@ class Record extends AbstractHelper } return $this->renderTemplate( 'list-entry.phtml', - array( + [ 'driver' => $this->driver, 'list' => $list, 'user' => $user, 'lists' => $lists - ) + ] ); } @@ -252,7 +252,7 @@ class Record extends AbstractHelper { return $this->renderTemplate( 'previewdata.phtml', - array('driver' => $this->driver, 'config' => $this->config) + ['driver' => $this->driver, 'config' => $this->config] ); } @@ -265,7 +265,7 @@ class Record extends AbstractHelper { return $this->renderTemplate( 'previewlink.phtml', - array('driver' => $this->driver, 'config' => $this->config) + ['driver' => $this->driver, 'config' => $this->config] ); } @@ -277,15 +277,15 @@ class Record extends AbstractHelper public function getPreviewIds() { // Extract identifiers from record driver if it supports appropriate methods: - $isbn = is_callable(array($this->driver, 'getCleanISBN')) + $isbn = is_callable([$this->driver, 'getCleanISBN']) ? $this->driver->getCleanISBN() : ''; - $lccn = is_callable(array($this->driver, 'getLCCN')) + $lccn = is_callable([$this->driver, 'getLCCN']) ? $this->driver->getLCCN() : ''; - $oclc = is_callable(array($this->driver, 'getOCLC')) - ? $this->driver->getOCLC() : array(); + $oclc = is_callable([$this->driver, 'getOCLC']) + ? $this->driver->getOCLC() : []; // Turn identifiers into class names to communicate with jQuery logic: - $idClasses = array(); + $idClasses = []; if (!empty($isbn)) { $idClasses[] = 'ISBN' . $isbn; } @@ -332,7 +332,7 @@ class Record extends AbstractHelper public function getLink($type, $lookfor) { return $this->renderTemplate( - 'link-' . $type . '.phtml', array('lookfor' => $lookfor) + 'link-' . $type . '.phtml', ['lookfor' => $lookfor] ); } @@ -345,7 +345,7 @@ class Record extends AbstractHelper */ public function getTab(\VuFind\RecordTab\TabInterface $tab) { - $context = array('driver' => $this->driver, 'tab' => $tab); + $context = ['driver' => $this->driver, 'tab' => $tab]; $classParts = explode('\\', get_class($tab)); $template = 'RecordTab/' . strtolower(array_pop($classParts)) . '.phtml'; $oldContext = $this->contextHelper->apply($context); @@ -389,7 +389,7 @@ class Record extends AbstractHelper $id = $this->driver->getResourceSource() . '|' . $this->driver->getUniqueId(); $context - = array('id' => $id, 'count' => $checkboxCount++, 'prefix' => $idPrefix); + = ['id' => $id, 'count' => $checkboxCount++, 'prefix' => $idPrefix]; return $this->contextHelper->renderInContext( 'record/checkbox.phtml', $context ); @@ -406,7 +406,7 @@ class Record extends AbstractHelper * * @return string|bool */ - public function getQrCode($context, $extra = array(), $level = "L", $size = 3, + public function getQrCode($context, $extra = [], $level = "L", $size = 3, $margin = 4 ) { if (!isset($this->config->QRCode)) { @@ -432,11 +432,11 @@ class Record extends AbstractHelper // Try to build text: $text = $this->renderTemplate( - $template, $extra + array('driver' => $this->driver) + $template, $extra + ['driver' => $this->driver] ); - $qrcode = array( + $qrcode = [ "text" => $text, 'level' => $level, 'size' => $size, 'margin' => $margin - ); + ]; $urlHelper = $this->getView()->plugin('url'); return $urlHelper('qrcode-show') . '?' . http_build_query($qrcode); @@ -453,7 +453,7 @@ class Record extends AbstractHelper public function getThumbnail($size = 'small') { // Try to build thumbnail: - $thumb = $this->driver->tryMethod('getThumbnail', array($size)); + $thumb = $this->driver->tryMethod('getThumbnail', [$size]); // No thumbnail? Return false: if (empty($thumb)) { @@ -495,7 +495,7 @@ class Record extends AbstractHelper // See if there are any links available: $urls = $this->driver->tryMethod('getURLs'); if (empty($urls)) { - return array(); + return []; } // If we found links, we may need to convert from the "route" format @@ -511,7 +511,7 @@ class Record extends AbstractHelper // Build URL from route/query details if missing: if (!isset($link['url'])) { $routeParams = isset($link['routeParams']) - ? $link['routeParams'] : array(); + ? $link['routeParams'] : []; $link['url'] = $serverUrlHelper( $urlHelper($link['route'], $routeParams) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Related.php b/module/VuFind/src/VuFind/View/Helper/Root/Related.php index b50ce423195..07a1b6b8c2e 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Related.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Related.php @@ -82,7 +82,7 @@ class Related extends AbstractHelper // Set up the rendering context: $contextHelper = $this->getView()->plugin('context'); $oldContext = $contextHelper($this->getView())->apply( - array('related' => $related) + ['related' => $related] ); // Get the current related item module's class name, then start a loop diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RenderArray.php b/module/VuFind/src/VuFind/View/Helper/Root/RenderArray.php index dac03ea5c88..cc0d9e4a35d 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/RenderArray.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/RenderArray.php @@ -56,8 +56,8 @@ class RenderArray extends AbstractHelper foreach ($rows as $label => $key) { if (isset($arr[$key])) { $html .= str_replace( - array('%%LABEL%%', '%%VALUE%%'), - array($label, $this->view->escapeHtml($arr[$key])), + ['%%LABEL%%', '%%VALUE%%'], + [$label, $this->view->escapeHtml($arr[$key])], $tpl ); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php index 52853f31d68..e6b16a5e9a3 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php @@ -171,7 +171,7 @@ class ResultFeed extends AbstractHelper } $author = $record->tryMethod('getPrimaryAuthor'); if (!empty($author)) { - $entry->addAuthor(array('name' => $author)); + $entry->addAuthor(['name' => $author]); } $formats = $record->tryMethod('getFormats'); if (is_array($formats)) { diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php index b1aff84f103..a51a69091b0 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php @@ -58,7 +58,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper * * @var array */ - protected $cachedConfigs = array(); + protected $cachedConfigs = []; /** * Constructor @@ -66,7 +66,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper * @param OptionsManager $optionsManager Search options plugin manager * @param array $config Configuration for search box */ - public function __construct(OptionsManager $optionsManager, $config = array()) + public function __construct(OptionsManager $optionsManager, $config = []) { $this->optionsManager = $optionsManager; $this->config = $config; @@ -127,7 +127,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper */ public function getFilterDetails($filterList, $checkboxFilters) { - $results = array(); + $results = []; foreach ($filterList as $field => $data) { foreach ($data as $value) { $results[] = "$field:\"$value\""; @@ -148,9 +148,9 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper $results[] = $current['filter']; } } - $final = array(); + $final = []; foreach ($results as $i => $val) { - $final[] = array('id' => 'applied_filter_' . ($i + 1), 'value' => $val); + $final[] = ['id' => 'applied_filter_' . ($i + 1), 'value' => $val]; } return $final; } @@ -182,13 +182,13 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper */ protected function getBasicHandlers($activeSearchClass, $activeHandler) { - $handlers = array(); + $handlers = []; $options = $this->optionsManager->get($activeSearchClass); foreach ($options->getBasicHandlers() as $searchVal => $searchDesc) { - $handlers[] = array( + $handlers[] = [ 'value' => $searchVal, 'label' => $searchDesc, 'indent' => false, 'selected' => ($activeHandler == $searchVal) - ); + ]; } return $handlers; } @@ -205,7 +205,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper if (!isset($this->cachedConfigs[$activeSearchClass])) { // Load and validate configuration: $settings = isset($this->config['CombinedHandlers']) - ? $this->config['CombinedHandlers'] : array(); + ? $this->config['CombinedHandlers'] : []; if (empty($settings)) { throw new \Exception('CombinedHandlers configuration missing.'); } @@ -241,7 +241,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper protected function getCombinedHandlers($activeSearchClass, $activeHandler) { // Build settings: - $handlers = array(); + $handlers = []; $selectedFound = false; $backupSelectedIndex = false; $settings = $this->getCombinedHandlerConfig($activeSearchClass); @@ -256,7 +256,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper $j = 0; $basic = $options->getBasicHandlers(); if (empty($basic)) { - $basic = array('' => ''); + $basic = ['' => '']; } foreach ($basic as $searchVal => $searchDesc) { $j++; @@ -269,18 +269,18 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper ) { $backupSelectedIndex = count($handlers); } - $handlers[] = array( + $handlers[] = [ 'value' => $type . ':' . $target . '|' . $searchVal, 'label' => $j == 1 ? $label : $searchDesc, 'indent' => $j == 1 ? false : true, 'selected' => $selected - ); + ]; } } else if ($type == 'External') { - $handlers[] = array( + $handlers[] = [ 'value' => $type . ':' . $target, 'label' => $label, 'indent' => false, 'selected' => false - ); + ]; } } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php index 48f67b0865a..8000cccac15 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php @@ -86,7 +86,7 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper */ public function __invoke($activeSearchClass, $query, $handler, $type = 'basic') { - $retVal = array(); + $retVal = []; foreach ($this->config as $class => $label) { if ($class == $activeSearchClass) { $retVal[] = $this->createSelectedTab($class, $label); @@ -117,11 +117,11 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper */ protected function createSelectedTab($class, $label) { - return array( + return [ 'class' => $class, 'label' => $label, 'selected' => true - ); + ]; } /** @@ -163,12 +163,12 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper */ protected function createBasicTab($class, $label, $newUrl) { - return array( + return [ 'class' => $class, 'label' => $label, 'selected' => false, 'url' => $newUrl - ); + ]; } /** @@ -185,12 +185,12 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper // to the search home: $options = $this->results->get($class)->getOptions(); $url = $this->url->__invoke($options->getSearchHomeAction()); - return array( + return [ 'class' => $class, 'label' => $label, 'selected' => false, 'url' => $url - ); + ]; } /** @@ -209,11 +209,11 @@ class SearchTabs extends \Zend\View\Helper\AbstractHelper $advSearch = $options->getAdvancedSearchAction(); $url = $this->url ->__invoke($advSearch ? $advSearch : $options->getSearchHomeAction()); - return array( + return [ 'class' => $class, 'label' => $label, 'selected' => false, 'url' => $url - ); + ]; } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SortFacetList.php b/module/VuFind/src/VuFind/View/Helper/Root/SortFacetList.php index fecd530aee0..52a7806e91b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SortFacetList.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SortFacetList.php @@ -54,7 +54,7 @@ class SortFacetList extends AbstractHelper */ public function __invoke($results, $field, $list, $searchRoute) { - $facets = array(); + $facets = []; // avoid limit on URL $results->getParams()->setLimit($results->getOptions()->getDefaultLimit()); $urlHelper = $this->getView()->plugin('url'); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/TransEsc.php b/module/VuFind/src/VuFind/View/Helper/Root/TransEsc.php index bee5e9ac479..85996bef930 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/TransEsc.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/TransEsc.php @@ -49,7 +49,7 @@ class TransEsc extends AbstractHelper * * @return string */ - public function __invoke($str, $tokens = array(), $default = null) + public function __invoke($str, $tokens = [], $default = null) { $escaper = $this->getView()->plugin('escapeHtml'); $translator = $this->getView()->plugin('translate'); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Translate.php b/module/VuFind/src/VuFind/View/Helper/Root/Translate.php index 6df6ff82ef5..22c98cd16bb 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Translate.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Translate.php @@ -51,7 +51,7 @@ class Translate extends \Zend\View\Helper\AbstractHelper * * @return string */ - public function __invoke($str, $tokens = array(), $default = null) + public function __invoke($str, $tokens = [], $default = null) { return $this->translate($str, $tokens, $default); } diff --git a/module/VuFind/src/VuFind/View/Helper/jQueryMobile/MobileMenu.php b/module/VuFind/src/VuFind/View/Helper/jQueryMobile/MobileMenu.php index 943809c84f1..3ffe37ee558 100644 --- a/module/VuFind/src/VuFind/View/Helper/jQueryMobile/MobileMenu.php +++ b/module/VuFind/src/VuFind/View/Helper/jQueryMobile/MobileMenu.php @@ -47,7 +47,7 @@ class MobileMenu extends AbstractHelper * * @return string */ - public function header($extras = array()) + public function header($extras = []) { $context = $this->getView()->plugin('context'); return $context($this->getView())->renderInContext('header.phtml', $extras); @@ -61,7 +61,7 @@ class MobileMenu extends AbstractHelper * * @return string */ - public function footer($extras = array()) + public function footer($extras = []) { $context = $this->getView()->plugin('context'); return $context($this->getView())->renderInContext('footer.phtml', $extras); diff --git a/module/VuFind/src/VuFind/XSLT/Import/VuFind.php b/module/VuFind/src/VuFind/XSLT/Import/VuFind.php index 74a0fa25a9d..a92fab34087 100644 --- a/module/VuFind/src/VuFind/XSLT/Import/VuFind.php +++ b/module/VuFind/src/VuFind/XSLT/Import/VuFind.php @@ -287,14 +287,14 @@ class VuFind $tika = $settings->Tika->path; // We need to use this method to get the output from STDOUT into the file - $descriptorspec = array( - 0 => array('pipe', 'r'), - 1 => array('file', $output, 'w'), - 2 => array('pipe', 'w') - ); - return array( - "java -jar $tika $arg -eUTF8 $input", $descriptorspec, array() - ); + $descriptorspec = [ + 0 => ['pipe', 'r'], + 1 => ['file', $output, 'w'], + 2 => ['pipe', 'w'] + ]; + return [ + "java -jar $tika $arg -eUTF8 $input", $descriptorspec, [] + ]; } /** @@ -342,7 +342,7 @@ class VuFind // Load the translation map and send back the appropriate value. Note // that PHP's parse_ini_file() function is not compatible with SolrMarc's // style of properties map, so we are parsing this manually. - $map = array(); + $map = []; $mapFile = ConfigLocator::getConfigPath($filename, 'import/translation_maps'); foreach (file($mapFile) as $line) { @@ -364,7 +364,7 @@ class VuFind */ public static function stripArticles($in) { - static $articles = array('a', 'an', 'the'); + static $articles = ['a', 'an', 'the']; $text = strtolower(trim($in)); @@ -390,7 +390,7 @@ class VuFind { // Ensure that $in is an array: if (!is_array($in)) { - $in = array($in); + $in = [$in]; } // Start building return value: @@ -424,7 +424,7 @@ class VuFind { // Ensure that $in is an array: if (!is_array($in)) { - $in = array($in); + $in = [$in]; } foreach ($in as $current) { diff --git a/module/VuFind/src/VuFind/XSLT/Import/VuFindSitemap.php b/module/VuFind/src/VuFind/XSLT/Import/VuFindSitemap.php index 0b60addb5f8..149a319b77d 100644 --- a/module/VuFind/src/VuFind/XSLT/Import/VuFindSitemap.php +++ b/module/VuFind/src/VuFind/XSLT/Import/VuFindSitemap.php @@ -72,7 +72,7 @@ class VuFindSitemap extends VuFind // Extract the keywords from the XML: preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches); - $keywords = array(); + $keywords = []; if (isset($matches[1])) { foreach ($matches[1] as $current) { $keywords[] = html_entity_decode($current, ENT_QUOTES, 'UTF-8'); @@ -85,12 +85,12 @@ class VuFindSitemap extends VuFind ? html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8') : ''; // Send back the extracted fields: - return array( + return [ 'title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final, - ); + ]; } /** @@ -114,7 +114,7 @@ class VuFindSitemap extends VuFind preg_match_all( '/<meta name="keywords" content="([^"]*)"/ms', $xml, $matches ); - $keywords = array(); + $keywords = []; if (isset($matches[1])) { foreach ($matches[1] as $current) { $keywords[] = html_entity_decode($current, ENT_QUOTES, 'UTF-8'); @@ -127,12 +127,12 @@ class VuFindSitemap extends VuFind ? html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8') : ''; // Send back the extracted fields: - return array( + return [ 'title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $title . ' ' . static::harvestWithTika($htmlFile), - ); + ]; } /** @@ -151,7 +151,7 @@ class VuFindSitemap extends VuFind preg_match_all( '/<meta name="subject" content="([^"]*)"/ms', $html, $matches ); - $subjects = array(); + $subjects = []; if (isset($matches[1])) { foreach ($matches[1] as $current) { $subjects[] = html_entity_decode($current, ENT_QUOTES, 'UTF-8'); @@ -162,7 +162,7 @@ class VuFindSitemap extends VuFind preg_match_all( '/<meta name="category" content="([^"]*)"/ms', $html, $matches ); - $categories = array(); + $categories = []; if (isset($matches[1])) { foreach ($matches[1] as $current) { $categories[] = html_entity_decode($current, ENT_QUOTES, 'UTF-8'); @@ -175,11 +175,11 @@ class VuFindSitemap extends VuFind ); $useCount = isset($matches[1][0]) ? $matches[1][0] : 1; - return array( + return [ 'category' => $categories, 'subject' => $subjects, 'use_count' => $useCount, - ); + ]; } /** @@ -193,7 +193,7 @@ class VuFindSitemap extends VuFind { $xml = ''; foreach ($fields as $key => $value) { - $value = is_array($value) ? $value : array($value); + $value = is_array($value) ? $value : [$value]; foreach ($value as $current) { if (!empty($current)) { $xml .= '<field name="' . $key . '">' @@ -232,7 +232,7 @@ class VuFindSitemap extends VuFind { $parser = static::getParser(); if ($parser == 'None') { - return array(); + return []; } // Grab the HTML and write it to disk: diff --git a/module/VuFind/src/VuFind/XSLT/Importer.php b/module/VuFind/src/VuFind/XSLT/Importer.php index 972ce8d8ed9..abc013b5a3e 100644 --- a/module/VuFind/src/VuFind/XSLT/Importer.php +++ b/module/VuFind/src/VuFind/XSLT/Importer.php @@ -141,7 +141,7 @@ class Importer implements ServiceLocatorAwareInterface if (isset($options['General']['php_function'])) { $functions = is_array($options['General']['php_function']) ? $options['General']['php_function'] - : array($options['General']['php_function']); + : [$options['General']['php_function']]; foreach ($functions as $function) { $xsl->registerPHPFunctions($function); } @@ -151,7 +151,7 @@ class Importer implements ServiceLocatorAwareInterface if (isset($options['General']['custom_class'])) { $classes = is_array($options['General']['custom_class']) ? $options['General']['custom_class'] - : array($options['General']['custom_class']); + : [$options['General']['custom_class']]; $truncate = isset($options['General']['truncate_custom_class']) ? $options['General']['truncate_custom_class'] : true; foreach ($classes as $class) { diff --git a/module/VuFind/src/VuFind/XSLT/Processor.php b/module/VuFind/src/VuFind/XSLT/Processor.php index 27c204dc5be..290b772e920 100644 --- a/module/VuFind/src/VuFind/XSLT/Processor.php +++ b/module/VuFind/src/VuFind/XSLT/Processor.php @@ -48,7 +48,7 @@ class Processor * * @return string Transformed XML */ - public static function process($xslt, $xml, $params = array()) + public static function process($xslt, $xml, $params = []) { $style = new DOMDocument(); // TODO: support local overrides diff --git a/module/VuFind/src/VuFindTest/RecordDriver/TestHarness.php b/module/VuFind/src/VuFindTest/RecordDriver/TestHarness.php index c4f655718b0..30edab3a4dd 100644 --- a/module/VuFind/src/VuFindTest/RecordDriver/TestHarness.php +++ b/module/VuFind/src/VuFindTest/RecordDriver/TestHarness.php @@ -65,7 +65,7 @@ class TestHarness extends \VuFind\RecordDriver\AbstractBase */ public function getBreadcrumb() { - return $this->__call('getBreadcrumb', array()); + return $this->__call('getBreadcrumb', []); } /** @@ -76,6 +76,6 @@ class TestHarness extends \VuFind\RecordDriver\AbstractBase */ public function getUniqueID() { - return $this->__call('getUniqueID', array()); + return $this->__call('getUniqueID', []); } } diff --git a/module/VuFind/src/VuFindTest/Search/TestHarness/Results.php b/module/VuFind/src/VuFindTest/Search/TestHarness/Results.php index af9023b6b83..cf9b94840d2 100644 --- a/module/VuFind/src/VuFindTest/Search/TestHarness/Results.php +++ b/module/VuFind/src/VuFindTest/Search/TestHarness/Results.php @@ -53,7 +53,7 @@ class Results extends \VuFind\Search\Base\Results * * @var array */ - protected $driverCache = array(); + protected $driverCache = []; /** * Constructor @@ -80,7 +80,7 @@ class Results extends \VuFind\Search\Base\Results public function getFacetList($filter = null) { // not supported - return array(); + return []; } /** @@ -93,7 +93,7 @@ class Results extends \VuFind\Search\Base\Results protected function performSearch() { $this->resultTotal = $this->fakeExpectedTotal; - $this->results = array(); + $this->results = []; $limit = $this->getParams()->getLimit(); $start = $this->getStartRecord(); for ($i = $start; $i < $start + $limit; $i++) { @@ -115,7 +115,7 @@ class Results extends \VuFind\Search\Base\Results { if (!isset($this->driverCache[$id])) { $this->driverCache[$id] = new RecordDriver(); - $this->driverCache[$id]->setRawData(array('UniqueID' => $id)); + $this->driverCache[$id]->setRawData(['UniqueID' => $id]); } return $this->driverCache[$id]; } diff --git a/module/VuFind/src/VuFindTest/Unit/DbTestCase.php b/module/VuFind/src/VuFindTest/Unit/DbTestCase.php index 33e95140210..bbdddfb0e2c 100644 --- a/module/VuFind/src/VuFindTest/Unit/DbTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/DbTestCase.php @@ -57,14 +57,14 @@ abstract class DbTestCase extends TestCase $sm->setService('VuFind\DbAdapter', $dbFactory->getAdapter()); $factory = new \VuFind\Db\Table\PluginManager( new \Zend\ServiceManager\Config( - array( + [ 'abstract_factories' => - array('VuFind\Db\Table\PluginFactory'), - 'factories' => array( + ['VuFind\Db\Table\PluginFactory'], + 'factories' => [ 'resource' => 'VuFind\Db\Table\Factory::getResource', 'user' => 'VuFind\Db\Table\Factory::getUser', - ) - ) + ] + ] ) ); $factory->setServiceLocator($sm); @@ -74,22 +74,22 @@ abstract class DbTestCase extends TestCase $sm->setAllowOverride(true); $sm->setService( 'config', - array( - 'vufind' => array( - 'pgsql_seq_mapping' => array( - 'comments' => array('id', 'comments_id_seq'), - 'oai_resumption' => array('id', 'oai_resumption_id_seq'), - 'resource' => array('id', 'resource_id_seq'), - 'resource_tags' => array('id', 'resource_tags_id_seq'), - 'search' => array('id', 'search_id_seq'), - 'session' => array('id', 'session_id_seq'), - 'tags' => array('id', 'tags_id_seq'), - 'user' => array('id', 'user_id_seq'), - 'user_list' => array('id', 'user_list_id_seq'), - 'user_resource' => array('id', 'user_resource_id_seq') - ) - ) - ) + [ + 'vufind' => [ + 'pgsql_seq_mapping' => [ + 'comments' => ['id', 'comments_id_seq'], + 'oai_resumption' => ['id', 'oai_resumption_id_seq'], + 'resource' => ['id', 'resource_id_seq'], + 'resource_tags' => ['id', 'resource_tags_id_seq'], + 'search' => ['id', 'search_id_seq'], + 'session' => ['id', 'session_id_seq'], + 'tags' => ['id', 'tags_id_seq'], + 'user' => ['id', 'user_id_seq'], + 'user_list' => ['id', 'user_list_id_seq'], + 'user_resource' => ['id', 'user_resource_id_seq'] + ] + ] + ] ); } return $sm; diff --git a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php index 2f8d22ec401..8ac1c25401f 100644 --- a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php @@ -182,7 +182,7 @@ abstract class MinkTestCase extends TestCase } // Reset the modified configs list. - $this->modifiedConfigs = array(); + $this->modifiedConfigs = []; } /** diff --git a/module/VuFind/src/VuFindTest/Unit/RecommendDeferredTestCase.php b/module/VuFind/src/VuFindTest/Unit/RecommendDeferredTestCase.php index 3040c53d003..a30423fc349 100644 --- a/module/VuFind/src/VuFindTest/Unit/RecommendDeferredTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/RecommendDeferredTestCase.php @@ -56,7 +56,7 @@ abstract class RecommendDeferredTestCase extends TestCase $results = $this->getMockResults(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $mod = new $class(); $mod->setConfig($settings); diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php index d2d9ea0bb6f..70c3080d11d 100644 --- a/module/VuFind/src/VuFindTest/Unit/TestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php @@ -59,7 +59,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase * * @return mixed */ - protected function callMethod($object, $method, array $arguments = array()) + protected function callMethod($object, $method, array $arguments = []) { $reflectionMethod = new \ReflectionMethod($object, $method); $reflectionMethod->setAccessible(true); @@ -113,12 +113,12 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase protected function setupSearchService() { $smConfig = new \Zend\ServiceManager\Config( - array( - 'factories' => array( + [ + 'factories' => [ 'Solr' => 'VuFind\Search\Factory\SolrDefaultBackendFactory', 'SolrAuth' => 'VuFind\Search\Factory\SolrAuthBackendFactory', - ) - ) + ] + ] ); $registry = $this->serviceManager->createScopedServiceManager(); $smConfig->configureServiceManager($registry); @@ -129,7 +129,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase $fh = new \VuFind\Search\Solr\HierarchicalFacetHelper(); $this->serviceManager->setService('VuFind\HierarchicalFacetHelper', $fh); $events = $ss->getEventManager(); - $events->attach('resolve', array($bm, 'onResolve')); + $events->attach('resolve', [$bm, 'onResolve']); } /** @@ -143,11 +143,11 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase $this->serviceManager = new \Zend\ServiceManager\ServiceManager(); $optionsFactory = new \VuFind\Search\Options\PluginManager( new \Zend\ServiceManager\Config( - array( + [ 'abstract_factories' => - array('VuFind\Search\Options\PluginFactory'), - 'aliases' => array('VuFind' => 'Solr'), - ) + ['VuFind\Search\Options\PluginFactory'], + 'aliases' => ['VuFind' => 'Solr'], + ] ) ); $optionsFactory->setServiceLocator($this->serviceManager); @@ -156,11 +156,11 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ); $paramsFactory = new \VuFind\Search\Params\PluginManager( new \Zend\ServiceManager\Config( - array( + [ 'abstract_factories' => - array('VuFind\Search\Params\PluginFactory'), - 'aliases' => array('VuFind' => 'Solr'), - ) + ['VuFind\Search\Params\PluginFactory'], + 'aliases' => ['VuFind' => 'Solr'], + ] ) ); $paramsFactory->setServiceLocator($this->serviceManager); @@ -169,11 +169,11 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ); $resultsFactory = new \VuFind\Search\Results\PluginManager( new \Zend\ServiceManager\Config( - array( + [ 'abstract_factories' => - array('VuFind\Search\Results\PluginFactory'), - 'aliases' => array('VuFind' => 'Solr'), - ) + ['VuFind\Search\Results\PluginFactory'], + 'aliases' => ['VuFind' => 'Solr'], + ] ) ); $resultsFactory->setServiceLocator($this->serviceManager); @@ -182,10 +182,10 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ); $recordDriverFactory = new \VuFind\RecordDriver\PluginManager( new \Zend\ServiceManager\Config( - array( + [ 'abstract_factories' => - array('VuFind\RecordDriver\PluginFactory') - ) + ['VuFind\RecordDriver\PluginFactory'] + ] ) ); $this->serviceManager->setService( @@ -202,7 +202,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ); $this->setupSearchService(); $cfg = new \Zend\ServiceManager\Config( - array('abstract_factories' => array('VuFind\Config\PluginFactory')) + ['abstract_factories' => ['VuFind\Config\PluginFactory']] ); $this->serviceManager->setService( 'VuFind\Config', new \VuFind\Config\PluginManager($cfg) @@ -216,7 +216,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase $this->serviceManager->get('VuFind\RecordDriverPluginManager') ) ); - $this->serviceManager->setService('Config', array()); + $this->serviceManager->setService('Config', []); $factory = new \Zend\Mvc\Service\TranslatorServiceFactory(); $this->serviceManager->setService( 'VuFind\Translator', $factory->createService($this->serviceManager) @@ -236,9 +236,9 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase if (!$sm->has('VuFind\AuthPluginManager')) { $authManager = new \VuFind\Auth\PluginManager( new \Zend\ServiceManager\Config( - array( - 'abstract_factories' => array('VuFind\Auth\PluginFactory'), - ) + [ + 'abstract_factories' => ['VuFind\Auth\PluginFactory'], + ] ) ); $authManager->setServiceLocator($sm); diff --git a/module/VuFind/src/VuFindTest/Unit/ViewHelperTestCase.php b/module/VuFind/src/VuFindTest/Unit/ViewHelperTestCase.php index d0aba580a52..f8c0f8ec452 100644 --- a/module/VuFind/src/VuFindTest/Unit/ViewHelperTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/ViewHelperTestCase.php @@ -47,7 +47,7 @@ abstract class ViewHelperTestCase extends TestCase * * @return \Zend\View\Renderer\PhpRenderer */ - protected function getPhpRenderer($plugins = array(), $theme = 'blueprint') + protected function getPhpRenderer($plugins = [], $theme = 'blueprint') { $resolver = new \Zend\View\Resolver\TemplatePathStack(); @@ -55,10 +55,10 @@ abstract class ViewHelperTestCase extends TestCase // from root with no intermediate themes. Probably safe for most // test situations, though other scenarios are possible. $resolver->setPaths( - array( + [ $this->getPathForTheme('root'), $this->getPathForTheme($theme) - ) + ] ); $renderer = new \Zend\View\Renderer\PhpRenderer(); $renderer->setResolver($resolver); diff --git a/module/VuFind/tests/bootstrap.php b/module/VuFind/tests/bootstrap.php index fb7be96e1be..e951bd4a78a 100644 --- a/module/VuFind/tests/bootstrap.php +++ b/module/VuFind/tests/bootstrap.php @@ -22,7 +22,7 @@ chdir(APPLICATION_PATH); // Ensure vendor/ is on include_path; some PEAR components may not load correctly // otherwise (i.e. File_MARC may cause a "Cannot redeclare class" error by pulling // from the shared PEAR directory instead of the local copy): -$pathParts = array(); +$pathParts = []; $pathParts[] = APPLICATION_PATH . '/vendor'; $pathParts[] = get_include_path(); set_include_path(implode(PATH_SEPARATOR, $pathParts)); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php index dcbc60a8adc..47895258d22 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/DatabaseTest.php @@ -115,13 +115,13 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getAccountCreationRequest($overrides = array()) + protected function getAccountCreationRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'email' => 'user@test.com', 'password' => 'testpass', 'password2' => 'testpass', 'firstname' => 'Test', 'lastname' => 'User' - ); + ]; return $this->getRequest($post); } @@ -133,11 +133,11 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'password' => 'testpass' - ); + ]; return $this->getRequest($post); } @@ -149,7 +149,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('username' => '')); + $request = $this->getAccountCreationRequest(['username' => '']); $this->auth->create($request); } @@ -161,7 +161,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('password' => '')); + $request = $this->getAccountCreationRequest(['password' => '']); $this->auth->create($request); } @@ -173,7 +173,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithPasswordMismatch() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('password2' => '')); + $request = $this->getAccountCreationRequest(['password2' => '']); $this->auth->create($request); } @@ -185,7 +185,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithInvalidEmail() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('email' => 'garbage')); + $request = $this->getAccountCreationRequest(['email' => 'garbage']); $this->auth->create($request); } @@ -208,7 +208,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithDuplicateUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('email' => 'user2@test.com')); + $request = $this->getAccountCreationRequest(['email' => 'user2@test.com']); $this->auth->create($request); } @@ -220,7 +220,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testCreationWithDuplicateEmail() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getAccountCreationRequest(array('username' => 'testuser2')); + $request = $this->getAccountCreationRequest(['username' => 'testuser2']); $this->auth->create($request); } @@ -232,7 +232,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->auth->authenticate($request); } @@ -244,7 +244,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->auth->authenticate($request); } @@ -256,7 +256,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithUnrecognizedUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => 'unknown')); + $request = $this->getLoginRequest(['username' => 'unknown']); $this->auth->authenticate($request); } @@ -268,7 +268,7 @@ class DatabaseTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBadPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => "' OR 1=1 LIMIT 1")); + $request = $this->getLoginRequest(['password' => "' OR 1=1 LIMIT 1"]); $this->auth->authenticate($request); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php index 47cd7399ca1..1f81e47f6f8 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ILSTest.php @@ -91,10 +91,10 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase $driverManager->setService('Sample', $this->driver); $mockConfigReader = $this->getMock('VuFind\Config\PluginManager'); $mockConfigReader->expects($this->any())->method('get') - ->will($this->returnValue(new \Zend\Config\Config(array()))); + ->will($this->returnValue(new \Zend\Config\Config([]))); $this->auth = new \VuFind\Auth\ILS( new \VuFind\ILS\Connection( - new \Zend\Config\Config(array('driver' => 'Sample')), + new \Zend\Config\Config(['driver' => 'Sample']), $driverManager, $mockConfigReader ), $this->getMockILSAuthenticator() @@ -123,11 +123,11 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'password' => 'testpass' - ); + ]; $request = new \Zend\Http\Request(); $request->setPost(new \Zend\Stdlib\Parameters($post)); return $request; @@ -141,7 +141,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->auth->authenticate($request); } @@ -153,7 +153,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->auth->authenticate($request); } @@ -166,7 +166,7 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase { // VuFind requires the ILS driver to return a value in cat_username // by default -- if that is missing, we should fail. - $response = array(); + $response = []; $this->driver->expects($this->once())->method('patronLogin') ->with($this->equalTo('testuser'), $this->equalTo('testpass')) ->will($this->returnValue($response)); @@ -181,10 +181,10 @@ class ILSTest extends \VuFindTest\Unit\DbTestCase */ public function testLogin() { - $response = array( + $response = [ 'cat_username' => 'testuser', 'cat_password' => 'testpass', 'email' => 'user@test.com' - ); + ]; $this->driver->expects($this->once())->method('patronLogin') ->with($this->equalTo('testuser'), $this->equalTo('testpass')) ->will($this->returnValue($response)); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php index fa5b9d1f600..1946cd45387 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Auth/ShibbolethTest.php @@ -99,15 +99,15 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase public function getAuthConfig() { $ldapConfig = new Config( - array( + [ 'login' => 'http://myserver', 'username' => 'username', 'email' => 'email', 'userattribute_1' => 'password', 'userattribute_value_1' => 'testpass' - ), true + ], true ); - return new Config(array('Shibboleth' => $ldapConfig), true); + return new Config(['Shibboleth' => $ldapConfig], true); } /** @@ -128,12 +128,12 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $server = $overrides + array( + $server = $overrides + [ 'username' => 'testuser', 'email' => 'user@test.com', 'password' => 'testpass' - ); + ]; $request = new \Zend\Http\PhpEnvironment\Request(); $request->setServer(new \Zend\Stdlib\Parameters($server)); return $request; @@ -147,7 +147,7 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -159,7 +159,7 @@ class ShibbolethTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php index 2f1ed678c40..89f628b75bf 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Db/Table/ChangeTrackerTest.php @@ -116,6 +116,6 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase $this->assertEquals($row->last_record_change, '2012-01-17 20:46:10'); // Clean up after ourselves: - $tracker->delete(array('core' => $core)); + $tracker->delete(['core' => $core]); } } \ No newline at end of file diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AdvancedSearchTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AdvancedSearchTest.php index bcc82d70d03..74e6f1bb271 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AdvancedSearchTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/AdvancedSearchTest.php @@ -47,7 +47,7 @@ class AdvancedSearchTest extends \VuFindTest\Unit\MinkTestCase { // Change the theme: $this->changeConfigs( - array('config' => array('Site' => array('theme' => 'bootstrap3'))) + ['config' => ['Site' => ['theme' => 'bootstrap3']]] ); // Go to the advanced search page diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php index 32291f88922..ecb716892eb 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/CartTest.php @@ -47,7 +47,7 @@ class CartTest extends \VuFindTest\Unit\MinkTestCase { // Activate the cart: $this->changeConfigs( - array('config' => array('Site' => array('showBookBag' => true))) + ['config' => ['Site' => ['showBookBag' => true]]] ); $session = $this->getMinkSession(); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php index cbcc6095574..ac18d11d16e 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php @@ -64,11 +64,11 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase ->will($this->returnValue('/test/path')); $recordLink = $this->getMock( - 'VuFind\View\Helper\Root\RecordLink', array(), - array(new \VuFind\Record\Router( + 'VuFind\View\Helper\Root\RecordLink', [], + [new \VuFind\Record\Router( $this->getServiceManager()->get('VuFind\RecordLoader'), - new \Zend\Config\Config(array())) - ) + new \Zend\Config\Config([])) + ] ); $recordLink->expects($this->any())->method('getUrl') ->will($this->returnValue('test/url')); @@ -77,11 +77,11 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase $serverUrl->expects($this->any())->method('__invoke') ->will($this->returnValue('http://server/url')); - return array( + return [ 'currentpath' => $currentPath, 'recordlink' => $recordLink, 'serverurl' => $serverUrl - ); + ]; } /** @@ -126,7 +126,7 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase $parsedFeed->getDescription(), 'Displaying the top 2 search results of 2 found' ); - $items = array(); + $items = []; $i = 0; foreach ($parsedFeed as $item) { $items[$i++] = $item; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php index e95fd51e87b..35507d0a140 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ChoiceAuthTest.php @@ -51,7 +51,7 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase public function testBadConfiguration() { $ca = new ChoiceAuth(); - $ca->setConfig(new Config(array())); + $ca->setConfig(new Config([])); } /** @@ -133,7 +133,7 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase */ public function testGetSelectableAuthOptions() { - $this->assertEquals(array('Database', 'Shibboleth'), $this->getChoiceAuth()->getSelectableAuthOptions()); + $this->assertEquals(['Database', 'Shibboleth'], $this->getChoiceAuth()->getSelectableAuthOptions()); } /** @@ -209,7 +209,7 @@ class ChoiceAuthTest extends \VuFindTest\Unit\TestCase { $ca = new ChoiceAuth(); $ca->setConfig( - new Config(array('ChoiceAuth' => array('choice_order' => $strategies))) + new Config(['ChoiceAuth' => ['choice_order' => $strategies]]) ); $ca->setPluginManager($pm ?: $this->getMockPluginManager()); return $ca; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php index eec0de96929..113d1a0b89b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/DatabaseUnitTest.php @@ -106,7 +106,7 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase { // Fake services: $table = $this->getMock( - 'VuFind\Db\Table\Tags', array('getByEmail', 'getByUsername') + 'VuFind\Db\Table\Tags', ['getByEmail', 'getByUsername'] ); $table->expects($this->once())->method('getByEmail') ->with($this->equalTo('me@mysite.com')) @@ -131,7 +131,7 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase { // Fake services: $table = $this->getMock( - 'VuFind\Db\Table\Tags', array('getByUsername') + 'VuFind\Db\Table\Tags', ['getByUsername'] ); $table->expects($this->any())->method('getByUsername') ->with($this->equalTo('good')) @@ -151,7 +151,7 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase { // Fake services: $table = $this->getMock( - 'VuFind\Db\Table\Tags', array('insert', 'getByEmail', 'getByUsername') + 'VuFind\Db\Table\Tags', ['insert', 'getByEmail', 'getByUsername'] ); $table->expects($this->once())->method('insert'); $table->expects($this->once())->method('getByEmail') @@ -175,14 +175,14 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase */ protected function getCreateParams() { - return array( + return [ 'firstname' => 'Foo', 'lastname' => 'Bar', 'username' => 'good', 'password' => 'pass', 'password2' => 'pass', 'email' => 'me@mysite.com', - ); + ]; } /** @@ -192,11 +192,11 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\PhpEnvironment\Request */ - protected function getRequest($post = array()) + protected function getRequest($post = []) { $post = new Parameters($post); $request - = $this->getMock('Zend\Http\PhpEnvironment\Request', array('getPost')); + = $this->getMock('Zend\Http\PhpEnvironment\Request', ['getPost']); $request->expects($this->any())->method('getPost') ->will($this->returnValue($post)); return $request; @@ -212,7 +212,7 @@ class DatabaseUnitTest extends \VuFindTest\Unit\DbTestCase protected function getDatabase($table) { $tableManager - = $this->getMock('VuFind\Db\Table\PluginManager', array('get')); + = $this->getMock('VuFind\Db\Table\PluginManager', ['get']); $tableManager->expects($this->once())->method('get') ->with($this->equalTo('User')) ->will($this->returnValue($table)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php index 7c4f4a4df8a..28b718af024 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ILSAuthenticatorTest.php @@ -47,13 +47,13 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testNewCatalogLoginSuccess() { - $user = $this->getMockUser(array('saveCredentials')); + $user = $this->getMockUser(['saveCredentials']); $user->expects($this->once())->method('saveCredentials')->with($this->equalTo('user'), $this->equalTo('pass')); - $manager = $this->getMockManager(array('isLoggedIn', 'updateSession')); + $manager = $this->getMockManager(['isLoggedIn', 'updateSession']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue($user)); $manager->expects($this->once())->method('updateSession')->with($this->equalTo($user)); - $details = array('foo' => 'bar'); - $connection = $this->getMockConnection(array('patronLogin')); + $details = ['foo' => 'bar']; + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->returnValue($details)); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals($details, $auth->newCatalogLogin('user', 'pass')); @@ -66,10 +66,10 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testNewCatalogFailure() { - $manager = $this->getMockManager(array('isLoggedIn')); + $manager = $this->getMockManager(['isLoggedIn']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue(false)); $details = false; - $connection = $this->getMockConnection(array('patronLogin')); + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->returnValue($details)); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals($details, $auth->newCatalogLogin('user', 'pass')); @@ -83,7 +83,7 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase public function testNewCatalogFailureByException() { $manager = $this->getMockManager(); - $connection = $this->getMockConnection(array('patronLogin')); + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->throwException(new \VuFind\Exception\ILS('kaboom'))); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals(false, $auth->newCatalogLogin('user', 'pass')); @@ -96,7 +96,7 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testLoggedOutStoredLoginAttempt() { - $manager = $this->getMockManager(array('isLoggedIn')); + $manager = $this->getMockManager(['isLoggedIn']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue(false)); $auth = $this->getAuthenticator($manager); $this->assertEquals(false, $auth->storedCatalogLogin()); @@ -109,14 +109,14 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testSuccessfulStoredLoginAttempt() { - $user = $this->getMockUser(array('__get', '__isset', 'getCatPassword')); + $user = $this->getMockUser(['__get', '__isset', 'getCatPassword']); $user->expects($this->any())->method('__get')->with($this->equalTo('cat_username'))->will($this->returnValue('user')); $user->expects($this->any())->method('__isset')->with($this->equalTo('cat_username'))->will($this->returnValue(true)); $user->expects($this->any())->method('getCatPassword')->will($this->returnValue('pass')); - $manager = $this->getMockManager(array('isLoggedIn')); + $manager = $this->getMockManager(['isLoggedIn']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue($user)); - $details = array('foo' => 'bar'); - $connection = $this->getMockConnection(array('patronLogin')); + $details = ['foo' => 'bar']; + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->returnValue($details)); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals($details, $auth->storedCatalogLogin()); @@ -133,14 +133,14 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testUnsuccessfulStoredLoginAttempt() { - $user = $this->getMockUser(array('__get', '__isset', 'clearCredentials', 'getCatPassword')); + $user = $this->getMockUser(['__get', '__isset', 'clearCredentials', 'getCatPassword']); $user->expects($this->any())->method('__get')->with($this->equalTo('cat_username'))->will($this->returnValue('user')); $user->expects($this->any())->method('__isset')->with($this->equalTo('cat_username'))->will($this->returnValue(true)); $user->expects($this->any())->method('getCatPassword')->will($this->returnValue('pass')); $user->expects($this->once())->method('clearCredentials'); - $manager = $this->getMockManager(array('isLoggedIn')); + $manager = $this->getMockManager(['isLoggedIn']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue($user)); - $connection = $this->getMockConnection(array('patronLogin')); + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->returnValue(false)); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals(false, $auth->storedCatalogLogin()); @@ -153,14 +153,14 @@ class ILSAuthenticatorTest extends \VuFindTest\Unit\TestCase */ public function testExceptionDuringStoredLoginAttempt() { - $user = $this->getMockUser(array('__get', '__isset', 'clearCredentials', 'getCatPassword')); + $user = $this->getMockUser(['__get', '__isset', 'clearCredentials', 'getCatPassword']); $user->expects($this->any())->method('__get')->with($this->equalTo('cat_username'))->will($this->returnValue('user')); $user->expects($this->any())->method('__isset')->with($this->equalTo('cat_username'))->will($this->returnValue(true)); $user->expects($this->any())->method('getCatPassword')->will($this->returnValue('pass')); $user->expects($this->once())->method('clearCredentials'); - $manager = $this->getMockManager(array('isLoggedIn')); + $manager = $this->getMockManager(['isLoggedIn']); $manager->expects($this->any())->method('isLoggedIn')->will($this->returnValue($user)); - $connection = $this->getMockConnection(array('patronLogin')); + $connection = $this->getMockConnection(['patronLogin']); $connection->expects($this->once())->method('patronLogin')->with($this->equalTo('user'), $this->equalTo('pass'))->will($this->throwException(new \VuFind\Exception\ILS('kaboom'))); $auth = $this->getAuthenticator($manager, $connection); $this->assertEquals(false, $auth->storedCatalogLogin()); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php index 0e8f30d1893..61a1c116c52 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/LDAPTest.php @@ -64,14 +64,14 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase public function getAuthConfig() { $ldapConfig = new Config( - array( + [ 'host' => 'localhost', 'port' => 1234, 'basedn' => 'basedn', 'username' => 'username' - ), true + ], true ); - return new Config(array('LDAP' => $ldapConfig), true); + return new Config(['LDAP' => $ldapConfig], true); } /** @@ -140,12 +140,12 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase // username should be lowercased: $this->assertEquals( 'upper', - $this->callMethod($auth, 'getSetting', array('username')) + $this->callMethod($auth, 'getSetting', ['username']) ); // basedn should not: $this->assertEquals( 'MixedCase', - $this->callMethod($auth, 'getSetting', array('basedn')) + $this->callMethod($auth, 'getSetting', ['basedn']) ); } @@ -167,11 +167,11 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'password' => 'testpass' - ); + ]; $request = new \Zend\Http\Request(); $request->setPost(new \Zend\Stdlib\Parameters($post)); return $request; @@ -185,7 +185,7 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -197,7 +197,7 @@ class LDAPTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php index 88467bc89e5..673d69f64ea 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php @@ -61,7 +61,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('getSessionInitiator')->with($this->equalTo('foo'))->will($this->returnValue('bar')); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $this->assertEquals('bar', $manager->getSessionInitiator('foo')); } @@ -73,12 +73,12 @@ class ManagerTest extends \VuFindTest\Unit\TestCase public function testGetSelectableAuthOptions() { // Simple case -- default Database helper. - $this->assertEquals(array('Database'), $this->getManager()->getSelectableAuthOptions()); + $this->assertEquals(['Database'], $this->getManager()->getSelectableAuthOptions()); // Advanced case -- ChoiceAuth. - $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $manager = $this->getManager($config); - $this->assertEquals(array('Database', 'Shibboleth'), $manager->getSelectableAuthOptions()); + $this->assertEquals(['Database', 'Shibboleth'], $manager->getSelectableAuthOptions()); // Advanced case -- ChoiceAuth's getSelectableAuthOptions returns false. $pm = $this->getMockPluginManager(); @@ -87,9 +87,9 @@ class ManagerTest extends \VuFindTest\Unit\TestCase ->getMock(); $mockChoice->expects($this->any())->method('getSelectableAuthOptions')->will($this->returnValue(false)); $pm->setService('ChoiceAuth2', $mockChoice); - $config = array('Authentication' => array('method' => 'ChoiceAuth2')); + $config = ['Authentication' => ['method' => 'ChoiceAuth2']]; $manager = $this->getManager($config, null, null, $pm); - $this->assertEquals(array('ChoiceAuth2'), $manager->getSelectableAuthOptions()); + $this->assertEquals(['ChoiceAuth2'], $manager->getSelectableAuthOptions()); } /** @@ -100,10 +100,10 @@ class ManagerTest extends \VuFindTest\Unit\TestCase public function testGetLoginTargets() { $pm = $this->getMockPluginManager(); - $targets = array('a', 'b', 'c'); + $targets = ['a', 'b', 'c']; $multi = $pm->get('MultiILS'); $multi->expects($this->once())->method('getLoginTargets')->will($this->returnValue($targets)); - $config = array('Authentication' => array('method' => 'MultiILS')); + $config = ['Authentication' => ['method' => 'MultiILS']]; $this->assertEquals($targets, $this->getManager($config, null, null, $pm)->getLoginTargets()); } @@ -118,7 +118,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $target = 'foo'; $multi = $pm->get('MultiILS'); $multi->expects($this->once())->method('getDefaultLoginTarget')->will($this->returnValue($target)); - $config = array('Authentication' => array('method' => 'MultiILS')); + $config = ['Authentication' => ['method' => 'MultiILS']]; $this->assertEquals($target, $this->getManager($config, null, null, $pm)->getDefaultLoginTarget()); } @@ -134,7 +134,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $db->expects($this->once())->method('logout')->with($this->equalTo('http://foo/bar'))->will($this->returnValue('http://baz')); $sm = $this->getMockSessionManager(); $sm->expects($this->once())->method('destroy'); - $manager = $this->getManager(array(), null, $sm, $pm); + $manager = $this->getManager([], null, $sm, $pm); $this->assertEquals('http://baz', $manager->logout('http://foo/bar')); } @@ -150,7 +150,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $db->expects($this->once())->method('logout')->with($this->equalTo('http://foo/bar'))->will($this->returnValue('http://baz')); $sm = $this->getMockSessionManager(); $sm->expects($this->exactly(0))->method('destroy'); - $manager = $this->getManager(array(), null, $sm, $pm); + $manager = $this->getManager([], null, $sm, $pm); $this->assertEquals('http://baz', $manager->logout('http://foo/bar', false)); } @@ -171,7 +171,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase */ public function testLoginDisabled() { - $config = array('Authentication' => array('hideLogin' => true)); + $config = ['Authentication' => ['hideLogin' => true]]; $this->assertFalse($this->getManager($config)->loginEnabled()); } @@ -182,7 +182,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase */ public function testSwitchingSuccess() { - $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $manager = $this->getManager($config); $this->assertEquals('ChoiceAuth', $manager->getAuthMethod()); // The default mock object in this test is configured to allow a @@ -200,7 +200,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase */ public function testSwitchingFailure() { - $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $manager = $this->getManager($config); $this->assertEquals('ChoiceAuth', $manager->getAuthMethod()); // The default mock object in this test is NOT configured to allow a @@ -215,7 +215,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase */ public function testSupportsCreation() { - $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('supportsCreation')->will($this->returnValue(true)); @@ -240,7 +240,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('supportsPasswordRecovery')->will($this->returnValue(true)); - $config = array('Authentication' => array('recover_password' => true)); + $config = ['Authentication' => ['recover_password' => true]]; $this->assertTrue($this->getManager($config, null, null, $pm)->supportsRecovery()); } @@ -258,7 +258,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('supportsPasswordChange')->will($this->returnValue(true)); - $config = array('Authentication' => array('change_password' => true)); + $config = ['Authentication' => ['change_password' => true]]; $this->assertTrue($this->getManager($config, null, null, $pm)->supportsPasswordChange()); } @@ -274,7 +274,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $this->assertEquals(get_class($pm->get('Database')), $this->getManager()->getAuthClassForTemplateRendering()); // Complex case involving proxied authenticator in ChoiceAuth: - $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $config = ['Authentication' => ['method' => 'ChoiceAuth']]; $choice = $pm->get('ChoiceAuth'); $choice->expects($this->once())->method('getSelectedAuthOption')->will($this->returnValue('Shibboleth')); $manager = $this->getManager($config, null, null, $pm); @@ -304,7 +304,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('create')->with($request)->will($this->returnValue($user)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $this->assertFalse($manager->isLoggedIn()); $this->assertEquals($user, $manager->create($request)); $this->assertEquals($user, $manager->isLoggedIn()); @@ -322,7 +322,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('authenticate')->with($request)->will($this->returnValue($user)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $this->assertFalse($manager->isLoggedIn()); $this->assertEquals($user, $manager->login($request)); $this->assertEquals($user, $manager->isLoggedIn()); @@ -342,7 +342,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('authenticate')->with($request)->will($this->throwException($e)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $manager->login($request); } @@ -360,7 +360,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('authenticate')->with($request)->will($this->throwException($e)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $manager->login($request); } @@ -378,7 +378,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('authenticate')->with($request)->will($this->throwException($e)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $manager->login($request); } @@ -394,7 +394,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $pm = $this->getMockPluginManager(); $db = $pm->get('Database'); $db->expects($this->once())->method('updatePassword')->with($request)->will($this->returnValue($user)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $this->assertEquals($user, $manager->updatePassword($request)); $this->assertEquals($user, $manager->isLoggedIn()); } @@ -416,7 +416,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $db = $pm->get('Database'); $db->expects($this->once())->method('create')->with($request)->will($this->returnValue($user)); $db->expects($this->once())->method('isExpired')->will($this->returnValue(true)); - $manager = $this->getManager(array(), null, null, $pm); + $manager = $this->getManager([], null, null, $pm); $manager->create($request); $this->assertTrue($manager->checkForExpiredCredentials()); } @@ -432,8 +432,8 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $user = $this->getMockUser(); $userArray = new \ArrayObject(); $userArray->append($user); - $table->expects($this->once())->method('select')->with($this->equalTo(array('id' => 'foo')))->will($this->returnValue($userArray->getIterator())); - $manager = $this->getManager(array(), $table); + $table->expects($this->once())->method('select')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue($userArray->getIterator())); + $manager = $this->getManager([], $table); $session = $this->getProperty($manager, 'session'); $session->userId = 'foo'; $this->assertEquals($user, $manager->isLoggedIn()); @@ -449,7 +449,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase * * @return Manager */ - protected function getManager($config = array(), $userTable = null, $sessionManager = null, $pm = null) + protected function getManager($config = [], $userTable = null, $sessionManager = null, $pm = null) { $config = new Config($config); if (null === $userTable) { @@ -499,7 +499,7 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $mockChoice = $this->getMockBuilder('VuFind\Auth\ChoiceAuth') ->disableOriginalConstructor() ->getMock(); - $mockChoice->expects($this->any())->method('getSelectableAuthOptions')->will($this->returnValue(array('Database', 'Shibboleth'))); + $mockChoice->expects($this->any())->method('getSelectableAuthOptions')->will($this->returnValue(['Database', 'Shibboleth'])); $mockDb = $this->getMockBuilder('VuFind\Auth\Database') ->disableOriginalConstructor() ->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php index 7b2c176c07c..fafffea763e 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/MultiAuthTest.php @@ -53,9 +53,9 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase } $serviceLocator = new \VuFind\Auth\PluginManager( new \Zend\ServiceManager\Config( - array( - 'abstract_factories' => array('VuFind\Auth\PluginFactory'), - ) + [ + 'abstract_factories' => ['VuFind\Auth\PluginFactory'], + ] ) ); $obj = clone($this->getAuthManager()->get('MultiAuth')); @@ -71,11 +71,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase public function getAuthConfig() { $config = new Config( - array( + [ 'method_order' => 'Database,ILS' - ), true + ], true ); - return new Config(array('MultiAuth' => $config), true); + return new Config(['MultiAuth' => $config], true); } /** @@ -99,11 +99,11 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'password' => 'testpass' - ); + ]; $request = new \Zend\Http\Request(); $request->setPost(new \Zend\Stdlib\Parameters($post)); return $request; @@ -151,7 +151,7 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -163,7 +163,7 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php index 9cfa93ab693..ffaab2a2434 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/SIP2Test.php @@ -64,12 +64,12 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase public function getAuthConfig() { $config = new Config( - array( + [ 'host' => 'my.fake.host', 'port' => '6002' - ), true + ], true ); - return new Config(array('MultiAuth' => $config), true); + return new Config(['MultiAuth' => $config], true); } /** @@ -80,11 +80,11 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase * * @return \Zend\Http\Request */ - protected function getLoginRequest($overrides = array()) + protected function getLoginRequest($overrides = []) { - $post = $overrides + array( + $post = $overrides + [ 'username' => 'testuser', 'password' => 'testpass' - ); + ]; $request = new \Zend\Http\Request(); $request->setPost(new \Zend\Stdlib\Parameters($post)); return $request; @@ -98,7 +98,7 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankUsername() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('username' => '')); + $request = $this->getLoginRequest(['username' => '']); $this->getAuthObject()->authenticate($request); } @@ -110,7 +110,7 @@ class SIP2Test extends \VuFindTest\Unit\DbTestCase public function testLoginWithBlankPassword() { $this->setExpectedException('VuFind\Exception\Auth'); - $request = $this->getLoginRequest(array('password' => '')); + $request = $this->getLoginRequest(['password' => '']); $this->getAuthObject()->authenticate($request); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php index 174ef5e68df..887a8e8faf2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Autocomplete/TagTest.php @@ -60,18 +60,18 @@ class TagTest extends \VuFindTest\Unit\DbTestCase public function testSuggestions() { // Fake DB response: - $tags = array( - array('tag' => 'bar1'), - array('tag' => 'bar2'), - ); + $tags = [ + ['tag' => 'bar1'], + ['tag' => 'bar2'], + ]; // Fake services: - $tagTable = $this->getMock('VuFind\Db\Table\Tags', array('matchText')); + $tagTable = $this->getMock('VuFind\Db\Table\Tags', ['matchText']); $tagTable->expects($this->once())->method('matchText') ->with($this->equalTo('foo')) ->will($this->returnValue($tags)); $tableManager - = $this->getMock('VuFind\Db\Table\PluginManager', array('get')); + = $this->getMock('VuFind\Db\Table\PluginManager', ['get']); $tableManager->expects($this->once())->method('get') ->with($this->equalTo('Tags')) ->will($this->returnValue($tagTable)); @@ -80,6 +80,6 @@ class TagTest extends \VuFindTest\Unit\DbTestCase $tag = new Tag(); $tag->setDbTableManager($tableManager); - $this->assertEquals(array('bar1', 'bar2'), $tag->getSuggestions('foo')); + $this->assertEquals(['bar1', 'bar2'], $tag->getSuggestions('foo')); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php index f63ffabc36a..f3c67576375 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/CartTest.php @@ -53,11 +53,11 @@ class CartTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->loader = $this->getMock( - 'VuFind\Record\Loader', array(), - array( + 'VuFind\Record\Loader', [], + [ $this->getMock('VuFindSearch\Service'), $this->getMock('VuFind\RecordDriver\PluginManager') - ) + ] ); } @@ -70,12 +70,12 @@ class CartTest extends \PHPUnit_Framework_TestCase * * @return \VuFind\Cart */ - protected function getCart($maxSize = 100, $active = true, $cookies = array(), + protected function getCart($maxSize = 100, $active = true, $cookies = [], $domain = null ) { return $this->getMock( - 'VuFind\Cart', array('setCookie'), - array($this->loader, $maxSize, $active, $cookies, $domain) + 'VuFind\Cart', ['setCookie'], + [$this->loader, $maxSize, $active, $cookies, $domain] ); } @@ -86,7 +86,7 @@ class CartTest extends \PHPUnit_Framework_TestCase */ public function testCookieDomain() { - $cart = $this->getCart(100, true, array(), '.example.com'); + $cart = $this->getCart(100, true, [], '.example.com'); $this->assertEquals('.example.com', $cart->getCookieDomain()); } @@ -99,7 +99,7 @@ class CartTest extends \PHPUnit_Framework_TestCase { $cart = $this->getCart(); $this->assertTrue($cart->isEmpty()); - $this->assertEquals(array(), $cart->getItems()); + $this->assertEquals([], $cart->getItems()); } /** @@ -122,12 +122,12 @@ class CartTest extends \PHPUnit_Framework_TestCase { $cart = $this->getCart(2); // create a very small cart $this->assertFalse($cart->isFull()); - $this->assertEquals(array('success' => true), $cart->addItem('VuFind|a')); + $this->assertEquals(['success' => true], $cart->addItem('VuFind|a')); $this->assertFalse($cart->isFull()); - $this->assertEquals(array('success' => true), $cart->addItem('VuFind|b')); + $this->assertEquals(['success' => true], $cart->addItem('VuFind|b')); $this->assertTrue($cart->isFull()); $this->assertEquals( - array('success' => false, 'notAdded' => 1), $cart->addItem('VuFind|c') + ['success' => false, 'notAdded' => 1], $cart->addItem('VuFind|c') ); } @@ -205,8 +205,8 @@ class CartTest extends \PHPUnit_Framework_TestCase public function testRemoveItems() { $cart = $this->getCart(); - $cart->addItems(array('VuFind|a', 'VuFind|b', 'VuFind|c')); - $cart->removeItems(array('VuFind|a', 'VuFind|b')); + $cart->addItems(['VuFind|a', 'VuFind|b', 'VuFind|c']); + $cart->removeItems(['VuFind|a', 'VuFind|b']); $this->assertTrue($cart->contains('VuFind|c')); $this->assertFalse($cart->contains('VuFind|a')); $this->assertFalse($cart->contains('VuFind|b')); @@ -221,7 +221,7 @@ class CartTest extends \PHPUnit_Framework_TestCase { $this->loader->expects($this->once()) ->method('loadBatch') - ->with($this->equalTo(array('VuFind|a'))) + ->with($this->equalTo(['VuFind|a'])) ->will($this->returnValue('success')); $cart = $this->getCart(); $cart->addItem('VuFind|a'); @@ -235,7 +235,7 @@ class CartTest extends \PHPUnit_Framework_TestCase */ public function testVF1Cookie() { - $cart = $this->getCart(100, true, array('vufind_cart' => "a\tb\tc")); + $cart = $this->getCart(100, true, ['vufind_cart' => "a\tb\tc"]); $this->assertEquals(3, count($cart->getItems())); $this->assertTrue($cart->contains('VuFind|a')); $this->assertTrue($cart->contains('VuFind|b')); @@ -249,10 +249,10 @@ class CartTest extends \PHPUnit_Framework_TestCase */ public function testVF2Cookie() { - $cookies = array( + $cookies = [ 'vufind_cart' => "Aa\tBb\tCc", 'vufind_cart_src' => "VuFind\tSummon\tWorldCat" - ); + ]; $cart = $this->getCart(100, true, $cookies); $this->assertEquals(3, count($cart->getItems())); $this->assertTrue($cart->contains('VuFind|a')); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php index 20de56247ec..34d8fac1667 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/PluginFactoryTest.php @@ -52,7 +52,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase * * @var array */ - protected static $filesToDelete = array(); + protected static $filesToDelete = []; /** * Plugin factory instance. @@ -95,7 +95,7 @@ class PluginFactoryTest extends \VuFindTest\Unit\TestCase } // Mark for cleanup: - self::$filesToDelete = array($parentPath, $childPath); + self::$filesToDelete = [$parentPath, $childPath]; } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/Reader/CacheDecoratorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/Reader/CacheDecoratorTest.php index 01655a29a1e..e1b5ccb72f4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/Reader/CacheDecoratorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/Reader/CacheDecoratorTest.php @@ -49,19 +49,19 @@ class CacheDecoratorTest extends \PHPUnit_Framework_TestCase */ public function testFromFileAndString() { - $cache = $this->getMockForAbstractClass('Zend\Cache\Storage\StorageInterface', array('setItem', 'hasItem')); + $cache = $this->getMockForAbstractClass('Zend\Cache\Storage\StorageInterface', ['setItem', 'hasItem']); $cache->expects($this->exactly(2)) ->method('setItem'); $cache->expects($this->exactly(2)) ->method('hasItem') ->will($this->returnValue(false)); - $reader = $this->getMockForAbstractClass('Zend\Config\Reader\ReaderInterface', array('fromFile', 'fromString')); + $reader = $this->getMockForAbstractClass('Zend\Config\Reader\ReaderInterface', ['fromFile', 'fromString']); $reader->expects($this->once()) ->method('fromFile') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $reader->expects($this->once()) ->method('fromString') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $deco = new CacheDecorator($reader, $cache); $deco->fromFile('ignore'); $deco->fromString('ignore'); @@ -74,7 +74,7 @@ class CacheDecoratorTest extends \PHPUnit_Framework_TestCase */ public function testFromFileAndStringCached() { - $cache = $this->getMockForAbstractClass('Zend\Cache\Storage\StorageInterface', array('setItem', 'hasItem', 'getItem')); + $cache = $this->getMockForAbstractClass('Zend\Cache\Storage\StorageInterface', ['setItem', 'hasItem', 'getItem']); $cache->expects($this->never()) ->method('setItem'); $cache->expects($this->exactly(2)) @@ -82,8 +82,8 @@ class CacheDecoratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $cache->expects($this->exactly(2)) ->method('getItem') - ->will($this->returnValue(array())); - $reader = $this->getMockForAbstractClass('Zend\Config\Reader\ReaderInterface', array('fromFile', 'fromString')); + ->will($this->returnValue([])); + $reader = $this->getMockForAbstractClass('Zend\Config\Reader\ReaderInterface', ['fromFile', 'fromString']); $deco = new CacheDecorator($reader, $cache); $deco->fromFile('ignore'); $deco->fromString('ignore'); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php index 86a0aee1568..907dbb47794 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/SearchSpecsReaderTest.php @@ -66,6 +66,6 @@ class SearchSpecsReaderTest extends \VuFindTest\Unit\TestCase { $reader = $this->getServiceManager()->get('VuFind\SearchSpecsReader'); $specs = $reader->get('notreallyasearchspecs.yaml'); - $this->assertEquals(array(), $specs); + $this->assertEquals([], $specs); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php index 87a86e2156f..ee4fc3a2030 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php @@ -121,7 +121,7 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase // Make sure that spelling recommendations are set up appropriately: $this->assertEquals( - array('TopFacets:ResultsTop', 'SpellingSuggestions'), + ['TopFacets:ResultsTop', 'SpellingSuggestions'], $results['searches.ini']['General']['default_top_recommend'] ); $this->assertTrue( @@ -131,14 +131,14 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ) ); $this->assertEquals( - array( - 'Author' => array('AuthorFacets', 'SpellingSuggestions'), - 'CallNumber' => array('TopFacets:ResultsTop') - ), + [ + 'Author' => ['AuthorFacets', 'SpellingSuggestions'], + 'CallNumber' => ['TopFacets:ResultsTop'] + ], $results['searches.ini']['TopRecommendations'] ); $this->assertEquals( - array('SummonDatabases', 'SpellingSuggestions'), + ['SummonDatabases', 'SpellingSuggestions'], $results['Summon.ini']['General']['default_top_recommend'] ); $this->assertTrue( @@ -148,11 +148,11 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ) ); $this->assertEquals( - array(), + [], $results['Summon.ini']['TopRecommendations'] ); - return array('configs' => $results, 'warnings' => $warnings); + return ['configs' => $results, 'warnings' => $warnings]; } /** @@ -373,7 +373,7 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ); $this->assertFalse( $this->callMethod( - $upgrader, 'fileContainsMeaningfulLines', array($meaningless) + $upgrader, 'fileContainsMeaningfulLines', [$meaningless] ) ); $meaningful = realpath( @@ -381,7 +381,7 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ); $this->assertTrue( $this->callMethod( - $upgrader, 'fileContainsMeaningfulLines', array($meaningful) + $upgrader, 'fileContainsMeaningfulLines', [$meaningful] ) ); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/WriterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/WriterTest.php index 440db135f5d..050a5493264 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/WriterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/WriterTest.php @@ -59,22 +59,22 @@ class WriterTest extends \VuFindTest\Unit\TestCase */ public function testReadArray() { - $cfg = array('Test' => array('key1' => 'val1', 'key2' => 'val2')); - $comments = array( - 'sections' => array( - 'Test' => array( + $cfg = ['Test' => ['key1' => 'val1', 'key2' => 'val2']]; + $comments = [ + 'sections' => [ + 'Test' => [ 'before' => "; section head\n", 'inline' => '; inline', - 'settings' => array( - 'key1' => array( + 'settings' => [ + 'key1' => [ 'before' => "; key head\n", 'inline' => '; key inline' - ) - ) - ) - ), + ] + ] + ] + ], 'after' => "; the end\n" - ); + ]; $target = "; section head\n[Test]\t; inline\n; key head\n" . "key1 = \"val1\"\t; key inline\n" . "key2 = \"val2\"\n; the end\n"; @@ -101,7 +101,7 @@ class WriterTest extends \VuFindTest\Unit\TestCase */ public function testStandardArray() { - $cfg = array('Test' => array('test' => array('val1', 'val2'))); + $cfg = ['Test' => ['test' => ['val1', 'val2']]]; $test = new Writer('fake.ini', $cfg); $expected = "[Test]\ntest[] = \"val1\"\n" . "test[] = \"val2\"\n\n"; @@ -116,7 +116,7 @@ class WriterTest extends \VuFindTest\Unit\TestCase */ public function testOutOfOrderArray() { - $cfg = array('Test' => array('test' => array(6 => 'val1', 8 => 'val2'))); + $cfg = ['Test' => ['test' => [6 => 'val1', 8 => 'val2']]]; $test = new Writer('fake.ini', $cfg); $expected = "[Test]\ntest[6] = \"val1\"\n" . "test[8] = \"val2\"\n\n"; @@ -130,9 +130,9 @@ class WriterTest extends \VuFindTest\Unit\TestCase */ public function testAssocArray() { - $cfg = array( - 'Test' => array('test' => array('key1' => 'val1', 'key2' => 'val2')) - ); + $cfg = [ + 'Test' => ['test' => ['key1' => 'val1', 'key2' => 'val2']] + ]; $test = new Writer('fake.ini', $cfg); $expected = "[Test]\ntest['key1'] = \"val1\"\n" . "test['key2'] = \"val2\"\n\n"; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/AmazonTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/AmazonTest.php index 016c65816fd..407ee3c9281 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/AmazonTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/AmazonTest.php @@ -45,7 +45,7 @@ class AmazonTest extends \PHPUnit_Framework_TestCase * * @var array */ - protected $params = array('ResponseGroup' => 'Images', 'AssociateTag' => 'fake'); + protected $params = ['ResponseGroup' => 'Images', 'AssociateTag' => 'fake']; /** * Test cover loading @@ -54,13 +54,13 @@ class AmazonTest extends \PHPUnit_Framework_TestCase */ public function testValidCoverLoading() { - $expected = array( + $expected = [ 'small' => 'http://ecx.images-amazon.com/images/I/518597FY50L._SL75_.jpg', 'medium' => 'http://ecx.images-amazon.com/images/I/518597FY50L._SL160_.jpg', 'large' => 'http://ecx.images-amazon.com/images/I/518597FY50L.jpg', - ); + ]; foreach ($expected as $size => $expectedUrl) { $this->assertEquals($expectedUrl, $this->getUrl($size)); } @@ -108,10 +108,10 @@ class AmazonTest extends \PHPUnit_Framework_TestCase protected function getUrl($size, $isbn = '0739313126', $throw = false) { $amazon = $this->getMock( - 'VuFind\Content\Covers\Amazon', array('getAmazonService'), - array('fake', 'fakesecret') + 'VuFind\Content\Covers\Amazon', ['getAmazonService'], + ['fake', 'fakesecret'] ); - $params = array(); + $params = []; if (!empty($isbn)) { $behavior = $throw ? $this->throwException(new \Exception('kaboom')) @@ -135,8 +135,8 @@ class AmazonTest extends \PHPUnit_Framework_TestCase protected function getFakeService($isbn, $expectedBehavior) { $service = $this->getMock( - 'ZendService\Amazon\Amazon', array('itemLookup'), - array('fakekey', 'US', 'fakesecret') + 'ZendService\Amazon\Amazon', ['itemLookup'], + ['fakekey', 'US', 'fakesecret'] ); if (!empty($isbn)) { $service->expects($this->once()) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php index e3c4a63bef1..c2e3b5f097a 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/BooksiteTest.php @@ -51,7 +51,7 @@ class BooksiteTest extends \PHPUnit_Framework_TestCase $this->assertEquals( 'http://base/poca/content_img?apikey=mykey&ean=9780739313121', $loader->getUrl( - 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + 'mykey', 'small', ['isbn' => new ISBN('0739313126')] ) ); } @@ -64,6 +64,6 @@ class BooksiteTest extends \PHPUnit_Framework_TestCase public function testMissingIsbn() { $loader = new Booksite('http://base', 'mykey'); - $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', [])); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php index a3f654b3ad6..7dfbe2e157e 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/ContentCafeTest.php @@ -47,12 +47,12 @@ class ContentCafeTest extends \PHPUnit_Framework_TestCase */ public function testValidCoverLoading() { - $loader = new ContentCafe(new Config(array('pw' => 'fakepw'))); + $loader = new ContentCafe(new Config(['pw' => 'fakepw'])); $this->assertEquals( 'http://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=mykey' . '&Password=fakepw&Return=1&Type=S&Value=9780739313121&erroroverride=1', $loader->getUrl( - 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + 'mykey', 'small', ['isbn' => new ISBN('0739313126')] ) ); } @@ -64,7 +64,7 @@ class ContentCafeTest extends \PHPUnit_Framework_TestCase */ public function testMissingIsbn() { - $loader = new ContentCafe(new Config(array('pw' => 'fakepw'))); - $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + $loader = new ContentCafe(new Config(['pw' => 'fakepw'])); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', [])); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php index dab3a0b4d14..94c909b3607 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/LibraryThingTest.php @@ -51,7 +51,7 @@ class LibraryThingTest extends \PHPUnit_Framework_TestCase $this->assertEquals( 'http://covers.librarything.com/devkey/mykey/small/isbn/9780739313121', $loader->getUrl( - 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + 'mykey', 'small', ['isbn' => new ISBN('0739313126')] ) ); } @@ -64,6 +64,6 @@ class LibraryThingTest extends \PHPUnit_Framework_TestCase public function testMissingIsbn() { $loader = new LibraryThing(); - $this->assertEquals(false, $loader->getUrl('mykey', 'small', array())); + $this->assertEquals(false, $loader->getUrl('mykey', 'small', [])); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php index b79d57c7811..7e4c2eabadc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/OpenLibraryTest.php @@ -51,7 +51,7 @@ class OpenLibraryTest extends \PHPUnit_Framework_TestCase $this->assertEquals( 'http://covers.openlibrary.org/b/isbn/9780739313121-S.jpg?default=false', $ol->getUrl( - 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + 'mykey', 'small', ['isbn' => new ISBN('0739313126')] ) ); } @@ -64,6 +64,6 @@ class OpenLibraryTest extends \PHPUnit_Framework_TestCase public function testMissingIsbn() { $ol = new OpenLibrary(); - $this->assertEquals(false, $ol->getUrl('mykey', 'small', array())); + $this->assertEquals(false, $ol->getUrl('mykey', 'small', [])); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php index 68b60f648ea..b0027b5a3e6 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Content/Covers/SummonTest.php @@ -52,7 +52,7 @@ class SummonTest extends \PHPUnit_Framework_TestCase 'http://api.summon.serialssolutions.com/2.0.0/image/isbn/' . 'mykey/9780739313121/small', $summon->getUrl( - 'mykey', 'small', array('isbn' => new ISBN('0739313126')) + 'mykey', 'small', ['isbn' => new ISBN('0739313126')] ) ); } @@ -65,6 +65,6 @@ class SummonTest extends \PHPUnit_Framework_TestCase public function testMissingIsbn() { $summon = new Summon(); - $this->assertEquals(false, $summon->getUrl('mykey', 'small', array())); + $this->assertEquals(false, $summon->getUrl('mykey', 'small', [])); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/FollowupTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/FollowupTest.php index 5ad0540f66b..29a487eab82 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/FollowupTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/FollowupTest.php @@ -83,7 +83,7 @@ class FollowupTest extends TestCase public function testRetrieveAndClear() { $f = new Followup(); - $f->store(array('foo' => 'bar'), 'baz'); + $f->store(['foo' => 'bar'], 'baz'); $this->assertEquals('bar', $f->retrieveAndClear('foo')); $this->assertEquals('baz', $f->retrieveAndClear('url')); $this->assertNull($f->retrieveAndClear('foo')); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php index a963005cf42..9395d29c6d4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php @@ -51,12 +51,12 @@ class NewItemsTest extends TestCase public function testGetBibIDsFromCatalog() { $flash = $this->getMock('Zend\Mvc\Controller\Plugin\FlashMessenger'); - $config = new Config(array('result_pages' => 10)); + $config = new Config(['result_pages' => 10]); $newItems = new NewItems($config); $bibs = $newItems->getBibIDsFromCatalog( $this->getMockCatalog(), $this->getMockParams(), 10, 'a', $flash ); - $this->assertEquals(array(1, 2), $bibs); + $this->assertEquals([1, 2], $bibs); } /** @@ -71,12 +71,12 @@ class NewItemsTest extends TestCase ->with($this->equalTo('info'))->will($this->returnValue($flash)); $flash->expects($this->once())->method('addMessage') ->with($this->equalTo('too_many_new_items')); - $config = new Config(array('result_pages' => 10)); + $config = new Config(['result_pages' => 10]); $newItems = new NewItems($config); $bibs = $newItems->getBibIDsFromCatalog( $this->getMockCatalog(), $this->getMockParams(1), 10, 'a', $flash ); - $this->assertEquals(array(1), $bibs); + $this->assertEquals([1], $bibs); } /** @@ -87,19 +87,19 @@ class NewItemsTest extends TestCase public function testGetFundList() { $catalog = $this->getMock( - 'VuFind\ILS\Connection', array('checkCapability', 'getFunds'), - array(), '', false + 'VuFind\ILS\Connection', ['checkCapability', 'getFunds'], + [], '', false ); $catalog->expects($this->once())->method('checkCapability') ->with($this->equalTo('getFunds'))->will($this->returnValue(true)); $catalog->expects($this->once())->method('getFunds') - ->will($this->returnValue(array('a', 'b', 'c'))); + ->will($this->returnValue(['a', 'b', 'c'])); $controller = $this->getMock('VuFind\Controller\SearchController'); $controller->expects($this->once())->method('getILS') ->will($this->returnValue($catalog)); - $newItems = new NewItems(new Config(array())); + $newItems = new NewItems(new Config([])); $newItems->setController($controller); - $this->assertEquals(array('a', 'b', 'c'), $newItems->getFundList()); + $this->assertEquals(['a', 'b', 'c'], $newItems->getFundList()); } /** @@ -109,8 +109,8 @@ class NewItemsTest extends TestCase */ public function testGetFundListWithoutILS() { - $newItems = new NewItems(new Config(array('method' => 'solr'))); - $this->assertEquals(array(), $newItems->getFundList()); + $newItems = new NewItems(new Config(['method' => 'solr'])); + $this->assertEquals([], $newItems->getFundList()); } /** @@ -120,9 +120,9 @@ class NewItemsTest extends TestCase */ public function testGetSingleHiddenFilter() { - $config = new Config(array('filter' => 'a:b')); + $config = new Config(['filter' => 'a:b']); $newItems = new NewItems($config); - $this->assertEquals(array('a:b'), $newItems->getHiddenFilters()); + $this->assertEquals(['a:b'], $newItems->getHiddenFilters()); } /** @@ -132,9 +132,9 @@ class NewItemsTest extends TestCase */ public function testGetMultipleHiddenFilters() { - $config = new Config(array('filter' => array('a:b', 'b:c'))); + $config = new Config(['filter' => ['a:b', 'b:c']]); $newItems = new NewItems($config); - $this->assertEquals(array('a:b', 'b:c'), $newItems->getHiddenFilters()); + $this->assertEquals(['a:b', 'b:c'], $newItems->getHiddenFilters()); } /** @@ -144,12 +144,12 @@ class NewItemsTest extends TestCase */ public function testDefaults() { - $config = new Config(array()); + $config = new Config([]); $newItems = new NewItems($config); - $this->assertEquals(array(), $newItems->getHiddenFilters()); + $this->assertEquals([], $newItems->getHiddenFilters()); $this->assertEquals('ils', $newItems->getMethod()); $this->assertEquals(30, $newItems->getMaxAge()); - $this->assertEquals(array(1, 5, 30), $newItems->getRanges()); + $this->assertEquals([1, 5, 30], $newItems->getRanges()); $this->assertEquals(10, $newItems->getResultPages()); } @@ -160,9 +160,9 @@ class NewItemsTest extends TestCase */ public function testCustomRanges() { - $config = new Config(array('ranges' => '10,150,300')); + $config = new Config(['ranges' => '10,150,300']); $newItems = new NewItems($config); - $this->assertEquals(array(10, 150, 300), $newItems->getRanges()); + $this->assertEquals([10, 150, 300], $newItems->getRanges()); } /** @@ -172,7 +172,7 @@ class NewItemsTest extends TestCase */ public function testCustomResultPages() { - $config = new Config(array('result_pages' => '2')); + $config = new Config(['result_pages' => '2']); $newItems = new NewItems($config); $this->assertEquals(2, $newItems->getResultPages()); } @@ -184,7 +184,7 @@ class NewItemsTest extends TestCase */ public function testIllegalResultPages() { - $config = new Config(array('result_pages' => '-2')); + $config = new Config(['result_pages' => '-2']); $newItems = new NewItems($config); // expect a default of 10 if a bad value was passed in $this->assertEquals(10, $newItems->getResultPages()); @@ -199,7 +199,7 @@ class NewItemsTest extends TestCase { $range = 30; $expected = 'first_indexed:[NOW-' . $range . 'DAY TO NOW]'; - $newItems = new NewItems(new Config(array())); + $newItems = new NewItems(new Config([])); $this->assertEquals($expected, $newItems->getSolrFilter($range)); } @@ -211,7 +211,7 @@ class NewItemsTest extends TestCase protected function getMockCatalog() { $catalog = $this->getMock( - 'VuFind\ILS\Connection', array('getNewItems'), array(), '', false + 'VuFind\ILS\Connection', ['getNewItems'], [], '', false ); $catalog->expects($this->once())->method('getNewItems') ->with( @@ -220,7 +220,7 @@ class NewItemsTest extends TestCase ) ->will( $this->returnValue( - array('results' => array(array('id' => 1), array('id' => 2))) + ['results' => [['id' => 1], ['id' => 2]]] ) ); return $catalog; @@ -236,7 +236,7 @@ class NewItemsTest extends TestCase protected function getMockParams($idLimit = 1024) { $params = $this - ->getMock('VuFind\Search\Solr\Params', array(), array(), '', false); + ->getMock('VuFind\Search\Solr\Params', [], [], '', false); $params->expects($this->once())->method('getLimit') ->will($this->returnValue(20)); $params->expects($this->once())->method('getQueryIDLimit') diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php index 4a5ee9f7a9c..aa4fa37938e 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/ResultScrollerTest.php @@ -52,10 +52,10 @@ class ResultScrollerTest extends TestCase $plugin = new ResultScroller(false); $results = $this->getMockResults(); $this->assertFalse($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => null, 'nextRecord' => null, 'currentPosition' => null, 'resultTotal' => null - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(1))); } @@ -69,10 +69,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(1, 10, 10); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => 'VuFind|4', 'nextRecord' => 'VuFind|6', 'currentPosition' => 5, 'resultTotal' => 10 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(5))); } @@ -86,10 +86,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(1, 10, 10); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => null, 'nextRecord' => 'VuFind|2', 'currentPosition' => 1, 'resultTotal' => 10 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(1))); } @@ -103,10 +103,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(1, 10, 10); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => 'VuFind|9', 'nextRecord' => null, 'currentPosition' => 10, 'resultTotal' => 10 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(10))); } @@ -120,10 +120,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(2, 10, 17); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => 'VuFind|16', 'nextRecord' => null, 'currentPosition' => 17, 'resultTotal' => 17 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(17))); } @@ -137,10 +137,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(2, 10, 30); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => 'VuFind|10', 'nextRecord' => 'VuFind|12', 'currentPosition' => 11, 'resultTotal' => 30 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(11))); } @@ -154,10 +154,10 @@ class ResultScrollerTest extends TestCase $results = $this->getMockResults(2, 10, 30); $plugin = $this->getMockResultScroller($results); $this->assertTrue($plugin->init($results)); - $expected = array( + $expected = [ 'previousRecord' => 'VuFind|19', 'nextRecord' => 'VuFind|21', 'currentPosition' => 20, 'resultTotal' => 30 - ); + ]; $this->assertEquals($expected, $plugin->getScrollData($results->getMockRecordDriver(20))); } @@ -189,7 +189,7 @@ class ResultScrollerTest extends TestCase * * @return ResultScroller */ - protected function getMockResultScroller($results = null, $methods = array('restoreLastSearch', 'rememberSearch')) + protected function getMockResultScroller($results = null, $methods = ['restoreLastSearch', 'rememberSearch']) { $mock = $this->getMock('VuFind\Controller\Plugin\ResultScroller', $methods); if (in_array('restoreLastSearch', $methods) && null !== $results) { diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php index 767b15e9064..2771c98aca0 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Cookie/ContainerTest.php @@ -75,7 +75,7 @@ class ContainerTest extends \VuFindTest\Unit\TestCase $this->assertEquals('tmp', $this->container->value); // Test get/set of array: - $this->container->testArray = array(1, 2); + $this->container->testArray = [1, 2]; $this->assertEquals(2, count($this->container->testArray)); // Test getAllValues: diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php index dc91fd25a79..61dcb4186f5 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Cover/LoaderTest.php @@ -58,9 +58,9 @@ class LoaderTest extends \VuFindTest\Unit\TestCase */ public function testUtterFailure() { - $theme = $this->getMock('VuFindTheme\ThemeInfo', array(), array('foo', 'bar')); - $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(array('images/noCover2.gif')))->will($this->returnValue(false)); - $loader = $this->getLoader(array(), null, $theme); + $theme = $this->getMock('VuFindTheme\ThemeInfo', [], ['foo', 'bar']); + $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(['images/noCover2.gif']))->will($this->returnValue(false)); + $loader = $this->getLoader([], null, $theme); $loader->getImage(); } @@ -98,8 +98,8 @@ class LoaderTest extends \VuFindTest\Unit\TestCase public function testMissingUserSpecifiedFailImage() { $badfile = 'not/a/real/file/at.all'; - $cfg = array('Content' => array('noCoverAvailableImage' => $badfile)); - $loader = $this->getLoader($cfg, null, null, null, array('debug')); + $cfg = ['Content' => ['noCoverAvailableImage' => $badfile]]; + $loader = $this->getLoader($cfg, null, null, null, ['debug']); // We expect the loader to complain about the bad filename and load the default image: $loader->expects($this->once())->method('debug')->with($this->equalTo("Cannot access '$badfile'")); @@ -115,8 +115,8 @@ class LoaderTest extends \VuFindTest\Unit\TestCase public function testFailImageIllegalExtension() { $badfile = 'templates/layout/layout.phtml'; - $cfg = array('Content' => array('noCoverAvailableImage' => $badfile)); - $loader = $this->getLoader($cfg, null, null, null, array('debug')); + $cfg = ['Content' => ['noCoverAvailableImage' => $badfile]]; + $loader = $this->getLoader($cfg, null, null, null, ['debug']); // We expect the loader to complain about the bad filename and load the default image: $expected = "Illegal file-extension 'phtml' for image '" . $this->getThemeDir() . '/' . $this->testTheme . '/' . $badfile . "'"; @@ -136,7 +136,7 @@ class LoaderTest extends \VuFindTest\Unit\TestCase * * @return void */ - protected function getLoader($config = array(), $manager = null, $theme = null, $client = null, $mock = false) + protected function getLoader($config = [], $manager = null, $theme = null, $client = null, $mock = false) { $config = new Config($config); if (null === $manager) { @@ -151,7 +151,7 @@ class LoaderTest extends \VuFindTest\Unit\TestCase $client->setAdapter($adapter); } if ($mock) { - return $this->getMock('VuFind\Cover\Loader', $mock, array($config, $manager, $theme, $client)); + return $this->getMock('VuFind\Cover\Loader', $mock, [$config, $manager, $theme, $client]); } return new Loader($config, $manager, $theme, $client); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Crypt/HMACTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Crypt/HMACTest.php index b5582576b04..c479e1323ab 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Crypt/HMACTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Crypt/HMACTest.php @@ -49,7 +49,7 @@ class HMACTest extends \VuFindTest\Unit\TestCase $hmac = new HMAC('secret'); $this->assertEquals( '330891b9db42bdf6aeb558a35e2a1780', - $hmac->generate(array('foo'), array('foo' => 'bar')) + $hmac->generate(['foo'], ['foo' => 'bar']) ); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Date/ConverterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Date/ConverterTest.php index d1a272e3b0d..d4b0ac2af01 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Date/ConverterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Date/ConverterTest.php @@ -54,7 +54,7 @@ class ConverterTest extends \VuFindTest\Unit\TestCase $real_zone = date_default_timezone_get(); // Try all the tests in different time zones to ensure consistency: - foreach (array('America/New_York', 'Europe/Helsinki') as $zone) { + foreach (['America/New_York', 'Europe/Helsinki'] as $zone) { date_default_timezone_set($zone); $this->runTests(); } @@ -72,7 +72,7 @@ class ConverterTest extends \VuFindTest\Unit\TestCase { // Build an object to test with (using empty configuration to ensure default // settings): - $date = new Converter(new Config(array())); + $date = new Converter(new Config([])); // Try some conversions: $this->assertEquals( diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ExportTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ExportTest.php index b7fd74d8e93..7f4d6da4e73 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ExportTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ExportTest.php @@ -46,20 +46,20 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testGetBulkOptions() { - $config = array( - 'BulkExport' => array( + $config = [ + 'BulkExport' => [ 'enabled' => 1, 'options' => 'foo:bar:baz', - ), - 'Export' => array( + ], + 'Export' => [ 'foo' => 1, 'bar' => 1, 'baz' => 0, 'xyzzy' => 1, - ), - ); + ], + ]; $export = $this->getExport($config); - $this->assertEquals(array('foo', 'bar'), $export->getBulkOptions()); + $this->assertEquals(['foo', 'bar'], $export->getBulkOptions()); } /** @@ -69,11 +69,11 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testNeedsRedirect() { - $config = array( - 'foo' => array('redirectUrl' => 'http://foo'), - 'bar' => array(), - ); - $export = $this->getExport(array(), $config); + $config = [ + 'foo' => ['redirectUrl' => 'http://foo'], + 'bar' => [], + ]; + $export = $this->getExport([], $config); $this->assertTrue($export->needsRedirect('foo')); $this->assertFalse($export->needsRedirect('bar')); } @@ -87,7 +87,7 @@ class ExportTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( "a\nb\nc\n", - $this->getExport()->processGroup('foo', array("a\n", "b\n", "c\n")) + $this->getExport()->processGroup('foo', ["a\n", "b\n", "c\n"]) ); } @@ -98,20 +98,20 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testProcessGroupXML() { - $config = array( - 'foo' => array( - 'combineNamespaces' => array('marc21|http://www.loc.gov/MARC21/slim'), + $config = [ + 'foo' => [ + 'combineNamespaces' => ['marc21|http://www.loc.gov/MARC21/slim'], 'combineXpath' => '/marc21:collection/marc21:record', - ), - ); + ], + ]; $this->assertEquals( "<?xml version=\"1.0\"?>\n" . '<collection xmlns="http://www.loc.gov/MARC21/slim">' . '<record><id>a</id></record><record><id>b</id></record></collection>', trim( - $this->getExport(array(), $config)->processGroup( + $this->getExport([], $config)->processGroup( 'foo', - array($this->getFakeMARCXML('a'), $this->getFakeMARCXML('b')) + [$this->getFakeMARCXML('a'), $this->getFakeMARCXML('b')] ) ) ); @@ -124,12 +124,12 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testRecordSupportsFormat() { - $config = array( - 'foo' => array('requiredMethods' => array('getTitle')), - 'bar' => array('requiredMethods' => array('getThingThatDoesNotExist')) - ); + $config = [ + 'foo' => ['requiredMethods' => ['getTitle']], + 'bar' => ['requiredMethods' => ['getThingThatDoesNotExist']] + ]; - $export = $this->getExport(array(), $config); + $export = $this->getExport([], $config); $primo = new \VuFind\RecordDriver\Primo(); $solr = new \VuFind\RecordDriver\SolrDefault(); @@ -155,14 +155,14 @@ class ExportTest extends \PHPUnit_Framework_TestCase { // Use RefWorks and EndNote as our test data, since these are the items // turned on by default if no main config is passed in. - $config = array( - 'RefWorks' => array('requiredMethods' => array('getTitle')), - 'EndNote' => array('requiredMethods' => array('getThingThatDoesNotExist')) - ); + $config = [ + 'RefWorks' => ['requiredMethods' => ['getTitle']], + 'EndNote' => ['requiredMethods' => ['getThingThatDoesNotExist']] + ]; - $export = $this->getExport(array(), $config); + $export = $this->getExport([], $config); $solr = new \VuFind\RecordDriver\SolrDefault(); - $this->assertEquals(array('RefWorks'), $export->getFormatsForRecord($solr)); + $this->assertEquals(['RefWorks'], $export->getFormatsForRecord($solr)); } /** @@ -172,28 +172,28 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testGetFormatsForRecords() { - $mainConfig = array( - 'BulkExport' => array( + $mainConfig = [ + 'BulkExport' => [ 'enabled' => 1, 'options' => 'anything:marc', - ), - 'Export' => array( + ], + 'Export' => [ 'anything' => 1, 'marc' => 1, - ), - ); - $exportConfig = array( - 'anything' => array('requiredMethods' => array('getTitle')), - 'marc' => array('requiredMethods' => array('getMarcRecord')) - ); + ], + ]; + $exportConfig = [ + 'anything' => ['requiredMethods' => ['getTitle']], + 'marc' => ['requiredMethods' => ['getMarcRecord']] + ]; $export = $this->getExport($mainConfig, $exportConfig); $solrDefault = new \VuFind\RecordDriver\SolrDefault(); $solrMarc = new \VuFind\RecordDriver\SolrMarc(); // Only $solrMarc supports the 'marc' option, so we should lose the 'marc' option when we add // the non-supporting $solrDefault to the array: - $this->assertEquals(array('anything', 'marc'), $export->getFormatsForRecords(array($solrMarc))); - $this->assertEquals(array('anything'), $export->getFormatsForRecords(array($solrMarc, $solrDefault))); + $this->assertEquals(['anything', 'marc'], $export->getFormatsForRecords([$solrMarc])); + $this->assertEquals(['anything'], $export->getFormatsForRecords([$solrMarc, $solrDefault])); } /** @@ -203,9 +203,9 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testGetHeaders() { - $config = array('foo' => array('headers' => array('bar'))); - $export = $this->getExport(array(), $config); - $this->assertEquals(array('bar'), $export->getHeaders('foo')->toArray()); + $config = ['foo' => ['headers' => ['bar']]]; + $export = $this->getExport([], $config); + $this->assertEquals(['bar'], $export->getHeaders('foo')->toArray()); } /** @@ -215,9 +215,9 @@ class ExportTest extends \PHPUnit_Framework_TestCase */ public function testGetRedirectUrl() { - $mainConfig = array('config' => array('this' => 'that=true')); + $mainConfig = ['config' => ['this' => 'that=true']]; $template = 'http://result?src={encodedCallback}&fallbacktest={config|config|unset|default}&configtest={encodedConfig|config|this|default}'; - $exportConfig = array('foo' => array('redirectUrl' => $template)); + $exportConfig = ['foo' => ['redirectUrl' => $template]]; $export = $this->getExport($mainConfig, $exportConfig); $this->assertEquals( 'http://result?src=http%3A%2F%2Fcallback&fallbacktest=default&configtest=that%3Dtrue', @@ -236,7 +236,7 @@ class ExportTest extends \PHPUnit_Framework_TestCase 'foo' => [], 'bar' => ['label' => 'baz'], ]; - $export = $this->getExport(array(), $config); + $export = $this->getExport([], $config); // test "use section label as default" $this->assertEquals('foo', $export->getLabelForFormat('foo')); // test "override with label setting" @@ -264,7 +264,7 @@ class ExportTest extends \PHPUnit_Framework_TestCase * * @return Export */ - protected function getExport($main = array(), $export = array()) + protected function getExport($main = [], $export = []) { return new Export(new Config($main), new Config($export)); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Harvester/OAITest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Harvester/OAITest.php index be49a521e0c..c3284103ce2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Harvester/OAITest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Harvester/OAITest.php @@ -65,7 +65,7 @@ class OAITest extends \VuFindTest\Unit\TestCase */ public function testConfig() { - $config = array( + $config = [ 'url' => 'http://localhost', 'set' => 'myset', 'metadataPrefix' => 'fakemdprefix', @@ -81,7 +81,7 @@ class OAITest extends \VuFindTest\Unit\TestCase 'verbose' => true, 'sanitize' => true, 'badXMLLog' => '/my/xml.log', - ); + ]; $oai = new OAI('test', $config, $this->getMockClient()); // Special cases where config key != class property: @@ -94,7 +94,7 @@ class OAITest extends \VuFindTest\Unit\TestCase // Special case where value is transformed: $this->assertEquals( - array($config['injectHeaderElements']), + [$config['injectHeaderElements']], $this->getProperty($oai, 'injectHeaderElements') ); @@ -124,21 +124,21 @@ class OAITest extends \VuFindTest\Unit\TestCase $response->expects($this->any()) ->method('getBody') ->will($this->returnValue('<?xml version="1.0"?><OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"><responseDate>2013-10-11T10:06:06Z</responseDate><request verb="ListSets" metadataPrefix="oai_dc" resumptionToken="" submit="Go">http://vu61162/vufind3/OAI/Server</request><ListSets><set><setSpec>Audio (Music)</setSpec><setName>Audio (Music)</setName></set><set><setSpec>Audio (Non-Music)</setSpec><setName>Audio (Non-Music)</setName></set></ListSets></OAI-PMH>')); - $config = array( + $config = [ 'url' => 'http://localhost', 'injectSetName' => 'setnametag', 'verbose' => true, 'dateGranularity' => 'mygranularity', - ); + ]; $oai = new OAI('test', $config, $client); $this->assertEquals( $config['injectSetName'], $this->getProperty($oai, 'injectSetName') ); $this->assertEquals( - array( + [ 'Audio (Music)' => 'Audio (Music)', 'Audio (Non-Music)' => 'Audio (Non-Music)' - ), $this->getProperty($oai, 'setNames') + ], $this->getProperty($oai, 'setNames') ); } @@ -152,12 +152,12 @@ class OAITest extends \VuFindTest\Unit\TestCase $client = $this->getMockClient(); $client->expects($this->once()) ->method('setOptions') - ->with($this->equalTo(array('sslverifypeer' => false))); - $config = array( + ->with($this->equalTo(['sslverifypeer' => false])); + $config = [ 'url' => 'http://localhost', 'sslverifypeer' => false, 'dateGranularity' => 'mygranularity', - ); + ]; $oai = new OAI('test', $config, $client); } @@ -176,10 +176,10 @@ class OAITest extends \VuFindTest\Unit\TestCase $response->expects($this->any()) ->method('getBody') ->will($this->returnValue($this->getIdentifyResponse())); - $config = array( + $config = [ 'url' => 'http://localhost', 'verbose' => true, - ); + ]; $oai = new OAI('test', $config, $client); $this->assertEquals( 'YYYY-MM-DDThh:mm:ssZ', $this->getProperty($oai, 'granularity') @@ -213,10 +213,10 @@ class OAITest extends \VuFindTest\Unit\TestCase ->method('get') ->with($this->equalTo('Retry-After')) ->will($this->returnValue($header)); - $config = array( + $config = [ 'url' => 'http://localhost', 'verbose' => true, - ); + ]; $oai = new OAI('test', $config, $client); $this->assertEquals( 'YYYY-MM-DDThh:mm:ssZ', $this->getProperty($oai, 'granularity') @@ -237,10 +237,10 @@ class OAITest extends \VuFindTest\Unit\TestCase $response->expects($this->any()) ->method('isSuccess') ->will($this->returnValue(false)); - $config = array( + $config = [ 'url' => 'http://localhost', 'verbose' => true, - ); + ]; $oai = new OAI('test', $config, $client); } @@ -255,7 +255,7 @@ class OAITest extends \VuFindTest\Unit\TestCase */ public function testMissingURLThrowsException() { - $oai = new OAI('test', array(), $this->getMockClient()); + $oai = new OAI('test', [], $this->getMockClient()); } // Internal API diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniReaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniReaderTest.php index dc1e0fc0205..83a130c23f2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniReaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniReaderTest.php @@ -48,10 +48,10 @@ class ExtendedIniReaderTest extends \VuFindTest\Unit\TestCase public function testNonJoinerOptions() { $reader = new ExtendedIniReader(); - $input = array('foo="bar"', 'baz=""'); - $output = array('foo' => 'bar', 'baz' => ''); + $input = ['foo="bar"', 'baz=""']; + $output = ['foo' => 'bar', 'baz' => '']; $nonJoiner = html_entity_decode('‌', ENT_NOQUOTES, 'UTF-8'); - $nonJoinerOutput = array('foo' => 'bar', 'baz' => $nonJoiner); + $nonJoinerOutput = ['foo' => 'bar', 'baz' => $nonJoiner]; // Test behavior with and without the $convertBlanks switch: $this->assertEquals($output, (array)$reader->getTextDomain($input, false)); $this->assertEquals($nonJoinerOutput, (array)$reader->getTextDomain($input)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php index 3ea6e2ec610..faf05c3e65c 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/I18n/Translator/Loader/ExtendedIniTest.php @@ -47,19 +47,19 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase */ public function testTranslations() { - $pathStack = array( + $pathStack = [ realpath(__DIR__ . '/../../../../../../fixtures/language/base'), realpath(__DIR__ . '/../../../../../../fixtures/language/overrides') - ); + ]; $loader = new ExtendedIni($pathStack); $result = $loader->load('en', null); $this->assertEquals( - array( + [ 'blank_line' => html_entity_decode('‌', ENT_NOQUOTES, 'UTF-8'), 'test1' => 'test one', 'test2' => 'test two - override', - ), + ], (array)$result ); } @@ -71,19 +71,19 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase */ public function testFallback() { - $pathStack = array( + $pathStack = [ realpath(__DIR__ . '/../../../../../../fixtures/language/base'), - ); + ]; $loader = new ExtendedIni($pathStack, 'en'); $result = $loader->load('fake', null); $this->assertEquals( - array( + [ 'blank_line' => html_entity_decode('‌', ENT_NOQUOTES, 'UTF-8'), 'test1' => 'test one', 'test2' => 'test two', 'test3' => 'test three', - ), + ], (array)$result ); } @@ -95,15 +95,15 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase */ public function testFallbackToSelf() { - $pathStack = array( + $pathStack = [ realpath(__DIR__ . '/../../../../../../fixtures/language/base'), - ); + ]; $loader = new ExtendedIni($pathStack, 'fake'); $result = $loader->load('fake', null); $this->assertEquals( - array( + [ 'test3' => 'test three', - ), + ], (array)$result ); } @@ -115,16 +115,16 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase */ public function testSelfAsParent() { - $pathStack = array( + $pathStack = [ realpath(__DIR__ . '/../../../../../../fixtures/language/base'), - ); + ]; $loader = new ExtendedIni($pathStack); $result = $loader->load('self-parent', null); $this->assertEquals( - array( + [ '@parent_ini' => 'self-parent.ini', 'string' => 'bad', - ), + ], (array)$result ); } @@ -136,18 +136,18 @@ class ExtendedIniTest extends \VuFindTest\Unit\TestCase */ public function testParentChain() { - $pathStack = array( + $pathStack = [ realpath(__DIR__ . '/../../../../../../fixtures/language/base'), - ); + ]; $loader = new ExtendedIni($pathStack); $result = $loader->load('child2', null); $this->assertEquals( - array( + [ '@parent_ini' => 'child1.ini', 'test1' => 'test 1', 'test2' => 'test 2', 'test3' => 'test three', - ), + ], (array)$result ); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php index 822577ea582..0621f946b5d 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/MultiBackendTest.php @@ -88,16 +88,16 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->throwException(new \Zend\Config\Exception\RuntimeException()) ); $driver = new MultiBackend($mockPM, $this->getMockILSAuthenticator()); - $driver->setConfig(array('Drivers' => array())); + $driver->setConfig(['Drivers' => []]); $driver->setLogger($logger); $driver->init(); - $this->callMethod($driver, 'getDriverConfig', array('bad')); + $this->callMethod($driver, 'getDriverConfig', ['bad']); $this->assertEquals( 'VuFind\ILS\Driver\MultiBackend: Could not load config for bad', $writer->events[0]['message'] ); - $this->callMethod($driver, 'getLocalId', array('bad')); + $this->callMethod($driver, 'getLocalId', ['bad']); $this->assertEquals( 'VuFind\ILS\Driver\MultiBackend: ' . "Could not find local id in 'bad' using '.'", @@ -114,41 +114,41 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager', 'd2' => 'Demo'); + $drivers = ['d1' => 'Voyager', 'd2' => 'Demo']; $this->setProperty($driver, 'drivers', $drivers); - $result = $this->callMethod($driver, 'getSourceFromParams', array('')); + $result = $this->callMethod($driver, 'getSourceFromParams', ['']); $this->assertEquals('', $result); - $data = array( + $data = [ 'id' => 'record1', 'cat_username' => 'record2' - ); - $result = $this->callMethod($driver, 'getSourceFromParams', array($data)); + ]; + $result = $this->callMethod($driver, 'getSourceFromParams', [$data]); $this->assertEquals('', $result); - $data = array( + $data = [ 'id' => 'record1', 'cat_username' => 'd1.record2' - ); - $result = $this->callMethod($driver, 'getSourceFromParams', array($data)); + ]; + $result = $this->callMethod($driver, 'getSourceFromParams', [$data]); $this->assertEquals('d1', $result); - $data = array( + $data = [ 'id' => 'd2.record1', 'cat_username' => 'record2' - ); - $result = $this->callMethod($driver, 'getSourceFromParams', array($data)); + ]; + $result = $this->callMethod($driver, 'getSourceFromParams', [$data]); $this->assertEquals('d2', $result); - $data = array( + $data = [ 'test' => 'true', - 'patron' => array( + 'patron' => [ 'id' => 'd2.record1', 'cat_username' => 'record2' - ) - ); - $result = $this->callMethod($driver, 'getSourceFromParams', array($data)); + ] + ]; + $result = $this->callMethod($driver, 'getSourceFromParams', [$data]); $this->assertEquals('d2', $result); } @@ -163,30 +163,30 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); //Set up the mock driver to be retrieved - $ILS = $this->getMockILS('Voyager', array('init', 'setConfig')); + $ILS = $this->getMockILS('Voyager', ['init', 'setConfig']); $ILS->expects($this->exactly(2)) ->method('init'); $ILS->expects($this->once()) ->method('setConfig') - ->with(array('config' => 'values')); + ->with(['config' => 'values']); //Set up the ServiceLocator so it returns our mock driver $sm = $this->getMockSM($this->once(), 'Voyager', $ILS); $driver->setServiceLocator($sm); //Add an entry for our test driver to the array of drivers - $drivers = array('testing2' => 'Voyager'); + $drivers = ['testing2' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); - $returnDriver = $this->callMethod($driver, 'getDriver', array('testing2')); + $returnDriver = $this->callMethod($driver, 'getDriver', ['testing2']); $this->assertEquals($ILS, $returnDriver); - $this->setProperty($driver, 'isInitialized', array()); - $returnDriver = $this->callMethod($driver, 'getDriver', array('testing2')); + $this->setProperty($driver, 'isInitialized', []); + $returnDriver = $this->callMethod($driver, 'getDriver', ['testing2']); $this->assertEquals($ILS, $returnDriver); $returnDriver - = $this->callMethod($driver, 'getDriver', array('nonexistent')); + = $this->callMethod($driver, 'getDriver', ['nonexistent']); $this->assertNull($returnDriver); } @@ -200,16 +200,16 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); //Set up the mock driver to be retrieved - $ILS = $this->getMockILS('Voyager', array('setConfig')); + $ILS = $this->getMockILS('Voyager', ['setConfig']); $ILS->expects($this->once()) ->method('setConfig') - ->with(array('config' => 'values')); + ->with(['config' => 'values']); //Set up the ServiceLocator so it returns our mock driver $sm = $this->getMockSM($this->once(), 'Voyager', $ILS); $driver->setServiceLocator($sm); //Add an entry for our test driver to the array of drivers - $drivers = array('testing' => 'Voyager'); + $drivers = ['testing' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); //Case: A driver is associated with the given name @@ -217,7 +217,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $unInitDriver = $this->callMethod( $driver, 'getUninitializedDriver', - array('testing') + ['testing'] ); $this->assertEquals($ILS, $unInitDriver); @@ -231,7 +231,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $unInitDriver = $this->callMethod( $driver, 'getUninitializedDriver', - array('testing') + ['testing'] ); $this->assertEquals($ILS, $unInitDriver); @@ -240,7 +240,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $unInitDriver = $this->callMethod( $driver, 'getUninitializedDriver', - array('noDriverWithThisName') + ['noDriverWithThisName'] ); $this->assertNull($unInitDriver); @@ -253,12 +253,12 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->throwException(new \Zend\Config\Exception\RuntimeException()) ); $driver = new MultiBackend($mockPM, $this->getMockILSAuthenticator()); - $driver->setConfig(array('Drivers' => array('d1' => 'Voyager'))); + $driver->setConfig(['Drivers' => ['d1' => 'Voyager']]); $driver->init(); $unInitDriver = $this->callMethod( $driver, 'getUninitializedDriver', - array('d1') + ['d1'] ); $this->assertNull($unInitDriver); } @@ -273,12 +273,12 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); //Set up the mock driver to be initialized. - $ILS = $this->getMockILS('Voyager', array('init')); + $ILS = $this->getMockILS('Voyager', ['init']); $ILS->expects($this->once()) ->method('init'); //Run the test method - $this->callMethod($driver, 'initializeDriver', array($ILS, 'test')); + $this->callMethod($driver, 'initializeDriver', [$ILS, 'test']); //Check the cache arrays $isInit = $this->getProperty($driver, 'isInitialized'); @@ -286,10 +286,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->assertSame($ILS, $cache['test']); $this->assertTrue($isInit['test']); - $this->setProperty($driver, 'isInitialized', array()); + $this->setProperty($driver, 'isInitialized', []); $d = new \VuFind\ILS\Driver\Voyager(new \VuFind\Date\Converter()); $this->setExpectedException('VuFind\Exception\ILS'); - $this->callMethod($driver, 'initializeDriver', array($d, 'fail')); + $this->callMethod($driver, 'initializeDriver', [$d, 'fail']); } /** @@ -299,9 +299,9 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetDriverConfig() { - $configData = array('config' => 'values'); + $configData = ['config' => 'values']; $driver = $this->getDriver(); - $val = $this->callMethod($driver, 'getDriverConfig', array('good')); + $val = $this->callMethod($driver, 'getDriverConfig', ['good']); $this->assertEquals($configData, $val); $config = new \Zend\Config\Config($configData); @@ -312,10 +312,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->throwException(new \Zend\Config\Exception\RuntimeException()) ); $driver = new MultiBackend($mockPM, $this->getMockILSAuthenticator()); - $driver->setConfig(array('Drivers' => array())); + $driver->setConfig(['Drivers' => []]); $driver->init(); - $val = $this->callMethod($driver, 'getDriverConfig', array('bad')); - $this->assertEquals(array(), $val); + $val = $this->callMethod($driver, 'getDriverConfig', ['bad']); + $this->assertEquals([], $val); } /** @@ -327,51 +327,51 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); $source = 'source'; - $data = array(); + $data = []; - $result = $this->callMethod($driver, 'addIdPrefixes', array($data, $source)); + $result = $this->callMethod($driver, 'addIdPrefixes', [$data, $source]); $this->assertEquals($data, $result); - $data = array( + $data = [ 'id' => 'record1', 'cat_username' => 'record2' - ); - $expected = array( + ]; + $expected = [ 'id' => "$source.record1", 'cat_username' => "$source.record2" - ); - $result = $this->callMethod($driver, 'addIdPrefixes', array($data, $source)); + ]; + $result = $this->callMethod($driver, 'addIdPrefixes', [$data, $source]); $this->assertEquals($expected, $result); - $data = array( + $data = [ 'id' => 'record1', - 'cat_username' => array( + 'cat_username' => [ 'id' => 'record2', - 'cat_username' => array( + 'cat_username' => [ 'id' => 'record3', 'cat_username' => 'record4' - ), + ], 'cat_info' => 'record5', 'other' => 'something' - ), + ], 'cat_info' => 'record6' - ); - $expected = array( + ]; + $expected = [ 'id' => "$source.record1", - 'cat_username' => array( + 'cat_username' => [ 'id' => "$source.record2", - 'cat_username' => array( + 'cat_username' => [ 'id' => "$source.record3", 'cat_username' => "$source.record4" - ), + ], 'cat_info' => "$source.record5", 'other' => 'something' - ), + ], 'cat_info' => "$source.record6" - ); - $modify = array('id', 'cat_username', 'cat_info'); + ]; + $modify = ['id', 'cat_username', 'cat_info']; $result = $this->callMethod( - $driver, 'addIdPrefixes', array($data, $source, $modify) + $driver, 'addIdPrefixes', [$data, $source, $modify] ); $this->assertEquals($expected, $result); } @@ -385,60 +385,60 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); $source = 'source'; - $data = array(); + $data = []; $result - = $this->callMethod($driver, 'stripIdPrefixes', array($data, $source)); + = $this->callMethod($driver, 'stripIdPrefixes', [$data, $source]); $this->assertEquals($data, $result); $data = "$source.record"; $result - = $this->callMethod($driver, 'stripIdPrefixes', array($data, $source)); + = $this->callMethod($driver, 'stripIdPrefixes', [$data, $source]); $this->assertEquals("record", $result); - $delimiters = array('login' => "\t"); + $delimiters = ['login' => "\t"]; $this->setproperty($driver, 'delimiters', $delimiters); - $expected = array( + $expected = [ 'id' => 'record1', 'cat_username' => 'record2' - ); - $data = array( + ]; + $data = [ 'id' => "$source.record1", 'cat_username' => "$source\trecord2" - ); + ]; $result - = $this->callMethod($driver, 'stripIdPrefixes', array($data, $source)); + = $this->callMethod($driver, 'stripIdPrefixes', [$data, $source]); $this->assertEquals($expected, $result); - $expected = array( + $expected = [ 'id' => 'record1', - 'cat_username' => array( + 'cat_username' => [ 'id' => 'record2', - 'cat_username' => array( + 'cat_username' => [ 'id' => 'record3', 'cat_username' => 'record4' - ), + ], 'cat_info' => 'record5', 'other' => "$source.something" - ), + ], 'cat_info' => 'record6' - ); - $data = array( + ]; + $data = [ 'id' => "$source.record1", - 'cat_username' => array( + 'cat_username' => [ 'id' => "$source.record2", - 'cat_username' => array( + 'cat_username' => [ 'id' => "$source.record3", 'cat_username' => "$source\trecord4" - ), + ], 'cat_info' => "$source.record5", 'other' => "$source.something" - ), + ], 'cat_info' => "$source.record6" - ); - $modify = array('id', 'cat_username', 'cat_info'); + ]; + $modify = ['id', 'cat_username', 'cat_info']; $result = $this->callMethod( - $driver, 'stripIdPrefixes', array($data, $source, $modify) + $driver, 'stripIdPrefixes', [$data, $source, $modify] ); $this->assertEquals($expected, $result); } @@ -451,26 +451,26 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase public function testMethodSupported() { $driver = $this->getDriver(); - $voyager = $this->getMockILS('Voyager', array('init')); + $voyager = $this->getMockILS('Voyager', ['init']); $result = $this->callMethod( - $driver, 'methodSupported', array($voyager, 'getHolding') + $driver, 'methodSupported', [$voyager, 'getHolding'] ); $this->assertTrue($result); $result = $this->callMethod( - $driver, 'methodSupported', array($voyager, 'INVALIDMETHOD') + $driver, 'methodSupported', [$voyager, 'INVALIDMETHOD'] ); $this->assertFalse($result); - $dummy = $this->getMockILS('Voyager', array('init', 'supportsMethod')); + $dummy = $this->getMockILS('Voyager', ['init', 'supportsMethod']); $dummy->expects($this->once()) ->method('supportsMethod') ->with('getHolding') ->will($this->returnValue(false)); $result = $this->callMethod( - $driver, 'methodSupported', array($dummy, 'getHolding') + $driver, 'methodSupported', [$dummy, 'getHolding'] ); $this->assertFalse($result); } @@ -483,11 +483,11 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase public function testGetHolding() { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager'); + $drivers = ['d1' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); $id = '123456'; - $ILS = $this->getMockILS('Voyager', array('init', 'getHolding')); + $ILS = $this->getMockILS('Voyager', ['init', 'getHolding']); $ILS->expects($this->exactly(2)) ->method('getHolding') ->with( @@ -500,9 +500,9 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->returnCallback( function ($param) { if ($param == '123456') { - return array('id' => '123456', 'status' => 'in'); + return ['id' => '123456', 'status' => 'in']; } - return array(); + return []; } ) ); @@ -510,15 +510,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $sm = $this->getMockSM($this->any(), 'Voyager', $ILS); $driver->setServiceLocator($sm); - $expectedReturn = array('id' => 'd1.123456', 'status' => 'in'); + $expectedReturn = ['id' => 'd1.123456', 'status' => 'in']; $return = $driver->getHolding("d1.$id"); $this->assertEquals($expectedReturn, $return); $return = $driver->getHolding("fail.$id"); - $this->assertEquals(array(), $return); + $this->assertEquals([], $return); $return = $driver->getHolding('d1.654321'); - $this->assertEquals(array(), $return); + $this->assertEquals([], $return); } /** @@ -529,12 +529,12 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase public function testGetPurchaseHistory() { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager'); + $drivers = ['d1' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); $id = 'd1.123456'; - $driverReturn = array('purchases' => '123456'); - $ILS = $this->getMockILS('Voyager', array('init', 'getPurchaseHistory')); + $driverReturn = ['purchases' => '123456']; + $ILS = $this->getMockILS('Voyager', ['init', 'getPurchaseHistory']); $ILS->expects($this->once()) ->method('getPurchaseHistory') ->with('123456') @@ -547,7 +547,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->assertEquals($driverReturn, $return); $return = $driver->getPurchaseHistory("fail.$id"); - $this->assertEquals(array(), $return); + $this->assertEquals([], $return); } /** @@ -560,7 +560,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $driver = $this->getDriver(); $result = $driver->getLoginDrivers(); - $this->assertEquals(array('d1', 'd2'), $result); + $this->assertEquals(['d1', 'd2'], $result); } /** @@ -576,22 +576,22 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->assertEquals('d1', $result); $driver->setConfig( - array( - 'Drivers' => array(), - 'Login' => array( - 'drivers' => array('d2', 'd1') - ) - ) + [ + 'Drivers' => [], + 'Login' => [ + 'drivers' => ['d2', 'd1'] + ] + ] ); $result = $driver->getDefaultLoginDriver(); $this->assertEquals('d2', $result); $driver->setConfig( - array( - 'Drivers' => array(), - 'Login' => array() - ) + [ + 'Drivers' => [], + 'Login' => [] + ] ); $result = $driver->getDefaultLoginDriver(); $this->assertEquals('', $result); @@ -605,10 +605,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase public function testGetStatus() { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager'); + $drivers = ['d1' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); - $ILS = $this->getMockILS('Voyager', array('init', 'getStatus')); + $ILS = $this->getMockILS('Voyager', ['init', 'getStatus']); $ILS->expects($this->exactly(2)) ->method('getStatus') ->with( @@ -620,7 +620,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ->will( $this->returnCallback( function ($param) { - $r_arr = array('id' => $param); + $r_arr = ['id' => $param]; if ($param == '123456') { $r_arr['status'] = 'in'; } elseif ($param == '654321') { @@ -637,13 +637,13 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $driver->setServiceLocator($sm); $return = $driver->getStatus('d1.123456'); - $this->assertEquals(array('id' => 'd1.123456', 'status' => 'in'), $return); + $this->assertEquals(['id' => 'd1.123456', 'status' => 'in'], $return); $return = $driver->getStatus('d1.654321'); - $this->assertEquals(array('id' => 'd1.654321', 'status' => 'out'), $return); + $this->assertEquals(['id' => 'd1.654321', 'status' => 'out'], $return); $return = $driver->getStatus('invalid.654321'); - $this->assertEquals(array(), $return); + $this->assertEquals([], $return); } /** @@ -654,10 +654,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase public function testGetStatuses() { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager'); + $drivers = ['d1' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); - $ILS = $this->getMockILS('Voyager', array('init', 'getStatus')); + $ILS = $this->getMockILS('Voyager', ['init', 'getStatus']); $ILS->expects($this->exactly(4)) ->method('getStatus') ->with( @@ -671,7 +671,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ->will( $this->returnCallback( function ($param) { - $r_arr = array('id' => $param); + $r_arr = ['id' => $param]; if ($param == '123456') { $r_arr['status'] = 'in'; } elseif ($param == '654321') { @@ -689,20 +689,20 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $sm = $this->getMockSM($this->any(), 'Voyager', $ILS); $driver->setServiceLocator($sm); - $ids = array( + $ids = [ 'd1.123456', 'd1.098765', 'd1.654321', 'd1.567890' - ); - $expectedReturn = array( - array('id' => "d1.123456", 'status' => 'in'), - array('id' => "d1.098765", 'status' => 'out'), - array('id' => "d1.654321", 'status' => 'out'), - array('id' => "d1.567890", 'status' => 'in') - ); + ]; + $expectedReturn = [ + ['id' => "d1.123456", 'status' => 'in'], + ['id' => "d1.098765", 'status' => 'out'], + ['id' => "d1.654321", 'status' => 'out'], + ['id' => "d1.567890", 'status' => 'in'] + ]; $return = $driver->getStatuses($ids); $this->assertEquals($expectedReturn, $return); - $return = $driver->getStatuses(array()); - $this->assertEquals(array(), $return); + $return = $driver->getStatuses([]); + $this->assertEquals([], $return); } /** @@ -714,10 +714,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); $term = "source.local"; - $return = $this->callMethod($driver, 'getLocalId', array($term)); + $return = $this->callMethod($driver, 'getLocalId', [$term]); $this->assertEquals("local", $return); - $return = $this->callMethod($driver, 'getLocalId', array($term, '!')); + $return = $this->callMethod($driver, 'getLocalId', [$term, '!']); $this->assertEquals($term, $return); } @@ -734,17 +734,17 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase //Result: return the function results for that driver $patron = $this->getPatron('username', 'institution'); - $drivers = array( + $drivers = [ 'otherinst' => 'Unicorn', 'institution' => 'Voyager' - ); + ]; $this->setProperty($driver, 'drivers', $drivers); $patronPrefixless = $this->callMethod( - $driver, 'stripIdPrefixes', array($patron, 'institution') + $driver, 'stripIdPrefixes', [$patron, 'institution'] ); - $ILS = $this->getMockILS('Voyager', array('getMyTransactions', 'init')); + $ILS = $this->getMockILS('Voyager', ['getMyTransactions', 'init']); $ILS->expects($this->atLeastOnce()) ->method('getMyTransactions') ->with($patronPrefixless) @@ -763,7 +763,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // fall back on the defaultDriver implementation $patron['cat_username'] = 'username'; - $ILS = $this->getMockILS('Unicorn', array('getMyTransactions', 'init')); + $ILS = $this->getMockILS('Unicorn', ['getMyTransactions', 'init']); $ILS->expects($this->atLeastOnce()) ->method('getMyTransactions') ->with($patron) @@ -784,19 +784,19 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetNewItems() { - $expected = array('test' => 'true'); + $expected = ['test' => 'true']; $driver = $this->initSimpleMethodTest( $this->once(), $this->never(), 'getNewItems', - array(1, 10, 5, 0), + [1, 10, 5, 0], $expected, $expected ); // getNewItems only works with a default driver, so the first calls fails $result = $driver->getNewItems(1, 10, 5, 0); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setProperty($driver, 'defaultDriver', 'd1'); $result = $driver->getNewItems(1, 10, 5, 0); @@ -810,19 +810,19 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testFindReserves() { - $expected = array('test' => 'true'); + $expected = ['test' => 'true']; $driver = $this->initSimpleMethodTest( $this->once(), $this->never(), 'findReserves', - array('course', 'inst', 'dept'), + ['course', 'inst', 'dept'], $expected, $expected ); // findReserves only works with a default driver, so the first calls fails $result = $driver->findReserves('course', 'inst', 'dept'); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setProperty($driver, 'defaultDriver', 'd1'); $result = $driver->findReserves('course', 'inst', 'dept'); @@ -836,19 +836,19 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyProfile() { - $expected1 = array('test' => '1'); - $expected2 = array('test' => '2'); + $expected1 = ['test' => '1']; + $expected2 = ['test' => '2']; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyProfile', - array($this->getPatron('username')), + [$this->getPatron('username')], $expected1, $expected2 ); $result = $driver->getMyProfile($this->getPatron('username', 'invalid')); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $result = $driver->getMyProfile($this->getPatron('username', 'd1')); $this->assertEquals($expected1, $result); @@ -870,7 +870,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $instance = 'institution'; //Set up the mock object and prepare its expectations - $ILS = $this->getMockILS('Voyager', array('patronLogin')); + $ILS = $this->getMockILS('Voyager', ['patronLogin']); $ILS->expects($this->at(0)) ->method('patronLogin') ->with('username', 'password') @@ -881,9 +881,9 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ->will($this->returnValue($patronReturn)); //Prep MultiBackend with values it will need - $drivers = array($instance => 'Voyager'); - $isInit = array($instance => true); - $cache = array($instance => $ILS); + $drivers = [$instance => 'Voyager']; + $isInit = [$instance => true]; + $cache = [$instance => $ILS]; $this->setProperty($driver, 'drivers', $drivers); $this->setProperty($driver, 'isInitialized', $isInit); $this->setProperty($driver, 'cache', $cache); @@ -899,15 +899,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Try with another delimiter $driver->setConfig( - array( - 'Drivers' => array(), - 'Login' => array( - 'drivers' => array('d2', 'd1') - ), - 'Delimiters' => array( + [ + 'Drivers' => [], + 'Login' => [ + 'drivers' => ['d2', 'd1'] + ], + 'Delimiters' => [ 'login' => "\t" - ) - ) + ] + ] ); $driver->init(); @@ -931,15 +931,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyTransactions() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyTransactions', - array($this->getPatron('username')), - array(array('id' => '1')), - array(array('id' => '1')) + [$this->getPatron('username')], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getMyTransactions($this->getPatron('username', 'd1')); @@ -963,28 +963,28 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetRenewDetails() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getRenewDetails', - array(array('id' => 'loanid')), - array(array('id' => '1')), - array(array('id' => '1')) + [['id' => 'loanid']], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getRenewDetails( - array( + [ 'id' => 'd1.loanid' - ) + ] ); $this->assertEquals($expected1, $result); $result = $driver->getRenewDetails( - array( + [ 'id' => 'd2.loanid' - ) + ] ); $this->assertEquals($expected2, $result); @@ -992,9 +992,9 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->getRenewDetails( - array( + [ 'id' => 'invalid.loanid' - ) + ] ); } @@ -1005,30 +1005,30 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testRenewMyItems() { - $expected1 = array( - array('id' => 'd1.1'), - array('id' => 'd1.2') - ); - $expected2 = array( - array('id' => 'd2.1'), - array('id' => 'd2.2') - ); + $expected1 = [ + ['id' => 'd1.1'], + ['id' => 'd1.2'] + ]; + $expected2 = [ + ['id' => 'd2.1'], + ['id' => 'd2.2'] + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'renewMyItems', - array(array('patron' => $this->getPatron('username'))), - array(array('id' => '1'), array('id' => '2')), - array(array('id' => '1'), array('id' => '2')) + [['patron' => $this->getPatron('username')]], + [['id' => '1'], ['id' => '2']], + [['id' => '1'], ['id' => '2']] ); $result = $driver->renewMyItems( - array('patron' => $this->getPatron('username', 'd1')) + ['patron' => $this->getPatron('username', 'd1')] ); $this->assertEquals($expected1, $result); $result = $driver->renewMyItems( - array('patron' => $this->getPatron('username', 'd2')) + ['patron' => $this->getPatron('username', 'd2')] ); $this->assertEquals($expected2, $result); @@ -1036,7 +1036,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->renewMyItems( - array('patron' => $this->getPatron('username', 'invalid')) + ['patron' => $this->getPatron('username', 'invalid')] ); } @@ -1047,15 +1047,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyFines() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyFines', - array($this->getPatron('username')), - array(array('id' => '1')), - array(array('id' => '1')) + [$this->getPatron('username')], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getMyFines($this->getPatron('username', 'd1')); @@ -1077,15 +1077,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyHolds() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyHolds', - array($this->getPatron('username')), - array(array('id' => '1')), - array(array('id' => '1')) + [$this->getPatron('username')], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getMyHolds($this->getPatron('username', 'd1')); @@ -1107,15 +1107,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyStorageRetrievalRequests() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyStorageRetrievalRequests', - array($this->getPatron('username')), - array(array('id' => '1')), - array(array('id' => '1')) + [$this->getPatron('username')], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getMyStorageRetrievalRequests( @@ -1132,7 +1132,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $result = $driver->getMyStorageRetrievalRequests( $this->getPatron('username', 'd3') ); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setExpectedException( 'VuFind\Exception\ILS', 'No suitable backend driver found' @@ -1155,29 +1155,29 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->once(), $this->once(), 'checkRequestIsValid', - array( + [ 'bibid', - array('id' => 'itemid'), + ['id' => 'itemid'], $this->getPatron('username') - ), + ], true, false ); $result = $driver->checkRequestIsValid( 'd1.bibid', - array( + [ 'id' => 'd1.itemid' - ), + ], $this->getPatron('username', 'd1') ); $this->assertEquals($expected1, $result); $result = $driver->checkRequestIsValid( 'd2.bibid', - array( + [ 'id' => 'd2.itemid' - ), + ], $this->getPatron('username', 'd2') ); $this->assertEquals($expected2, $result); @@ -1185,9 +1185,9 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Cross-driver request must not be accepted $result = $driver->checkRequestIsValid( 'd1.bibid', - array( + [ 'id' => 'd1.itemid' - ), + ], $this->getPatron('username', 'd2') ); $this->assertFalse($result); @@ -1195,18 +1195,18 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Request with a patron missing cat_username must not be accepted $result = $driver->checkRequestIsValid( 'd1.bibid', - array( + [ 'id' => 'd1.itemid' - ), - array('bad patron') + ], + ['bad patron'] ); $this->assertFalse($result); $result = $driver->checkRequestIsValid( 'invalid.bibid', - array( + [ 'id' => 'invalid.itemid' - ), + ], $this->getPatron('username', 'invalid') ); $this->assertFalse($result); @@ -1225,29 +1225,29 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->once(), $this->once(), 'checkStorageRetrievalRequestIsValid', - array( + [ 'bibid', - array('id' => 'itemid'), + ['id' => 'itemid'], $this->getPatron('username') - ), + ], true, false ); $result = $driver->checkStorageRetrievalRequestIsValid( 'd1.bibid', - array( + [ 'id' => 'd1.itemid' - ), + ], $this->getPatron('username', 'd1') ); $this->assertEquals($expected1, $result); $result = $driver->checkStorageRetrievalRequestIsValid( 'd2.bibid', - array( + [ 'id' => 'd2.itemid' - ), + ], $this->getPatron('username', 'd2') ); $this->assertEquals($expected2, $result); @@ -1255,18 +1255,18 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Cross-driver request must not be accepted $result = $driver->checkStorageRetrievalRequestIsValid( 'd1.bibid', - array( + [ 'id' => 'd1.itemid' - ), + ], $this->getPatron('username', 'd2') ); $this->assertFalse($result); $result = $driver->checkStorageRetrievalRequestIsValid( 'invalid.bibid', - array( + [ 'id' => 'invalid.itemid' - ), + ], $this->getPatron('username', 'invalid') ); $this->assertFalse($result); @@ -1279,45 +1279,45 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetPickUpLocations() { - $expected1 = array(array('locationID' => '1')); - $expected2 = array(array('locationID' => '2')); + $expected1 = [['locationID' => '1']]; + $expected2 = [['locationID' => '2']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getPickUpLocations', - array( + [ $this->getPatron('username'), - array('id' => '1') - ), + ['id' => '1'] + ], $expected1, $expected2 ); $result = $driver->getPickUpLocations( $this->getPatron('username', 'd1'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); $this->assertEquals($expected1, $result); $result = $driver->getPickUpLocations( $this->getPatron('username', 'd2'), - array('id' => 'd2.1') + ['id' => 'd2.1'] ); $this->assertEquals($expected2, $result); // Must return empty set if sources of patron id and bib id differ $result = $driver->getPickUpLocations( $this->getPatron('username', 'd2'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setExpectedException( 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->getPickUpLocations( $this->getPatron('username', 'invalid'), - array('id' => '1') + ['id' => '1'] ); } @@ -1334,30 +1334,30 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->once(), $this->once(), 'getDefaultPickUpLocation', - array( + [ $this->getPatron('username'), - array('id' => '1') - ), + ['id' => '1'] + ], $expected1, $expected2 ); $result = $driver->getDefaultPickUpLocation( $this->getPatron('username', 'd1'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); $this->assertEquals($expected1, $result); $result = $driver->getDefaultPickUpLocation( $this->getPatron('username', 'd2'), - array('id' => 'd2.1') + ['id' => 'd2.1'] ); $this->assertEquals($expected2, $result); // Must return false if sources of patron id and bib id differ $result = $driver->getDefaultPickUpLocation( $this->getPatron('username', 'd2'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); $this->assertFalse($result); @@ -1366,7 +1366,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ); $result = $driver->getDefaultPickUpLocation( $this->getPatron('username', 'invalid'), - array('id' => '1') + ['id' => '1'] ); } @@ -1377,16 +1377,16 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetRequestGroups() { - $expected1 = array(array('locationID' => '1')); - $expected2 = array(array('locationID' => '2')); + $expected1 = [['locationID' => '1']]; + $expected2 = [['locationID' => '2']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getRequestGroups', - array( + [ '1', $this->getPatron('username') - ), + ], $expected1, $expected2 ); @@ -1408,7 +1408,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'd1.1', $this->getPatron('username', 'd2') ); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setExpectedException( 'VuFind\Exception\ILS', 'No suitable backend driver found' @@ -1432,30 +1432,30 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->once(), $this->once(), 'getDefaultRequestGroup', - array( + [ $this->getPatron('username'), - array('id' => '1') - ), + ['id' => '1'] + ], $expected1, $expected2 ); $result = $driver->getDefaultRequestGroup( $this->getPatron('username', 'd1'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); $this->assertEquals($expected1, $result); $result = $driver->getDefaultRequestGroup( $this->getPatron('username', 'd2'), - array('id' => 'd2.1') + ['id' => 'd2.1'] ); $this->assertEquals($expected2, $result); // Must return false if sources of patron id and bib id differ $result = $driver->getDefaultRequestGroup( $this->getPatron('username', 'd2'), - array('id' => 'd1.1') + ['id' => 'd1.1'] ); $this->assertFalse($result); @@ -1464,7 +1464,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ); $result = $driver->getDefaultRequestGroup( $this->getPatron('username', 'invalid'), - array('id' => '1') + ['id' => '1'] ); } @@ -1475,48 +1475,48 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testPlaceHold() { - $expected1 = array( + $expected1 = [ 'success' => true, 'status' => '' - ); - $expected2 = array( + ]; + $expected2 = [ 'success' => false, 'status' => 'hold_error_fail' - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'placeHold', - array(array('patron' => $this->getPatron('username'), 'id' => 1)), + [['patron' => $this->getPatron('username'), 'id' => 1]], $expected1, $expected2 ); $result = $driver->placeHold( - array( + [ 'patron' => $this->getPatron('username', 'd1'), 'id' => 'd1.1' - ) + ] ); $this->assertEquals($expected1, $result); $result = $driver->placeHold( - array( + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 'd2.1' - ) + ] ); $this->assertEquals($expected2, $result); // Patron/item source mismatch $result = $driver->placeHold( - array( + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 'd1.1' - ) + ] ); $this->assertEquals( - array('success' => false, 'sysMessage' => 'hold_wrong_user_institution'), + ['success' => false, 'sysMessage' => 'hold_wrong_user_institution'], $result ); @@ -1524,10 +1524,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->placeHold( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), 'id' => 'invalid.1' - ) + ] ); } @@ -1538,44 +1538,44 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testCancelHolds() { - $expected = array( - '1' => array( + $expected = [ + '1' => [ 'success' => true, 'status' => 'hold_cancel_success' - ), - '2' => array( + ], + '2' => [ 'success' => false, 'status' => 'hold_cancel_fail' - ) + ] - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'cancelHolds', - array( - array( + [ + [ 'patron' => $this->getPatron('username'), - 'details' => array('1', '2') - ) - ), + 'details' => ['1', '2'] + ] + ], $expected, $expected ); $result = $driver->cancelHolds( - array( + [ 'patron' => $this->getPatron('username', 'd1'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); $result = $driver->cancelHolds( - array( + [ 'patron' => $this->getPatron('username', 'd2'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); @@ -1583,10 +1583,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->cancelHolds( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); } @@ -1597,23 +1597,23 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetCancelHoldDetails() { - $expected = array('1', '2'); + $expected = ['1', '2']; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getCancelHoldDetails', - array(array('id' => '1', 'item_id' => '2')), + [['id' => '1', 'item_id' => '2']], $expected, $expected ); $result = $driver->getCancelHoldDetails( - array('id' => 'd1.1', 'item_id' => 2) + ['id' => 'd1.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); $result = $driver->getCancelHoldDetails( - array('id' => 'd2.1', 'item_id' => 2) + ['id' => 'd2.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); @@ -1621,7 +1621,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->getCancelHoldDetails( - array('id' => 'invalid.1', 'item_id' => 2) + ['id' => 'invalid.1', 'item_id' => 2] ); } @@ -1632,48 +1632,48 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testPlaceStorageRetrievalRequest() { - $expected1 = array( + $expected1 = [ 'success' => true, 'status' => '' - ); - $expected2 = array( + ]; + $expected2 = [ 'success' => false, 'status' => 'storage_retrieval_request_error_blocked' - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'placeStorageRetrievalRequest', - array(array('patron' => $this->getPatron('username'), 'id' => 1)), + [['patron' => $this->getPatron('username'), 'id' => 1]], $expected1, $expected2 ); $result = $driver->placeStorageRetrievalRequest( - array( + [ 'patron' => $this->getPatron('username', 'd1'), 'id' => 'd1.1' - ) + ] ); $this->assertEquals($expected1, $result); $result = $driver->placeStorageRetrievalRequest( - array( + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 'd2.1' - ) + ] ); $this->assertEquals($expected2, $result); // Patron/item source mismatch $result = $driver->placeStorageRetrievalRequest( - array( + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 'd1.1' - ) + ] ); $this->assertEquals( - array('success' => false, 'sysMessage' => 'hold_wrong_user_institution'), + ['success' => false, 'sysMessage' => 'hold_wrong_user_institution'], $result ); @@ -1681,10 +1681,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->placeStorageRetrievalRequest( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), 'id' => 'invalid.1' - ) + ] ); } @@ -1695,44 +1695,44 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testCancelStorageRetrievalRequests() { - $expected = array( - '1' => array( + $expected = [ + '1' => [ 'success' => true, 'status' => 'storage_retrieval_request_cancel_success' - ), - '2' => array( + ], + '2' => [ 'success' => false, 'status' => 'storage_retrieval_request_cancel_fail' - ) + ] - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'cancelStorageRetrievalRequests', - array( - array( + [ + [ 'patron' => $this->getPatron('username'), - 'details' => array('1', '2') - ) - ), + 'details' => ['1', '2'] + ] + ], $expected, $expected ); $result = $driver->cancelStorageRetrievalRequests( - array( + [ 'patron' => $this->getPatron('username', 'd1'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); $result = $driver->cancelStorageRetrievalRequests( - array( + [ 'patron' => $this->getPatron('username', 'd2'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); @@ -1740,10 +1740,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->cancelStorageRetrievalRequests( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); } @@ -1754,23 +1754,23 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetCancelStorageRetrievalRequestDetails() { - $expected = array('1', '2'); + $expected = ['1', '2']; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getCancelStorageRetrievalRequestDetails', - array(array('id' => '1','item_id' => '2')), + [['id' => '1','item_id' => '2']], $expected, $expected ); $result = $driver->getCancelStorageRetrievalRequestDetails( - array('id' => 'd1.1', 'item_id' => 2) + ['id' => 'd1.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); $result = $driver->getCancelStorageRetrievalRequestDetails( - array('id' => 'd2.1', 'item_id' => 2) + ['id' => 'd2.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); @@ -1778,7 +1778,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->getCancelStorageRetrievalRequestDetails( - array('id' => 'invalid.1', 'item_id' => 2) + ['id' => 'invalid.1', 'item_id' => 2] ); } @@ -1795,28 +1795,28 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->exactly(2), $this->once(), 'checkILLRequestIsValid', - array( + [ 'bibid', - array('id' => 'itemid'), + ['id' => 'itemid'], $this->logicalOr( $this->getPatron('username', 'd1'), $this->getPatron('username', 'd2') ) - ), + ], true, false ); $result = $driver->checkILLRequestIsValid( 'd1.bibid', - array('id' => 'd1.itemid'), + ['id' => 'd1.itemid'], $this->getPatron('username', 'd1') ); $this->assertEquals($expected1, $result); $result = $driver->checkILLRequestIsValid( 'd2.bibid', - array('id' => 'd2.itemid'), + ['id' => 'd2.itemid'], $this->getPatron('username', 'd2') ); $this->assertEquals($expected2, $result); @@ -1824,7 +1824,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Cross-driver request must be accepted $result = $driver->checkILLRequestIsValid( 'd1.bibid', - array('id' => 'd1.itemid'), + ['id' => 'd1.itemid'], $this->getPatron('username', 'd2') ); $this->assertEquals(true, $result); @@ -1834,7 +1834,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ); $result = $driver->checkILLRequestIsValid( 'invalid.bibid', - array('id' => 'invalid.itemid'), + ['id' => 'invalid.itemid'], $this->getPatron('username', 'invalid') ); $this->assertFalse($result); @@ -1847,19 +1847,19 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetILLPickupLibraries() { - $expected1 = array(array('locationID' => '1')); - $expected2 = array(array('locationID' => '2')); + $expected1 = [['locationID' => '1']]; + $expected2 = [['locationID' => '2']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getILLPickupLibraries', - array( + [ '1', $this->logicalOr( $this->getPatron('username', 'd1'), $this->getPatron('username', 'd2') ) - ), + ], $expected1, $expected2 ); @@ -1892,20 +1892,20 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetILLPickupLocations() { - $expected1 = array(array('locationID' => '1')); - $expected2 = array(array('locationID' => '2')); + $expected1 = [['locationID' => '1']]; + $expected2 = [['locationID' => '2']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getILLPickupLocations', - array( + [ '1', '2', $this->logicalOr( $this->getPatron('username', 'd1'), $this->getPatron('username', 'd2') ) - ), + ], $expected1, $expected2 ); @@ -1941,47 +1941,47 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testPlaceILLRequest() { - $expected1 = array( + $expected1 = [ 'success' => true, 'status' => '' - ); - $expected2 = array( + ]; + $expected2 = [ 'success' => false, 'status' => 'ill_request_error_fail' - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'placeILLRequest', - array( + [ $this->logicalOr( - array( + [ 'patron' => $this->getPatron('username', 'd1'), 'id' => 1 - ), - array( + ], + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 1 - ) + ] ) - ), + ], $expected1, $expected2 ); $result = $driver->placeILLRequest( - array( + [ 'patron' => $this->getPatron('username', 'd1'), 'id' => 'd1.1' - ) + ] ); $this->assertEquals($expected1, $result); $result = $driver->placeILLRequest( - array( + [ 'patron' => $this->getPatron('username', 'd2'), 'id' => 'd2.1' - ) + ] ); $this->assertEquals($expected2, $result); @@ -1989,10 +1989,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->placeILLRequest( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), 'id' => 'invalid.1' - ) + ] ); } @@ -2003,15 +2003,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetMyILLRequests() { - $expected1 = array(array('id' => 'd1.1')); - $expected2 = array(array('id' => 'd2.1')); + $expected1 = [['id' => 'd1.1']]; + $expected2 = [['id' => 'd2.1']]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getMyILLRequests', - array($this->getPatron('username')), - array(array('id' => '1')), - array(array('id' => '1')) + [$this->getPatron('username')], + [['id' => '1']], + [['id' => '1']] ); $result = $driver->getMyILLRequests($this->getPatron('username', 'd1')); @@ -2022,7 +2022,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase // Try handling of unsupported request $result = $driver->getMyILLRequests($this->getPatron('username', 'd3')); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); $this->setExpectedException( 'VuFind\Exception\ILS', 'No suitable backend driver found' @@ -2039,44 +2039,44 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testCancelILLRequests() { - $expected = array( - '1' => array( + $expected = [ + '1' => [ 'success' => true, 'status' => 'ill_request_cancel_success' - ), - '2' => array( + ], + '2' => [ 'success' => false, 'status' => 'storage_retrieval_request_cancel_fail' - ) + ] - ); + ]; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'cancelILLRequests', - array( - array( + [ + [ 'patron' => $this->getPatron('username'), - 'details' => array('1', '2') - ) - ), + 'details' => ['1', '2'] + ] + ], $expected, $expected ); $result = $driver->cancelILLRequests( - array( + [ 'patron' => $this->getPatron('username', 'd1'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); $result = $driver->cancelILLRequests( - array( + [ 'patron' => $this->getPatron('username', 'd2'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); $this->assertEquals($expected, $result); @@ -2084,10 +2084,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->cancelILLRequests( - array( + [ 'patron' => $this->getPatron('username', 'invalid'), - 'details' => array('1', '2') - ) + 'details' => ['1', '2'] + ] ); } @@ -2098,23 +2098,23 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetCancelILLRequestDetails() { - $expected = array('1', '2'); + $expected = ['1', '2']; $driver = $this->initSimpleMethodTest( $this->once(), $this->once(), 'getCancelILLRequestDetails', - array(array('id' => '1','item_id' => '2')), + [['id' => '1','item_id' => '2']], $expected, $expected ); $result = $driver->getCancelILLRequestDetails( - array('id' => 'd1.1', 'item_id' => 2) + ['id' => 'd1.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); $result = $driver->getCancelILLRequestDetails( - array('id' => 'd2.1', 'item_id' => 2) + ['id' => 'd2.1', 'item_id' => 2] ); $this->assertEquals($expected, $result); @@ -2122,7 +2122,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'VuFind\Exception\ILS', 'No suitable backend driver found' ); $result = $driver->getCancelILLRequestDetails( - array('id' => 'invalid.1', 'item_id' => 2) + ['id' => 'invalid.1', 'item_id' => 2] ); } @@ -2133,40 +2133,40 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ public function testGetConfig() { - $expected1 = array('config' => 'ok1'); - $expected2 = array('config' => 'ok2'); + $expected1 = ['config' => 'ok1']; + $expected2 = ['config' => 'ok2']; $driver = $this->initSimpleMethodTest( $this->exactly(3), $this->once(), 'getConfig', - array( + [ $this->logicalOr( 'Holds', - array('Holds', array('id' => '123456')), - array( + ['Holds', ['id' => '123456']], + [ 'Holds', - array('patron' => $this->getPatron('123456')) - ) + ['patron' => $this->getPatron('123456')] + ] ) - ), + ], $expected1, $expected2 ); - $result = $driver->getConfig('Holds', array('id' => 'd1.123456')); + $result = $driver->getConfig('Holds', ['id' => 'd1.123456']); $this->assertEquals($expected1, $result); $result = $driver->getConfig( 'Holds', - array('patron' => $this->getPatron('123456', 'd1')) + ['patron' => $this->getPatron('123456', 'd1')] ); $this->assertEquals($expected1, $result); - $return = $driver->getConfig('Holds', array('id' => 'fail.123456')); - $this->assertEquals(array(), $return); + $return = $driver->getConfig('Holds', ['id' => 'fail.123456']); + $this->assertEquals([], $return); $this->setProperty($driver, 'defaultDriver', 'd2'); - $return = $driver->getConfig('Holds', array()); + $return = $driver->getConfig('Holds', []); $this->assertEquals($expected2, $return); $mockAuth = $this->getMockILSAuthenticator('d1'); @@ -2186,10 +2186,10 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase { $driver = $this->getDriver(); //Set up the mock driver to be retrieved - $ILS = $this->getMockILS('Voyager', array('setConfig', 'init')); + $ILS = $this->getMockILS('Voyager', ['setConfig', 'init']); $ILS->expects($this->once()) ->method('setConfig') - ->with(array('config' => 'values')); + ->with(['config' => 'values']); $ILS->expects($this->once()) ->method('init'); @@ -2198,7 +2198,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $driver->setServiceLocator($sm); //Add an entry for our test driver to the array of drivers - $drivers = array('testing3' => 'Voyager'); + $drivers = ['testing3' => 'Voyager']; $this->setProperty($driver, 'drivers', $drivers); //Case: No driver info in params, but default driver has method @@ -2218,7 +2218,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase //Case: Instance to use is in parameters but does not have method //Result: A return of false - $patron = array($this->getPatron('username', 'testing3')); + $patron = [$this->getPatron('username', 'testing3')]; $methodReturn = $driver->supportsMethod('fail', $patron); $this->assertFalse($methodReturn); @@ -2262,17 +2262,17 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $times1, $times2, $function, $params, $return1, $return2 ) { $driver = $this->getDriver(); - $drivers = array('d1' => 'Voyager', 'd2' => 'Demo', 'd3' => 'DummyILS'); + $drivers = ['d1' => 'Voyager', 'd2' => 'Demo', 'd3' => 'DummyILS']; $this->setProperty($driver, 'drivers', $drivers); - $voyager = $this->getMockILS('Voyager', array('init', $function)); + $voyager = $this->getMockILS('Voyager', ['init', $function]); call_user_func_array( - array($voyager->expects($times1)->method($function), 'with'), $params + [$voyager->expects($times1)->method($function), 'with'], $params )->will($this->returnValue($return1)); - $demo = $this->getMockILS('Demo', array('init', $function)); + $demo = $this->getMockILS('Demo', ['init', $function]); call_user_func_array( - array($demo->expects($times2)->method($function), 'with'), $params + [$demo->expects($times2)->method($function), 'with'], $params )->will($this->returnValue($return2)); $dummyILS = new DummyILS(); @@ -2313,13 +2313,13 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase $this->getPluginManager(), $this->getMockILSAuthenticator() ); $driver->setConfig( - array( - 'Drivers' => array(), - 'Login' => array( - 'drivers' => array('d1', 'd2'), + [ + 'Drivers' => [], + 'Login' => [ + 'drivers' => ['d1', 'd2'], 'default_driver' => 'd1' - ), - ) + ], + ] ); $driver->init(); return $driver; @@ -2355,7 +2355,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase */ protected function getPluginManager() { - $configData = array('config' => 'values'); + $configData = ['config' => 'values']; $config = new \Zend\Config\Config($configData); $mockPM = $this->getMock('\VuFind\Config\PluginManager'); $mockPM->expects($this->any()) @@ -2375,7 +2375,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase protected function getPatron($username, $instance = null) { $cat_username = $instance ? $instance . '.' . $username : $username; - return array( + return [ 'id' => 1, 'firstname' => 'JANE', 'lastname' => 'DOE', @@ -2384,7 +2384,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase 'email' => '', 'major' => '', 'college' => '' - ); + ]; } /** @@ -2425,15 +2425,15 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase if ($type == 'Demo') { $mock = $this->getMock( "VuFind\ILS\Driver\\$type", $methods, - array( + [ new \VuFind\Date\Converter(), $this->getMock('VuFindSearch\Service') - ) + ] ); } else { $mock = $this->getMock( "VuFind\ILS\Driver\\$type", $methods, - array(new \VuFind\Date\Converter()) + [new \VuFind\Date\Converter()] ); } } catch(\Exception $e) { @@ -2446,7 +2446,7 @@ class MultiBackendTest extends \VuFindTest\Unit\TestCase ->method('init') ->will($this->returnValue(null)); } - $mock->setConfig(array('dummy_config' => true)); + $mock->setConfig(['dummy_config' => true]); return $mock; } } @@ -2489,7 +2489,7 @@ class DummyILS extends \VuFind\ILS\Driver\AbstractBase */ public function getStatus($id) { - return array(); + return []; } /** @@ -2505,7 +2505,7 @@ class DummyILS extends \VuFind\ILS\Driver\AbstractBase */ public function getStatuses($ids) { - return array(); + return []; } /** @@ -2524,7 +2524,7 @@ class DummyILS extends \VuFind\ILS\Driver\AbstractBase */ public function getHolding($id, array $patron = null) { - return array(); + return []; } /** @@ -2540,6 +2540,6 @@ class DummyILS extends \VuFind\ILS\Driver\AbstractBase */ public function getPurchaseHistory($id) { - return array(); + return []; } } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php index 862c5bfceae..2590964cacc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/NoILSTest.php @@ -61,11 +61,11 @@ class NoILSTest extends \VuFindTest\Unit\TestCase public function setUp() { $this->loader = $this->getMock( - 'VuFind\Record\Loader', array(), - array( + 'VuFind\Record\Loader', [], + [ $this->getMock('VuFindSearch\Service'), $this->getMock('VuFind\RecordDriver\PluginManager') - ) + ] ); $this->driver = new NoILS($this->loader); $this->driver->init(); @@ -109,7 +109,7 @@ class NoILSTest extends \VuFindTest\Unit\TestCase public function testMarcHoldingsVisibility() { $this->driver - ->setConfig(array('settings' => array('useHoldings' => 'marc'))); + ->setConfig(['settings' => ['useHoldings' => 'marc']]); $this->assertTrue($this->driver->hasHoldings('foo')); } @@ -120,9 +120,9 @@ class NoILSTest extends \VuFindTest\Unit\TestCase */ public function testUnsupportedFunctions() { - $this->assertEquals(array(), $this->driver->getPurchaseHistory('foo')); + $this->assertEquals([], $this->driver->getPurchaseHistory('foo')); $this->assertEquals(null, $this->driver->patronLogin('foo', 'bar')); - $this->assertEquals(array(), $this->driver->getNewItems(1, 20, 30)); + $this->assertEquals([], $this->driver->getNewItems(1, 20, 30)); $this->assertFalse($this->driver->getConfig('Holds')); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php index 2fa4ce2ebe3..f067dee0b40 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/SymphonyTest.php @@ -66,7 +66,7 @@ class SymphonyTest extends \VuFindTest\Unit\TestCase } $this->driver->setConfig( - array('WebServices' => array('baseURL' => 'invalid')) + ['WebServices' => ['baseURL' => 'invalid']] ); $this->driver->init(); $pickup = @$this->driver->getPickUpLocations(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Log/LoggerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Log/LoggerTest.php index 403dc7f5416..5daa6656505 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Log/LoggerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Log/LoggerTest.php @@ -76,17 +76,17 @@ CONTEXT; && false !== strpos($a[5], 'function =') && count($a) == 5; }; - $logger = $this->getMock('VuFind\Log\Logger', array('log')); + $logger = $this->getMock('VuFind\Log\Logger', ['log']); $logger->expects($this->once())->method('log')->with($this->equalTo(Logger::CRIT), $this->callback($callback)); try { throw new \Exception('test'); } catch (\Exception $e) { $fakeServer = new \Zend\Stdlib\Parameters( - array( + [ 'REMOTE_ADDR' => '1.2.3.4', 'HTTP_USER_AGENT' => 'Fake browser', 'REQUEST_URI' => '/foo/bar' - ) + ] ); $logger->logException($e, $fakeServer); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php index becec6bda4b..0da2c3a1b49 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Mailer/MailerTest.php @@ -142,7 +142,7 @@ class MailerTest extends \VuFindTest\Unit\TestCase && $in['from'] == 'from@example.com' && $in['message'] == 'message'; }; - $view = $this->getMock('Zend\View\Renderer\PhpRenderer', array('partial')); + $view = $this->getMock('Zend\View\Renderer\PhpRenderer', ['partial']); $view->expects($this->once())->method('partial') ->with($this->equalTo('Email/share-link.phtml'), $this->callback($viewCallback)) ->will($this->returnValue('body')); @@ -183,7 +183,7 @@ class MailerTest extends \VuFindTest\Unit\TestCase && $in['from'] == 'from@example.com' && $in['message'] == 'message'; }; - $view = $this->getMock('Zend\View\Renderer\PhpRenderer', array('partial')); + $view = $this->getMock('Zend\View\Renderer\PhpRenderer', ['partial']); $view->expects($this->once())->method('partial') ->with($this->equalTo('Email/record.phtml'), $this->callback($viewCallback)) ->will($this->returnValue('body')); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php index 1921f607bb2..ed4324ec17c 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php @@ -78,8 +78,8 @@ class ServerTest extends \VuFindTest\Unit\TestCase * * @return Server */ - protected function getServer($config = array(), $baseURL = 'http://foo', - $params = array() + protected function getServer($config = [], $baseURL = 'http://foo', + $params = [] ) { // Force an email into the configuration if missing; this is required by the // server. diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php index bc22fbf35d9..363b9acdf50 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/QRCode/LoaderTest.php @@ -57,9 +57,9 @@ class LoaderTest extends \VuFindTest\Unit\TestCase */ public function testUtterFailure() { - $theme = $this->getMock('VuFindTheme\ThemeInfo', array(), array('foo', 'bar')); - $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(array('images/noQRCode.gif')))->will($this->returnValue(false)); - $loader = $this->getLoader(array(), $theme); + $theme = $this->getMock('VuFindTheme\ThemeInfo', [], ['foo', 'bar']); + $theme->expects($this->once())->method('findContainingTheme')->with($this->equalTo(['images/noQRCode.gif']))->will($this->returnValue(false)); + $loader = $this->getLoader([], $theme); $loader->getImage(); } @@ -85,14 +85,14 @@ class LoaderTest extends \VuFindTest\Unit\TestCase * * @return void */ - protected function getLoader($config = array(), $theme = null, $mock = false) + protected function getLoader($config = [], $theme = null, $mock = false) { $config = new Config($config); if (null === $theme) { $theme = new ThemeInfo($this->getThemeDir(), $this->testTheme); } if ($mock) { - return $this->getMock('VuFind\QRCode\Loader', $mock, array($config, $theme)); + return $this->getMock('VuFind\QRCode\Loader', $mock, [$config, $theme]); } return new Loader($config, $theme); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/CollectionSideFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/CollectionSideFacetsTest.php index 4833604fb93..0226fa0e03b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/CollectionSideFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/CollectionSideFacetsTest.php @@ -76,7 +76,7 @@ class CollectionSideFacetsTest extends \VuFindTest\Unit\TestCase $facetHelper = new \VuFind\Search\Solr\HierarchicalFacetHelper(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $sf = new CollectionSideFacets($configLoader, $facetHelper); $sf->setConfig($settings); @@ -93,7 +93,7 @@ class CollectionSideFacetsTest extends \VuFindTest\Unit\TestCase * * @return \VuFind\Config\PluginManager */ - protected function getMockConfigLoader($config = array(), $key = 'facets') + protected function getMockConfigLoader($config = [], $key = 'facets') { $loader = $this->getMockBuilder('VuFind\Config\PluginManager') ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/ExpandFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/ExpandFacetsTest.php index 61bfed135c0..fab6634e8b2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/ExpandFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/ExpandFacetsTest.php @@ -59,18 +59,18 @@ class ExpandFacetsTest extends \VuFindTest\Unit\TestCase public function testFacetInit() { $configLoader = $this->getMockConfigLoader( - array( - 'Results' => array( + [ + 'Results' => [ 'format' => 'Format', - ), - ) + ], + ] ); $results = $this->getMockResults(); $params = $results->getParams(); $params->expects($this->once())->method('addFacet')->with($this->equalTo('format'), $this->equalTo('Format')); - $results->expects($this->once())->method('getFacetList')->with($this->equalTo(array('format' => 'Format')))->will($this->returnValue(array('foo'))); + $results->expects($this->once())->method('getFacetList')->with($this->equalTo(['format' => 'Format']))->will($this->returnValue(['foo'])); $ef = $this->getExpandFacets($configLoader, $results); - $this->assertEquals(array('foo'), $ef->getExpandedSet()); + $this->assertEquals(['foo'], $ef->getExpandedSet()); } /** @@ -96,7 +96,7 @@ class ExpandFacetsTest extends \VuFindTest\Unit\TestCase $emptyResults = $this->getMockResults(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $sf = new ExpandFacets($configLoader, $emptyResults); $sf->setConfig($settings); @@ -113,7 +113,7 @@ class ExpandFacetsTest extends \VuFindTest\Unit\TestCase * * @return \VuFind\Config\PluginManager */ - protected function getMockConfigLoader($config = array(), $key = 'facets') + protected function getMockConfigLoader($config = [], $key = 'facets') { $loader = $this->getMockBuilder('VuFind\Config\PluginManager') ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FacetCloudTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FacetCloudTest.php index 81a96f2a257..d81fc758bae 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FacetCloudTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FacetCloudTest.php @@ -48,7 +48,7 @@ class FacetCloudTest extends \VuFindTest\Unit\TestCase { $results = $this->getMockResults(); $results->getParams()->expects($this->once())->method('getFacetSettings') - ->will($this->returnValue(array('limit' => 50))); + ->will($this->returnValue(['limit' => 50])); $fc = $this->getFacetCloud(null,$results); $this->assertEquals(49, $fc->getFacetLimit()); } @@ -76,7 +76,7 @@ class FacetCloudTest extends \VuFindTest\Unit\TestCase $emptyResults = $this->getMockResults(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $fc = new FacetCloud($configLoader, $emptyResults); $fc->setConfig($settings); @@ -93,7 +93,7 @@ class FacetCloudTest extends \VuFindTest\Unit\TestCase * * @return \VuFind\Config\PluginManager */ - protected function getMockConfigLoader($config = array(), $key = 'facets') + protected function getMockConfigLoader($config = [], $key = 'facets') { $loader = $this->getMockBuilder('VuFind\Config\PluginManager') ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FavoriteFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FavoriteFacetsTest.php index 1035384fa23..7f677aeb853 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FavoriteFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/FavoriteFacetsTest.php @@ -47,7 +47,7 @@ class FavoriteFacetsTest extends \VuFindTest\Unit\TestCase public function testFacetInitWithDisabledTags() { $configLoader = $this->getMockConfigLoader( - array('Social' => array('tags' => false)) + ['Social' => ['tags' => false]] ); $results = $this->getMockResults(); $params = $results->getParams(); @@ -90,7 +90,7 @@ class FavoriteFacetsTest extends \VuFindTest\Unit\TestCase $facetHelper = new \VuFind\Search\Solr\HierarchicalFacetHelper(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $sf = new FavoriteFacets($configLoader, $facetHelper); $sf->setConfig($settings); @@ -107,7 +107,7 @@ class FavoriteFacetsTest extends \VuFindTest\Unit\TestCase * * @return \VuFind\Config\PluginManager */ - protected function getMockConfigLoader($config = array(), $key = 'config') + protected function getMockConfigLoader($config = [], $key = 'config') { $loader = $this->getMockBuilder('VuFind\Config\PluginManager') ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php index 78fddda61e0..591ab795961 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/RandomRecommendTest.php @@ -131,7 +131,7 @@ class RandomRecommendTest extends TestCase ) ); $this->assertEquals( - array(), \PHPUnit_Framework_Assert::readAttribute( + [], \PHPUnit_Framework_Assert::readAttribute( $this->recommend, 'filters' ) ); @@ -210,7 +210,7 @@ class RandomRecommendTest extends TestCase $service = $this->getMock('VuFindSearch\Service'); $paramManager = $this->getMock('VuFind\Search\Params\PluginManager'); $recommend = new Random($service, $paramManager); - $records = array("1", "2", "3", "4", "5"); + $records = ["1", "2", "3", "4", "5"]; // Use Solr since some Base components are abstract: $results = $this->getServiceManager()->get('VuFind\SearchResultsPluginManager') @@ -248,7 +248,7 @@ class RandomRecommendTest extends TestCase $service = $this->getMock('VuFindSearch\Service'); $paramManager = $this->getMock('VuFind\Search\Params\PluginManager'); $recommend = new Random($service, $paramManager); - $records = array("1", "2", "3", "4", "5"); + $records = ["1", "2", "3", "4", "5"]; // Use Solr since some Base components are abstract: $results = $this->getServiceManager()->get('VuFind\SearchResultsPluginManager') diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php index 7028c0b1ebe..7947e3e32ba 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SideFacetsTest.php @@ -59,16 +59,16 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase public function testHierarchicalGetters() { $configLoader = $this->getMockConfigLoader( - array( - 'SpecialFacets' => array( - 'hierarchical' => array('format'), - 'hierarchicalFacetSortOptions' => array('a', 'b', 'c') - ) - ) + [ + 'SpecialFacets' => [ + 'hierarchical' => ['format'], + 'hierarchicalFacetSortOptions' => ['a', 'b', 'c'] + ] + ] ); $sf = $this->getSideFacets($configLoader, null, '', null, null); - $this->assertEquals(array('format'), $sf->getHierarchicalFacets()); - $this->assertEquals(array('a', 'b', 'c'), $sf->getHierarchicalFacetSortOptions()); + $this->assertEquals(['format'], $sf->getHierarchicalFacets()); + $this->assertEquals(['a', 'b', 'c'], $sf->getHierarchicalFacetSortOptions()); } /** @@ -81,19 +81,19 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase public function testMissingHierarchicalFacetHelper() { $configLoader = $this->getMockConfigLoader( - array( - 'Results' => array( + [ + 'Results' => [ 'format' => 'Format', - ), - 'SpecialFacets' => array( - 'hierarchical' => array('format') - ) - ) + ], + 'SpecialFacets' => [ + 'hierarchical' => ['format'] + ] + ] ); $results = $this->getMockResults(); - $response = array('format' => array('dummy')); + $response = ['format' => ['dummy']]; $results->expects($this->once())->method('getFacetList') - ->with($this->equalTo(array('format' => 'Format'))) + ->with($this->equalTo(['format' => 'Format'])) ->will($this->returnValue($response)); $sf = $this->getSideFacets($configLoader, $results, '', null, null); $sf->getFacetSet(); @@ -107,17 +107,17 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase public function testFacetInit() { $configLoader = $this->getMockConfigLoader( - array( - 'Results' => array( + [ + 'Results' => [ 'format' => 'Format', - ), - 'Results_Settings' => array( + ], + 'Results_Settings' => [ 'orFacets' => '*', // test or facet support - ), - 'Checkboxes' => array( + ], + 'Checkboxes' => [ 'description' => 'filter', - ) - ) + ] + ] ); $results = $this->getMockResults(); $params = $results->getParams(); @@ -135,14 +135,14 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase { $this->assertEquals('AND', $this->getSideFacets()->getFacetOperator('format')); // default $configLoader = $this->getMockConfigLoader( - array( - 'Results' => array( + [ + 'Results' => [ 'format' => 'Format', - ), - 'Results_Settings' => array( + ], + 'Results_Settings' => [ 'orFacets' => '*', // test or facet support - ), - ) + ], + ] ); $sf = $this->getSideFacets($configLoader); $this->assertEquals('OR', $sf->getFacetOperator('format')); @@ -157,14 +157,14 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase { $this->assertFalse($this->getSideFacets()->excludeAllowed('format')); // default $configLoader = $this->getMockConfigLoader( - array( - 'Results' => array( + [ + 'Results' => [ 'format' => 'Format', - ), - 'Results_Settings' => array( + ], + 'Results_Settings' => [ 'exclude' => '*', // test or facet support - ), - ) + ], + ] ); $sf = $this->getSideFacets($configLoader); $this->assertTrue($sf->excludeAllowed('format')); @@ -177,22 +177,22 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase */ public function testGetVisibleFilters() { - $filters = array( - 'format' => array( - array('value' => 'foo'), - array('value' => 'bar', 'suppressDisplay' => true), - ), - ); + $filters = [ + 'format' => [ + ['value' => 'foo'], + ['value' => 'bar', 'suppressDisplay' => true], + ], + ]; $results = $this->getMockResults(); $results->getParams()->expects($this->once())->method('getFilterList') ->with($this->equalTo(true))->will($this->returnValue($filters)); $sf = $this->getSideFacets(null, $results); $this->assertEquals( - array( - 'format' => array(array('value' => 'foo')), - 'extra' => array(array('value' => 'baz')), - ), - $sf->getVisibleFilters(array('extra' => array(array('value' => 'baz')))) + [ + 'format' => [['value' => 'foo']], + 'extra' => [['value' => 'baz']], + ], + $sf->getVisibleFilters(['extra' => [['value' => 'baz']]]) ); } @@ -203,30 +203,30 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase */ public function testGetAllRangeFacets() { - $config = array( - 'SpecialFacets' => array( - 'dateRange' => array('date'), - 'fullDateRange' => array('fullDate'), - 'genericRange' => array('generic'), - 'numericRange' => array('numeric'), - ) - ); - $filters = array( - 'date' => array('[1900 TO 1905]'), - 'fullDate' => array('[1900-01-01 TO 1905-12-31]'), - 'generic' => array('[A TO Z]'), - 'numeric' => array('[1 TO 9]'), - ); + $config = [ + 'SpecialFacets' => [ + 'dateRange' => ['date'], + 'fullDateRange' => ['fullDate'], + 'genericRange' => ['generic'], + 'numericRange' => ['numeric'], + ] + ]; + $filters = [ + 'date' => ['[1900 TO 1905]'], + 'fullDate' => ['[1900-01-01 TO 1905-12-31]'], + 'generic' => ['[A TO Z]'], + 'numeric' => ['[1 TO 9]'], + ]; $results = $this->getMockResults(); $results->getParams()->expects($this->any())->method('getFilters') ->will($this->returnValue($filters)); $sf = $this->getSideFacets($this->getMockConfigLoader($config), $results); - $expected = array( - 'date' => array('type' => 'date', 'values' => array('1900', '1905')), - 'fullDate' => array('type' => 'fulldate', 'values' => array('1900-01-01', '1905-12-31')), - 'generic' => array('type' => 'generic', 'values' => array('A', 'Z')), - 'numeric' => array('type' => 'numeric', 'values' => array('1', '9')), - ); + $expected = [ + 'date' => ['type' => 'date', 'values' => ['1900', '1905']], + 'fullDate' => ['type' => 'fulldate', 'values' => ['1900-01-01', '1905-12-31']], + 'generic' => ['type' => 'generic', 'values' => ['A', 'Z']], + 'numeric' => ['type' => 'numeric', 'values' => ['1', '9']], + ]; $this->assertEquals($expected, $sf->getAllRangeFacets()); } @@ -237,7 +237,7 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase */ public function testGetCollapsedFacetsDefault() { - $this->assertEquals(array(), $this->getSideFacets()->getCollapsedFacets()); + $this->assertEquals([], $this->getSideFacets()->getCollapsedFacets()); } /** @@ -247,11 +247,11 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase */ public function testGetCollapsedFacetsDelimitedList() { - $config = array( - 'Results_Settings' => array('collapsedFacets' => ' foo, bar,baz '), - ); + $config = [ + 'Results_Settings' => ['collapsedFacets' => ' foo, bar,baz '], + ]; $sf = $this->getSideFacets($this->getMockConfigLoader($config)); - $this->assertEquals(array('foo', 'bar', 'baz'), $sf->getCollapsedFacets()); + $this->assertEquals(['foo', 'bar', 'baz'], $sf->getCollapsedFacets()); } /** @@ -261,25 +261,25 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase */ public function testGetCollapsedFacetsWildcard() { - $config = array( - 'Results' => array( + $config = [ + 'Results' => [ 'format' => 'Format', - ), - 'Results_Settings' => array('collapsedFacets' => '*'), - ); - $filters = array( - 'format' => array( - array('value' => 'foo'), - array('value' => 'bar', 'suppressDisplay' => true), - ), - ); + ], + 'Results_Settings' => ['collapsedFacets' => '*'], + ]; + $filters = [ + 'format' => [ + ['value' => 'foo'], + ['value' => 'bar', 'suppressDisplay' => true], + ], + ]; $results = $this->getMockResults(); - $response = array('format' => array('dummy')); + $response = ['format' => ['dummy']]; $results->expects($this->once())->method('getFacetList') - ->with($this->equalTo(array('format' => 'Format'))) + ->with($this->equalTo(['format' => 'Format'])) ->will($this->returnValue($response)); $sf = $this->getSideFacets($this->getMockConfigLoader($config), $results); - $this->assertEquals(array('format'), $sf->getCollapsedFacets()); + $this->assertEquals(['format'], $sf->getCollapsedFacets()); } /** @@ -305,7 +305,7 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase $facetHelper = new \VuFind\Search\Solr\HierarchicalFacetHelper(); } if (null === $request) { - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); } $sf = new SideFacets($configLoader, $facetHelper); $sf->setConfig($settings); @@ -322,7 +322,7 @@ class SideFacetsTest extends \VuFindTest\Unit\TestCase * * @return \VuFind\Config\PluginManager */ - protected function getMockConfigLoader($config = array(), $key = 'facets') + protected function getMockConfigLoader($config = [], $key = 'facets') { $loader = $this->getMockBuilder('VuFind\Config\PluginManager') ->disableOriginalConstructor()->getMock(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SwitchQueryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SwitchQueryTest.php index 521bd822591..dee8968cd10 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SwitchQueryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/SwitchQueryTest.php @@ -61,10 +61,10 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('a or b'); $sq = $this->getSwitchQuery($results); $this->assertEquals( - array( + [ 'switchquery_lowercasebools' => 'a OR b', 'switchquery_wildcard' => 'a or b*', - ), + ], $sq->getSuggestions() ); } @@ -79,7 +79,7 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('a or b'); $bm = $this->getMockBackendManager(false); $sq = $this->getSwitchQuery($results, ':unwantedbools,wildcard', $bm); - $this->assertEquals(array(), $sq->getSuggestions()); + $this->assertEquals([], $sq->getSuggestions()); } /** @@ -92,7 +92,7 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('id:foo'); $sq = $this->getSwitchQuery($results); $this->assertEquals( - array(), + [], $sq->getSuggestions() ); } @@ -107,7 +107,7 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('', 'advanced'); $sq = $this->getSwitchQuery($results); $this->assertEquals( - array(), + [], $sq->getSuggestions() ); } @@ -122,10 +122,10 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('AND NOT OR'); $sq = $this->getSwitchQuery($results); $this->assertEquals( - array( + [ 'switchquery_unwantedbools' => '"AND NOT OR"', 'switchquery_wildcard' => 'AND NOT OR*', - ), + ], $sq->getSuggestions() ); } @@ -140,9 +140,9 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('"my phrase"'); $sq = $this->getSwitchQuery($results); $this->assertEquals( - array( + [ 'switchquery_unwantedquotes' => 'my phrase' - ), + ], $sq->getSuggestions() ); } @@ -157,9 +157,9 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase $results = $this->getMockResults('abcd'); $sq = $this->getSwitchQuery($results, ':wildcard:truncatechar'); $this->assertEquals( - array( + [ 'switchquery_truncatechar' => 'abc' - ), + ], $sq->getSuggestions() ); } @@ -173,7 +173,7 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase { $results = $this->getMockResults('"my phrase"'); $sq = $this->getSwitchQuery($results, ':unwantedquotes:truncatechar'); - $this->assertEquals(array(), $sq->getSuggestions()); + $this->assertEquals([], $sq->getSuggestions()); } /** @@ -195,7 +195,7 @@ class SwitchQueryTest extends \VuFindTest\Unit\TestCase } $sq = new SwitchQuery($bm); $sq->setConfig($settings); - $sq->init($results->getParams(), new \Zend\StdLib\Parameters(array())); + $sq->init($results->getParams(), new \Zend\StdLib\Parameters([])); $sq->process($results); return $sq; } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php index fd467b31160..f59ef4829fb 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Recommend/WorldCatTermsTest.php @@ -46,20 +46,20 @@ class WorldCatTermsTest extends \VuFindTest\Unit\TestCase */ public function testNormalOperation() { - $terms = array( + $terms = [ 'exact' => 'exact', 'junk' => 'junk' - ); + ]; $wcu = $this->getMockWorldCatUtils(); $wcu->expects($this->once())->method('getRelatedTerms') ->with($this->equalTo('foo'), $this->equalTo('lcsh')) ->will($this->returnValue($terms)); $results = $this->getMockResults(); - $request = new \Zend\StdLib\Parameters(array()); + $request = new \Zend\StdLib\Parameters([]); $module = new WorldCatTerms($wcu); $module->setConfig(''); $module->init($results->getParams(), $request); $module->process($results); - $this->assertEquals(array('exact' => 'exact'), $module->getTerms()); + $this->assertEquals(['exact' => 'exact'], $module->getTerms()); } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php index 13ca7fd756c..07e78f67dd5 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php @@ -55,7 +55,7 @@ class LoaderTest extends TestCase */ public function testMissingRecord() { - $collection = $this->getCollection(array()); + $collection = $this->getCollection([]); $service = $this->getMock('VuFindSearch\Service'); $service->expects($this->once())->method('retrieve') ->with($this->equalTo('VuFind'), $this->equalTo('test')) @@ -71,7 +71,7 @@ class LoaderTest extends TestCase */ public function testToleratedMissingRecord() { - $collection = $this->getCollection(array()); + $collection = $this->getCollection([]); $service = $this->getMock('VuFindSearch\Service'); $service->expects($this->once())->method('retrieve') ->with($this->equalTo('VuFind'), $this->equalTo('test')) @@ -94,7 +94,7 @@ class LoaderTest extends TestCase public function testSingleRecord() { $driver = $this->getDriver(); - $collection = $this->getCollection(array($driver)); + $collection = $this->getCollection([$driver]); $service = $this->getMock('VuFindSearch\Service'); $service->expects($this->once())->method('retrieve') ->with($this->equalTo('VuFind'), $this->equalTo('test')) @@ -115,9 +115,9 @@ class LoaderTest extends TestCase $driver3 = $this->getDriver('test3', 'Summon'); $missing = $this->getDriver('missing', 'Missing'); - $collection1 = $this->getCollection(array($driver1, $driver2)); - $collection2 = $this->getCollection(array($driver3)); - $collection3 = $this->getCollection(array()); + $collection1 = $this->getCollection([$driver1, $driver2]); + $collection2 = $this->getCollection([$driver3]); + $collection3 = $this->getCollection([]); $factory = $this->getMock('VuFind\RecordDriver\PluginManager'); $factory->expects($this->once())->method('get') @@ -126,21 +126,21 @@ class LoaderTest extends TestCase $service = $this->getMock('VuFindSearch\Service'); $service->expects($this->at(0))->method('retrieveBatch') - ->with($this->equalTo('VuFind'), $this->equalTo(array('test1', 'test2'))) + ->with($this->equalTo('VuFind'), $this->equalTo(['test1', 'test2'])) ->will($this->returnValue($collection1)); $service->expects($this->at(1))->method('retrieveBatch') - ->with($this->equalTo('Summon'), $this->equalTo(array('test3'))) + ->with($this->equalTo('Summon'), $this->equalTo(['test3'])) ->will($this->returnValue($collection2)); $service->expects($this->at(2))->method('retrieveBatch') - ->with($this->equalTo('WorldCat'), $this->equalTo(array('test4'))) + ->with($this->equalTo('WorldCat'), $this->equalTo(['test4'])) ->will($this->returnValue($collection3)); $loader = $this->getLoader($service, $factory); - $input = array( - array('source' => 'VuFind', 'id' => 'test1'), + $input = [ + ['source' => 'VuFind', 'id' => 'test1'], 'VuFind|test2', 'Summon|test3', 'WorldCat|test4' - ); - $this->assertEquals(array($driver1, $driver2, $driver3, $missing), $loader->loadBatch($input)); + ]; + $this->assertEquals([$driver1, $driver2, $driver3, $missing], $loader->loadBatch($input)); } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php index 3beefe76392..c71c2020a0f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php @@ -54,7 +54,7 @@ class RouterTest extends TestCase $driver = $this->getDriver(); $router = $this->getRouter($driver); $this->assertEquals( - array('params' => array('id' => 'test'), 'route' => 'record'), + ['params' => ['id' => 'test'], 'route' => 'record'], $router->getRouteDetails($driver) ); } @@ -68,7 +68,7 @@ class RouterTest extends TestCase { $router = $this->getRouter(); $this->assertEquals( - array('params' => array('id' => 'test'), 'route' => 'summonrecord'), + ['params' => ['id' => 'test'], 'route' => 'summonrecord'], $router->getRouteDetails('Summon|test') ); } @@ -82,7 +82,7 @@ class RouterTest extends TestCase { $router = $this->getRouter(); $this->assertEquals( - array('params' => array('id' => 'test', 'tab' => 'foo'), 'route' => 'summonrecord'), + ['params' => ['id' => 'test', 'tab' => 'foo'], 'route' => 'summonrecord'], $router->getTabRouteDetails('Summon|test', 'foo') ); } @@ -96,9 +96,9 @@ class RouterTest extends TestCase { $driver = $this->getDriver(); $driver->expects($this->once())->method('tryMethod')->with($this->equalTo('isCollection'))->will($this->returnValue(true)); - $router = $this->getRouter($driver, array('Collections' => array('collections' => true))); + $router = $this->getRouter($driver, ['Collections' => ['collections' => true]]); $this->assertEquals( - array('params' => array('id' => 'test', 'tab' => 'foo'), 'route' => 'collection'), + ['params' => ['id' => 'test', 'tab' => 'foo'], 'route' => 'collection'], $router->getTabRouteDetails('VuFind|test', 'foo') ); } @@ -112,9 +112,9 @@ class RouterTest extends TestCase { $driver = $this->getDriver(); $driver->expects($this->once())->method('tryMethod')->with($this->equalTo('isCollection'))->will($this->returnValue(true)); - $router = $this->getRouter($driver, array('Collections' => array('collections' => true))); + $router = $this->getRouter($driver, ['Collections' => ['collections' => true]]); $this->assertEquals( - array('params' => array('id' => 'test', 'tab' => 'foo'), 'route' => 'collection'), + ['params' => ['id' => 'test', 'tab' => 'foo'], 'route' => 'collection'], $router->getTabRouteDetails('test', 'foo') ); } @@ -128,9 +128,9 @@ class RouterTest extends TestCase { $driver = $this->getDriver(); $driver->expects($this->once())->method('tryMethod')->with($this->equalTo('isCollection'))->will($this->returnValue(true)); - $router = $this->getRouter($driver, array('Collections' => array('collections' => true))); + $router = $this->getRouter($driver, ['Collections' => ['collections' => true]]); $this->assertEquals( - array('params' => array('id' => 'test', 'tab' => 'foo'), 'route' => 'collection'), + ['params' => ['id' => 'test', 'tab' => 'foo'], 'route' => 'collection'], $router->getTabRouteDetails($driver, 'foo') ); } @@ -144,7 +144,7 @@ class RouterTest extends TestCase { $router = $this->getRouter(); $this->assertEquals( - array('params' => array('id' => 'test'), 'route' => 'record'), + ['params' => ['id' => 'test'], 'route' => 'record'], $router->getRouteDetails('test') ); } @@ -159,7 +159,7 @@ class RouterTest extends TestCase $driver = $this->getDriver(); $router = $this->getRouter($driver); $this->assertEquals( - array('params' => array('id' => 'test'), 'route' => 'record-sms'), + ['params' => ['id' => 'test'], 'route' => 'record-sms'], $router->getActionRouteDetails($driver, 'SMS') ); } @@ -190,17 +190,17 @@ class RouterTest extends TestCase * * @return Router */ - protected function getRouter($record = null, $config = array()) + protected function getRouter($record = null, $config = []) { if (null === $record) { $record = $this->getDriver(); } $loader = $this->getMock( - 'VuFind\Record\Loader', array(), - array( + 'VuFind\Record\Loader', [], + [ $this->getMock('VuFindSearch\Service'), $this->getMock('VuFind\RecordDriver\PluginManager') - ) + ] ); $loader->expects($this->any())->method('load') ->will($this->returnValue($record)); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrDefaultTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrDefaultTest.php index 63d7def81f9..c63b97fb1b3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrDefaultTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrDefaultTest.php @@ -60,13 +60,13 @@ class SolrDefaultTest extends \VuFindTest\Unit\TestCase */ public function testArticleOpenURL() { - $overrides = array( - 'format' => array('Article'), + $overrides = [ + 'format' => ['Article'], 'container_title' => 'Fake Container', 'container_volume' => 'XVII', 'container_issue' => '6', 'container_start_page' => '12', - ); + ]; $driver = $this->getDriver($overrides); $this->assertEquals('ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fvufind.svn.sourceforge.net%3Agenerator&rft.date=1992&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.issn=&rft.isbn=8820737493&rft.volume=XVII&rft.issue=6&rft.spage=12&rft.jtitle=Fake+Container&rft.atitle=La+congiura+dei+Principi+Napoletani+1701+%3A+%28prima+e+seconda+stesura%29+%2F&rft.au=Vico%2C+Giambattista%2C+1668-1744.&rft.format=Article&rft.language=Italian', $driver->getOpenURL()); } @@ -78,10 +78,10 @@ class SolrDefaultTest extends \VuFindTest\Unit\TestCase */ public function testJournalOpenURL() { - $overrides = array( - 'format' => array('Journal'), - 'issn' => array('1234-5678'), - ); + $overrides = [ + 'format' => ['Journal'], + 'issn' => ['1234-5678'], + ]; $driver = $this->getDriver($overrides); $this->assertEquals('ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fvufind.svn.sourceforge.net%3Agenerator&rft.title=La+congiura+dei+Principi+Napoletani+1701+%3A+%28prima+e+seconda+stesura%29+%2F&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rft.creator=Vico%2C+Giambattista%2C+1668-1744.&rft.pub=Centro+di+Studi+Vichiani%2C&rft.format=Journal&rft.language=Italian&rft.issn=1234-5678', $driver->getOpenURL()); } @@ -93,9 +93,9 @@ class SolrDefaultTest extends \VuFindTest\Unit\TestCase */ public function testUnknownTypeOpenURL() { - $overrides = array( - 'format' => array('Thingie'), - ); + $overrides = [ + 'format' => ['Thingie'], + ]; $driver = $this->getDriver($overrides); $this->assertEquals('ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fvufind.svn.sourceforge.net%3Agenerator&rft.title=La+congiura+dei+Principi+Napoletani+1701+%3A+%28prima+e+seconda+stesura%29+%2F&rft.date=1992&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rft.creator=Vico%2C+Giambattista%2C+1668-1744.&rft.pub=Centro+di+Studi+Vichiani%2C&rft.format=Thingie&rft.language=Italian', $driver->getOpenURL()); } @@ -107,7 +107,7 @@ class SolrDefaultTest extends \VuFindTest\Unit\TestCase * * @return SolrDefault */ - protected function getDriver($overrides = array()) + protected function getDriver($overrides = []) { $fixture = json_decode( file_get_contents( diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrMarcTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrMarcTest.php index 0a7918018b7..20fc1e34fcc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrMarcTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/SolrMarcTest.php @@ -53,16 +53,16 @@ class SolrMarcTest extends \VuFindTest\Unit\TestCase */ public function testBug1() { - $configArr = array('Record' => array('marc_links' => '760,765,770,772,774,773,775,777,780,785')); + $configArr = ['Record' => ['marc_links' => '760,765,770,772,774,773,775,777,780,785']]; $config = new \Zend\Config\Config($configArr); $record = new \VuFind\RecordDriver\SolrMarc($config); $fixture = $this->loadRecordFixture('testbug1.json'); $record->setRawData($fixture['response']['docs'][0]); - $expected = array( - array('title' => 'note_785_1', 'value' => 'Bollettino della Unione matematica italiana', 'link' => array('type' => 'bib', 'value' => '000343528')), - array('title' => 'note_785_1', 'value' => 'Bollettino della Unione matematica', 'link' => array('type' => 'bib', 'value' => '000343529')), - array('title' => 'note_785_8', 'value' => 'Bollettino della Unione matematica italiana', 'link' => array('type' => 'bib', 'value' => '000394898')), - ); + $expected = [ + ['title' => 'note_785_1', 'value' => 'Bollettino della Unione matematica italiana', 'link' => ['type' => 'bib', 'value' => '000343528']], + ['title' => 'note_785_1', 'value' => 'Bollettino della Unione matematica', 'link' => ['type' => 'bib', 'value' => '000343529']], + ['title' => 'note_785_8', 'value' => 'Bollettino della Unione matematica italiana', 'link' => ['type' => 'bib', 'value' => '000394898']], + ]; $this->assertEquals($expected, $record->getAllRecordLinks()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/SimilarTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/SimilarTest.php index fde145777b8..53d038b6f70 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/SimilarTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/SimilarTest.php @@ -48,18 +48,18 @@ class SimilarTest extends \VuFindTest\Unit\TestCase { // Similar is really just a thin wrapper around the search service; make // sure it does its job properly with the help of some mocks. - $driver = $this->getMock('VuFind\RecordDriver\SolrDefault', array('getUniqueId')); + $driver = $this->getMock('VuFind\RecordDriver\SolrDefault', ['getUniqueId']); $driver->expects($this->once()) ->method('getUniqueId') ->will($this->returnValue('fakeid')); - $service = $this->getMock('VuFindSearch\Service', array('similar')); + $service = $this->getMock('VuFindSearch\Service', ['similar']); $service->expects($this->once()) ->method('similar') ->with($this->equalTo('Solr'), $this->equalTo('fakeid')) - ->will($this->returnValue(array('fakeresponse'))); + ->will($this->returnValue(['fakeresponse'])); $similar = new Similar($service); $similar->init('', $driver); - $this->assertEquals(array('fakeresponse'), $similar->getResults()); + $this->assertEquals(['fakeresponse'], $similar->getResults()); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/WorldCatSimilarTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/WorldCatSimilarTest.php index 96fb374d166..cefc85e8f00 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Related/WorldCatSimilarTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Related/WorldCatSimilarTest.php @@ -48,7 +48,7 @@ class WorldCatSimilarTest extends \VuFindTest\Unit\TestCase { $driver = $this->getMock( 'VuFind\RecordDriver\WorldCat', - array('tryMethod', 'getPrimaryAuthor', 'getAllSubjectHeadings', 'getTitle', 'getUniqueId', 'getResourceSource') + ['tryMethod', 'getPrimaryAuthor', 'getAllSubjectHeadings', 'getTitle', 'getUniqueId', 'getResourceSource'] ); $driver->expects($this->once()) ->method('tryMethod') @@ -59,7 +59,7 @@ class WorldCatSimilarTest extends \VuFindTest\Unit\TestCase ->will($this->returnValue('fakepa')); $driver->expects($this->once()) ->method('getAllSubjectHeadings') - ->will($this->returnValue(array(array('fakesh1a', 'fakesh1b'), array('fakesh2')))); + ->will($this->returnValue([['fakesh1a', 'fakesh1b'], ['fakesh2']])); $driver->expects($this->once()) ->method('getTitle') ->will($this->returnValue('faketitle')); @@ -69,12 +69,12 @@ class WorldCatSimilarTest extends \VuFindTest\Unit\TestCase $driver->expects($this->once()) ->method('getResourceSource') ->will($this->returnValue('WorldCat')); - $service = $this->getMock('VuFindSearch\Service', array('search')); + $service = $this->getMock('VuFindSearch\Service', ['search']); $expectedQuery = new Query('(srw.dd any "fakedc" or srw.au all "fakepa" or srw.su all "fakesh1a fakesh1b" or srw.su all "fakesh2" or srw.ti any "faketitle") not srw.no all "fakeid"'); - $response = $this->getMock('VuFindSearch\Backend\WorldCat\Response\XML\RecordCollection', array('getRecords'), array(array('offset' => 0, 'total' => 0))); + $response = $this->getMock('VuFindSearch\Backend\WorldCat\Response\XML\RecordCollection', ['getRecords'], [['offset' => 0, 'total' => 0]]); $response->expects($this->once()) ->method('getRecords') - ->will($this->returnValue(array('fakeresponse'))); + ->will($this->returnValue(['fakeresponse'])); $service->expects($this->once()) ->method('search') ->with($this->equalTo('WorldCat'), $this->equalTo($expectedQuery), $this->equalTo(0), $this->equalTo(5)) @@ -82,6 +82,6 @@ class WorldCatSimilarTest extends \VuFindTest\Unit\TestCase $similar = new WorldCatSimilar($service); $similar->init('', $driver); - $this->assertEquals(array('fakeresponse'), $similar->getResults()); + $this->assertEquals(['fakeresponse'], $similar->getResults()); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php index f8abb31f9cd..c2f46aa1ead 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Reserves/CsvReaderTest.php @@ -46,12 +46,12 @@ class CsvReaderTest extends \VuFindTest\Unit\TestCase */ public function testGetInstructors() { - $instructors = array( + $instructors = [ 'Mr. English' => 'Mr. English', 'Ms. Math' => 'Ms. Math', 'Junk' => 'Junk', 'M. Geography' => 'M. Geography', - ); + ]; $this->assertEquals($instructors, $this->getReader()->getInstructors()); } @@ -62,12 +62,12 @@ class CsvReaderTest extends \VuFindTest\Unit\TestCase */ public function testGetCourses() { - $courses = array( + $courses = [ 'English 101' => 'English 101', 'Math 101' => 'Math 101', 'Bad Row' => 'Bad Row', 'Geography 101' => 'Geography 101', - ); + ]; $this->assertEquals($courses, $this->getReader()->getCourses()); } @@ -78,12 +78,12 @@ class CsvReaderTest extends \VuFindTest\Unit\TestCase */ public function testGetDepartments() { - $departments = array( + $departments = [ 'English' => 'English', 'Math' => 'Math', 'Garbage' => 'Garbage', 'Geography' => 'Geography', - ); + ]; $this->assertEquals($departments, $this->getReader()->getDepartments()); } @@ -94,26 +94,26 @@ class CsvReaderTest extends \VuFindTest\Unit\TestCase */ public function testGetReserves() { - $reserves = array( - array( + $reserves = [ + [ 'BIB_ID' => 1, 'INSTRUCTOR_ID' => 'Mr. English', 'COURSE_ID' => 'English 101', 'DEPARTMENT_ID' => 'English', - ), - array( + ], + [ 'BIB_ID' => 2, 'INSTRUCTOR_ID' => 'Ms. Math', 'COURSE_ID' => 'Math 101', 'DEPARTMENT_ID' => 'Math', - ), - array( + ], + [ 'BIB_ID' => 3, 'INSTRUCTOR_ID' => 'M. Geography', 'COURSE_ID' => 'Geography 101', 'DEPARTMENT_ID' => 'Geography', - ), - ); + ], + ]; $this->assertEquals($reserves, $this->getReader()->getReserves()); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php index b4d6e223ae2..524fdb5e9d6 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/SMS/ClickatellTest.php @@ -59,9 +59,9 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase */ public function testCarriers() { - $expected = array( - 'Clickatell' => array('name' => 'Clickatell', 'domain' => null) - ); + $expected = [ + 'Clickatell' => ['name' => 'Clickatell', 'domain' => null] + ]; $obj = $this->getClickatell(); $this->assertEquals($expected, $obj->getCarriers()); } @@ -164,7 +164,7 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase } return new Clickatell( new \Zend\Config\Config($config), - array('client' => $client) + ['client' => $client] ); } @@ -175,13 +175,13 @@ class ClickatellTest extends \VuFindTest\Unit\TestCase */ protected function getDefaultConfig() { - return array( - 'Clickatell' => array( + return [ + 'Clickatell' => [ 'user' => 'user', 'password' => 'password', 'api_id' => 'api_id', - ), - ); + ], + ]; } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/QueryAdapterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/QueryAdapterTest.php index 6580b3f3330..917d6a89eff 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/QueryAdapterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/QueryAdapterTest.php @@ -50,7 +50,7 @@ class QueryAdapterTest extends TestCase */ public function testConversions() { - $cases = array('basic', 'advanced'); + $cases = ['basic', 'advanced']; $fixturePath = realpath(__DIR__ . '/../../../../fixtures/searches') . '/'; foreach ($cases as $case) { // Load minified, unminified, and Query object data: @@ -85,7 +85,7 @@ class QueryAdapterTest extends TestCase */ public function testEmptyRequest() { - $req = new \Zend\Stdlib\Parameters(array()); + $req = new \Zend\Stdlib\Parameters([]); $this->assertEquals(new Query(), QueryAdapter::fromRequest($req, 'AllFields')); } @@ -97,10 +97,10 @@ class QueryAdapterTest extends TestCase public function testDisplay() { // Array of fixture directory => expected display query - $cases = array( + $cases = [ 'basic' => 'john smith', 'advanced' => '(CallNumber:oranges AND toc:bananas AND ISN:pears) OR (Title:cars OR Subject:trucks) NOT ((AllFields:squid))' - ); + ]; // Create simple closure to fill in for translation callbacks: $echo = function ($str) { diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php index 9e20c2424b6..be16a454986 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/HierarchicalFacetHelperTest.php @@ -43,57 +43,57 @@ use VuFind\Search\Solr\HierarchicalFacetHelper; */ class HierarchicalFacetHelperTest extends TestCase { - protected $facetList = array( - array( + protected $facetList = [ + [ 'value' => '0/Book/', 'displayText' => 'Book', 'count' => 1000, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '0/AV/', 'displayText' => 'Audiovisual', 'count' => 600, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '0/Audio/', 'displayText' => 'Sound', 'count' => 400, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '1/Book/BookPart/', 'displayText' => 'Book Part', 'count' => 300, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '1/Book/Section/', 'displayText' => 'Book Section', 'count' => 200, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '1/Audio/Spoken/', 'displayText' => 'Spoken Text', 'count' => 100, 'operator' => 'OR', 'isApplied' => false - ), - array( + ], + [ 'value' => '1/Audio/Music/', 'displayText' => '1/Audio/Music/', 'count' => 50, 'operator' => 'OR', 'isApplied' => false - ) - ); + ] + ]; /** * Hierarchical Facet Helper diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php index bff90c8b96c..2f59fc82478 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/MultiIndexListenerTest.php @@ -53,54 +53,54 @@ class MultiIndexListenerTest extends TestCase * * @var array */ - protected static $specs = array( - 'test' => array( - 'QueryFields' => array( - 'A' => array( - array('onephrase', 500), - array('and', 200) - ), - 'B' => array( - array('and', 100), - array('or', 50), - ), - 0 => array( - 0 => array('AND', 50), - 'C' => array( - array('onephrase', 200), - ), - 'D' => array( - array('onephrase', 300), - ), - '-E' => array( - array('or', '~') - ) - ) - ), + protected static $specs = [ + 'test' => [ + 'QueryFields' => [ + 'A' => [ + ['onephrase', 500], + ['and', 200] + ], + 'B' => [ + ['and', 100], + ['or', 50], + ], + 0 => [ + 0 => ['AND', 50], + 'C' => [ + ['onephrase', 200], + ], + 'D' => [ + ['onephrase', 300], + ], + '-E' => [ + ['or', '~'] + ] + ] + ], 'FilterQuery' => 'format:Book', - ) - ); + ] + ]; /** * Available shards used for stripping tests. * * @var array */ - protected static $shards = array( + protected static $shards = [ 'a' => 'example.org/a', 'b' => 'example.org/b', 'c' => 'example.org/c', - ); + ]; /** * Shard fields used for stripping tests. * * @var array */ - protected static $fields = array( - 'a' => array('field_1', 'field_3'), - 'b' => array('field_3'), - ); + protected static $fields = [ + 'a' => ['field_1', 'field_3'], + 'b' => ['field_3'], + ]; /** * Backend. @@ -123,7 +123,7 @@ class MultiIndexListenerTest extends TestCase */ protected function setup() { - $handlermap = new HandlerMap(array('select' => array('fallback' => true))); + $handlermap = new HandlerMap(['select' => ['fallback' => true]]); $connector = new Connector('http://example.org/', $handlermap); $this->backend = new Backend($connector); $this->listener = new MultiIndexListener($this->backend, self::$shards, self::$fields, self::$specs); @@ -137,17 +137,17 @@ class MultiIndexListenerTest extends TestCase public function testStripFacetFields() { $params = new ParamBag( - array( - 'facet.field' => array('field_1', 'field_2', 'field_3'), - 'shards' => array(self::$shards['b'], self::$shards['c']), - ) + [ + 'facet.field' => ['field_1', 'field_2', 'field_3'], + 'shards' => [self::$shards['b'], self::$shards['c']], + ] ); - $event = new Event('pre', $this->backend, array('params' => $params)); + $event = new Event('pre', $this->backend, ['params' => $params]); $this->listener->onSearchPre($event); $facets = $params->get('facet.field'); sort($facets); - $this->assertEquals(array('field_1', 'field_2'), $facets); + $this->assertEquals(['field_1', 'field_2'], $facets); } /** @@ -158,19 +158,19 @@ class MultiIndexListenerTest extends TestCase public function testAllShardsUsedForRecordRetrieval() { $params = new ParamBag( - array( - 'shards' => array(self::$shards['b'], self::$shards['c']), - ) + [ + 'shards' => [self::$shards['b'], self::$shards['c']], + ] ); $event = new Event( 'pre', $this->backend, - array('params' => $params, 'context' => 'retrieve') + ['params' => $params, 'context' => 'retrieve'] ); $this->listener->onSearchPre($event); $shards = $params->get('shards'); $this->assertEquals( - array(implode(',', array(self::$shards['a'], self::$shards['b'], self::$shards['c']))), + [implode(',', [self::$shards['a'], self::$shards['b'], self::$shards['c']])], $shards ); } @@ -186,7 +186,7 @@ class MultiIndexListenerTest extends TestCase $mock->expects($this->once())->method('attach')->with( $this->equalTo('VuFind\Search'), $this->equalTo('pre'), - $this->equalTo(array($this->listener, 'onSearchPre')) + $this->equalTo([$this->listener, 'onSearchPre']) ); $this->listener->attach($mock); } @@ -198,8 +198,8 @@ class MultiIndexListenerTest extends TestCase */ public function testStripSpecsEmptySpecs() { - $this->setProperty($this->listener, 'specs', array()); - $specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('A', 'B', 'E'))); + $this->setProperty($this->listener, 'specs', []); + $specs = $this->callMethod($this->listener, 'getSearchSpecs', [['A', 'B', 'E']]); $this->assertEmpty($specs); } @@ -210,7 +210,7 @@ class MultiIndexListenerTest extends TestCase */ public function testStripSpecsNoFieldsToStrip() { - $specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('F', 'G', 'H'))); + $specs = $this->callMethod($this->listener, 'getSearchSpecs', [['F', 'G', 'H']]); $this->assertEquals($specs, self::$specs); } @@ -221,23 +221,23 @@ class MultiIndexListenerTest extends TestCase */ public function testStripSpecsStrip() { - $specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('A', 'B', 'E'))); + $specs = $this->callMethod($this->listener, 'getSearchSpecs', [['A', 'B', 'E']]); $this->assertEquals( - array('test' => array( - 'QueryFields' => array( - 0 => array( - 0 => array('AND', 50), - 'C' => array( - array('onephrase', 200) - ), - 'D' => array( - array('onephrase', 300) - ) - ) - ), + ['test' => [ + 'QueryFields' => [ + 0 => [ + 0 => ['AND', 50], + 'C' => [ + ['onephrase', 200] + ], + 'D' => [ + ['onephrase', 300] + ] + ] + ], 'FilterQuery' => 'format:Book', - ) - ), + ] + ], $specs ); } @@ -249,9 +249,9 @@ class MultiIndexListenerTest extends TestCase */ public function testStripSpecsAllQueryFields() { - $specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('A', 'B', 'C', 'D', 'E'))); + $specs = $this->callMethod($this->listener, 'getSearchSpecs', [['A', 'B', 'C', 'D', 'E']]); $this->assertEquals( - array('test' => array('QueryFields' => array(), 'FilterQuery' => 'format:Book')), + ['test' => ['QueryFields' => [], 'FilterQuery' => 'format:Book']], $specs ); } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php index f2ea7f192c4..8100669944a 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php @@ -62,7 +62,7 @@ class SpellingProcessorTest extends TestCase */ public function testNonDefaultConfigs() { - $config = new Config(array('limit' => 5, 'skip_numeric' => false)); + $config = new Config(['limit' => 5, 'skip_numeric' => false]); $sp = new SpellingProcessor($config); $this->assertEquals(false, $sp->shouldSkipNumericSpelling()); $this->assertEquals(5, $sp->getSpellingLimit()); @@ -91,32 +91,32 @@ class SpellingProcessorTest extends TestCase */ public function testSuggestionProcessingWithNonDefaultLimit() { - $config = new Config(array('limit' => 5)); + $config = new Config(['limit' => 5]); $sp = new SpellingProcessor($config); $spelling = $this->getFixture('spell1'); $query = $this->getFixture('query1'); $this->assertEquals( - array( - 'grumble' => array( + [ + 'grumble' => [ 'freq' => 2, - 'suggestions' => array( + 'suggestions' => [ 'grumbler' => 4, 'rumble' => 40, 'crumble' => 15, 'trumble' => 13, 'brumble' => 3, - ), - ), - 'grimble' => array( + ], + ], + 'grimble' => [ 'freq' => 7, - 'suggestions' => array( + 'suggestions' => [ 'trimble' => 110, 'gribble' => 21, 'grimsley' => 24, 'grimalde' => 8, - ), - ), - ), + ], + ], + ], $sp->getSuggestions($spelling, $query) ); } @@ -135,48 +135,48 @@ class SpellingProcessorTest extends TestCase $params->setBasicSearch($query->getString(), $query->getHandler()); $sp = new SpellingProcessor(); $this->assertEquals( - array( - 'grumble' => array( + [ + 'grumble' => [ 'freq' => 2, - 'suggestions' => array( - 'grumbler' => array( + 'suggestions' => [ + 'grumbler' => [ 'freq' => 4, 'new_term' => 'grumbler', 'expand_term' => '(grumble OR grumbler)', - ), - 'rumble' => array( + ], + 'rumble' => [ 'freq' => 40, 'new_term' => 'rumble', 'expand_term' => '(grumble OR rumble)', - ), - 'crumble' => array( + ], + 'crumble' => [ 'freq' => 15, 'new_term' => 'crumble', 'expand_term' => '(grumble OR crumble)', - ), - ), - ), - 'grimble' => array( + ], + ], + ], + 'grimble' => [ 'freq' => 7, - 'suggestions' => array( - 'trimble' => array( + 'suggestions' => [ + 'trimble' => [ 'freq' => 110, 'new_term' => 'trimble', 'expand_term' => '(grimble OR trimble)', - ), - 'gribble' => array( + ], + 'gribble' => [ 'freq' => 21, 'new_term' => 'gribble', 'expand_term' => '(grimble OR gribble)', - ), - 'grimsley' => array( + ], + 'grimsley' => [ 'freq' => 24, 'new_term' => 'grimsley', 'expand_term' => '(grimble OR grimsley)', - ), - ), - ), - ), + ], + ], + ], + ], $sp->processSuggestions( $this->getExpectedQuery1Suggestions(), $spelling->getQuery(), $params ) @@ -195,45 +195,45 @@ class SpellingProcessorTest extends TestCase $params = $this->getServiceManager()->get('VuFind\SearchParamsPluginManager') ->get('Solr'); $params->setBasicSearch($query->getString(), $query->getHandler()); - $config = new Config(array('expand' => false, 'phrase' => true)); + $config = new Config(['expand' => false, 'phrase' => true]); $sp = new SpellingProcessor($config); $this->assertEquals( - array( - 'grumble' => array( + [ + 'grumble' => [ 'freq' => 2, - 'suggestions' => array( - 'grumbler grimble' => array( + 'suggestions' => [ + 'grumbler grimble' => [ 'freq' => 4, 'new_term' => 'grumbler', - ), - 'rumble grimble' => array( + ], + 'rumble grimble' => [ 'freq' => 40, 'new_term' => 'rumble', - ), - 'crumble grimble' => array( + ], + 'crumble grimble' => [ 'freq' => 15, 'new_term' => 'crumble', - ), - ), - ), - 'grimble' => array( + ], + ], + ], + 'grimble' => [ 'freq' => 7, - 'suggestions' => array( - 'grumble trimble' => array( + 'suggestions' => [ + 'grumble trimble' => [ 'freq' => 110, 'new_term' => 'trimble', - ), - 'grumble gribble' => array( + ], + 'grumble gribble' => [ 'freq' => 21, 'new_term' => 'gribble', - ), - 'grumble grimsley' => array( + ], + 'grumble grimsley' => [ 'freq' => 24, 'new_term' => 'grimsley', - ), - ), - ), - ), + ], + ], + ], + ], $sp->processSuggestions( $this->getExpectedQuery1Suggestions(), $spelling->getQuery(), $params ) @@ -249,18 +249,18 @@ class SpellingProcessorTest extends TestCase { $this->runSpellingTest( 2, - array( - 'preamble gribble' => array( + [ + 'preamble gribble' => [ 'freq' => 0, - 'suggestions' => array( - 'preamble article' => array( + 'suggestions' => [ + 'preamble article' => [ 'freq' => 1, 'new_term' => 'preamble article', 'expand_term' => '((preamble gribble) OR (preamble article))', - ), - ), - ), - ) + ], + ], + ], + ] ); } @@ -277,38 +277,38 @@ class SpellingProcessorTest extends TestCase { $this->runSpellingTest( 4, - array( - 'lake' => array( + [ + 'lake' => [ 'freq' => 2719, - 'suggestions' => array( - 'late' => array( + 'suggestions' => [ + 'late' => [ 'freq' => 30753, 'new_term' => 'late', 'expand_term' => '(lake OR late)', - ), - 'lane' => array( + ], + 'lane' => [ 'freq' => 8054, 'new_term' => 'lane', 'expand_term' => '(lake OR lane)', - ), - 'make' => array( + ], + 'make' => [ 'freq' => 5735, 'new_term' => 'make', 'expand_term' => '(lake OR make)', - ) - ) - ), - 'geneve' => array( + ] + ] + ], + 'geneve' => [ 'freq' => 662, - 'suggestions' => array( - 'geneva' => array( + 'suggestions' => [ + 'geneva' => [ 'freq' => 1170, 'new_term' => 'geneva', 'expand_term' => '(geneve OR geneva)', - ) - ) - ) - ) + ] + ] + ] + ] ); } @@ -320,26 +320,26 @@ class SpellingProcessorTest extends TestCase public function testSpellingTokenization() { $sp = new SpellingProcessor(); - $this->assertEquals(array('single'), $sp->tokenize('single')); - $this->assertEquals(array('two', 'terms'), $sp->tokenize('two terms')); - $this->assertEquals(array('two', 'terms'), $sp->tokenize('two terms')); - $this->assertEquals(array('apples', 'oranges'), $sp->tokenize('apples OR oranges')); - $this->assertEquals(array('"word"'), $sp->tokenize('"word"')); - $this->assertEquals(array('"word"', 'second'), $sp->tokenize('"word" second')); - $this->assertEquals(array(), $sp->tokenize('')); - $this->assertEquals(array('0', 'is', 'zero'), $sp->tokenize('0 is zero')); - $this->assertEquals(array("'twas", 'successful'), $sp->tokenize("'twas successful")); - $this->assertEquals(array('word'), $sp->tokenize('(word)')); - $this->assertEquals(array('word', 'second'), $sp->tokenize('(word) second')); - $this->assertEquals(array('apples', 'oranges', 'pears'), $sp->tokenize('(apples OR oranges) AND pears')); - $this->assertEquals(array('two', 'terms'), $sp->tokenize("two\tterms")); + $this->assertEquals(['single'], $sp->tokenize('single')); + $this->assertEquals(['two', 'terms'], $sp->tokenize('two terms')); + $this->assertEquals(['two', 'terms'], $sp->tokenize('two terms')); + $this->assertEquals(['apples', 'oranges'], $sp->tokenize('apples OR oranges')); + $this->assertEquals(['"word"'], $sp->tokenize('"word"')); + $this->assertEquals(['"word"', 'second'], $sp->tokenize('"word" second')); + $this->assertEquals([], $sp->tokenize('')); + $this->assertEquals(['0', 'is', 'zero'], $sp->tokenize('0 is zero')); + $this->assertEquals(["'twas", 'successful'], $sp->tokenize("'twas successful")); + $this->assertEquals(['word'], $sp->tokenize('(word)')); + $this->assertEquals(['word', 'second'], $sp->tokenize('(word) second')); + $this->assertEquals(['apples', 'oranges', 'pears'], $sp->tokenize('(apples OR oranges) AND pears')); + $this->assertEquals(['two', 'terms'], $sp->tokenize("two\tterms")); $this->assertEquals( - array('"two words"', 'single', '"three word phrase"', 'single'), + ['"two words"', 'single', '"three word phrase"', 'single'], $sp->tokenize('((("two words" OR single) NOT "three word phrase") AND single)') ); - $this->assertEquals(array('"unfinished phrase'), $sp->tokenize('"unfinished phrase')); - $this->assertEquals(array('"'), $sp->tokenize('"')); - $this->assertEquals(array('""'), $sp->tokenize('""')); + $this->assertEquals(['"unfinished phrase'], $sp->tokenize('"unfinished phrase')); + $this->assertEquals(['"'], $sp->tokenize('"')); + $this->assertEquals(['""'], $sp->tokenize('""')); } /** @@ -351,27 +351,27 @@ class SpellingProcessorTest extends TestCase { $this->runSpellingTest( 3, - array( - '1234567980' => array( + [ + '1234567980' => [ 'freq' => 0, - 'suggestions' => array( - '12345678' => array( + 'suggestions' => [ + '12345678' => [ 'freq' => 1, 'new_term' => '12345678' - ) - ) - ), - 'sqid' => array( + ] + ] + ], + 'sqid' => [ 'freq' => 0, - 'suggestions' => array( - 'squid' => array( + 'suggestions' => [ + 'squid' => [ 'freq' => 34, 'new_term' => 'squid' - ) - ) - ), - ), - array('limit' => 1, 'skip_numeric' => false, 'expand' => false) + ] + ] + ], + ], + ['limit' => 1, 'skip_numeric' => false, 'expand' => false] ); } @@ -384,18 +384,18 @@ class SpellingProcessorTest extends TestCase { $this->runSpellingTest( 3, - array( - 'sqid' => array( + [ + 'sqid' => [ 'freq' => 0, - 'suggestions' => array( - 'squid' => array( + 'suggestions' => [ + 'squid' => [ 'freq' => 34, 'new_term' => 'squid' - ) - ) - ), - ), - array('limit' => 1, 'skip_numeric' => true, 'expand' => false) + ] + ] + ], + ], + ['limit' => 1, 'skip_numeric' => true, 'expand' => false] ); } @@ -408,7 +408,7 @@ class SpellingProcessorTest extends TestCase */ public function testDetectionOfMissingExtendedResultsSetting() { - $sp = new SpellingProcessor(new Config(array())); + $sp = new SpellingProcessor(new Config([])); $spelling = $this->getFixture('spell5'); $query = $this->getFixture('query5'); $sp->getSuggestions($spelling, $query); @@ -423,7 +423,7 @@ class SpellingProcessorTest extends TestCase * * @return void */ - protected function runSpellingTest($testNum, $expected, $config = array()) + protected function runSpellingTest($testNum, $expected, $config = []) { $spelling = $this->getFixture('spell' . $testNum); $query = $this->getFixture('query' . $testNum); @@ -447,24 +447,24 @@ class SpellingProcessorTest extends TestCase */ protected function getExpectedQuery1Suggestions() { - return array( - 'grumble' => array( + return [ + 'grumble' => [ 'freq' => 2, - 'suggestions' => array( + 'suggestions' => [ 'grumbler' => 4, 'rumble' => 40, 'crumble' => 15, - ), - ), - 'grimble' => array( + ], + ], + 'grimble' => [ 'freq' => 7, - 'suggestions' => array( + 'suggestions' => [ 'trimble' => 110, 'gribble' => 21, 'grimsley' => 24 - ), - ), - ); + ], + ], + ]; } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V3/ErrorListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V3/ErrorListenerTest.php index e167f38ebb9..92255df80c3 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V3/ErrorListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V3/ErrorListenerTest.php @@ -61,7 +61,7 @@ class ErrorListenerTest extends TestCase $backend = $this->getMockForAbstractClass('VuFindSearch\Backend\BackendInterface'); $exception = HttpErrorException::createFromResponse($response); - $params = array('backend_instance' => $backend); + $params = ['backend_instance' => $backend]; $event = new Event(null, $exception, $params); $listener = new ErrorListener($backend); $listener->onSearchError($event); @@ -79,7 +79,7 @@ class ErrorListenerTest extends TestCase $backend = $this->getMockForAbstractClass('VuFindSearch\Backend\BackendInterface'); $exception = HttpErrorException::createFromResponse($response); - $params = array('backend_instance' => $backend); + $params = ['backend_instance' => $backend]; $event = new Event(null, $exception, $params); $listener = new ErrorListener($backend); $listener->onSearchError($event); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V4/ErrorListenerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V4/ErrorListenerTest.php index d7103bd41f2..20748789169 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V4/ErrorListenerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/V4/ErrorListenerTest.php @@ -61,7 +61,7 @@ class ErrorListenerTest extends TestCase $backend = $this->getMockForAbstractClass('VuFindSearch\Backend\BackendInterface'); $exception = HttpErrorException::createFromResponse($response); - $params = array('backend_instance' => $backend); + $params = ['backend_instance' => $backend]; $event = new Event(null, $exception, $params); $listener = new ErrorListener($backend); $listener->onSearchError($event); @@ -79,7 +79,7 @@ class ErrorListenerTest extends TestCase $backend = $this->getMockForAbstractClass('VuFindSearch\Backend\BackendInterface'); $exception = HttpErrorException::createFromResponse($response); - $params = array('backend_instance' => $backend); + $params = ['backend_instance' => $backend]; $event = new Event(null, $exception, $params); $listener = new ErrorListener($backend); $listener->onSearchError($event); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php index 059df25a2e2..ccd220bf9ca 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/UtilsTest.php @@ -68,7 +68,7 @@ class UtilsTest extends \VuFindTest\Unit\TestCase */ public function testSanitizeDate() { - $tests = array( + $tests = [ '[2014]' => '2014-01-01', 'n.d.' => null, 'may 7, 1981' => '1981-05-07', @@ -88,7 +88,7 @@ class UtilsTest extends \VuFindTest\Unit\TestCase '5/1901' => '1901-05-01', '2nd Quarter 2004' => '2004-01-01', 'Nov 2009 and Dec 2009' => '2009-01-01', - ); + ]; foreach ($tests as $in => $out) { $this->assertEquals( diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/WriterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/WriterTest.php index ace04286d2b..30195d85c13 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/WriterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Solr/WriterTest.php @@ -121,7 +121,7 @@ class WriterTest extends \VuFindTest\Unit\TestCase $ct->expects($this->at(0))->method('markDeleted')->with($this->equalTo('biblio'), $this->equalTo('foo')); $ct->expects($this->at(1))->method('markDeleted')->with($this->equalTo('biblio'), $this->equalTo('bar')); $writer = new Writer($bm, $ct); - $writer->deleteRecords('Solr', array('foo', 'bar')); + $writer->deleteRecords('Solr', ['foo', 'bar']); } /** @@ -138,7 +138,7 @@ class WriterTest extends \VuFindTest\Unit\TestCase ->getMock(); $mockConnector = $this->getMockBuilder('VuFindSearch\Backend\Solr\Connector') ->disableOriginalConstructor() - ->setMethods(array('getUrl', 'setTimeout', 'write')) + ->setMethods(['getUrl', 'setTimeout', 'write']) ->getMock(); $mockBackend->expects($this->any())->method('getConnector')->will($this->returnValue($mockConnector)); $mockConnector->expects($this->any())->method('getTimeout')->will($this->returnValue(30)); @@ -156,7 +156,7 @@ class WriterTest extends \VuFindTest\Unit\TestCase { return $this->getMockBuilder('VuFind\Db\Table\ChangeTracker') ->disableOriginalConstructor() - ->setMethods(array('markDeleted')) + ->setMethods(['markDeleted']) ->getMock(); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php index d3a50d03a1b..8449ad28ab4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/TagsTest.php @@ -61,7 +61,7 @@ class TagsTest extends \PHPUnit_Framework_TestCase public function testTagParsing() { $this->assertEquals( - array('this', 'that', 'the other'), + ['this', 'that', 'the other'], $this->parser->parse('this that "the other"') ); } @@ -73,7 +73,7 @@ class TagsTest extends \PHPUnit_Framework_TestCase */ public function testEmptyTagParsing() { - $this->assertEquals(array(), $this->parser->parse('')); + $this->assertEquals([], $this->parser->parse('')); } /** @@ -83,7 +83,7 @@ class TagsTest extends \PHPUnit_Framework_TestCase */ public function testDeduplication() { - $this->assertEquals(array('test'), $this->parser->parse('test test test')); + $this->assertEquals(['test'], $this->parser->parse('test test test')); } /** @@ -95,6 +95,6 @@ class TagsTest extends \PHPUnit_Framework_TestCase { // Create custom object w/ small size limit: $parser = new \VuFind\Tags(10); - $this->assertEquals(array('0123456789'), $parser->parse('01234567890')); + $this->assertEquals(['0123456789'], $parser->parse('01234567890')); } } \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CartTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CartTest.php index 627116bce69..ed09d153ec1 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CartTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CartTest.php @@ -47,14 +47,14 @@ class CartTest extends \PHPUnit_Framework_TestCase { // Create a mock cart object: $mockLoader = $this->getMock( - 'VuFind\Record\Loader', array(), - array( + 'VuFind\Record\Loader', [], + [ $this->getMock('VuFindSearch\Service'), $this->getMock('VuFind\RecordDriver\PluginManager') - ) + ] ); $cart = $this->getMock( - 'VuFind\Cart', null, array($mockLoader) + 'VuFind\Cart', null, [$mockLoader] ); // Create a helper object: diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php index 9797ab7e618..9c409fe8d86 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php @@ -44,269 +44,269 @@ class CitationTest extends \VuFindTest\Unit\ViewHelperTestCase * * @var array */ - protected $citations = array( + protected $citations = [ // @codingStandardsIgnoreStart - array( - 'raw' => array( - 'SecondaryAuthors' => array('Shafer, Kathleen Newton'), + [ + 'raw' => [ + 'SecondaryAuthors' => ['Shafer, Kathleen Newton'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => '', 'Edition' => '', - 'PlacesOfPublication' => array('St. Louis'), - 'Publishers' => array('Mosby'), - 'PublicationDates' => array('1958') - ), + 'PlacesOfPublication' => ['St. Louis'], + 'Publishers' => ['Mosby'], + 'PublicationDates' => ['1958'] + ], 'apa' => 'Shafer, K. N. (1958). <span style="font-style:italic;">Medical-surgical nursing</span>. St. Louis: Mosby.', 'mla' => 'Shafer, Kathleen Newton. <span style="font-style:italic;">Medical-surgical Nursing</span>. St. Louis: Mosby, 1958.', 'chicago' => 'Shafer, Kathleen Newton. <span style="font-style:italic;">Medical-surgical Nursing</span>. St. Louis: Mosby, 1958.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Lewis, S.M.'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Lewis, S.M.'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'assessment and management of clinical problems.', 'Edition' => '7th ed. /', - 'PlacesOfPublication' => array('St. Louis, Mo.'), - 'Publishers' => array('Mosby Elsevier'), - 'PublicationDates' => array('2007') - ), + 'PlacesOfPublication' => ['St. Louis, Mo.'], + 'Publishers' => ['Mosby Elsevier'], + 'PublicationDates' => ['2007'] + ], 'apa' => 'Lewis, S. (2007). <span style="font-style:italic;">Medical-surgical nursing: Assessment and management of clinical problems</span> (7th ed.). St. Louis, Mo: Mosby Elsevier.', 'mla' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', - ), - array( // subtitle embedded in title - 'raw' => array( - 'SecondaryAuthors' => array('Lewis, S.M.'), + ], + [ // subtitle embedded in title + 'raw' => [ + 'SecondaryAuthors' => ['Lewis, S.M.'], 'Title' => 'Medical-surgical nursing: assessment and management of clinical problems.', 'Edition' => '7th ed. /', - 'PlacesOfPublication' => array('St. Louis, Mo.'), - 'Publishers' => array('Mosby Elsevier'), - 'PublicationDates' => array('2007') - ), + 'PlacesOfPublication' => ['St. Louis, Mo.'], + 'Publishers' => ['Mosby Elsevier'], + 'PublicationDates' => ['2007'] + ], 'apa' => 'Lewis, S. (2007). <span style="font-style:italic;">Medical-surgical nursing: Assessment and management of clinical problems</span> (7th ed.). St. Louis, Mo: Mosby Elsevier.', 'mla' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Lewis, S.M.'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Lewis, S.M.'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'assessment and management of clinical problems.', 'Edition' => '1st ed.', - 'PlacesOfPublication' => array('St. Louis, Mo.'), - 'Publishers' => array('Mosby Elsevier'), - 'PublicationDates' => array('2007') - ), + 'PlacesOfPublication' => ['St. Louis, Mo.'], + 'Publishers' => ['Mosby Elsevier'], + 'PublicationDates' => ['2007'] + ], 'apa' => 'Lewis, S. (2007). <span style="font-style:italic;">Medical-surgical nursing: Assessment and management of clinical problems</span>. St. Louis, Mo: Mosby Elsevier.', 'mla' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. St. Louis, Mo: Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Assessment and Management of Clinical Problems</span>. St. Louis, Mo: Mosby Elsevier, 2007.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Lewis, S.M., Weirdlynamed'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Lewis, S.M., Weirdlynamed'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'why?', 'Edition' => '7th ed.', - 'PlacesOfPublication' => array('St. Louis, Mo.'), - 'Publishers' => array('Mosby Elsevier'), - 'PublicationDates' => array('2007') - ), + 'PlacesOfPublication' => ['St. Louis, Mo.'], + 'Publishers' => ['Mosby Elsevier'], + 'PublicationDates' => ['2007'] + ], 'apa' => 'Lewis, S. (2007). <span style="font-style:italic;">Medical-surgical nursing: Why?</span> (7th ed.). St. Louis, Mo: Mosby Elsevier.', 'mla' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Why?</span> 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <span style="font-style:italic;">Medical-surgical Nursing: Why?</span> 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Lewis, S.M., IV'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Lewis, S.M., IV'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'why?', 'Edition' => '1st ed.', - 'PlacesOfPublication' => array('St. Louis, Mo.'), - 'Publishers' => array('Mosby Elsevier'), - 'PublicationDates' => array('2007') - ), + 'PlacesOfPublication' => ['St. Louis, Mo.'], + 'Publishers' => ['Mosby Elsevier'], + 'PublicationDates' => ['2007'] + ], 'apa' => 'Lewis, S., IV. (2007). <span style="font-style:italic;">Medical-surgical nursing: Why?</span> St. Louis, Mo: Mosby Elsevier.', 'mla' => 'Lewis, S.M., IV. <span style="font-style:italic;">Medical-surgical Nursing: Why?</span> St. Louis, Mo: Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M., IV. <span style="font-style:italic;">Medical-surgical Nursing: Why?</span> St. Louis, Mo: Mosby Elsevier, 2007.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Burch, Philip H., Jr.'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Burch, Philip H., Jr.'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', - 'PlacesOfPublication' => array('New York :'), - 'Publishers' => array('Holmes & Meier,'), - 'PublicationDates' => array('1980.') - ), + 'PlacesOfPublication' => ['New York :'], + 'Publishers' => ['Holmes & Meier,'], + 'PublicationDates' => ['1980.'] + ], 'apa' => 'Burch, P. H., Jr. (1980). <span style="font-style:italic;">The New Deal to the Carter administration</span>. New York: Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier, 1980.', 'chicago' => 'Burch, Philip H., Jr. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier, 1980.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', - 'PlacesOfPublication' => array('New York :'), - 'Publishers' => array('Holmes & Meier,'), - 'PublicationDates' => array('1980.') - ), + 'PlacesOfPublication' => ['New York :'], + 'Publishers' => ['Holmes & Meier,'], + 'PublicationDates' => ['1980.'] + ], 'apa' => 'Burch, P. H., Jr., Coauthor, F., & Fakeperson, T., III. (1980). <span style="font-style:italic;">The New Deal to the Carter administration</span>. New York: Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr., Fictional Coauthor, and Third Fakeperson, III. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier, 1980.', 'chicago' => 'Burch, Philip H., Jr., Fictional Coauthor, and Third Fakeperson, III. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier, 1980.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III', 'Mob, Writing', 'Manypeople, Letsmakeup'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III', 'Mob, Writing', 'Manypeople, Letsmakeup'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => '', 'Publishers' => '', 'PublicationDates' => '' - ), + ], 'apa' => 'Burch, P. H., Jr., Coauthor, F., Fakeperson, T., III, Mob, W., & Manypeople, L. <span style="font-style:italic;">The New Deal to the Carter administration</span>.', 'mla' => 'Burch, Philip H., Jr., et al. <span style="font-style:italic;">The New Deal to the Carter Administration</span>.', 'chicago' => 'Burch, Philip H., Jr., Fictional Coauthor, Third Fakeperson, III, Writing Mob, and Letsmakeup Manypeople. <span style="font-style:italic;">The New Deal to the Carter Administration</span>.', - ), - array( - 'raw' => array( - 'SecondaryAuthors' => array('Burch, Philip H., Jr.', 'Anonymous, 1971-1973', 'Elseperson, Firstnamery, 1971-1973'), + ], + [ + 'raw' => [ + 'SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Anonymous, 1971-1973', 'Elseperson, Firstnamery, 1971-1973'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', - 'PlacesOfPublication' => array('New York'), - 'Publishers' => array('Holmes & Meier') - ), + 'PlacesOfPublication' => ['New York'], + 'Publishers' => ['Holmes & Meier'] + ], 'apa' => 'Burch, P. H., Jr., Anonymous, & Elseperson, F. <span style="font-style:italic;">The New Deal to the Carter administration</span>. New York: Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr., Anonymous, and Firstnamery Elseperson. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier.', 'chicago' => 'Burch, Philip H., Jr., Anonymous, and Firstnamery Elseperson. <span style="font-style:italic;">The New Deal to the Carter Administration</span>. New York: Holmes & Meier.', - ), - array( // eight authors - 'raw' => array( - 'SecondaryAuthors' => array('One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person', 'Eight, Person'), + ], + [ // eight authors + 'raw' => [ + 'SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person', 'Eight, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Eight, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, Person Seven, and Person Eight. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // seven authors - 'raw' => array( - 'SecondaryAuthors' => array('One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person'), + ], + [ // seven authors + 'raw' => [ + 'SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., & Seven, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, and Person Seven. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // six authors - 'raw' => array( - 'SecondaryAuthors' => array('One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person'), + ], + [ // six authors + 'raw' => [ + 'SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., & Six, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, and Person Six. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // two authors - 'raw' => array( - 'SecondaryAuthors' => array('One, Person', 'Two, Person'), + ], + [ // two authors + 'raw' => [ + 'SecondaryAuthors' => ['One, Person', 'Two, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., & Two, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, and Person Two. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, and Person Two. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // one author - 'raw' => array( - 'SecondaryAuthors' => array('One, Person'), + ], + [ // one author + 'raw' => [ + 'SecondaryAuthors' => ['One, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // eight authors in "first name first" format. - 'raw' => array( - 'SecondaryAuthors' => array('Person One', 'Person Two', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight'), + ], + [ // eight authors in "first name first" format. + 'raw' => [ + 'SecondaryAuthors' => ['Person One', 'Person Two', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Eight, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, Person Seven, and Person Eight. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // ten authors in "first name first" format. - 'raw' => array( - 'SecondaryAuthors' => array('Person One', 'Person Two', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight', 'Person Nine', 'Person Ten'), + ], + [ // ten authors in "first name first" format. + 'raw' => [ + 'SecondaryAuthors' => ['Person One', 'Person Two', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight', 'Person Nine', 'Person Ten'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21 - ), + ], 'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Ten, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21.', 'mla' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person, et al. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ), - array( // DOI - 'raw' => array( - 'SecondaryAuthors' => array('One, Person'), + ], + [ // DOI + 'raw' => [ + 'SecondaryAuthors' => ['One, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, - 'PublicationDates' => array('1999'), + 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21, 'CleanDOI' => 'testDOI' - ), + ], 'apa' => 'One, P. (1999). Test Article. <span style="font-style:italic;">Test Journal, 1</span>(7), pp. 19-21. doi:testDOI', 'mla' => 'One, Person. "Test Article." <span style="font-style:italic;">Test Journal</span> 1.7 (1999): 19-21.', 'chicago' => 'One, Person. "Test Article." <span style="font-style:italic;">Test Journal</span> 1, no. 7 (1999): 19-21.', - ) + ] // @codingStandardsIgnoreEnd - ); + ]; /** * Setup test case. diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php index 3ccbe6f3df1..0ab826e016b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php @@ -94,12 +94,12 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $context = $this->getMockContext(); $context->expects($this->once())->method('apply') - ->with($this->equalTo(array('format' => 'foo'))) - ->will($this->returnValue(array('bar' => 'baz'))); + ->with($this->equalTo(['format' => 'foo'])) + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->once())->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); + ->with($this->equalTo(['bar' => 'baz'])); $record = $this->getRecord( - $this->loadRecordFixture('testbug1.json'), array(), $context + $this->loadRecordFixture('testbug1.json'), [], $context ); $record->getView()->expects($this->at(0))->method('render') ->with($this->equalTo('RecordDriver/SolrMarc/format-class.phtml')) @@ -173,19 +173,19 @@ class RecordTest extends \PHPUnit_Framework_TestCase $driver = $this->getMock('VuFind\RecordDriver\AbstractBase'); $driver->expects($this->once())->method('getContainingLists') ->with($this->equalTo(42)) - ->will($this->returnValue(array(1, 2, 3))); + ->will($this->returnValue([1, 2, 3])); $user = new \StdClass; $user->id = 42; - $expected = array( - 'driver' => $driver, 'list' => null, 'user' => $user, 'lists' => array(1, 2, 3) - ); + $expected = [ + 'driver' => $driver, 'list' => null, 'user' => $user, 'lists' => [1, 2, 3] + ]; $context = $this->getMockContext(); $context->expects($this->once())->method('apply') ->with($this->equalTo($expected)) - ->will($this->returnValue(array('bar' => 'baz'))); + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->once())->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); - $record = $this->getRecord($driver, array(), $context); + ->with($this->equalTo(['bar' => 'baz'])); + $record = $this->getRecord($driver, [], $context); $record->getView()->expects($this->at(0))->method('render') ->will($this->throwException(new RuntimeException('boom'))); $record->getView()->expects($this->at(1))->method('render') @@ -203,15 +203,15 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $driver = new \VuFindTest\RecordDriver\TestHarness(); $driver->setRawData( - array( + [ 'CleanISBN' => '0123456789', 'LCCN' => '12345', - 'OCLC' => array('1', '2'), - ) + 'OCLC' => ['1', '2'], + ] ); $record = $this->getRecord($driver); $this->assertEquals( - array('ISBN0123456789', 'LCCN12345', 'OCLC1', 'OCLC2'), + ['ISBN0123456789', 'LCCN12345', 'OCLC1', 'OCLC2'], $record->getPreviewIds() ); } @@ -241,13 +241,13 @@ class RecordTest extends \PHPUnit_Framework_TestCase public function testGetPreviews() { $driver = $this->loadRecordFixture('testbug1.json'); - $config = new \Zend\Config\Config(array('foo' => 'bar')); + $config = new \Zend\Config\Config(['foo' => 'bar']); $context = $this->getMockContext(); $context->expects($this->exactly(2))->method('apply') ->with($this->equalTo(compact('driver', 'config'))) - ->will($this->returnValue(array('bar' => 'baz'))); + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->exactly(2))->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); + ->with($this->equalTo(['bar' => 'baz'])); $record = $this->getRecord($driver, $config, $context); $record->getView()->expects($this->at(0))->method('render') ->with($this->equalTo('RecordDriver/SolrMarc/previewdata.phtml')) @@ -267,12 +267,12 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $context = $this->getMockContext(); $context->expects($this->once())->method('apply') - ->with($this->equalTo(array('lookfor' => 'foo'))) - ->will($this->returnValue(array('bar' => 'baz'))); + ->with($this->equalTo(['lookfor' => 'foo'])) + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->once())->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); + ->with($this->equalTo(['bar' => 'baz'])); $record = $this->getRecord( - $this->loadRecordFixture('testbug1.json'), array(), $context + $this->loadRecordFixture('testbug1.json'), [], $context ); $record->getView()->expects($this->at(0))->method('render') ->with($this->equalTo('RecordDriver/SolrMarc/link-bar.phtml')) @@ -289,13 +289,13 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $context = $this->getMockContext(); $context->expects($this->at(1))->method('renderInContext') - ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(array('id' => 'VuFind|000105196', 'count' => 0, 'prefix' => 'bar'))) + ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'VuFind|000105196', 'count' => 0, 'prefix' => 'bar'])) ->will($this->returnValue('success')); $context->expects($this->at(2))->method('renderInContext') - ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(array('id' => 'VuFind|000105196', 'count' => 1, 'prefix' => 'bar'))) + ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'VuFind|000105196', 'count' => 1, 'prefix' => 'bar'])) ->will($this->returnValue('success')); $record = $this->getRecord( - $this->loadRecordFixture('testbug1.json'), array(), $context + $this->loadRecordFixture('testbug1.json'), [], $context ); // We run the test twice to ensure that checkbox incrementing works properly: $this->assertEquals('success', $record->getCheckbox('bar', 'foo')); @@ -314,10 +314,10 @@ class RecordTest extends \PHPUnit_Framework_TestCase $context = $this->getMockContext(); $context->expects($this->once())->method('apply') ->with($this->equalTo(compact('driver', 'tab'))) - ->will($this->returnValue(array('bar' => 'baz'))); + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->once())->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); - $record = $this->getRecord($driver, array(), $context); + ->with($this->equalTo(['bar' => 'baz'])); + $record = $this->getRecord($driver, [], $context); $record->getView()->expects($this->at(0))->method('render') ->with($this->equalTo('RecordTab/description.phtml')) ->will($this->returnValue('success')); @@ -336,7 +336,7 @@ class RecordTest extends \PHPUnit_Framework_TestCase $this->assertFalse($record->getQrCode('core')); // Disabled mode: - $config = array('QRCode' => array('showInCore' => false)); + $config = ['QRCode' => ['showInCore' => false]]; $record = $this->getRecord($this->loadRecordFixture('testbug1.json'), $config); $this->assertFalse($record->getQrCode('core')); @@ -354,16 +354,16 @@ class RecordTest extends \PHPUnit_Framework_TestCase $driver = $this->loadRecordFixture('testbug1.json'); $context = $this->getMockContext(); $context->expects($this->once())->method('apply') - ->with($this->equalTo(array('driver' => $driver, 'extra' => 'xyzzy'))) - ->will($this->returnValue(array('bar' => 'baz'))); + ->with($this->equalTo(['driver' => $driver, 'extra' => 'xyzzy'])) + ->will($this->returnValue(['bar' => 'baz'])); $context->expects($this->once())->method('restore') - ->with($this->equalTo(array('bar' => 'baz'))); - $config = array('QRCode' => array('showInCore' => true)); + ->with($this->equalTo(['bar' => 'baz'])); + $config = ['QRCode' => ['showInCore' => true]]; $record = $this->getRecord($driver, $config, $context, '2:qrcode-show'); $record->getView()->expects($this->at(0))->method('render') ->with($this->equalTo('RecordDriver/SolrMarc/core-qrcode.phtml')) ->will($this->returnValue('success')); - $this->assertEquals('http://foo/bar?text=success&level=L&size=3&margin=4', $record->getQrCode('core', array('extra' => 'xyzzy'))); + $this->assertEquals('http://foo/bar?text=success&level=L&size=3&margin=4', $record->getQrCode('core', ['extra' => 'xyzzy'])); } /** @@ -375,7 +375,7 @@ class RecordTest extends \PHPUnit_Framework_TestCase { // No thumbnail: $driver = new \VuFindTest\RecordDriver\TestHarness(); - $driver->setRawData(array('Thumbnail' => false)); + $driver->setRawData(['Thumbnail' => false]); $record = $this->getRecord($driver); $this->assertFalse($record->getThumbnail()); } @@ -389,7 +389,7 @@ class RecordTest extends \PHPUnit_Framework_TestCase { // Hard-coded thumbnail: $driver = new \VuFindTest\RecordDriver\TestHarness(); - $driver->setRawData(array('Thumbnail' => 'http://foo/this.jpg')); + $driver->setRawData(['Thumbnail' => 'http://foo/this.jpg']); $record = $this->getRecord($driver); $this->assertEquals('http://foo/this.jpg', $record->getThumbnail()); } @@ -403,8 +403,8 @@ class RecordTest extends \PHPUnit_Framework_TestCase { // Hard-coded thumbnail: $driver = new \VuFindTest\RecordDriver\TestHarness(); - $driver->setRawData(array('Thumbnail' => array('bar' => 'baz'))); - $record = $this->getRecord($driver, array(), null, '1:cover-show'); + $driver->setRawData(['Thumbnail' => ['bar' => 'baz']]); + $record = $this->getRecord($driver, [], null, '1:cover-show'); $this->assertEquals('http://foo/bar?bar=baz', $record->getThumbnail()); } @@ -418,7 +418,7 @@ class RecordTest extends \PHPUnit_Framework_TestCase // Hard-coded thumbnail: $driver = new \VuFindTest\RecordDriver\TestHarness(); $record = $this->getRecord($driver); - $this->assertEquals(array(), $record->getLinkDetails()); + $this->assertEquals([], $record->getLinkDetails()); } /** @@ -430,17 +430,17 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $driver = new \VuFindTest\RecordDriver\TestHarness(); $driver->setRawData( - array( - 'URLs' => array( - array('route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link') - ) - ) + [ + 'URLs' => [ + ['route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link'] + ] + ] ); - $record = $this->getRecord($driver, array(), null, '1:fake-route', 2); + $record = $this->getRecord($driver, [], null, '1:fake-route', 2); $this->assertEquals( - array( - array('route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link', 'url' => 'http://proxy?_=http://server-foo/baz') - ), + [ + ['route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link', 'url' => 'http://proxy?_=http://server-foo/baz'] + ], $record->getLinkDetails() ); } @@ -456,17 +456,17 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $driver = new \VuFindTest\RecordDriver\TestHarness(); $driver->setRawData( - array( - 'URLs' => array( - array('bad' => 'junk') - ) - ) + [ + 'URLs' => [ + ['bad' => 'junk'] + ] + ] ); $record = $this->getRecord($driver); $this->assertEquals( - array( - array('route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link', 'url' => 'http://proxy?_=http://server-foo/baz') - ), + [ + ['route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link', 'url' => 'http://proxy?_=http://server-foo/baz'] + ], $record->getLinkDetails() ); } @@ -480,15 +480,15 @@ class RecordTest extends \PHPUnit_Framework_TestCase { $driver = new \VuFindTest\RecordDriver\TestHarness(); $driver->setRawData( - array( - 'URLs' => array( - array('route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link') - ) - ) + [ + 'URLs' => [ + ['route' => 'fake-route', 'prefix' => 'http://proxy?_=', 'desc' => 'a link'] + ] + ] ); - $record = $this->getRecord($driver, array(), null, '1:fake-route', 2); + $record = $this->getRecord($driver, [], null, '1:fake-route', 2); $this->assertEquals( - array('http://proxy?_=http://server-foo/baz'), $record->getUrlList() + ['http://proxy?_=http://server-foo/baz'], $record->getUrlList() ); } @@ -503,7 +503,7 @@ class RecordTest extends \PHPUnit_Framework_TestCase * * @return Record */ - protected function getRecord($driver, $config = array(), $context = null, $url = false, $serverurl = false) + protected function getRecord($driver, $config = [], $context = null, $url = false, $serverurl = false) { if (null === $context) { $context = $this->getMockContext(); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/jQueryMobile/MobileMenuTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/jQueryMobile/MobileMenuTest.php index b13249abaf2..b8b5436fa58 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/jQueryMobile/MobileMenuTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/jQueryMobile/MobileMenuTest.php @@ -46,7 +46,7 @@ class MobileMenuTest extends \PHPUnit_Framework_TestCase */ public function testHeader() { - $extras = array('bar' => 'baz'); + $extras = ['bar' => 'baz']; $mm = $this->getMobileMenu('header.phtml', $extras); $this->assertEquals('foo', $mm->header($extras)); } @@ -58,7 +58,7 @@ class MobileMenuTest extends \PHPUnit_Framework_TestCase */ public function testFooter() { - $extras = array('bar' => 'baz'); + $extras = ['bar' => 'baz']; $mm = $this->getMobileMenu('footer.phtml', $extras); $this->assertEquals('foo', $mm->footer($extras)); } diff --git a/module/VuFindAdmin/Module.php b/module/VuFindAdmin/Module.php index 0b40322baae..8d3377e2ea4 100644 --- a/module/VuFindAdmin/Module.php +++ b/module/VuFindAdmin/Module.php @@ -57,12 +57,12 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } } diff --git a/module/VuFindAdmin/config/module.config.php b/module/VuFindAdmin/config/module.config.php index 882ace30efe..3a83ae49c3b 100644 --- a/module/VuFindAdmin/config/module.config.php +++ b/module/VuFindAdmin/config/module.config.php @@ -1,94 +1,94 @@ <?php namespace VuFindAdmin\Module\Configuration; -$config = array( - 'controllers' => array( - 'invokables' => array( +$config = [ + 'controllers' => [ + 'invokables' => [ 'admin' => 'VuFindAdmin\Controller\AdminController', 'adminconfig' => 'VuFindAdmin\Controller\ConfigController', 'adminsocial' => 'VuFindAdmin\Controller\SocialstatsController', 'adminmaintenance' => 'VuFindAdmin\Controller\MaintenanceController', 'adminstatistics' => 'VuFindAdmin\Controller\StatisticsController', 'admintags' => 'VuFindAdmin\Controller\TagsController', - ), - ), - 'router' => array( - 'routes' => array( - 'admin' => array( + ], + ], + 'router' => [ + 'routes' => [ + 'admin' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/Admin', - 'defaults' => array( + 'defaults' => [ 'controller' => 'Admin', 'action' => 'Home', - ) - ), + ] + ], 'may_terminate' => true, - 'child_routes' => array( - 'disabled' => array( + 'child_routes' => [ + 'disabled' => [ 'type' => 'Zend\Mvc\Router\Http\Literal', - 'options' => array( + 'options' => [ 'route' => '/Disabled', - 'defaults' => array( + 'defaults' => [ 'controller' => 'Admin', 'action' => 'Disabled', - ) - ) - ), - 'config' => array( + ] + ] + ], + 'config' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Config[/:action]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'AdminConfig', 'action' => 'Home', - ) - ) - ), - 'maintenance' => array( + ] + ] + ], + 'maintenance' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Maintenance[/:action]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'AdminMaintenance', 'action' => 'Home', - ) - ) - ), - 'social' => array( + ] + ] + ], + 'social' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Social[/:action]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'AdminSocial', 'action' => 'Home', - ) - ) - ), - 'statistics' => array( + ] + ] + ], + 'statistics' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Statistics[/:action]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'AdminStatistics', 'action' => 'Home', - ) - ) - ), - 'tags' => array( + ] + ] + ], + 'tags' => [ 'type' => 'Zend\Mvc\Router\Http\Segment', - 'options' => array( + 'options' => [ 'route' => '/Tags[/:action]', - 'defaults' => array( + 'defaults' => [ 'controller' => 'AdminTags', 'action' => 'Home', - ) - ) - ), - ), - ), - ), - ), -); + ] + ] + ], + ], + ], + ], + ], +]; return $config; \ No newline at end of file diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php index 43c311f8640..10ac05b7adc 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php @@ -60,7 +60,7 @@ class MaintenanceController extends AbstractAdmin public function clearcacheAction() { $cacheManager = $this->getServiceLocator()->get('VuFind\CacheManager'); - foreach ($this->params()->fromQuery('cache', array()) as $cache) { + foreach ($this->params()->fromQuery('cache', []) as $cache) { $cacheManager->getCache($cache)->flush(); } // If cache is unset, we didn't go through the loop above, so no message diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/StatisticsController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/StatisticsController.php index c387cec4214..60ba9886f5f 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/StatisticsController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/StatisticsController.php @@ -54,7 +54,7 @@ class StatisticsController extends AbstractAdmin $search = $this->getServiceLocator()->get('VuFind\SearchStats'); $view->searchesBySource = $config->Statistics->searchesBySource ?: false; $searchSummary = $search->getStatsSummary(7, $view->searchesBySource); - foreach (array('top', 'empty', 'total') as $section) { + foreach (['top', 'empty', 'total'] as $section) { $key = $section . 'Searches'; $view->$key = isset($searchSummary[$section]) ? $searchSummary[$section] : null; diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php index 15d1d37cfb0..d28821331b2 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php @@ -131,17 +131,17 @@ class TagsController extends AbstractAdmin $action = ("list" == $origin) ? 'List' : 'Manage'; $originUrl = $this->url() - ->fromRoute('admin/tags', array('action' => $action)); + ->fromRoute('admin/tags', ['action' => $action]); if ($action == 'List') { $originUrl .= '?' . http_build_query( - array( + [ 'user_id' => $this->getParam('user_id'), 'resource_id' => $this->getParam('resource_id'), 'tag_id' => $this->getParam('tag_id'), - ) + ] ); } - $newUrl = $this->url()->fromRoute('admin/tags', array('action' => 'Delete')); + $newUrl = $this->url()->fromRoute('admin/tags', ['action' => 'Delete']); $confirm = $this->params()->fromPost('confirm', false); @@ -182,10 +182,10 @@ class TagsController extends AbstractAdmin $this->flashMessenger()->setNamespace('info') ->addMessage( - array( + [ 'msg' => 'tags_deleted', - 'tokens' => array('%count%' => $delete) - ) + 'tokens' => ['%count%' => $delete] + ] ); return $this->redirect()->toUrl($originUrl); } @@ -199,37 +199,37 @@ class TagsController extends AbstractAdmin */ protected function getConfirmDeleteMessages($count) { - $messages = array(); + $messages = []; $user = $this->getTable('user') - ->select(array('id' => $this->getParam('user_id'))) + ->select(['id' => $this->getParam('user_id')]) ->current(); $userMsg = (false !== $user) ? $user->username . " (" . $user->id . ")" : "All"; $tag = $this->getTable('tags') - ->select(array('id' => $this->getParam('tag_id'))) + ->select(['id' => $this->getParam('tag_id')]) ->current(); $tagMsg = (false !== $tag) ? $tag->tag . " (" . $tag->id . ")" : " All"; $resource = $this->getTable('resource') - ->select(array('id' => $this->getParam('resource_id'))) + ->select(['id' => $this->getParam('resource_id')]) ->current(); $resourceMsg = (false !== $resource) ? $resource->title . " (" . $resource->id . ")" : " All"; - $messages[] = array( + $messages[] = [ 'msg' => 'tag_delete_warning', - 'tokens' => array('%count%' => $count) - ); + 'tokens' => ['%count%' => $count] + ]; if (false !== $user || false !== $tag || false !== $resource) { - $messages[] = array( + $messages[] = [ 'msg' => 'tag_delete_filter', - 'tokens' => array( + 'tokens' => [ '%username%' => $userMsg, '%tag%' => $tagMsg, '%resource%' => $resourceMsg - ) - ); + ] + ]; } return $messages; } @@ -247,22 +247,22 @@ class TagsController extends AbstractAdmin { $count = count($ids); - $data = array( - 'data' => array( + $data = [ + 'data' => [ 'confirm' => $newUrl, 'cancel' => $originUrl, 'title' => "confirm_delete_tags_brief", 'messages' => $this->getConfirmDeleteMessages($count), 'ids' => $ids, - 'extras' => array( + 'extras' => [ 'origin' => 'list', 'user_id' => $this->getParam('user_id'), 'tag_id' => $this->getParam('tag_id'), 'resource_id' => $this->getParam('resource_id'), 'ids' => $ids - ) - ) - ); + ] + ] + ]; return $this->forwardTo('Confirm', 'Confirm', $data); } @@ -284,22 +284,22 @@ class TagsController extends AbstractAdmin $this->convertFilter($this->getParam('tag_id')) )->getTotalItemCount(); - $data = array( - 'data' => array( + $data = [ + 'data' => [ 'confirm' => $newUrl, 'cancel' => $originUrl, 'title' => "confirm_delete_tags_brief", 'messages' => $this->getConfirmDeleteMessages($count), - 'extras' => array( + 'extras' => [ 'origin' => 'manage', 'type' => $this->getParam('type'), 'user_id' => $this->getParam('user_id'), 'tag_id' => $this->getParam('tag_id'), 'resource_id' => $this->getParam('resource_id'), 'deleteFilter' => $this->getParam('deleteFilter') - ) - ) - ); + ] + ] + ]; return $this->forwardTo('Confirm', 'Confirm', $data); } @@ -386,7 +386,7 @@ class TagsController extends AbstractAdmin protected function deleteResourceTagsByFilter() { $tags = $this->getResourceTags(); - $ids = array(); + $ids = []; foreach ($tags as $tag) { $ids[] = $tag->id; } diff --git a/module/VuFindAdmin/tests/unit-tests/src/VuFindTest/Controller/SocialstatsControllerTest.php b/module/VuFindAdmin/tests/unit-tests/src/VuFindTest/Controller/SocialstatsControllerTest.php index 297e6a264da..851ae60cac8 100644 --- a/module/VuFindAdmin/tests/unit-tests/src/VuFindTest/Controller/SocialstatsControllerTest.php +++ b/module/VuFindAdmin/tests/unit-tests/src/VuFindTest/Controller/SocialstatsControllerTest.php @@ -47,14 +47,14 @@ class SocialstatsControllerTest extends \VuFindTest\Unit\TestCase public function testHome() { // Create mocks to simulate database lookups: - $c = $this->getMock('VuFindAdmin\Controller\SocialstatsController', array('getTable')); - $comments = $this->getMock('VuFind\Db\Table\Comments', array('getStatistics')); + $c = $this->getMock('VuFindAdmin\Controller\SocialstatsController', ['getTable']); + $comments = $this->getMock('VuFind\Db\Table\Comments', ['getStatistics']); $comments->expects($this->once())->method('getStatistics')->will($this->returnValue('comments-data')); $c->expects($this->at(0))->method('getTable')->with($this->equalTo('comments'))->will($this->returnValue($comments)); - $userresource = $this->getMock('VuFind\Db\Table\UserResource', array('getStatistics')); + $userresource = $this->getMock('VuFind\Db\Table\UserResource', ['getStatistics']); $userresource->expects($this->once())->method('getStatistics')->will($this->returnValue('userresource-data')); $c->expects($this->at(1))->method('getTable')->with($this->equalTo('userresource'))->will($this->returnValue($userresource)); - $resourcetags = $this->getMock('VuFind\Db\Table\ResourceTags', array('getStatistics')); + $resourcetags = $this->getMock('VuFind\Db\Table\ResourceTags', ['getStatistics']); $resourcetags->expects($this->once())->method('getStatistics')->will($this->returnValue('resourcetags-data')); $c->expects($this->at(2))->method('getTable')->with($this->equalTo('resourcetags'))->will($this->returnValue($resourcetags)); diff --git a/module/VuFindConsole/Module.php b/module/VuFindConsole/Module.php index 1c8db1608c4..15fe9e017a0 100644 --- a/module/VuFindConsole/Module.php +++ b/module/VuFindConsole/Module.php @@ -56,13 +56,13 @@ class Module implements \Zend\ModuleManager\Feature\ConsoleUsageProviderInterfac */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } /** @@ -76,7 +76,7 @@ class Module implements \Zend\ModuleManager\Feature\ConsoleUsageProviderInterfac */ public function getConsoleUsage(Console $console) { - return array( + return [ 'generate extendservice' => 'Override a service with a new child class', 'harvest harvest_oai' => 'OAI-PMH harvester', 'harvest merge-marc' => 'MARC merge tool', @@ -94,6 +94,6 @@ class Module implements \Zend\ModuleManager\Feature\ConsoleUsageProviderInterfac 'util optimize' => 'Solr optimize tool', 'util sitemap' => 'XML sitemap generator', 'util suppressed' => 'Remove ILS-suppressed records from Solr', - ); + ]; } } diff --git a/module/VuFindConsole/config/module.config.php b/module/VuFindConsole/config/module.config.php index a99e4f80cb7..14e0a849335 100644 --- a/module/VuFindConsole/config/module.config.php +++ b/module/VuFindConsole/config/module.config.php @@ -1,25 +1,25 @@ <?php namespace VuFindConsole\Module\Configuration; -$config = array( - 'controllers' => array( - 'invokables' => array( +$config = [ + 'controllers' => [ + 'invokables' => [ 'generate' => 'VuFindConsole\Controller\GenerateController', 'harvest' => 'VuFindConsole\Controller\HarvestController', 'import' => 'VuFindConsole\Controller\ImportController', 'language' => 'VuFindConsole\Controller\LanguageController', 'util' => 'VuFindConsole\Controller\UtilController', - ), - ), - 'console' => array( - 'router' => array( + ], + ], + 'console' => [ + 'router' => [ 'router_class' => 'VuFindConsole\Mvc\Router\ConsoleRouter', - ), - ), - 'view_manager' => array( + ], + ], + 'view_manager' => [ // CLI tools are admin-oriented, so we should always output full errors: 'display_exceptions' => true, - ), -); + ], +]; return $config; \ No newline at end of file diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php index 734711e0b77..d3fb35b2fbb 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php @@ -60,7 +60,7 @@ class AbstractBase extends AbstractActionController } // Get access to information about the CLI request. - $this->consoleOpts = new Getopt(array()); + $this->consoleOpts = new Getopt([]); // Switch the context back to the original working directory so that // relative paths work as expected. (This constant is set in diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/GenerateController.php b/module/VuFindConsole/src/VuFindConsole/Controller/GenerateController.php index 4cf5479e76d..7810aa7ca28 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/GenerateController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/GenerateController.php @@ -77,7 +77,7 @@ class GenerateController extends AbstractBase } $sourceType = $parts[$partCount - 2]; - $supportedTypes = array('factories', 'invokables'); + $supportedTypes = ['factories', 'invokables']; if (!in_array($sourceType, $supportedTypes)) { Console::writeLine( 'Unsupported service type; supported values: ' diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php b/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php index 887b7baf3aa..6ab46cfad0a 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php @@ -50,7 +50,7 @@ class HarvestController extends AbstractBase // Parse switches: $this->consoleOpts->addRules( - array('from-s' => 'Harvest start date', 'until-s' => 'Harvest end date') + ['from-s' => 'Harvest start date', 'until-s' => 'Harvest end date'] ); $from = $this->consoleOpts->getOption('from'); $until = $this->consoleOpts->getOption('until'); @@ -68,7 +68,7 @@ class HarvestController extends AbstractBase $argv = $this->consoleOpts->getRemainingArgs(); if (isset($argv[0])) { if (isset($oaiSettings[$argv[0]])) { - $oaiSettings = array($argv[0] => $oaiSettings[$argv[0]]); + $oaiSettings = [$argv[0] => $oaiSettings[$argv[0]]]; } else { Console::writeLine("Could not load settings for {$argv[0]}."); return $this->getFailureResponse(); diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php b/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php index a3ce52cc91c..0ef07edb6a1 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php @@ -48,7 +48,7 @@ class ImportController extends AbstractBase { // Parse switches: $this->consoleOpts->addRules( - array('test-only' => 'Use test mode', 'index-s' => 'Solr index to use') + ['test-only' => 'Use test mode', 'index-s' => 'Solr index to use'] ); $testMode = $this->consoleOpts->getOption('test-only') ? true : false; $index = $this->consoleOpts->getOption('index'); @@ -99,7 +99,7 @@ class ImportController extends AbstractBase $this->performImport($argv[0], $argv[1], $index, $testMode); } catch (\Exception $e) { Console::writeLine("Fatal error: " . $e->getMessage()); - if (is_callable(array($e, 'getPrevious')) && $e = $e->getPrevious()) { + if (is_callable([$e, 'getPrevious']) && $e = $e->getPrevious()) { while ($e) { Console::writeLine("Previous exception: " . $e->getMessage()); $e = $e->getPrevious(); @@ -186,7 +186,7 @@ class ImportController extends AbstractBase $xml = simplexml_load_file($file); if ($xml) { // Are there any child sitemaps? If so, pull them in: - $results = isset($xml->sitemap) ? $xml->sitemap : array(); + $results = isset($xml->sitemap) ? $xml->sitemap : []; foreach ($results as $current) { if (isset($current->loc)) { if (!$this->harvestSitemap((string)$current->loc, $verbose)) { diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php index 7a97bb92584..1ee913db2d6 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php @@ -105,15 +105,15 @@ class UtilController extends AbstractBase ini_set('max_execution_time', '3600'); $this->consoleOpts->setOptions( - array(\Zend\Console\Getopt::CONFIG_CUMULATIVE_PARAMETERS => true) + [\Zend\Console\Getopt::CONFIG_CUMULATIVE_PARAMETERS => true] ); $this->consoleOpts->addRules( - array( + [ 'h|help' => 'Get help', 'd-s' => 'Delimiter', 't-s' => 'Template', 'f-s' => 'File', - ) + ] ); if ($this->consoleOpts->getOption('h') @@ -208,9 +208,9 @@ class UtilController extends AbstractBase $id = $course_id . '|' . $instructor_id . '|' . $department_id; if (!isset($index[$id])) { - $index[$id] = array( + $index[$id] = [ 'id' => $id, - 'bib_id' => array(), + 'bib_id' => [], 'instructor_id' => $instructor_id, 'instructor' => isset($instructors[$instructor_id]) ? $instructors[$instructor_id] : '', @@ -220,7 +220,7 @@ class UtilController extends AbstractBase 'department_id' => $department_id, 'department' => isset($departments[$department_id]) ? $departments[$department_id] : '' - ); + ]; } $index[$id]['bib_id'][] = $record['BIB_ID']; } @@ -328,7 +328,7 @@ class UtilController extends AbstractBase } // Build list of records to delete: - $ids = array(); + $ids = []; // Flat file mode: if ($mode == 'flat') { @@ -398,10 +398,10 @@ class UtilController extends AbstractBase { // Setup Solr Connection $this->consoleOpts->addRules( - array( + [ 'authorities' => 'Delete authority records instead of bibliographic records' - ) + ] ); $backend = $this->consoleOpts->getOption('authorities') ? 'SolrAuth' : 'Solr'; @@ -444,14 +444,14 @@ class UtilController extends AbstractBase $recordLoader = $this->getServiceLocator()->get('VuFind\RecordLoader'); // Parse switches: $this->consoleOpts->addRules( - array( + [ 'skip-xml|sx' => 'Skip the XML cache', 'skip-json|sj' => 'Skip the JSON cache' - ) + ] ); $hierarchies = $this->getServiceLocator() ->get('VuFind\SearchResultsPluginManager')->get('Solr') - ->getFullFieldFacets(array('hierarchy_top_id')); + ->getFullFieldFacets(['hierarchy_top_id']); foreach ($hierarchies['hierarchy_top_id']['data']['list'] as $hierarchy) { $recordid = $hierarchy['value']; $count = $hierarchy['count']; @@ -470,7 +470,7 @@ class UtilController extends AbstractBase if (!$this->consoleOpts->getOption('skip-json')) { Console::writeLine("\t\tJSON cache..."); $driver->getHierarchyDriver()->getTreeSource()->getJSON( - $recordid, array('refresh' => true) + $recordid, ['refresh' => true] ); } else { Console::writeLine("\t\tJSON skipped."); @@ -479,7 +479,7 @@ class UtilController extends AbstractBase if (!$this->consoleOpts->getOption('skip-xml')) { Console::writeLine("\t\tXML cache..."); $driver->getHierarchyDriver()->getTreeSource()->getXML( - $recordid, array('refresh' => true) + $recordid, ['refresh' => true] ); } else { Console::writeLine("\t\tXML skipped."); diff --git a/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php b/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php index 80beda7b160..acdd3c47b59 100644 --- a/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php +++ b/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php @@ -88,7 +88,7 @@ class ConsoleRouter extends SimpleRouteStack array_unshift($argv, "$script $controller $action"); $argc -= 2; - return array($controller, $action); + return [$controller, $action]; } /** @@ -156,7 +156,7 @@ class ConsoleRouter extends SimpleRouteStack } $routeMatch = new RouteMatch( - array('controller' => $controller, 'action' => $actionName), 1 + ['controller' => $controller, 'action' => $actionName], 1 ); // Override standard routing: diff --git a/module/VuFindConsole/tests/unit-tests/bootstrap.php b/module/VuFindConsole/tests/unit-tests/bootstrap.php index 3986a50bff1..01e13955ada 100644 --- a/module/VuFindConsole/tests/unit-tests/bootstrap.php +++ b/module/VuFindConsole/tests/unit-tests/bootstrap.php @@ -9,13 +9,13 @@ */ require_once('Zend/Loader/AutoloaderFactory.php'); \Zend\Loader\AutoloaderFactory::factory( - array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ 'VuFindConsole' => realpath(__DIR__ . '/../../src/VuFindConsole'), 'VuFindTest' => realpath(__DIR__ . '/src/VuFindTest'), - ), + ], 'autoregister_zf' => true - ) - ) + ] + ] ); diff --git a/module/VuFindConsole/tests/unit-tests/src/VuFindTest/Mvc/Router/ConsoleRouterTest.php b/module/VuFindConsole/tests/unit-tests/src/VuFindTest/Mvc/Router/ConsoleRouterTest.php index 94d63286cd8..baa538e6e97 100644 --- a/module/VuFindConsole/tests/unit-tests/src/VuFindTest/Mvc/Router/ConsoleRouterTest.php +++ b/module/VuFindConsole/tests/unit-tests/src/VuFindTest/Mvc/Router/ConsoleRouterTest.php @@ -48,7 +48,7 @@ class ConsoleRouterTest extends \PHPUnit_Framework_TestCase { $router = ConsoleRouter::factory(); $router->setCliDir(__DIR__); - $request = $this->getMock('Zend\Console\Request', array('getScriptName')); + $request = $this->getMock('Zend\Console\Request', ['getScriptName']); $request->expects($this->any())->method('getScriptName') ->will($this->returnValue('ConsoleRouterTest.php')); $result = $router->match($request); diff --git a/module/VuFindDevTools/Module.php b/module/VuFindDevTools/Module.php index 1fd5615a092..38cb7eb043e 100644 --- a/module/VuFindDevTools/Module.php +++ b/module/VuFindDevTools/Module.php @@ -57,12 +57,12 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } } diff --git a/module/VuFindDevTools/config/module.config.php b/module/VuFindDevTools/config/module.config.php index e37ca41d6c0..ffc4d312bba 100644 --- a/module/VuFindDevTools/config/module.config.php +++ b/module/VuFindDevTools/config/module.config.php @@ -1,12 +1,12 @@ <?php namespace VuFindLocalTemplate\Module\Configuration; -$config = array( - 'controllers' => array( - 'invokables' => array( +$config = [ + 'controllers' => [ + 'invokables' => [ 'devtools' => 'VuFindDevTools\Controller\DevtoolsController', - ), - ), -); + ], + ], +]; return $config; \ No newline at end of file diff --git a/module/VuFindDevTools/src/VuFindDevTools/Controller/DevtoolsController.php b/module/VuFindDevTools/src/VuFindDevTools/Controller/DevtoolsController.php index 48a4287c5ae..836e6b6d204 100644 --- a/module/VuFindDevTools/src/VuFindDevTools/Controller/DevtoolsController.php +++ b/module/VuFindDevTools/src/VuFindDevTools/Controller/DevtoolsController.php @@ -53,10 +53,10 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase $dir = APPLICATION_PATH . '/themes/root/templates/HelpTranslations/' . $language; if (!file_exists($dir) || !is_dir($dir)) { - return array(); + return []; } $handle = opendir($dir); - $files = array(); + $files = []; while ($file = readdir($handle)) { if (substr($file, -6) == '.phtml') { $files[] = $file; @@ -73,7 +73,7 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase */ protected function getLanguages() { - $langs = array(); + $langs = []; $dir = opendir(APPLICATION_PATH . '/languages'); while ($file = readdir($dir)) { if (substr($file, -4) == '.ini') { @@ -113,12 +113,12 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase */ protected function compareLanguages($lang1, $lang2) { - return array( + return [ 'notInL1' => $this->findMissingLanguageStrings($lang2, $lang1), 'notInL2' => $this->findMissingLanguageStrings($lang1, $lang2), 'l1Percent' => number_format(count($lang1) / count($lang2) * 100, 2), 'l2Percent' => number_format(count($lang2) / count($lang1) * 100, 2), - ); + ]; } /** @@ -153,12 +153,12 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase { // Test languages with no local overrides and no fallback: $loader = new \VuFind\I18n\Translator\Loader\ExtendedIni( - array(APPLICATION_PATH . '/languages') + [APPLICATION_PATH . '/languages'] ); $mainLanguage = $this->params()->fromQuery('main', 'en'); $main = $loader->load($mainLanguage, null); - $details = array(); + $details = []; $allLangs = $this->getLanguages(); sort($allLangs); foreach ($allLangs as $langCode) { @@ -173,11 +173,11 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase $details[$langCode]['helpFiles'] = $this->getHelpFiles($langCode); } - return array( + return [ 'details' => $details, 'mainCode' => $mainLanguage, 'mainName' => $this->getLangName($mainLanguage), 'main' => $main, - ); + ]; } } \ No newline at end of file diff --git a/module/VuFindDevTools/tests/unit-tests/src/VuFindTest/Controller/DevtoolsControllerTest.php b/module/VuFindDevTools/tests/unit-tests/src/VuFindTest/Controller/DevtoolsControllerTest.php index d650be34acf..57780b5fa9a 100644 --- a/module/VuFindDevTools/tests/unit-tests/src/VuFindTest/Controller/DevtoolsControllerTest.php +++ b/module/VuFindDevTools/tests/unit-tests/src/VuFindTest/Controller/DevtoolsControllerTest.php @@ -69,16 +69,16 @@ class DevtoolsControllerTest extends \VuFindTest\Unit\TestCase */ public function testComparison() { - $l1 = array('1' => 'one', '2' => 'two', '3' => 'three'); - $l2 = array('2' => 'two', '4' => 'four'); + $l1 = ['1' => 'one', '2' => 'two', '3' => 'three']; + $l2 = ['2' => 'two', '4' => 'four']; $c = new Controller(); - $expected = array( - 'notInL1' => array(4), - 'notInL2' => array(1, 3), + $expected = [ + 'notInL1' => [4], + 'notInL2' => [1, 3], 'l1Percent' => '150.00', 'l2Percent' => '66.67' - ); - $this->assertEquals($expected, $this->callMethod($c, 'compareLanguages', array($l1, $l2))); + ]; + $this->assertEquals($expected, $this->callMethod($c, 'compareLanguages', [$l1, $l2])); } /** @@ -122,8 +122,8 @@ class DevtoolsControllerTest extends \VuFindTest\Unit\TestCase */ protected function getMockController() { - $config = new Config(array('Languages' => array('en' => 'English'))); - $c = $this->getMock('VuFindDevTools\Controller\DevtoolsController', array('getConfig')); + $config = new Config(['Languages' => ['en' => 'English']]); + $c = $this->getMock('VuFindDevTools\Controller\DevtoolsController', ['getConfig']); $c->expects($this->any())->method('getConfig')->will($this->returnValue($config)); return $c; } diff --git a/module/VuFindLocalTemplate/Module.php b/module/VuFindLocalTemplate/Module.php index 521a8ad247a..34c93e262d8 100644 --- a/module/VuFindLocalTemplate/Module.php +++ b/module/VuFindLocalTemplate/Module.php @@ -57,13 +57,13 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } /** diff --git a/module/VuFindLocalTemplate/config/module.config.php b/module/VuFindLocalTemplate/config/module.config.php index ec6d9cd3508..2478d241748 100644 --- a/module/VuFindLocalTemplate/config/module.config.php +++ b/module/VuFindLocalTemplate/config/module.config.php @@ -1,7 +1,7 @@ <?php namespace VuFindLocalTemplate\Module\Configuration; -$config = array( -); +$config = [ +]; return $config; \ No newline at end of file diff --git a/module/VuFindSearch/Module.php b/module/VuFindSearch/Module.php index dbea2d1fed9..1f157531372 100644 --- a/module/VuFindSearch/Module.php +++ b/module/VuFindSearch/Module.php @@ -64,12 +64,12 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php index 284dd339e02..4b25c8a40b3 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php @@ -199,7 +199,7 @@ class Backend extends AbstractBackend // create query parameters from VuFind data $queryString = !empty($query) ? $query->getAllTerms() : ''; - $paramsStr = implode('&', null !== $params ? $params->request() : array()); + $paramsStr = implode('&', null !== $params ? $params->request() : []); $this->debugPrint( "Query: $queryString, Limit: $limit, Offset: $offset, " . "Params: $paramsStr" @@ -241,7 +241,7 @@ class Backend extends AbstractBackend } break; default: - $response = array(); + $response = []; break; } } catch(Exception $e) { @@ -307,7 +307,7 @@ class Backend extends AbstractBackend throw $e; } } - $collection = $this->createRecordCollection(array('Records' => $response)); + $collection = $this->createRecordCollection(['Records' => $response]); $this->injectSourceIdentifier($collection); return $collection; } @@ -322,12 +322,12 @@ class Backend extends AbstractBackend protected function paramBagToEBSCOSearchModel(ParamBag $params) { $params = $params->getArrayCopy(); - $options = array(); + $options = []; // Most parameters need to be flattened from array format, but a few // should remain as arrays: - $arraySettings = array( + $arraySettings = [ 'query', 'facets', 'filters', 'groupFilters', 'rangeFilters', 'limiters' - ); + ]; foreach ($params as $key => $param) { $options[$key] = in_array($key, $arraySettings) ? $param : $param[0]; @@ -435,7 +435,7 @@ class Backend extends AbstractBackend $results = $this->client->authenticate($username, $password, $orgId); $token = $results['AuthToken']; $timeout = $results['AuthTimeout'] + time(); - $authTokenData = array('token' => $token, 'expiration' => $timeout); + $authTokenData = ['token' => $token, 'expiration' => $timeout]; $this->cache->setItem('edsAuthenticationToken', $authTokenData); } return $token; @@ -589,7 +589,7 @@ class Backend extends AbstractBackend } } else { - $response = array(); + $response = []; } } return $response; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Base.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Base.php index fa67a39cbed..bb4372d6efc 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Base.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Base.php @@ -95,7 +95,7 @@ abstract class EdsApi_REST_Base * <li>profile - EBSCO profile to use for calls to the API. </li> * </ul> */ - public function __construct($settings = array()) + public function __construct($settings = []) { if (is_array($settings)) { foreach ($settings as $key => $value) { @@ -157,7 +157,7 @@ abstract class EdsApi_REST_Base 'Create Session for profile: ' . "$profile, guest: $isGuest, authToken: $authToken " ); - $qs = array('profile' => $profile, 'guest' => $isGuest); + $qs = ['profile' => $profile, 'guest' => $isGuest]; $url = $this->edsApiHost . '/createsession'; $headers = $this->setTokens($authToken, null); return $this->call($url, $headers, $qs); @@ -183,7 +183,7 @@ abstract class EdsApi_REST_Base $this->debugPrint( "Get Record. an: $an, dbid: $dbId, $highlightTerms: $highlightTerms" ); - $qs = array('an' => $an, 'dbid' => $dbId); + $qs = ['an' => $an, 'dbid' => $dbId]; if (null != $highlightTerms) { $qs['highlightterms'] = $highlightTerms; } @@ -228,7 +228,7 @@ abstract class EdsApi_REST_Base ); $url = $this->authHost . '/uidauth'; $org = isset($orgid) ? $orgid : $this->orgId; - $authInfo = array(); + $authInfo = []; if (isset($username)) { $authInfo['UserId'] = $username; } @@ -251,7 +251,7 @@ abstract class EdsApi_REST_Base */ protected function createQSFromArray($params) { - $queryParameters = array(); + $queryParameters = []; if (null != $params && is_array($params)) { foreach ($params as $key => $value) { if (is_array($value)) { @@ -292,7 +292,7 @@ abstract class EdsApi_REST_Base * @throws \EbscoEdsApiException * @return object EDS API response (or an Error object). */ - protected function call($baseUrl, $headerParams, $params = array(), + protected function call($baseUrl, $headerParams, $params = [], $method = 'GET', $message = null, $messageFormat = "" ) { // Build Query String Parameters @@ -303,10 +303,10 @@ abstract class EdsApi_REST_Base } $this->debugPrint("Querystring to use: $queryString "); // Build headers - $headers = array( + $headers = [ 'Accept' => $this->accept, 'Content-Type' => $this->contentType - ); + ]; if (null != $headerParams && !empty($headerParams)) { foreach ($headerParams as $key => $value) { $headers[$key] = $value; @@ -354,7 +354,7 @@ abstract class EdsApi_REST_Base */ protected function setTokens($authenticationToken = null, $sessionToken = null) { - $headers = array(); + $headers = []; if (!empty($authenticationToken)) { $headers['x-authenticationToken'] = $authenticationToken; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Exception.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Exception.php index 529bbcd824f..8527958bc8e 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Exception.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Exception.php @@ -42,7 +42,7 @@ class EbscoEdsApiException extends Exception * * @var array */ - protected $apiErrorDetails = array(); + protected $apiErrorDetails = []; /** * Constructor diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/QueryBuilder.php index b24570f400b..02e79cf0dae 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/QueryBuilder.php @@ -64,7 +64,7 @@ class QueryBuilder $queries = $this->abstractQueryToArray($query); // Send back results - $params = new ParamBag(array('query' => $queries)); + $params = new ParamBag(['query' => $queries]); return $params; } @@ -103,7 +103,7 @@ class QueryBuilder protected function abstractQueryToArray(AbstractQuery $query) { if ($query instanceof Query) { - return array('1' => $this->queryToEdsQuery($query)); + return ['1' => $this->queryToEdsQuery($query)]; } else { return $this->queryGroupToArray($query); } @@ -118,7 +118,7 @@ class QueryBuilder */ protected function queryGroupToArray(QueryGroup $query) { - $groups = array(); + $groups = []; foreach ($query->getQueries() as $params) { // Advanced Search if ($params instanceof QueryGroup) { diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php index 3eec49cef95..8fd7076ad03 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php @@ -86,7 +86,7 @@ class RecordCollection extends AbstractRecordCollection { return isset($this->response['SearchResult']) && isset($this->response['SearchResult']['AvailableFacets']) - ? $this->response['SearchResult']['AvailableFacets'] : array(); + ? $this->response['SearchResult']['AvailableFacets'] : []; } /** @@ -96,21 +96,21 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - $vufindFacetList = array(); + $vufindFacetList = []; $facets = isset($this->response['SearchResult']) && isset($this->response['SearchResult']['AvailableFacets']) - ? $this->response['SearchResult']['AvailableFacets'] : array(); + ? $this->response['SearchResult']['AvailableFacets'] : []; foreach ($facets as $facet) { $vufindFacet['displayName'] = $facet['Id']; $vufindFacet['displayText'] = $facet['Label']; $vufindFacet['fieldName'] = $facet['Id']; - $values = array(); + $values = []; foreach ($facet['AvailableFacetValues'] as $availableFacetValue) { - $values[] = array( + $values[] = [ 'value' => $availableFacetValue['Value'], 'count' => $availableFacetValue['Count'], 'displayText' => $availableFacetValue['Value'] - ); + ]; } $vufindFacet['counts'] = $values; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php index 3dc58315aa1..be954c42ed7 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php @@ -93,7 +93,7 @@ class RecordCollectionFactory implements RecordCollectionFactoryInterface } $collection = new $this->collectionClass($response); //obtain path to records - $records = array(); + $records = []; if (isset($response['SearchResult']) && isset($response['SearchResult']['Data']) && isset($response['SearchResult']['Data']['Records']) diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/SearchRequestModel.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/SearchRequestModel.php index 3ef2d1d1106..c0b927247a3 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/SearchRequestModel.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/SearchRequestModel.php @@ -42,7 +42,7 @@ class SearchRequestModel * * @var array */ - protected $query = array(); + protected $query = []; /** * Whether or not to return facets with the search results. valid values are @@ -57,7 +57,7 @@ class SearchRequestModel * * @var array */ - protected $facetFilters = array(); + protected $facetFilters = []; /** * Sort option to apply @@ -71,7 +71,7 @@ class SearchRequestModel * * @var array */ - protected $limiters = array(); + protected $limiters = []; /** * Mode to be effective in the search @@ -85,7 +85,7 @@ class SearchRequestModel * * @var string */ - protected $expanders = array(); + protected $expanders = []; /** * Requested level of detail to return the results with @@ -121,7 +121,7 @@ class SearchRequestModel * * @var array */ - protected $actions = array(); + protected $actions = []; /** * Constructor @@ -130,7 +130,7 @@ class SearchRequestModel * * @param array $parameters parameters to populate request */ - public function __construct($parameters = array()) + public function __construct($parameters = []) { $this->setParameters($parameters); } @@ -168,7 +168,7 @@ class SearchRequestModel * * @return void */ - public function setParameters($parameters = array()) + public function setParameters($parameters = []) { foreach ($parameters as $key => $values) { switch($key) { @@ -214,7 +214,7 @@ class SearchRequestModel */ public function convertToQueryStringParameterArray() { - $qs = array(); + $qs = []; if (isset($this->query) && 0 < sizeof($this->query)) { $qs['query-x'] = $this->query; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Zend2.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Zend2.php index b0a34530d77..783c4ec6113 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Zend2.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Zend2.php @@ -91,19 +91,19 @@ class Zend2 extends EdsApi_REST_Base implements LoggerAwareInterface * </ul> * @param Zend2HttpClient $client Zend2 HTTP client object (optional) */ - public function __construct($settings = array(), $client = null) + public function __construct($settings = [], $client = null) { parent::__construct($settings); $this->client = is_object($client) ? $client : new Zend2HttpClient(); - $this->client->setOptions(array('timeout' => 120)); + $this->client->setOptions(['timeout' => 120]); $adapter = new CurlAdapter(); $adapter->setOptions( - array( - 'curloptions' => array( + [ + 'curloptions' => [ CURLOPT_SSL_VERIFYPEER => false, CURLOPT_FOLLOWLOCATION => true, - ) - ) + ] + ] ); $this->client->setAdapter($adapter); } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Connector.php index 9fa9a6baf93..dce867757ad 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Connector.php @@ -79,7 +79,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface * * @var array */ - protected $dbs = array(); + protected $dbs = []; /** * Constructor @@ -117,15 +117,15 @@ class Connector implements \Zend\Log\LoggerAwareInterface $params->set('pwd', $this->pwd); $response = $this->call('GET', $params->getArrayCopy(), false); $xml = simplexml_load_string($response); - $finalDocs = array(); + $finalDocs = []; foreach ($xml->SearchResults->records->rec as $doc) { $finalDocs[] = simplexml_load_string($doc->asXML()); } - return array( + return [ 'docs' => $finalDocs, 'offset' => $offset, 'total' => (integer)$xml->Hits - ); + ]; } /** @@ -154,7 +154,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface protected function call($method = 'GET', $params = null) { if ($params) { - $query = array(); + $query = []; foreach ($params as $function => $value) { if (is_array($value)) { foreach ($value as $additional) { @@ -208,14 +208,14 @@ class Connector implements \Zend\Log\LoggerAwareInterface $this->client->resetParameters(); $response = $this->call('GET', $params->getArrayCopy(), false); $xml = simplexml_load_string($response); - $finalDocs = array(); + $finalDocs = []; foreach ($xml->SearchResults->records->rec as $doc) { $finalDocs[] = simplexml_load_string($doc->asXML()); } - return array( + return [ 'docs' => $finalDocs, 'offset' => 0, 'total' => (integer)$xml->Hits - ); + ]; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/QueryBuilder.php index 61d4aedd082..b042d440c10 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/QueryBuilder.php @@ -104,12 +104,12 @@ class QueryBuilder */ protected function queryGroupToString(QueryGroup $query) { - $groups = $excludes = array(); + $groups = $excludes = []; foreach ($query->getQueries() as $params) { // Advanced Search if ($params instanceof QueryGroup) { - $thisGroup = array(); + $thisGroup = []; // Process each search group foreach ($params->getQueries() as $group) { // Build this group individually as a basic search @@ -162,7 +162,7 @@ class QueryBuilder // The index may contain multiple parts -- we want to search all listed index // fields: $index = explode(':', $index); - $clauses = array(); + $clauses = []; foreach ($index as $currentIndex) { $clauses[] = "{$currentIndex} {$lookfor}"; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php index 38f2657d4fc..a652a6cb712 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php @@ -80,7 +80,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - return array(); // not supported by EIT + return []; // not supported by EIT } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Exception/BackendException.php b/module/VuFindSearch/src/VuFindSearch/Backend/Exception/BackendException.php index e3499864369..9de0750b26e 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Exception/BackendException.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Exception/BackendException.php @@ -46,7 +46,7 @@ class BackendException extends RuntimeException * * @var array */ - protected $tags = array(); + protected $tags = []; /** * Add a tag. diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Backend.php index 299c60b9f92..1b01460a704 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Backend.php @@ -221,11 +221,11 @@ class Backend extends AbstractBackend $params = $params->getArrayCopy(); // Convert the options: - $options = array(); + $options = []; // Most parameters need to be flattened from array format, but a few // should remain as arrays: - $arraySettings = array(/* TODO: determine if values are needed here. */); + $arraySettings = [/* TODO: determine if values are needed here. */]; foreach ($params as $key => $param) { $options[$key] = in_array($key, $arraySettings) ? $param : $param[0]; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Connector.php index e96c9b223c4..0bd5c982d5b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Connector.php @@ -118,11 +118,11 @@ class Connector implements \Zend\Log\LoggerAwareInterface } catch (\Exception $e) { if ($returnErr) { $this->debug($e->getMessage()); - $result = array( + $result = [ 'recordCount' => 0, - 'documents' => array(), + 'documents' => [], 'error' => $e->getMessage() - ); + ]; } else { throw $e; } @@ -174,23 +174,23 @@ class Connector implements \Zend\Log\LoggerAwareInterface throw new \Exception('LibGuides did not return any data'); } - $items = array(); + $items = []; // Extract titles and URLs from response: $regex = '/<a href="([^"]*)"[^>]*>([^<]*)</'; $count = preg_match_all($regex, $data, $matches); for ($i = 0; $i < $count; $i++) { - $items[] = array( + $items[] = [ 'id' => $matches[1][$i], // ID = URL 'title' => $matches[2][$i], - ); + ]; } - $results = array( + $results = [ 'recordCount' => count($items), 'documents' => $items - ); + ]; return $results; } @@ -206,14 +206,14 @@ class Connector implements \Zend\Log\LoggerAwareInterface { // defaults for params (vary by version) if ($this->apiVersion < 2) { - $args = array( + $args = [ 'iid' => $this->iid, 'type' => 'guides', 'more' => 'false', 'sortby' => 'relevance', - ); + ]; } else { - $args = array( + $args = [ 'site_id' => $this->iid, 'sort_by' => 'relevance', 'widget_type' => 1, @@ -227,7 +227,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface 'enable_group_search_limit' => 0, 'enable_subject_search_limit' => 0, 'widget_embed_type' => 2, - ); + ]; // remap v1 --> v2 params: if (isset($params['search'])) { $params['search_terms'] = $params['search']; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/QueryBuilder.php index cbddd890636..e222dced52e 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/QueryBuilder.php @@ -116,6 +116,6 @@ class QueryBuilder // Clean and validate input: $index = $query->getHandler(); $lookfor = $query->getString(); - return array(compact('index', 'lookfor')); + return [compact('index', 'lookfor')]; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php index 4044f4063d0..3ec8c76e06b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php @@ -80,7 +80,7 @@ class RecordCollection extends AbstractRecordCollection public function getFacets() { // Not supported: - return array(); + return []; } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php index 3ec251ad187..b23380f25fb 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php @@ -156,11 +156,11 @@ class Backend extends AbstractBackend } $showParams = new ParamBag( - array('block' => 1, 'num' => $limit, 'start' => $offset) + ['block' => 1, 'num' => $limit, 'start' => $offset] ); $response = $this->connector->show($showParams); - $hits = isset($response->hit) ? $response->hit : array(); + $hits = isset($response->hit) ? $response->hit : []; $collection = $this->createRecordCollection( $hits, intval($response->merged), $offset ); @@ -179,7 +179,7 @@ class Backend extends AbstractBackend public function retrieve($id, ParamBag $params = null) { $response = $this->connector->record($id); - $collection = $this->createRecordCollection(array($response), 1); + $collection = $this->createRecordCollection([$response], 1); $this->injectSourceIdentifier($collection); return $collection; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Connector.php index f5f4344654d..4c490c982ae 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Connector.php @@ -168,7 +168,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface sprintf( '<= %s %s', $response->getStatusCode(), $response->getReasonPhrase() - ), array('time' => $time) + ), ['time' => $time] ); if (!$response->isSuccess()) { @@ -201,7 +201,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface */ public function record($id) { - return $this->query('record', new ParamBag(array('id' => $id))); + return $this->query('record', new ParamBag(['id' => $id])); } /** @@ -308,6 +308,6 @@ class Connector implements \Zend\Log\LoggerAwareInterface */ public function bytarget($id) { - return $this->query('bytarget', new ParamBag(array('id' => $id))); + return $this->query('bytarget', new ParamBag(['id' => $id])); } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Response/RecordCollection.php index 1b8be80ff61..0a1219c125b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Response/RecordCollection.php @@ -80,6 +80,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - return array(); + return []; } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php index cb1ed3cd270..dbaef82b146 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Backend.php @@ -224,12 +224,12 @@ class Backend extends AbstractBackend $params = $params->getArrayCopy(); // Convert the options: - $options = array(); + $options = []; // Most parameters need to be flattened from array format, but a few // should remain as arrays: - $arraySettings = array( + $arraySettings = [ 'query', 'facets', 'filterList', 'groupFilters', 'rangeFilters' - ); + ]; foreach ($params as $key => $param) { $options[$key] = in_array($key, $arraySettings) ? $param : $param[0]; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php index 0461f16e6e7..66f4d808167 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Connector.php @@ -129,7 +129,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface public function query($institution, $terms, $params = null) { // defaults for params - $args = array( + $args = [ "phrase" => false, "onCampus" => true, "didYouMean" => false, @@ -138,7 +138,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface "limit" => 20, "sort" => null, "returnErr" => true, - ); + ]; if (isset($params)) { $args = array_merge($args, $params); } @@ -149,12 +149,12 @@ class Connector implements \Zend\Log\LoggerAwareInterface } catch (\Exception $e) { if ($args["returnErr"]) { $this->debug($e->getMessage()); - return array( + return [ 'recordCount' => 0, - 'documents' => array(), - 'facets' => array(), + 'documents' => [], + 'facets' => [], 'error' => $e->getMessage() - ); + ]; } else { throw $e; } @@ -196,7 +196,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface // we have to build a querystring because I think adding them // incrementally is implemented as a dictionary, but we are allowed // multiple querystring parameters with the same key. - $qs = array(); + $qs = []; // QUERYSTRING: query (search terms) // re: phrase searches, turns out we can just pass whatever we got @@ -401,7 +401,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface // Get results set data and add to $items array // This foreach grabs all the child elements of sear:DOC, // except those with namespaces - $items = array(); + $items = []; $docset = $sxe->xpath('//sear:DOC'); if (empty($docset) && isset($sxe->JAGROOT->RESULT->DOCSET->DOC)) { @@ -409,7 +409,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface } foreach ($docset as $doc) { - $item = array(); + $item = []; // Due to a bug in the primo API, the first result has // a namespace (prim:) while the rest of the results do not. // Those child elements do not get added to $doc. @@ -508,7 +508,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface // which has the name of the facet as an attribute. // We only get the first level of elements // because child elements have a namespace prefix - $facets = array(); + $facets = []; $facetSet = $sxe->xpath('//sear:FACET'); if (empty($facetSet)) { @@ -533,18 +533,18 @@ class Connector implements \Zend\Log\LoggerAwareInterface } } - $didYouMean = array(); + $didYouMean = []; $suggestions = $sxe->xpath('//sear:QUERYTRANSFORMS'); foreach ($suggestions as $suggestion) { $didYouMean[] = (string)$suggestion->attributes()->QUERY; } - return array( + return [ 'recordCount' => $totalhits, 'documents' => $items, 'facets' => $facets, 'didYouMean' => $didYouMean - ); + ]; } /** @@ -560,7 +560,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface { // Query String Parameters if (isset($recordId)) { - $qs = array(); + $qs = []; $qs[] = "query=any,contains,\"$recordId\""; $qs[] = "institution=$inst_code"; $qs[] = "onCampus=true"; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/QueryBuilder.php index dda3b70893b..3aa6e5e5ff5 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/QueryBuilder.php @@ -94,7 +94,7 @@ class QueryBuilder protected function queryGroupToArray(QueryGroup $query) { $nextLevel = $query->getQueries(); - $parts = array(); + $parts = []; foreach ($nextLevel[0]->getQueries() as $q) { $index = $q->getHandler(); $op = $q->getOperator(); @@ -116,6 +116,6 @@ class QueryBuilder // Clean and validate input: $index = $query->getHandler(); $lookfor = $query->getString(); - return array(compact('index', 'lookfor')); + return [compact('index', 'lookfor')]; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php index 8b2a5dec268..354290119ac 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php @@ -80,7 +80,7 @@ class RecordCollection extends AbstractRecordCollection public function getFacets() { return isset($this->response['facets']) - ? $this->response['facets'] : array(); + ? $this->response['facets'] : []; } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php index d2e5e62c9bf..a3e2cbf5594 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/SRU/Connector.php @@ -104,11 +104,11 @@ class Connector implements \Zend\Log\LoggerAwareInterface "NOT rec.id=$id"; // Query String Parameters - $options = array('operation' => 'searchRetrieve', + $options = ['operation' => 'searchRetrieve', 'query' => $query, 'maximumRecords' => $max, 'startRecord' => 1, - 'recordSchema' => 'marcxml'); + 'recordSchema' => 'marcxml']; $this->debug('More Like This Query: ' . print_r($query, true)); @@ -126,8 +126,8 @@ class Connector implements \Zend\Log\LoggerAwareInterface */ public function scan($clause, $pos = null, $maxTerms = null) { - $options = array('operation' => 'scan', - 'scanClause' => $clause); + $options = ['operation' => 'scan', + 'scanClause' => $clause]; if (!is_null($pos)) { $options['responsePosition'] = $pos; } @@ -156,10 +156,10 @@ class Connector implements \Zend\Log\LoggerAwareInterface $this->debug('Query: ' . print_r($query, true)); // Query String Parameters - $options = array('operation' => 'searchRetrieve', + $options = ['operation' => 'searchRetrieve', 'query' => $query, 'startRecord' => ($start) ? $start : 1, - 'recordSchema' => $schema); + 'recordSchema' => $schema]; if (!is_null($limit)) { $options['maximumRecords'] = $limit; } @@ -197,7 +197,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface protected function call($method = 'GET', $params = null, $process = true) { if ($params) { - $query = array('version=' . $this->sruVersion); + $query = ['version=' . $this->sruVersion]; foreach ($params as $function => $value) { if (is_array($value)) { foreach ($value as $additional) { diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php index 5eb830e8371..33025bc09cc 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php @@ -175,14 +175,14 @@ class Backend extends AbstractBackend // Retrieve records a page at a time: $results = false; while (count($ids) > 0) { - $currentPage = array_splice($ids, 0, $pageSize, array()); + $currentPage = array_splice($ids, 0, $pageSize, []); $currentPage = array_map($formatIds, $currentPage); $params = new ParamBag( - array( + [ 'q' => 'id:(' . implode(' OR ', $currentPage) . ')', 'start' => 0, 'rows' => $pageSize - ) + ] ); $this->injectResponseWriter($params); $next = $this->createRecordCollection( @@ -366,7 +366,7 @@ class Backend extends AbstractBackend } $qtime = isset($response['responseHeader']['QTime']) ? $response['responseHeader']['QTime'] : 'n/a'; - $this->log('debug', 'Deserialized SOLR response', array('qtime' => $qtime)); + $this->log('debug', 'Deserialized SOLR response', ['qtime' => $qtime]); return $response; } @@ -406,7 +406,7 @@ class Backend extends AbstractBackend */ protected function injectResponseWriter(ParamBag $params) { - if (array_diff($params->get('wt') ?: array(), array('json'))) { + if (array_diff($params->get('wt') ?: [], ['json'])) { throw new InvalidArgumentException( sprintf( 'Invalid response writer type: %s', @@ -414,7 +414,7 @@ class Backend extends AbstractBackend ) ); } - if (array_diff($params->get('json.nl') ?: array(), array('arrarr'))) { + if (array_diff($params->get('json.nl') ?: [], ['arrarr'])) { throw new InvalidArgumentException( sprintf( 'Invalid named list implementation type: %s', @@ -422,7 +422,7 @@ class Backend extends AbstractBackend ) ); } - $params->set('wt', array('json')); - $params->set('json.nl', array('arrarr')); + $params->set('wt', ['json']); + $params->set('json.nl', ['arrarr']); } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php index 8ee6bf538c8..ac21588a481 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Connector.php @@ -357,7 +357,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface $client = $this->createClient($url, $method); $client->setRawBody($paramString); $client->setEncType(HttpClient::ENC_URLENCODED); - $client->setHeaders(array('Content-Length' => strlen($paramString))); + $client->setHeaders(['Content-Length' => strlen($paramString)]); } else { $url = $url . '?' . $paramString; $client = $this->createClient($url, $method); @@ -391,7 +391,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface sprintf( '<= %s %s', $response->getStatusCode(), $response->getReasonPhrase() - ), array('time' => $time) + ), ['time' => $time] ); if (!$response->isSuccess()) { @@ -412,7 +412,7 @@ class Connector implements \Zend\Log\LoggerAwareInterface { $client = new HttpClient(); $client->setAdapter($this->adapter); - $client->setOptions(array('timeout' => $this->timeout)); + $client->setOptions(['timeout' => $this->timeout]); $client->setUri($url); $client->setMethod($method); if ($this->proxy) { diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/DeleteDocument.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/DeleteDocument.php index fa931084a27..b4ef43414f0 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/DeleteDocument.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/DeleteDocument.php @@ -62,8 +62,8 @@ class DeleteDocument extends AbstractDocument */ public function __construct() { - $this->keys = array(); - $this->queries = array(); + $this->keys = []; + $this->queries = []; } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/UpdateDocument.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/UpdateDocument.php index 5375ef7f818..aaec97e53ab 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/UpdateDocument.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Document/UpdateDocument.php @@ -89,7 +89,7 @@ class UpdateDocument extends AbstractDocument $writer->writeAttribute($name, $value); } foreach ($record->getFields() as $name => $values) { - $values = is_array($values) ? $values : array($values); + $values = is_array($values) ? $values : [$values]; foreach ($values as $value) { $writer->startElement('field'); $writer->writeAttribute('name', $name); @@ -113,7 +113,7 @@ class UpdateDocument extends AbstractDocument * @return void */ public function addRecord(SerializableRecordInterface $record, - array $indexAttr = array() + array $indexAttr = [] ) { $this->records->attach($record, $indexAttr); } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/HandlerMap.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/HandlerMap.php index a97c7da0851..9715a2aa8a5 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/HandlerMap.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/HandlerMap.php @@ -73,10 +73,10 @@ class HandlerMap extends AbstractHandlerMap * * @return void */ - public function __construct(array $map = array()) + public function __construct(array $map = []) { - $this->handlers = array(); - $this->parameters = array(); + $this->handlers = []; + $this->parameters = []; $this->setHandlerMap($map); } @@ -250,7 +250,7 @@ class HandlerMap extends AbstractHandlerMap // Create ParamBag if not already present; this also handles validation // of the $type parameter. if (!isset($this->parameters[$handler][$type])) { - $this->setParameters($handler, $type, array()); + $this->setParameters($handler, $type, []); } return $this->parameters[$handler][$type]; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php index dc16a17a548..d43cc312ac5 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/LuceneSyntaxHelper.php @@ -78,7 +78,7 @@ class LuceneSyntaxHelper * * @var array */ - protected $allBools = array('AND', 'OR', 'NOT'); + protected $allBools = ['AND', 'OR', 'NOT']; /** * Constructor. @@ -153,7 +153,7 @@ class LuceneSyntaxHelper } // Check for unescaped parentheses: - $stripped = str_replace(array('\(', '\)'), '', $searchString); + $stripped = str_replace(['\(', '\)'], '', $searchString); if (strstr($stripped, '(') && strstr($stripped, ')')) { return true; } @@ -218,7 +218,7 @@ class LuceneSyntaxHelper * * @return string */ - public function capitalizeBooleans($string, $bools = array('AND', 'OR', 'NOT')) + public function capitalizeBooleans($string, $bools = ['AND', 'OR', 'NOT']) { // Short-circuit if no Booleans were selected: if (empty($bools)) { @@ -232,7 +232,7 @@ class LuceneSyntaxHelper $lookahead = self::$insideQuotes; // Create standard conversions: - $regs = $replace = array(); + $regs = $replace = []; foreach ($bools as $bool) { $regs[] = "/\s+{$bool}\s+{$lookahead}/i"; $replace[] = ' ' . $bool . ' '; @@ -261,9 +261,9 @@ class LuceneSyntaxHelper // problems in case-sensitive fields when the reserved words are // actually used as search terms. $lookahead = self::$insideQuotes; - $regs = array("/(\[)([^\]]+)\s+TO\s+([^\]]+)(\]){$lookahead}/i", - "/(\{)([^}]+)\s+TO\s+([^}]+)(\}){$lookahead}/i"); - $callback = array($this, 'capitalizeRangesCallback'); + $regs = ["/(\[)([^\]]+)\s+TO\s+([^\]]+)(\]){$lookahead}/i", + "/(\{)([^}]+)\s+TO\s+([^}]+)(\}){$lookahead}/i"]; + $callback = [$this, 'capitalizeRangesCallback']; return trim(preg_replace_callback($regs, $callback, $string)); } @@ -302,7 +302,7 @@ class LuceneSyntaxHelper protected function normalizeFancyQuotes($input) { // Normalize fancy quotes: - $quotes = array( + $quotes = [ "\xC2\xAB" => '"', // « (U+00AB) in UTF-8 "\xC2\xBB" => '"', // » (U+00BB) in UTF-8 "\xE2\x80\x98" => "'", // ‘ (U+2018) in UTF-8 @@ -315,7 +315,7 @@ class LuceneSyntaxHelper "\xE2\x80\x9F" => '"', // ? (U+201F) in UTF-8 "\xE2\x80\xB9" => "'", // ‹ (U+2039) in UTF-8 "\xE2\x80\xBA" => "'", // › (U+203A) in UTF-8 - ); + ]; return strtr($input, $quotes); } @@ -347,7 +347,7 @@ class LuceneSyntaxHelper // -- dmaus, 2012-11-11 $start = preg_match_all('/\(/', $input, $tmp); $end = preg_match_all('/\)/', $input, $tmp); - return ($start != $end) ? str_replace(array('(', ')'), '', $input) : $input; + return ($start != $end) ? str_replace(['(', ')'], '', $input) : $input; } /** @@ -387,7 +387,7 @@ class LuceneSyntaxHelper // invalid brackets/braces, and transform our tokens back into valid ones. // Obviously, the order of the patterns/merges array is critically // important to get this right!! - $patterns = array( + $patterns = [ // STEP 1 -- escape valid brackets/braces '/\[([^\[\]\s]+\s+TO\s+[^\[\]\s]+)\]/' . ($this->caseSensitiveRanges ? '' : 'i'), @@ -397,14 +397,14 @@ class LuceneSyntaxHelper '/[\[\]\{\}]/', // STEP 3 -- unescape valid brackets/braces '/\^\^lbrack\^\^/', '/\^\^rbrack\^\^/', - '/\^\^lbrace\^\^/', '/\^\^rbrace\^\^/'); - $matches = array( + '/\^\^lbrace\^\^/', '/\^\^rbrace\^\^/']; + $matches = [ // STEP 1 -- escape valid brackets/braces '^^lbrack^^$1^^rbrack^^', '^^lbrace^^$1^^rbrace^^', // STEP 2 -- destroy remaining brackets/braces '', // STEP 3 -- unescape valid brackets/braces - '[', ']', '{', '}'); + '[', ']', '{', '}']; return preg_replace($patterns, $matches, $input); } @@ -480,7 +480,7 @@ class LuceneSyntaxHelper // If the string consists only of control characters and/or BOOLEANs with no // other input, wipe it out entirely to prevent weird errors: - $operators = array('AND', 'OR', 'NOT', '+', '-', '"', '&', '|'); + $operators = ['AND', 'OR', 'NOT', '+', '-', '"', '&', '|']; if (trim(str_replace($operators, '', $input)) == '') { return ''; } @@ -522,7 +522,7 @@ class LuceneSyntaxHelper || $this->caseSensitiveBooleans === 1 || $this->caseSensitiveBooleans === "1" ) { - return array(); + return []; } // Callback function to clean up configuration settings: diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php index 91ad49e8855..88149a56939 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php @@ -61,14 +61,14 @@ class QueryBuilder implements QueryBuilderInterface * * @var array */ - protected $specs = array(); + protected $specs = []; /** * Search specs for exact searches. * * @var array */ - protected $exactSpecs = array(); + protected $exactSpecs = []; /** * Should we create the hl.q parameter when appropriate? @@ -100,7 +100,7 @@ class QueryBuilder implements QueryBuilderInterface * * @return void */ - public function __construct(array $specs = array(), + public function __construct(array $specs = [], $defaultDismaxHandler = 'dismax' ) { $this->defaultDismaxHandler = $defaultDismaxHandler; @@ -306,7 +306,7 @@ class QueryBuilder implements QueryBuilderInterface { if ($component instanceof QueryGroup) { $reduced = array_map( - array($this, 'reduceQueryGroupComponents'), $component->getQueries() + [$this, 'reduceQueryGroupComponents'], $component->getQueries() ); $searchString = $component->isNegated() ? 'NOT ' : ''; $searchString .= sprintf( diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/NamedList.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/NamedList.php index 5abb2801544..4b7b966a8b7 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/NamedList.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/NamedList.php @@ -78,7 +78,7 @@ class NamedList implements Countable, Iterator */ public function toArray() { - $arr = array(); + $arr = []; foreach ($this as $k => $v) { $arr[$k] = $v; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php index 7f9961914c5..a4b838c9ee6 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php @@ -48,12 +48,12 @@ class RecordCollection extends AbstractRecordCollection * * @var array */ - protected static $template = array( - 'responseHeader' => array(), - 'response' => array('numFound' => 0, 'start' => 0), - 'spellcheck' => array('suggestions' => array()), - 'facet_counts' => array(), - ); + protected static $template = [ + 'responseHeader' => [], + 'response' => ['numFound' => 0, 'start' => 0], + 'spellcheck' => ['suggestions' => []], + 'facet_counts' => [], + ]; /** * Deserialized SOLR response. @@ -136,7 +136,7 @@ class RecordCollection extends AbstractRecordCollection public function getGroups() { return isset($this->response['grouped']) - ? $this->response['grouped'] : array(); + ? $this->response['grouped'] : []; } /** @@ -147,7 +147,7 @@ class RecordCollection extends AbstractRecordCollection public function getHighlighting() { return isset($this->response['highlighting']) - ? $this->response['highlighting'] : array(); + ? $this->response['highlighting'] : []; } /** @@ -158,7 +158,7 @@ class RecordCollection extends AbstractRecordCollection protected function getSolrParameters() { return isset($this->response['responseHeader']['params']) - ? $this->response['responseHeader']['params'] : array(); + ? $this->response['responseHeader']['params'] : []; } /** @@ -182,6 +182,6 @@ class RecordCollection extends AbstractRecordCollection protected function getRawSpellcheckSuggestions() { return isset($this->response['spellcheck']['suggestions']) - ? $this->response['spellcheck']['suggestions'] : array(); + ? $this->response['spellcheck']['suggestions'] : []; } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Spellcheck.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Spellcheck.php index 1659bf87b31..c53d69bfbeb 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Spellcheck.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Spellcheck.php @@ -114,7 +114,7 @@ class Spellcheck implements IteratorAggregate, Countable public function mergeWith(Spellcheck $spellcheck) { // Merge primary suggestions: - $this->terms->uksort(array($this, 'compareTermLength')); + $this->terms->uksort([$this, 'compareTermLength']); foreach ($spellcheck as $term => $info) { if (!$this->contains($term)) { $this->terms->offsetSet($term, $info); diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Terms.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Terms.php index 533d7fa6b33..61c1440b536 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Terms.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Terms.php @@ -59,7 +59,7 @@ class Terms implements IteratorAggregate public function __construct(array $terms) { $terms = array_replace( - array('responseHeader' => array(), 'terms' => array()), $terms + ['responseHeader' => [], 'terms' => []], $terms ); $this->terms = new ArrayObject(); foreach ($terms['terms'] as $field => $info) { diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php index 28f42a7e0a5..26b59d4ec73 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/SearchHandler.php @@ -51,17 +51,17 @@ class SearchHandler * * @var array */ - protected static $configKeys = array( + protected static $configKeys = [ 'CustomMunge', 'DismaxFields', 'DismaxHandler', 'QueryFields', 'DismaxParams', 'FilterQuery' - ); + ]; /** * Known boolean operators. * * @var array */ - protected static $booleanOperators = array('AND', 'OR', 'NOT'); + protected static $booleanOperators = ['AND', 'OR', 'NOT']; /** * Search handler specification. @@ -82,7 +82,7 @@ class SearchHandler public function __construct(array $spec, $defaultDismaxHandler = 'dismax') { foreach (self::$configKeys as $key) { - $this->specs[$key] = isset($spec[$key]) ? $spec[$key] : array(); + $this->specs[$key] = isset($spec[$key]) ? $spec[$key] : []; } // Set dismax handler to default if not specified: if (empty($this->specs['DismaxHandler'])) { @@ -132,7 +132,7 @@ class SearchHandler */ public function createBoostQueryString($search) { - $boostQuery = array(); + $boostQuery = []; if ($this->hasDismax()) { foreach ($this->getDismaxParams() as $param) { list($name, $value) = $param; @@ -257,7 +257,7 @@ class SearchHandler */ protected function dismaxSubquery($search) { - $dismaxParams = array(); + $dismaxParams = []; foreach ($this->specs['DismaxParams'] as $param) { $dismaxParams[] = sprintf( "%s='%s'", $param[0], addcslashes($param[1], "'") @@ -287,19 +287,19 @@ class SearchHandler { if ($tokenize) { $tokens = $this->tokenize($search); - $mungeValues = array( + $mungeValues = [ 'onephrase' => sprintf( '"%s"', str_replace('"', '', implode(' ', $tokens)) ), 'and' => implode(' AND ', $tokens), 'or' => implode(' OR ', $tokens), 'identity' => $search, - ); + ]; } else { - $mungeValues = array( + $mungeValues = [ 'and' => $search, 'or' => $search, - ); + ]; // If we're skipping tokenization, we just want to pass $lookfor through // unmodified (it's probably an advanced search that won't benefit from // tokenization). We'll just set all possible values to the same thing, @@ -404,7 +404,7 @@ class SearchHandler */ protected function munge(array $mungeRules, array $mungeValues, $joiner = 'OR') { - $clauses = array(); + $clauses = []; foreach ($mungeRules as $field => $clausearray) { if (is_numeric($field)) { // shift off the join string and weight @@ -453,12 +453,12 @@ class SearchHandler protected function tokenize($string) { // Tokenize on spaces and quotes - $phrases = array(); + $phrases = []; preg_match_all('/"[^"]*"[~[0-9]+]*|"[^"]*"|[^ ]+/', $string, $phrases); $phrases = $phrases[0]; - $tokens = array(); - $token = array(); + $tokens = []; + $token = []; reset($phrases); while (current($phrases) !== false) { @@ -471,7 +471,7 @@ class SearchHandler } } else { $tokens[] = implode(' ', $token); - $token = array(); + $token = []; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Backend.php index 3a10fd8e7b2..0ccbd5626af 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Backend.php @@ -164,14 +164,14 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface // Retrieve records a page at a time: $results = false; while (count($ids) > 0) { - $currentPage = array_splice($ids, 0, $pageSize, array()); + $currentPage = array_splice($ids, 0, $pageSize, []); $query = new SummonQuery( null, - array( + [ 'idsToFetch' => $currentPage, 'pageNumber' => 1, 'pageSize' => $pageSize - ) + ] ); $next = $this->createRecordCollection( $this->connector->query($query) @@ -270,10 +270,10 @@ class Backend extends AbstractBackend implements RetrieveBatchInterface unset($params['query']); // Convert the options: - $options = array(); + $options = []; // Most parameters need to be flattened from array format, but a few // should remain as arrays: - $arraySettings = array('facets', 'filters', 'groupFilters', 'rangeFilters'); + $arraySettings = ['facets', 'filters', 'groupFilters', 'rangeFilters']; foreach ($params as $key => $param) { $options[$key] = in_array($key, $arraySettings) ? $param : $param[0]; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/QueryBuilder.php index a6dae4ec11b..72b8b028144 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/QueryBuilder.php @@ -105,12 +105,12 @@ class QueryBuilder */ protected function queryGroupToString(QueryGroup $query) { - $groups = $excludes = array(); + $groups = $excludes = []; foreach ($query->getQueries() as $params) { // Advanced Search if ($params instanceof QueryGroup) { - $thisGroup = array(); + $thisGroup = []; // Process each search group foreach ($params->getQueries() as $group) { // Build this group individually as a basic search diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php index cb7e5e42966..c235298a9b1 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php @@ -88,7 +88,7 @@ class RecordCollection extends AbstractRecordCollection public function getFacets() { return isset($this->response['facetFields']) - ? $this->response['facetFields'] : array(); + ? $this->response['facetFields'] : []; } /** @@ -103,7 +103,7 @@ class RecordCollection extends AbstractRecordCollection ) { return $this->response['didYouMeanSuggestions']; } - return array(); + return []; } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php index e9e595fbfd7..538d282568b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php @@ -110,11 +110,11 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector $xml = simplexml_load_string($body); $error = isset($xml->diagnostic); - return array( - 'docs' => $error ? array() : array($body), + return [ + 'docs' => $error ? [] : [$body], 'offset' => 0, 'total' => $error ? 0 : 1 - ); + ]; } /** @@ -136,16 +136,16 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector $response = $this->call('POST', $params->getArrayCopy(), false); $xml = simplexml_load_string($response); - $docs = isset($xml->records->record) ? $xml->records->record : array(); - $finalDocs = array(); + $docs = isset($xml->records->record) ? $xml->records->record : []; + $finalDocs = []; foreach ($docs as $doc) { $finalDocs[] = $doc->recordData->asXML(); } - return array( + return [ 'docs' => $finalDocs, 'offset' => $offset, 'total' => isset($xml->numberOfRecords) ? (int)$xml->numberOfRecords : 0 - ); + ]; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/QueryBuilder.php index 2e3d60ccfac..f0389e0975b 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/QueryBuilder.php @@ -118,12 +118,12 @@ class QueryBuilder */ protected function queryGroupToString(QueryGroup $query) { - $groups = $excludes = array(); + $groups = $excludes = []; foreach ($query->getQueries() as $params) { // Advanced Search if ($params instanceof QueryGroup) { - $thisGroup = array(); + $thisGroup = []; // Process each search group foreach ($params->getQueries() as $group) { // Build this group individually as a basic search @@ -176,7 +176,7 @@ class QueryBuilder // The index may contain multiple parts -- we want to search all listed index // fields: $index = explode(':', $index); - $clauses = array(); + $clauses = []; foreach ($index as $currentIndex) { $clauses[] = "{$currentIndex} all \"{$lookfor}\""; } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Response/XML/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Response/XML/RecordCollection.php index 0b00c89f984..5eb725016d2 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Response/XML/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Response/XML/RecordCollection.php @@ -79,6 +79,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - return array(); // not supported by WorldCat + return []; // not supported by WorldCat } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/ParamBag.php b/module/VuFindSearch/src/VuFindSearch/ParamBag.php index c9c0cc56f47..f1d035d0956 100644 --- a/module/VuFindSearch/src/VuFindSearch/ParamBag.php +++ b/module/VuFindSearch/src/VuFindSearch/ParamBag.php @@ -48,7 +48,7 @@ class ParamBag * * @var array */ - protected $params = array(); + protected $params = []; /** * Constructor. @@ -57,7 +57,7 @@ class ParamBag * * @return void */ - public function __construct(array $initial = array()) + public function __construct(array $initial = []) { foreach ($initial as $name => $value) { $this->add($name, $value); @@ -103,7 +103,7 @@ class ParamBag if (is_array($value)) { $this->params[$name] = $value; } else { - $this->params[$name] = array($value); + $this->params[$name] = [$value]; } } @@ -132,7 +132,7 @@ class ParamBag public function add($name, $value) { if (!isset($this->params[$name])) { - $this->params[$name] = array(); + $this->params[$name] = []; } if (is_array($value)) { $this->params[$name] = array_merge($this->params[$name], $value); @@ -191,7 +191,7 @@ class ParamBag public function exchangeArray(array $input) { $current = $this->params; - $this->params = array(); + $this->params = []; foreach ($input as $key => $value) { $this->set($key, $value); } @@ -208,7 +208,7 @@ class ParamBag */ public function request() { - $request = array(); + $request = []; foreach ($this->params as $name => $values) { if (!empty($values)) { $request = array_merge( diff --git a/module/VuFindSearch/src/VuFindSearch/Query/QueryGroup.php b/module/VuFindSearch/src/VuFindSearch/Query/QueryGroup.php index fb9c0e18066..0b25ff0668e 100644 --- a/module/VuFindSearch/src/VuFindSearch/Query/QueryGroup.php +++ b/module/VuFindSearch/src/VuFindSearch/Query/QueryGroup.php @@ -46,7 +46,7 @@ class QueryGroup extends AbstractQuery * * @var array */ - protected static $operators = array('AND', 'OR', 'NOT'); + protected static $operators = ['AND', 'OR', 'NOT']; /** * Name of the handler to be used if the query group is reduced. @@ -89,7 +89,7 @@ class QueryGroup extends AbstractQuery * * @return void */ - public function __construct($operator, array $queries = array(), + public function __construct($operator, array $queries = [], $reducedHandler = null ) { $this->setOperator($operator); @@ -104,7 +104,7 @@ class QueryGroup extends AbstractQuery */ public function __clone() { - $new = array(); + $new = []; foreach ($this->queries as $q) { $new[] = clone($q); } @@ -174,7 +174,7 @@ class QueryGroup extends AbstractQuery */ public function setQueries(array $queries) { - $this->queries = array(); + $this->queries = []; $this->addQueries($queries); } @@ -260,7 +260,7 @@ class QueryGroup extends AbstractQuery */ public function getAllTerms() { - $parts = array(); + $parts = []; foreach ($this->getQueries() as $q) { $parts[] = $q->getAllTerms(); } diff --git a/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php index de961972a93..fdfd37a820f 100644 --- a/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php @@ -44,7 +44,7 @@ abstract class AbstractRecordCollection implements RecordCollectionInterface * * @var array */ - protected $records = array(); + protected $records = []; /** * Source identifier diff --git a/module/VuFindSearch/src/VuFindSearch/Service.php b/module/VuFindSearch/src/VuFindSearch/Service.php index c3626c793b9..48fa56d6e98 100644 --- a/module/VuFindSearch/src/VuFindSearch/Service.php +++ b/module/VuFindSearch/src/VuFindSearch/Service.php @@ -79,7 +79,7 @@ class Service */ public function __construct() { - $this->backends = array(); + $this->backends = []; } /** @@ -246,7 +246,7 @@ class Service } else { // Default case: retrieve n random records: $response = false; - $retrievedIndexes = array(); + $retrievedIndexes = []; for ($i = 0; $i < $limit; $i++) { $nextIndex = rand(0, $total_records - 1); while (in_array($nextIndex, $retrievedIndexes)) { @@ -315,7 +315,7 @@ class Service */ public function setEventManager(EventManagerInterface $events) { - $events->setIdentifiers(array('VuFind\Search', 'VuFindSearch')); + $events->setIdentifiers(['VuFind\Search', 'VuFindSearch']); $this->events = $events; } diff --git a/module/VuFindSearch/tests/unit-tests/bootstrap.php b/module/VuFindSearch/tests/unit-tests/bootstrap.php index 8066a89b62a..9ef1e7ad79c 100644 --- a/module/VuFindSearch/tests/unit-tests/bootstrap.php +++ b/module/VuFindSearch/tests/unit-tests/bootstrap.php @@ -9,15 +9,15 @@ */ require_once('Zend/Loader/AutoloaderFactory.php'); \Zend\Loader\AutoloaderFactory::factory( - array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ 'VuFindSearch' => realpath(__DIR__ . '/../../src/VuFindSearch'), 'VuFindTest' => realpath(__DIR__ . '/src/VuFindTest'), - ), + ], 'autoregister_zf' => true - ) - ) + ] + ] ); define('PHPUNIT_SEARCH_FIXTURES', realpath(__DIR__ . '/fixtures')); \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/AbstractHandlerMapTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/AbstractHandlerMapTest.php index 421027e2f7c..fb6c5001953 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/AbstractHandlerMapTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/AbstractHandlerMapTest.php @@ -56,7 +56,7 @@ class AbstractHandlerMapTest extends TestCase ->method('getDefaults') ->will( $this->returnValue( - new ParamBag(array('p1' => array('default'), 'p2' => array('default'))) + new ParamBag(['p1' => ['default'], 'p2' => ['default']]) ) ); $map->expects($this->once()) @@ -68,7 +68,7 @@ class AbstractHandlerMapTest extends TestCase $this->returnValue(new ParamBag()) ); - $params = new ParamBag(array('p2' => array('non-default'))); + $params = new ParamBag(['p2' => ['non-default']]); $map->prepare('f', $params); $this->assertTrue($params->contains('p1', 'default')); $this->assertFalse($params->contains('p2', 'default')); @@ -88,12 +88,12 @@ class AbstractHandlerMapTest extends TestCase ->will($this->returnValue(new ParamBag())); $map->expects($this->once()) ->method('getAppends') - ->will($this->returnValue(new ParamBag(array('p1' => 'append')))); + ->will($this->returnValue(new ParamBag(['p1' => 'append']))); $map->expects($this->once()) ->method('getInvariants') ->will($this->returnValue(new ParamBag())); - $params = new ParamBag(array('p1' => array('something'))); + $params = new ParamBag(['p1' => ['something']]); $map->prepare('f', $params); $this->assertTrue($params->contains('p1', 'something')); $this->assertTrue($params->contains('p1', 'append')); @@ -112,12 +112,12 @@ class AbstractHandlerMapTest extends TestCase ->will($this->returnValue(new ParamBag())); $map->expects($this->once()) ->method('getAppends') - ->will($this->returnValue(new ParamBag(array('p1' => array('append'))))); + ->will($this->returnValue(new ParamBag(['p1' => ['append']]))); $map->expects($this->once()) ->method('getInvariants') - ->will($this->returnValue(new ParamBag(array('p1' => array('invariant'))))); + ->will($this->returnValue(new ParamBag(['p1' => ['invariant']]))); - $params = new ParamBag(array('p1' => array('something'))); + $params = new ParamBag(['p1' => ['something']]); $map->prepare('f', $params); $this->assertFalse($params->contains('p1', 'something')); $this->assertFalse($params->contains('p1', 'append')); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/BackendTest.php index 5cba3d05e46..1004c3c5a96 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/BackendTest.php @@ -51,14 +51,14 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testRetrieve() { - $conn = $this->getConnectorMock(array('retrieve')); + $conn = $this->getConnectorMock(['retrieve']); $conn->expects($this->once()) ->method('retrieve') ->will($this->returnValue($this->loadResponse('retrieve'))); $back = $this->getBackend( - $conn, $this->getRCFactory(), null, null, array(), - array('getAuthenticationToken', 'getSessionToken') + $conn, $this->getRCFactory(), null, null, [], + ['getAuthenticationToken', 'getSessionToken'] ); $back->expects($this->any()) ->method('getAuthenticationToken') @@ -83,14 +83,14 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('search')); + $conn = $this->getConnectorMock(['search']); $conn->expects($this->once()) ->method('search') ->will($this->returnValue($this->loadResponse('search'))); $back = $this->getBackend( - $conn, $this->getRCFactory(), null, null, array(), - array('getAuthenticationToken', 'getSessionToken') + $conn, $this->getRCFactory(), null, null, [], + ['getAuthenticationToken', 'getSessionToken'] ); $back->expects($this->any()) ->method('getAuthenticationToken') @@ -117,7 +117,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase $this->assertEquals('SourceType', $rawFacets[0]['Id']); $this->assertEquals('Source Type', $rawFacets[0]['Label']); $this->assertEquals(8, count($rawFacets[0]['AvailableFacetValues'])); - $expected = array('Value' => 'News', 'Count' => '12055', 'AddAction' => 'addfacetfilter(SourceType:News)'); + $expected = ['Value' => 'News', 'Count' => '12055', 'AddAction' => 'addfacetfilter(SourceType:News)']; $this->assertEquals($expected, $rawFacets[0]['AvailableFacetValues'][0]); $facets = $coll->getFacets(); $this->assertEquals(count($facets), count($rawFacets)); @@ -147,12 +147,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase { $fact = $this->getMock('VuFindSearch\Response\RecordCollectionFactoryInterface'); $conn = $this->getConnectorMock(); - $config = array( - 'EBSCO_Account' => array( + $config = [ + 'EBSCO_Account' => [ 'user_name' => 'un', 'password' => 'pw', 'ip_auth' => true, 'profile' => 'pr', 'organization_id' => 'oi' - ) - ); + ] + ]; $back = $this->getBackend($conn, $fact, null, null, $config); $this->assertEquals($fact, $back->getRecordCollectionFactory()); $this->assertEquals($conn, $this->getProperty($back, 'client')); @@ -190,11 +190,11 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( - 'VuFindSearch\Backend\EDS\Zend2', $mock, array(array(), $client) + 'VuFindSearch\Backend\EDS\Zend2', $mock, [[], $client] ); } @@ -208,7 +208,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase * @param array $settings Additional settings * @param array $mock Methods to mock (or null for a real object) */ - protected function getBackend($connector, $factory = null, $cache = null, $container = null, $settings = array(), $mock = null) + protected function getBackend($connector, $factory = null, $cache = null, $container = null, $settings = [], $mock = null) { if (null === $factory) { $factory = $this->getMock('VuFindSearch\Response\RecordCollectionFactoryInterface'); @@ -223,7 +223,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase if (null === $mock) { return new Backend($connector, $factory, $cache, $container, new \Zend\Config\Config($settings)); } else { - $params = array($connector, $factory, $cache, $container, new \Zend\Config\Config($settings)); + $params = [$connector, $factory, $cache, $container, new \Zend\Config\Config($settings)]; return $this->getMock('VuFindSearch\Backend\EDS\Backend', $mock, $params); } } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/QueryBuilderTest.php index 2c3bcb393aa..84552f54ca1 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/QueryBuilderTest.php @@ -52,9 +52,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase // Set up an array of expected inputs (serialized objects) and outputs // (queries): // @codingStandardsIgnoreStart - $tests = array( - array('advanced', array('AND,cheese', 'AND,SU:test')) - ); + $tests = [ + ['advanced', ['AND,cheese', 'AND,SU:test']] + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder(); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionTest.php index b9ec3ad6cd6..81e50d3a8ff 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EDS/Response/RecordCollectionTest.php @@ -49,10 +49,10 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $rc = new RecordCollection(array()); + $rc = new RecordCollection([]); $this->assertEquals(0, $rc->getTotal()); $this->assertEquals(0, $rc->getOffset()); - $this->assertEquals(array(), $rc->getFacets()); - $this->assertEquals(array(), $rc->getRawFacets()); + $this->assertEquals([], $rc->getFacets()); + $this->assertEquals([], $rc->getRawFacets()); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/BackendTest.php index b3a78a5932a..ec2854dcc04 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/BackendTest.php @@ -52,7 +52,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testRetrieve() { - $conn = $this->getConnectorMock(array('call')); + $conn = $this->getConnectorMock(['call']); $conn->expects($this->once()) ->method('call') ->will($this->returnValue($this->loadResponse('retrieve'))); @@ -75,7 +75,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('call')); + $conn = $this->getConnectorMock(['call']); $conn->expects($this->once()) ->method('call') ->will($this->returnValue($this->loadResponse('search'))); @@ -163,12 +163,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( 'VuFindSearch\Backend\EIT\Connector', $mock, - array('http://fake', $client, 'profile', 'pwd', 'dbs') + ['http://fake', $client, 'profile', 'pwd', 'dbs'] ); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/QueryBuilderTest.php index d7583f1b1f5..0f0a926131b 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/QueryBuilderTest.php @@ -52,9 +52,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase // Set up an array of expected inputs (serialized objects) and outputs // (queries): // @codingStandardsIgnoreStart - $tests = array( - array('advanced', '((TX cheese) AND (AU cross)) NOT (((TI expansion)))') - ); + $tests = [ + ['advanced', '((TX cheese) AND (AU cross)) NOT (((TI expansion)))'] + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder(); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionTest.php index 4a55800d345..042c513bd5b 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/EIT/Response/XML/RecordCollectionTest.php @@ -49,10 +49,10 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $rc = new RecordCollection(array()); + $rc = new RecordCollection([]); $this->assertEquals(0, $rc->getTotal()); $this->assertEquals(0, $rc->getOffset()); - $this->assertEquals(array(), $rc->getFacets()); + $this->assertEquals([], $rc->getFacets()); } /** @@ -62,7 +62,7 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testNonDefaults() { - $rc = new RecordCollection(array('total' => 5, 'offset' => 2)); + $rc = new RecordCollection(['total' => 5, 'offset' => 2]); $this->assertEquals(5, $rc->getTotal()); $this->assertEquals(2, $rc->getOffset()); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php index 54cbbba389f..bec7138c4e9 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/BackendTest.php @@ -146,7 +146,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearchWrapsLibGuidesException() { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->throwException(new \Exception())); @@ -161,13 +161,13 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testMergedParamBag() { - $myParams = new ParamBag(array('foo' => 'bar')); - $expectedParams = array('foo' => 'bar', 'search' => 'baz'); - $conn = $this->getConnectorMock(array('query')); + $myParams = new ParamBag(['foo' => 'bar']); + $expectedParams = ['foo' => 'bar', 'search' => 'baz']; + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->with($this->equalTo($expectedParams), $this->equalTo(0), $this->equalTo(10)) - ->will($this->returnValue(array('recordCount' => 0, 'documents' => array()))); + ->will($this->returnValue(['recordCount' => 0, 'documents' => []])); $back = new Backend($conn); $back->search(new Query('baz'), 0, 10, $myParams); } @@ -179,17 +179,17 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearchFallback() { - $conn = $this->getConnectorMock(array('query')); - $expectedParams0 = array('search' => 'baz'); + $conn = $this->getConnectorMock(['query']); + $expectedParams0 = ['search' => 'baz']; $conn->expects($this->at(0)) ->method('query') ->with($this->equalTo($expectedParams0), $this->equalTo(0), $this->equalTo(10)) - ->will($this->returnValue(array('recordCount' => 0, 'documents' => array()))); - $expectedParams1 = array('search' => 'fallback'); + ->will($this->returnValue(['recordCount' => 0, 'documents' => []])); + $expectedParams1 = ['search' => 'fallback']; $conn->expects($this->at(1)) ->method('query') ->with($this->equalTo($expectedParams1), $this->equalTo(0), $this->equalTo(10)) - ->will($this->returnValue(array('recordCount' => 0, 'documents' => array()))); + ->will($this->returnValue(['recordCount' => 0, 'documents' => []])); $back = new Backend($conn, null, 'fallback'); $back->search(new Query('baz'), 0, 10); } @@ -239,12 +239,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( 'VuFindSearch\Backend\LibGuides\Connector', $mock, - array('fakeid', $client) + ['fakeid', $client] ); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php index c77d0cb2aaf..5f0f660de94 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/QueryBuilderTest.php @@ -53,7 +53,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase { $q = new Query('query1'); $qb = new QueryBuilder(); - $expected = array('query1'); + $expected = ['query1']; $result = $qb->build($q)->get('search'); $this->assertEquals($expected, $result); } @@ -68,6 +68,6 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase public function testAdvanced() { $qb = new QueryBuilder(); - $qb->build(new QueryGroup('AND', array())); + $qb->build(new QueryGroup('AND', [])); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php index 5da2a87eaa1..2c313e69790 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionFactoryTest.php @@ -49,7 +49,7 @@ class RecordCollectionFactoryTest extends PHPUnit_Framework_TestCase */ public function testFactory() { - $resp = array('documents' => array(array(), array(), array())); + $resp = ['documents' => [[], [], []]]; $fact = new RecordCollectionFactory(); $coll = $fact->factory($resp); $this->assertEquals(3, count($coll)); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionTest.php index 80b10f93c37..cd5b90a937c 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/LibGuides/Response/RecordCollectionTest.php @@ -49,10 +49,10 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $rc = new RecordCollection(array()); + $rc = new RecordCollection([]); $this->assertEquals(0, $rc->getTotal()); $this->assertEquals(0, $rc->getOffset()); - $this->assertEquals(array(), $rc->getFacets()); + $this->assertEquals([], $rc->getFacets()); } /** @@ -62,7 +62,7 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testNonDefaults() { - $rc = new RecordCollection(array('recordCount' => 5, 'offset' => 2)); + $rc = new RecordCollection(['recordCount' => 5, 'offset' => 2]); $this->assertEquals(5, $rc->getTotal()); $this->assertEquals(2, $rc->getOffset()); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Pazpar2/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Pazpar2/BackendTest.php index a23cd013ae4..88f1c146b9c 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Pazpar2/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Pazpar2/BackendTest.php @@ -52,8 +52,8 @@ class BackendTest extends TestCase public function testGetConnector() { $connector = $this->getMock( - 'VuFindSearch\Backend\Pazpar2\Connector', array(), - array('http://fake', $this->getMock('Zend\Http\Client')) + 'VuFindSearch\Backend\Pazpar2\Connector', [], + ['http://fake', $this->getMock('Zend\Http\Client')] ); $back = new Backend( $connector, @@ -69,7 +69,7 @@ class BackendTest extends TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('search', 'show', 'stat')); + $conn = $this->getConnectorMock(['search', 'show', 'stat']); $conn->expects($this->once()) ->method('search') ->will($this->returnValue($this->loadResponse('pp2search'))); @@ -148,11 +148,11 @@ class BackendTest extends TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( - 'VuFindSearch\Backend\Pazpar2\Connector', $mock, array('fake', $client) + 'VuFindSearch\Backend\Pazpar2\Connector', $mock, ['fake', $client] ); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php index d347a2420de..c6aa10e9ff0 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/BackendTest.php @@ -51,7 +51,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testRetrieve() { - $conn = $this->getConnectorMock(array('getRecord')); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') ->will($this->returnValue($this->loadResponse('retrieve'))); @@ -74,7 +74,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->returnValue($this->loadResponse('search'))); @@ -136,7 +136,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testSearchWrapsPrimoException() { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->throwException(new \Exception())); @@ -152,7 +152,7 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testRetrieveWrapsPrimoException() { - $conn = $this->getConnectorMock(array('getRecord')); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') ->will($this->throwException(new \Exception())); @@ -167,13 +167,13 @@ class BackendTest extends \VuFindTest\Unit\TestCase */ public function testMergedParamBag() { - $myParams = new ParamBag(array('foo' => 'bar')); - $expectedParams = array('foo' => 'bar', 'limit' => 10, 'pageNumber' => 1.0, 'query' => array(array('index' => null, 'lookfor' => 'baz'))); - $conn = $this->getConnectorMock(array('query')); + $myParams = new ParamBag(['foo' => 'bar']); + $expectedParams = ['foo' => 'bar', 'limit' => 10, 'pageNumber' => 1.0, 'query' => [['index' => null, 'lookfor' => 'baz']]]; + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->with($this->equalTo('inst-id'), $this->equalTo($expectedParams['query']), $this->equalTo($expectedParams)) - ->will($this->returnValue(array('recordCount' => 0, 'documents' => array()))); + ->will($this->returnValue(['recordCount' => 0, 'documents' => []])); $back = new Backend($conn); $back->search(new Query('baz'), 0, 10, $myParams); } @@ -205,12 +205,12 @@ class BackendTest extends \VuFindTest\Unit\TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( 'VuFindSearch\Backend\Primo\Connector', $mock, - array('api-id', 'inst-id', $client) + ['api-id', 'inst-id', $client] ); } } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php index ee7773d93e4..f0318683ed0 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/ConnectorTest.php @@ -78,7 +78,7 @@ class ConnectorTest extends PHPUnit_Framework_TestCase public function testEmptyQueryError() { $conn = $this->createConnector(); - $terms = array(); + $terms = []; $result = $conn->query('dummyinst', $terms); $this->assertEquals(0, $result['recordCount']); $this->assertEquals('Primo API does not accept a null query', $result['error']); @@ -92,10 +92,10 @@ class ConnectorTest extends PHPUnit_Framework_TestCase public function testQuery() { $conn = $this->createConnector('search-http'); - $terms = array( - array('index' => 'Title', 'lookfor' => 'test'), - array('index' => 'Author', 'lookfor' => 'test'), - ); + $terms = [ + ['index' => 'Title', 'lookfor' => 'test'], + ['index' => 'Author', 'lookfor' => 'test'], + ]; $result = $conn->query('dummyinst', $terms); $this->assertEquals(1245, $result['recordCount']); $this->assertEquals('Abstract Test', $result['documents'][0]['title']); @@ -109,14 +109,14 @@ class ConnectorTest extends PHPUnit_Framework_TestCase public function testDifferentlyNamespacedQuery() { $conn = $this->createConnector('swansea-search-http'); - $terms = array( - array('index' => 'Title', 'lookfor' => 'dummy query'), - ); - $result = $conn->query('dummyinst', $terms, array('returnErr' => false)); + $terms = [ + ['index' => 'Title', 'lookfor' => 'dummy query'], + ]; + $result = $conn->query('dummyinst', $terms, ['returnErr' => false]); $this->assertEquals(1, $result['recordCount']); $this->assertEquals('Lord', $result['documents'][0]['title']); - $this->assertEquals(array(), $result['didYouMean']); - $this->assertEquals(array('eng' => 1), $result['facets']['lang']); + $this->assertEquals([], $result['didYouMean']); + $this->assertEquals(['eng' => 1], $result['facets']['lang']); } /** @@ -130,10 +130,10 @@ class ConnectorTest extends PHPUnit_Framework_TestCase public function testErrorInSuccessfulResponse() { $conn = $this->createConnector('error-with-success-http'); - $terms = array( - array('index' => 'Title', 'lookfor' => 'dummy query'), - ); - $result = $conn->query('dummyinst', $terms, array('returnErr' => false)); + $terms = [ + ['index' => 'Title', 'lookfor' => 'dummy query'], + ]; + $result = $conn->query('dummyinst', $terms, ['returnErr' => false]); } /** diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/QueryBuilderTest.php index f8a8e44fedf..c1e66784df9 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/QueryBuilderTest.php @@ -53,7 +53,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase { $q = new Query('query1', 'handler1'); $qb = new QueryBuilder(); - $expected = array(array('lookfor' => 'query1', 'index' => 'handler1')); + $expected = [['lookfor' => 'query1', 'index' => 'handler1']]; $result = $qb->build($q)->get('query'); $this->assertEquals($expected, $result); } @@ -69,14 +69,14 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase // inside another query group containing a collection of queries. $q1 = new Query('query1', 'handler1', 'OR'); $q2 = new Query('query2', 'handler2', 'AND'); - $qsub = new QueryGroup('AND', array($q1, $q2)); - $q = new QueryGroup('AND', array($qsub)); + $qsub = new QueryGroup('AND', [$q1, $q2]); + $q = new QueryGroup('AND', [$qsub]); $qb = new QueryBuilder(); - $expected = array( - array('lookfor' => 'query1', 'index' => 'handler1', 'op' => 'OR'), - array('lookfor' => 'query2', 'index' => 'handler2', 'op' => 'AND') - ); + $expected = [ + ['lookfor' => 'query1', 'index' => 'handler1', 'op' => 'OR'], + ['lookfor' => 'query2', 'index' => 'handler2', 'op' => 'AND'] + ]; $result = $qb->build($q)->get('query'); $this->assertEquals($expected, $result); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionTest.php index 1a7cfa2cb8f..af03acc0a4d 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Primo/Response/RecordCollectionTest.php @@ -49,9 +49,9 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $rc = new RecordCollection(array()); + $rc = new RecordCollection([]); $this->assertEquals(0, $rc->getTotal()); $this->assertEquals(0, $rc->getOffset()); - $this->assertEquals(array(), $rc->getFacets()); + $this->assertEquals([], $rc->getFacets()); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php index 4a8ee3b1d96..89f7cb76d7f 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/BackendTest.php @@ -57,7 +57,7 @@ class BackendTest extends PHPUnit_Framework_TestCase public function testRetrieve() { $resp = $this->loadResponse('single-record'); - $conn = $this->getConnectorMock(array('retrieve')); + $conn = $this->getConnectorMock(['retrieve']); $conn->expects($this->once()) ->method('retrieve') ->will($this->returnValue($resp->getBody())); @@ -80,14 +80,14 @@ class BackendTest extends PHPUnit_Framework_TestCase public function testRetrieveBatch() { $resp = $this->loadResponse('multi-record'); - $conn = $this->getConnectorMock(array('search')); + $conn = $this->getConnectorMock(['search']); $conn->expects($this->once()) ->method('search') ->will($this->returnValue($resp->getBody())); $back = new Backend($conn); $back->setIdentifier('test'); - $coll = $back->retrieveBatch(array('12345', '125456', '234547')); + $coll = $back->retrieveBatch(['12345', '125456', '234547']); $this->assertCount(3, $coll); $this->assertEquals('test', $coll->getSourceIdentifier()); $rec = $coll->first(); @@ -109,7 +109,7 @@ class BackendTest extends PHPUnit_Framework_TestCase public function testSimilar() { $resp = $this->loadResponse('morelikethis'); - $conn = $this->getConnectorMock(array('similar')); + $conn = $this->getConnectorMock(['similar']); $conn->expects($this->once()) ->method('similar') ->will($this->returnValue($resp->getBody())); @@ -132,7 +132,7 @@ class BackendTest extends PHPUnit_Framework_TestCase public function testTerms() { $resp = $this->loadResponse('terms'); - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->returnValue($resp->getBody())); @@ -153,7 +153,7 @@ class BackendTest extends PHPUnit_Framework_TestCase */ public function testBadJson() { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->returnValue('bad {')); @@ -173,7 +173,7 @@ class BackendTest extends PHPUnit_Framework_TestCase { $conn = $this->getConnectorMock(); $back = new Backend($conn); - $back->retrieve('foobar', new ParamBag(array('wt' => array('xml')))); + $back->retrieve('foobar', new ParamBag(['wt' => ['xml']])); } /** @@ -188,7 +188,7 @@ class BackendTest extends PHPUnit_Framework_TestCase { $conn = $this->getConnectorMock(); $back = new Backend($conn); - $back->retrieve('foobar', new ParamBag(array('json.nl' => array('bad')))); + $back->retrieve('foobar', new ParamBag(['json.nl' => ['bad']])); } /** @@ -260,15 +260,15 @@ class BackendTest extends PHPUnit_Framework_TestCase public function testRandom() { // Test that random sort parameter is added: - $params = $this->getMock('VuFindSearch\ParamBag', array('set')); + $params = $this->getMock('VuFindSearch\ParamBag', ['set']); $params->expects($this->once())->method('set') ->with($this->equalTo('sort'), $this->matchesRegularExpression('/[0-9]+_random asc/')); // Test that random proxies search; stub out injectResponseWriter() to prevent it // from injecting unwanted extra parameters into $params: $back = $this->getMock( - 'VuFindSearch\Backend\Solr\Backend', array('search', 'injectResponseWriter'), - array($this->getConnectorMock()) + 'VuFindSearch\Backend\Solr\Backend', ['search', 'injectResponseWriter'], + [$this->getConnectorMock()] ); $back->expects($this->once())->method('injectResponseWriter'); $back->expects($this->once())->method('search') @@ -287,7 +287,7 @@ class BackendTest extends PHPUnit_Framework_TestCase */ protected function runRefineExceptionCall($msg) { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $e = new RemoteErrorException($msg, 400, new \Zend\Http\Response()); $conn->expects($this->once())->method('query') ->with($this->equalTo('browse')) @@ -321,9 +321,9 @@ class BackendTest extends PHPUnit_Framework_TestCase * * @return Connector */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { - $map = new HandlerMap(array('select' => array('fallback' => true))); - return $this->getMock('VuFindSearch\Backend\Solr\Connector', $mock, array('http://example.org/', $map)); + $map = new HandlerMap(['select' => ['fallback' => true]]); + return $this->getMock('VuFindSearch\Backend\Solr\Connector', $mock, ['http://example.org/', $map]); } } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php index b54fdc83c9d..6e8b832ecbb 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/ConnectorTest.php @@ -138,7 +138,7 @@ class ConnectorTest extends PHPUnit_Framework_TestCase public function testGetters() { $url = 'http://example.tld/'; - $map = new HandlerMap(array('select' => array('fallback' => true))); + $map = new HandlerMap(['select' => ['fallback' => true]]); $key = 'foo'; $conn = new Connector($url, $map, $key); $this->assertEquals($url, $conn->getUrl()); @@ -175,7 +175,7 @@ class ConnectorTest extends PHPUnit_Framework_TestCase $this->response = file_get_contents($file); } - $map = new HandlerMap(array('select' => array('fallback' => true))); + $map = new HandlerMap(['select' => ['fallback' => true]]); $conn = new Connector('http://example.tld/', $map); $conn->setProxy($this); return $conn; diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/DeleteDocumentTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/DeleteDocumentTest.php index b08f06f6c58..18460bfda13 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/DeleteDocumentTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/DeleteDocumentTest.php @@ -68,7 +68,7 @@ class DeleteDocumentTest extends PHPUnit_Framework_TestCase public function testAsXMLMultiKey() { $document = new DeleteDocument(); - $document->addKeys(array('foo', 'bar')); + $document->addKeys(['foo', 'bar']); $xml = $document->asXML(); $this->assertXmlStringEqualsXmlString( '<delete><id>foo</id><id>bar</id></delete>', diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/UpdateDocumentTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/UpdateDocumentTest.php index ae8e26fecdc..585e272f34e 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/UpdateDocumentTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Document/UpdateDocumentTest.php @@ -53,9 +53,9 @@ class UpdateDocumentTest extends PHPUnit_Framework_TestCase $record = $this->getMockForAbstractClass('VuFindSearch\Backend\Solr\Record\SerializableRecordInterface'); $record->expects($this->once()) ->method('getFields') - ->will($this->returnValue(array('id' => 'ID', 'field' => 'FIELD'))); + ->will($this->returnValue(['id' => 'ID', 'field' => 'FIELD'])); $document = new UpdateDocument(); - $document->addRecord($record, array('boost' => '2.0')); + $document->addRecord($record, ['boost' => '2.0']); $xml = $document->asXML(); $this->assertXmlStringEqualsXmlString( '<add><doc boost="2.0"><field name="id">ID</field><field name="field">FIELD</field></doc></add>', diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php index cdac54d2f70..f47d299dba9 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/HandlerMapTest.php @@ -56,10 +56,10 @@ class HandlerMapTest extends TestCase */ public function testSetHandlerMapThrowsOnDuplicateFallback() { - $map = array( - 'h1' => array('fallback' => true), - 'h2' => array('fallback' => true), - ); + $map = [ + 'h1' => ['fallback' => true], + 'h2' => ['fallback' => true], + ]; new HandlerMap($map); } @@ -73,10 +73,10 @@ class HandlerMapTest extends TestCase */ public function testSetHandlerMapThrowsOnDuplicateFunctionHandler() { - $map = array( - 'h1' => array('functions' => array('foo')), - 'h2' => array('functions' => array('foo')), - ); + $map = [ + 'h1' => ['functions' => ['foo']], + 'h2' => ['functions' => ['foo']], + ]; new HandlerMap($map); } @@ -90,7 +90,7 @@ class HandlerMapTest extends TestCase */ public function testGetHandlerThrowsOnUndefinedFunctionHandler() { - $map = new HandlerMap(array()); + $map = new HandlerMap([]); $map->getHandler('search'); } @@ -104,7 +104,7 @@ class HandlerMapTest extends TestCase */ public function testGetParametersThrowsOnUndefinedType() { - $map = new HandlerMap(array('h1' => array('functions' => array('foo')))); + $map = new HandlerMap(['h1' => ['functions' => ['foo']]]); $map->getParameters('h1', 'bad'); } @@ -118,8 +118,8 @@ class HandlerMapTest extends TestCase */ public function testSetParametersThrowsOnUndefinedType() { - $map = new HandlerMap(array('h1' => array('functions' => array('foo')))); - $map->setParameters('h1', 'bad', array()); + $map = new HandlerMap(['h1' => ['functions' => ['foo']]]); + $map->setParameters('h1', 'bad', []); } /** @@ -130,25 +130,25 @@ class HandlerMapTest extends TestCase public function testGetDefaultsAppendsInvariants() { $map = new HandlerMap( - array( - 'search' => array( - 'functions' => array('search'), - 'invariants' => array('p1' => 'v1'), - 'defaults' => array('p2' => 'v2'), - 'appends' => array('p3' => 'v3'), - ) - ) + [ + 'search' => [ + 'functions' => ['search'], + 'invariants' => ['p1' => 'v1'], + 'defaults' => ['p2' => 'v2'], + 'appends' => ['p3' => 'v3'], + ] + ] ); $this->assertEquals( - array('p1' => array('v1')), + ['p1' => ['v1']], $map->getInvariants('search')->getArrayCopy() ); $this->assertEquals( - array('p2' => array('v2')), + ['p2' => ['v2']], $map->getDefaults('search')->getArrayCopy() ); $this->assertEquals( - array('p3' => array('v3')), + ['p3' => ['v3']], $map->getAppends('search')->getArrayCopy() ); } @@ -163,25 +163,25 @@ class HandlerMapTest extends TestCase public function testGetDefaultsAppendsInvariantsPureFallback() { $map = new HandlerMap( - array( - 'search' => array( + [ + 'search' => [ 'fallback' => true, - 'invariants' => array('p1' => 'v1'), - 'defaults' => array('p2' => 'v2'), - 'appends' => array('p3' => 'v3'), - ) - ) + 'invariants' => ['p1' => 'v1'], + 'defaults' => ['p2' => 'v2'], + 'appends' => ['p3' => 'v3'], + ] + ] ); $this->assertEquals( - array('p1' => array('v1')), + ['p1' => ['v1']], $map->getInvariants('search')->getArrayCopy() ); $this->assertEquals( - array('p2' => array('v2')), + ['p2' => ['v2']], $map->getDefaults('search')->getArrayCopy() ); $this->assertEquals( - array('p3' => array('v3')), + ['p3' => ['v3']], $map->getAppends('search')->getArrayCopy() ); } @@ -194,16 +194,16 @@ class HandlerMapTest extends TestCase public function testAddParameter() { $map = new HandlerMap( - array( - 'search' => array( - 'functions' => array('search'), - 'invariants' => array('p1' => 'v1'), - ) - ) + [ + 'search' => [ + 'functions' => ['search'], + 'invariants' => ['p1' => 'v1'], + ] + ] ); $map->addParameter('search', 'invariants', 'p2', 'v2'); $this->assertEquals( - array('p1' => array('v1'), 'p2' => array('v2')), + ['p1' => ['v1'], 'p2' => ['v2']], $map->getInvariants('search')->getArrayCopy() ); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/LuceneSyntaxHelperTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/LuceneSyntaxHelperTest.php index ebeca1cea50..a68c8ae5284 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/LuceneSyntaxHelperTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/LuceneSyntaxHelperTest.php @@ -52,22 +52,22 @@ class LuceneSyntaxHelperTest extends \VuFindTest\Unit\TestCase // Set up an array of expected inputs and outputs: // @codingStandardsIgnoreStart - $tests = array( - array('this not that', 'this NOT that'), // capitalize not - array('this and that', 'this AND that'), // capitalize and - array('this or that', 'this OR that'), // capitalize or - array('apples and oranges (not that)', 'apples AND oranges (NOT that)'), - array('"this not that"', '"this not that"'), // do not capitalize inside quotes - array('"this and that"', '"this and that"'), // do not capitalize inside quotes - array('"this or that"', '"this or that"'), // do not capitalize inside quotes - array('"apples and oranges (not that)"', '"apples and oranges (not that)"'), - array('this AND that', 'this AND that'), // don't mess up existing caps - array('and and and', 'and AND and'), - array('andornot noted andy oranges', 'andornot noted andy oranges'), - array('(this or that) and (apples not oranges)', '(this OR that) AND (apples NOT oranges)'), - array('this aNd that', 'this AND that'), // strange capitalization of AND - array('this nOt that', 'this NOT that'), // strange capitalization of NOT - ); + $tests = [ + ['this not that', 'this NOT that'], // capitalize not + ['this and that', 'this AND that'], // capitalize and + ['this or that', 'this OR that'], // capitalize or + ['apples and oranges (not that)', 'apples AND oranges (NOT that)'], + ['"this not that"', '"this not that"'], // do not capitalize inside quotes + ['"this and that"', '"this and that"'], // do not capitalize inside quotes + ['"this or that"', '"this or that"'], // do not capitalize inside quotes + ['"apples and oranges (not that)"', '"apples and oranges (not that)"'], + ['this AND that', 'this AND that'], // don't mess up existing caps + ['and and and', 'and AND and'], + ['andornot noted andy oranges', 'andornot noted andy oranges'], + ['(this or that) and (apples not oranges)', '(this OR that) AND (apples NOT oranges)'], + ['this aNd that', 'this AND that'], // strange capitalization of AND + ['this nOt that', 'this NOT that'], // strange capitalization of NOT + ]; // @codingStandardsIgnoreEnd // Test all the operations: @@ -111,23 +111,23 @@ class LuceneSyntaxHelperTest extends \VuFindTest\Unit\TestCase $in = 'this or that and the other not everything else (not me)'; $this->assertEquals( 'this OR that AND the other NOT everything else (NOT me)', - $lh->capitalizeBooleans($in, array('AND', 'OR', 'NOT')) + $lh->capitalizeBooleans($in, ['AND', 'OR', 'NOT']) ); $this->assertEquals( 'this OR that and the other NOT everything else (NOT me)', - $lh->capitalizeBooleans($in, array('OR', 'NOT')) + $lh->capitalizeBooleans($in, ['OR', 'NOT']) ); $this->assertEquals( 'this or that and the other NOT everything else (NOT me)', - $lh->capitalizeBooleans($in, array('NOT')) + $lh->capitalizeBooleans($in, ['NOT']) ); $this->assertEquals( 'this or that AND the other not everything else (not me)', - $lh->capitalizeBooleans($in, array('AND')) + $lh->capitalizeBooleans($in, ['AND']) ); $this->assertEquals( 'this OR that and the other not everything else (not me)', - $lh->capitalizeBooleans($in, array('OR')) + $lh->capitalizeBooleans($in, ['OR']) ); } @@ -142,31 +142,31 @@ class LuceneSyntaxHelperTest extends \VuFindTest\Unit\TestCase // Default behavior: do not capitalize: $this->assertEquals( - array(), $this->callMethod($lh, 'getBoolsToCap') + [], $this->callMethod($lh, 'getBoolsToCap') ); // Test "capitalize all": $lh = new LuceneSyntaxHelper(false); $this->assertEquals( - array('AND', 'OR', 'NOT'), $this->callMethod($lh, 'getBoolsToCap') + ['AND', 'OR', 'NOT'], $this->callMethod($lh, 'getBoolsToCap') ); // Test selective capitalization: $lh = new LuceneSyntaxHelper(' not '); $this->assertEquals( - array('AND', 'OR'), $this->callMethod($lh, 'getBoolsToCap') + ['AND', 'OR'], $this->callMethod($lh, 'getBoolsToCap') ); $lh = new LuceneSyntaxHelper('NOT'); $this->assertEquals( - array('AND', 'OR'), $this->callMethod($lh, 'getBoolsToCap') + ['AND', 'OR'], $this->callMethod($lh, 'getBoolsToCap') ); $lh = new LuceneSyntaxHelper('AND,OR'); $this->assertEquals( - array('NOT'), $this->callMethod($lh, 'getBoolsToCap') + ['NOT'], $this->callMethod($lh, 'getBoolsToCap') ); $lh = new LuceneSyntaxHelper('and, or'); $this->assertEquals( - array('NOT'), $this->callMethod($lh, 'getBoolsToCap') + ['NOT'], $this->callMethod($lh, 'getBoolsToCap') ); } @@ -208,26 +208,26 @@ class LuceneSyntaxHelperTest extends \VuFindTest\Unit\TestCase // Set up an array of expected inputs and outputs: // @codingStandardsIgnoreStart - $tests = array( - array('"{a to b}"', '"{a to b}"'), // don't capitalize inside quotes - array('"[a to b]"', '"[a to b]"'), - array('[a to b]', '([a TO b] OR [A TO B])'), // expand alphabetic cases - array('[a TO b]', '([a TO b] OR [A TO B])'), - array('[a To b]', '([a TO b] OR [A TO B])'), - array('[a tO b]', '([a TO b] OR [A TO B])'), - array('{a to b}', '({a TO b} OR {A TO B})'), - array('{a TO b}', '({a TO b} OR {A TO B})'), - array('{a To b}', '({a TO b} OR {A TO B})'), - array('{a tO b}', '({a TO b} OR {A TO B})'), - array('[1900 to 1910]', '[1900 TO 1910]'), // don't expand numeric cases - array('[1900 TO 1910]', '[1900 TO 1910]'), - array('{1900 to 1910}', '{1900 TO 1910}'), - array('{1900 TO 1910}', '{1900 TO 1910}'), - array('[a to b]', '([a TO b] OR [A TO B])'), // handle extra spaces + $tests = [ + ['"{a to b}"', '"{a to b}"'], // don't capitalize inside quotes + ['"[a to b]"', '"[a to b]"'], + ['[a to b]', '([a TO b] OR [A TO B])'], // expand alphabetic cases + ['[a TO b]', '([a TO b] OR [A TO B])'], + ['[a To b]', '([a TO b] OR [A TO B])'], + ['[a tO b]', '([a TO b] OR [A TO B])'], + ['{a to b}', '({a TO b} OR {A TO B})'], + ['{a TO b}', '({a TO b} OR {A TO B})'], + ['{a To b}', '({a TO b} OR {A TO B})'], + ['{a tO b}', '({a TO b} OR {A TO B})'], + ['[1900 to 1910]', '[1900 TO 1910]'], // don't expand numeric cases + ['[1900 TO 1910]', '[1900 TO 1910]'], + ['{1900 to 1910}', '{1900 TO 1910}'], + ['{1900 TO 1910}', '{1900 TO 1910}'], + ['[a to b]', '([a TO b] OR [A TO B])'], // handle extra spaces // special case for timestamps: - array('[1900-01-01t00:00:00z to 1900-12-31t23:59:59z]', '[1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z]'), - array('{1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z}', '{1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z}') - ); + ['[1900-01-01t00:00:00z to 1900-12-31t23:59:59z]', '[1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z]'], + ['{1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z}', '{1900-01-01T00:00:00Z TO 1900-12-31T23:59:59Z}'] + ]; // @codingStandardsIgnoreEnd // Test all the operations: diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php index 8d5815b8804..3b638c00177 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php @@ -52,43 +52,43 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase { // Set up an array of expected inputs and outputs: // @codingStandardsIgnoreStart - $tests = array( - array("", "*:*"), // empty query - array("()", "*:*"), // empty parens - array("((()))", "*:*"), // nested empty parens - array("((())", "*:*"), // mismatched parens - array("this that ()", "this that"), // text mixed w/ empty parens - array('"()"', '"()"'), // empty parens in quotes - array('title - sub', 'title sub'), // freestanding hyphen - array('"title - sub"', '"title - sub"'), // freestanding hyphen in quotes - array('test~1', 'test'), // meaningless proximity - array('test~1.', 'test'), // meaningless proximity w/dec. - array('test~1.000', 'test'), // meaningless proximity w/dec. - array('test~1 fish', 'test fish'), // meaningless proximity - array('test~1. fish', 'test fish'), // meaningless proximity w/dec. - array('test~1.000 fish', 'test fish'), // meaningless proximity w/dec. - array('"test~1"', '"test~1"'), // meaningless prox. in quotes - array('test~0.9', 'test~0.9'), // valid proximity - array('test~10', 'test~10'), // illegal prox. (leave alone) - array('test~10 fish', 'test~10 fish'), // illegal prox. (leave alone) - array('^10 test^10', '10 test10'), // invalid boosts - array('^10', '10'), // invalid boosts - array('test^ test^6', 'test test6'), // invalid boosts - array('test^1 test^2', 'test^1 test^2'), // valid boosts - array('this / that', 'this that'), // freestanding slash - array('/ this', 'this'), // leading slash - array('title /', 'title'), // trailing slash - array('this - that', 'this that'), // freestanding hyphen - array('- this', 'this'), // leading hyphen - array('title -', 'title'), // trailing hyphen - array('AND', 'and'), // freestanding operator - array('OR', 'or'), // freestanding operator - array('NOT', 'not'), // freestanding operator - array('*bad', 'bad'), // leading wildcard - array('?bad', 'bad'), // leading wildcard - array("\xE2\x80\x9Ca\xE2\x80\x9D", '"a"'),// fancy quotes - array('a:{a TO b} [ }', 'a:{a TO b}'), // floating braces/brackets - ); + $tests = [ + ["", "*:*"], // empty query + ["()", "*:*"], // empty parens + ["((()))", "*:*"], // nested empty parens + ["((())", "*:*"], // mismatched parens + ["this that ()", "this that"], // text mixed w/ empty parens + ['"()"', '"()"'], // empty parens in quotes + ['title - sub', 'title sub'], // freestanding hyphen + ['"title - sub"', '"title - sub"'], // freestanding hyphen in quotes + ['test~1', 'test'], // meaningless proximity + ['test~1.', 'test'], // meaningless proximity w/dec. + ['test~1.000', 'test'], // meaningless proximity w/dec. + ['test~1 fish', 'test fish'], // meaningless proximity + ['test~1. fish', 'test fish'], // meaningless proximity w/dec. + ['test~1.000 fish', 'test fish'], // meaningless proximity w/dec. + ['"test~1"', '"test~1"'], // meaningless prox. in quotes + ['test~0.9', 'test~0.9'], // valid proximity + ['test~10', 'test~10'], // illegal prox. (leave alone) + ['test~10 fish', 'test~10 fish'], // illegal prox. (leave alone) + ['^10 test^10', '10 test10'], // invalid boosts + ['^10', '10'], // invalid boosts + ['test^ test^6', 'test test6'], // invalid boosts + ['test^1 test^2', 'test^1 test^2'], // valid boosts + ['this / that', 'this that'], // freestanding slash + ['/ this', 'this'], // leading slash + ['title /', 'title'], // trailing slash + ['this - that', 'this that'], // freestanding hyphen + ['- this', 'this'], // leading hyphen + ['title -', 'title'], // trailing hyphen + ['AND', 'and'], // freestanding operator + ['OR', 'or'], // freestanding operator + ['NOT', 'not'], // freestanding operator + ['*bad', 'bad'], // leading wildcard + ['?bad', 'bad'], // leading wildcard + ["\xE2\x80\x9Ca\xE2\x80\x9D", '"a"'],// fancy quotes + ['a:{a TO b} [ }', 'a:{a TO b}'], // floating braces/brackets + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder(); @@ -110,15 +110,15 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase { // Set up an array of expected inputs and outputs: // @codingStandardsIgnoreStart - $tests = array( - array('this?', '((this?) OR (this\?))'),// trailing question mark - ); + $tests = [ + ['this?', '((this?) OR (this\?))'],// trailing question mark + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder( - array( - 'test' => array() - ) + [ + 'test' => [] + ] ); foreach ($tests as $test) { list($input, $output) = $test; @@ -138,14 +138,14 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testExactQueryHandler() { $qb = new QueryBuilder( - array( - 'test' => array( - 'DismaxFields' => array('a', 'b'), - 'ExactSettings' => array( - 'DismaxFields' => array('c', 'd') - ) - ) - ) + [ + 'test' => [ + 'DismaxFields' => ['a', 'b'], + 'ExactSettings' => [ + 'DismaxFields' => ['c', 'd'] + ] + ] + ] ); // non-quoted search uses main DismaxFields @@ -169,9 +169,9 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testQueryHandlerWithFilterQueryAndDisMax() { $qb = new QueryBuilder( - array( - 'test' => array('DismaxFields' => array('a'), 'FilterQuery' => 'a:filter') - ) + [ + 'test' => ['DismaxFields' => ['a'], 'FilterQuery' => 'a:filter'] + ] ); $q = new Query('q', 'test'); $response = $qb->build($q); @@ -187,9 +187,9 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testQueryHandlerWithFilterQueryAndNoDisMax() { $qb = new QueryBuilder( - array( - 'test' => array('FilterQuery' => 'a:filter') - ) + [ + 'test' => ['FilterQuery' => 'a:filter'] + ] ); $q = new Query('q', 'test'); $response = $qb->build($q); @@ -206,9 +206,9 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testMatchAllQueryWithFilterQueryAndNoDisMax() { $qb = new QueryBuilder( - array( - 'test' => array('FilterQuery' => 'a:filter') - ) + [ + 'test' => ['FilterQuery' => 'a:filter'] + ] ); $q = new Query('*:*', 'test'); $response = $qb->build($q); @@ -224,12 +224,12 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testHighlighting() { $qb = new QueryBuilder( - array( - 'test' => array( - 'DismaxFields' => array('test1'), - 'DismaxParams' => array(array('bq', 'boost')) - ) - ) + [ + 'test' => [ + 'DismaxFields' => ['test1'], + 'DismaxParams' => [['bq', 'boost']] + ] + ] ); $q = new Query('*:*', 'test'); @@ -255,12 +255,12 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testSpelling() { $qb = new QueryBuilder( - array( - 'test' => array( - 'DismaxFields' => array('test1'), - 'DismaxParams' => array(array('bq', 'boost')) - ) - ) + [ + 'test' => [ + 'DismaxFields' => ['test1'], + 'DismaxParams' => [['bq', 'boost']] + ] + ] ); $q = new Query('my friend', 'test'); @@ -286,19 +286,19 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testQueryGroup() { $qb = new QueryBuilder( - array( - 'a' => array( - 'DismaxFields' => array('field_a'), - ), - 'b' => array( - 'DismaxFields' => array('field_b'), - ) - ) + [ + 'a' => [ + 'DismaxFields' => ['field_a'], + ], + 'b' => [ + 'DismaxFields' => ['field_b'], + ] + ] ); $q1 = new Query('value1', 'a'); $q2 = new Query('value2', 'b'); - $q = new QueryGroup('OR', array($q1, $q2)); + $q = new QueryGroup('OR', [$q1, $q2]); $response = $qb->build($q); $processedQ = $response->get('q'); @@ -313,23 +313,23 @@ class QueryBuilderTest extends \VuFindTest\Unit\TestCase public function testQueryGroupWithAdvancedSyntax() { $qb = new QueryBuilder( - array( - 'a' => array( - 'DismaxFields' => array('field_a'), - 'QueryFields' => array( - 'field_a' => array(array('and', 100)), - 'field_c' => array(array('and', 200)) - ) - ), - 'b' => array( - 'DismaxFields' => array('field_b'), - ) - ) + [ + 'a' => [ + 'DismaxFields' => ['field_a'], + 'QueryFields' => [ + 'field_a' => [['and', 100]], + 'field_c' => [['and', 200]] + ] + ], + 'b' => [ + 'DismaxFields' => ['field_b'], + ] + ] ); $q1 = new Query('value*', 'a'); $q2 = new Query('value2', 'b'); - $q = new QueryGroup('OR', array($q1, $q2)); + $q = new QueryGroup('OR', [$q1, $q2]); $response = $qb->build($q); $processedQ = $response->get('q'); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Record/SerializableRecordTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Record/SerializableRecordTest.php index e449eaf5ce2..5e44c2477d8 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Record/SerializableRecordTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Record/SerializableRecordTest.php @@ -48,7 +48,7 @@ class SerializableRecordTest extends \PHPUnit_Framework_TestCase */ public function testGetFields() { - $fields = array('a' => 'b'); + $fields = ['a' => 'b']; $sr = new SerializableRecord($fields); $this->assertEquals($fields, $sr->getFields()); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/FacetsTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/FacetsTest.php index 2b6c9425fd1..c0c6c601ab4 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/FacetsTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/FacetsTest.php @@ -50,12 +50,12 @@ class FacetsTest extends TestCase public function testFacets() { $facets = new Facets( - array( - 'facet_fields' => array( - 'field1' => array(array('a', 1), array('b', 2)) - ), - 'facet_queries' => array(), - ) + [ + 'facet_fields' => [ + 'field1' => [['a', 1], ['b', 2]] + ], + 'facet_queries' => [], + ] ); $this->assertCount(0, $facets->getQueryFacets()); $fieldFacets = $facets->getFieldFacets(); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/NamedListTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/NamedListTest.php index 9d68ead0b43..c54e20b650a 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/NamedListTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/NamedListTest.php @@ -49,12 +49,12 @@ class NamedListTest extends TestCase */ public function testIterate() { - $list = new NamedList(array(array('first term', 'info'), array('second term', 'info'))); - $keys = array(); + $list = new NamedList([['first term', 'info'], ['second term', 'info']]); + $keys = []; foreach ($list as $key => $value) { $keys [] = $key; } - $this->assertEquals(array('first term', 'second term'), $keys); + $this->assertEquals(['first term', 'second term'], $keys); } /** @@ -64,7 +64,7 @@ class NamedListTest extends TestCase */ public function testCountable() { - $list = new NamedList(array(array('first term', 'info'), array('second term', 'info'))); + $list = new NamedList([['first term', 'info'], ['second term', 'info']]); $this->assertEquals(2, count($list)); } @@ -75,7 +75,7 @@ class NamedListTest extends TestCase */ public function testToArray() { - $list = new NamedList(array(array('first term', 'info'), array('second term', 'info2'))); - $this->assertEquals(array('first term' => 'info', 'second term' => 'info2'), $list->toArray()); + $list = new NamedList([['first term', 'info'], ['second term', 'info2']]); + $this->assertEquals(['first term' => 'info', 'second term' => 'info2'], $list->toArray()); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php index 09fe61f621d..9fb24f03b87 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionFactoryTest.php @@ -49,7 +49,7 @@ class RecordCollectionFactoryTest extends PHPUnit_Framework_TestCase */ public function testFactory() { - $json = json_encode(array('response' => array('start' => 0, 'docs' => array(array(), array(), array())))); + $json = json_encode(['response' => ['start' => 0, 'docs' => [[], [], []]]]); $fact = new RecordCollectionFactory(); $coll = $fact->factory(json_decode($json, true)); $this->assertEquals(3, count($coll)); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionTest.php index a2c1210b0b9..d9b04653638 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/RecordCollectionTest.php @@ -50,7 +50,7 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $coll = new RecordCollection(array()); + $coll = new RecordCollection([]); $this->assertEquals( 'VuFindSearch\Backend\Solr\Response\Json\Spellcheck', get_class($coll->getSpellcheck()) @@ -60,8 +60,8 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase 'VuFindSearch\Backend\Solr\Response\Json\Facets', get_class($coll->getFacets()) ); - $this->assertEquals(array(), $coll->getGroups()); - $this->assertEquals(array(), $coll->getHighlighting()); + $this->assertEquals([], $coll->getGroups()); + $this->assertEquals([], $coll->getHighlighting()); $this->assertEquals(0, $coll->getOffset()); } @@ -73,9 +73,9 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase public function testOffsets() { $coll = new RecordCollection( - array( - 'response' => array('numFound' => 10, 'start' => 5) - ) + [ + 'response' => ['numFound' => 10, 'start' => 5] + ] ); for ($i = 0; $i < 5; $i++) { $coll->add($this->getMock('VuFindSearch\Response\RecordInterface')); @@ -93,14 +93,14 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testSpellingQuery() { - $input = array( - 'responseHeader' => array( - 'params' => array( + $input = [ + 'responseHeader' => [ + 'params' => [ 'spellcheck.q' => 'foo', 'q' => 'bar', - ) - ) - ); + ] + ] + ]; $coll = new RecordCollection($input); $this->assertEquals('foo', $coll->getSpellcheck()->getQuery()); unset($input['responseHeader']['params']['spellcheck.q']); @@ -115,32 +115,32 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testSpellingSuggestions() { - $input = array( - 'spellcheck' => array( - 'suggestions' => array( - array( + $input = [ + 'spellcheck' => [ + 'suggestions' => [ + [ 'frunkensteen', - array( + [ 'numFound' => 6, 'startOffset' => 0, 'endOffset' => 12, 'origFreq' => 0, - 'suggestion' => array( - array( + 'suggestion' => [ + [ 'word' => 'frankenstein', 'freq' => 218, - ), - array( + ], + [ 'word' => 'funkenstein', 'freq' => 10, - ), - ), - ), - ), - array('correctlySpelled', false), - ) - ) - ); + ], + ], + ], + ], + ['correctlySpelled', false], + ] + ] + ]; $coll = new RecordCollection($input); $spell = $coll->getSpellcheck(); $this->assertEquals(1, count($spell)); @@ -153,17 +153,17 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testReplace() { - $coll = new RecordCollection(array()); + $coll = new RecordCollection([]); $r1 = new TestHarness(); - $r1->setRawData(array('UniqueId' => 1)); + $r1->setRawData(['UniqueId' => 1]); $r2 = new TestHarness(); - $r2->setRawData(array('UniqueId' => 2)); + $r2->setRawData(['UniqueId' => 2]); $r3 = new TestHarness(); - $r3->setRawData(array('UniqueId' => 3)); + $r3->setRawData(['UniqueId' => 3]); $coll->add($r1); $coll->add($r2); $coll->replace($r1, $r3); - $this->assertEquals(array($r3, $r2), $coll->getRecords()); + $this->assertEquals([$r3, $r2], $coll->getRecords()); } /** @@ -175,13 +175,13 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase { // Since shuffle is random, there is no 100% reliable way to test its // behavior, but we can at least test that it doesn't corrupt anything. - $coll = new RecordCollection(array()); + $coll = new RecordCollection([]); $r1 = new TestHarness(); - $r1->setRawData(array('UniqueId' => 1)); + $r1->setRawData(['UniqueId' => 1]); $r2 = new TestHarness(); - $r2->setRawData(array('UniqueId' => 2)); + $r2->setRawData(['UniqueId' => 2]); $r3 = new TestHarness(); - $r3->setRawData(array('UniqueId' => 3)); + $r3->setRawData(['UniqueId' => 3]); $coll->add($r1); $coll->add($r2); $coll->add($r3); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/SpellcheckTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/SpellcheckTest.php index f0c32e9b6c1..b4234b94423 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/SpellcheckTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/SpellcheckTest.php @@ -50,19 +50,19 @@ class SpellcheckTest extends TestCase public function testMerge() { $s1 = new Spellcheck( - array( - array('this is a phrase', array()), - array('foo', array()), - array('foobar', array()) - ), + [ + ['this is a phrase', []], + ['foo', []], + ['foobar', []] + ], 'fake query' ); $s2 = new Spellcheck( - array( - array('is a', array()), - array('bar', array()), - array('foo bar', array()) - ), + [ + ['is a', []], + ['bar', []], + ['foo bar', []] + ], 'fake query' ); $s1->mergeWith($s2); @@ -77,9 +77,9 @@ class SpellcheckTest extends TestCase */ public function testDoubleMerge() { - $s1 = new Spellcheck(array(array('a', array())), 'fake'); - $s2 = new Spellcheck(array(array('b', array())), 'fake'); - $s3 = new Spellcheck(array(array('c', array())), 'fake'); + $s1 = new Spellcheck([['a', []]], 'fake'); + $s2 = new Spellcheck([['b', []]], 'fake'); + $s3 = new Spellcheck([['c', []]], 'fake'); $s1->mergeWith($s2); $s1->mergeWith($s3); $this->assertCount(3, $s1); @@ -94,8 +94,8 @@ class SpellcheckTest extends TestCase */ public function testExactDuplication() { - $s1 = new Spellcheck(array(array('a', array())), 'fake'); - $s2 = new Spellcheck(array(array('a', array())), 'fake'); + $s1 = new Spellcheck([['a', []]], 'fake'); + $s2 = new Spellcheck([['a', []]], 'fake'); $s1->mergeWith($s2); $this->assertCount(1, $s1); } @@ -107,7 +107,7 @@ class SpellcheckTest extends TestCase */ public function testGetQuery() { - $s = new Spellcheck(array(), 'test'); + $s = new Spellcheck([], 'test'); $this->assertEquals('test', $s->getQuery()); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/TermsTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/TermsTest.php index 20c9e59b5f4..3ba747c0781 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/TermsTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/Response/Json/TermsTest.php @@ -49,13 +49,13 @@ class TermsTest extends TestCase */ public function testTerms() { - $field1 = array(array('a', 1), array('b', 2), array('c', 3)); + $field1 = [['a', 1], ['b', 2], ['c', 3]]; $terms = new Terms( - array( - 'terms' => array( + [ + 'terms' => [ 'field1' => $field1, - ) - ) + ] + ] ); $this->assertEquals('ArrayIterator', get_class($terms->getIterator())); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/SearchHandlerTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/SearchHandlerTest.php index cc5beb15d88..e8ea3966dcb 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/SearchHandlerTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/SearchHandlerTest.php @@ -49,7 +49,7 @@ class SearchHandlerTest extends PHPUnit_Framework_TestCase */ public function testSimpleSearchDismax() { - $spec = array('DismaxParams' => array(array('foo', 'bar')), 'DismaxFields' => array('field1', 'field2')); + $spec = ['DismaxParams' => [['foo', 'bar']], 'DismaxFields' => ['field1', 'field2']]; $hndl = new SearchHandler($spec); $this->assertEquals('(_query_:"{!dismax qf=\"field1 field2\" foo=\\\'bar\\\'}foobar")', $hndl->createSimpleQueryString('foobar')); } @@ -61,9 +61,9 @@ class SearchHandlerTest extends PHPUnit_Framework_TestCase */ public function testToArray() { - $spec = array('DismaxParams' => array(array('foo', 'bar')), 'DismaxFields' => array('field1', 'field2')); + $spec = ['DismaxParams' => [['foo', 'bar']], 'DismaxFields' => ['field1', 'field2']]; $hndl = new SearchHandler($spec); - $defaults = array('CustomMunge' => array(), 'DismaxHandler' => 'dismax', 'QueryFields' => array(), 'FilterQuery' => array()); + $defaults = ['CustomMunge' => [], 'DismaxHandler' => 'dismax', 'QueryFields' => [], 'FilterQuery' => []]; $this->assertEquals($spec + $defaults, $hndl->toArray()); } @@ -74,7 +74,7 @@ class SearchHandlerTest extends PHPUnit_Framework_TestCase */ public function testSimpleSearchExtendedDismax() { - $spec = array('DismaxParams' => array(array('foo', 'bar')), 'DismaxFields' => array('field1', 'field2')); + $spec = ['DismaxParams' => [['foo', 'bar']], 'DismaxFields' => ['field1', 'field2']]; $hndl = new SearchHandler($spec, 'edismax'); $this->assertEquals('(_query_:"{!edismax qf=\"field1 field2\" foo=\\\'bar\\\'}foobar")', $hndl->createSimpleQueryString('foobar')); } @@ -87,31 +87,31 @@ class SearchHandlerTest extends PHPUnit_Framework_TestCase public function testCustomMunge() { // fake munge rules based on a simplified version of default searchspecs.yaml - $spec = array( - 'CustomMunge' => array( - 'callnumber_exact' => array( - array('uppercase'), - array('preg_replace', '/[ "]/', ""), - array('preg_replace', '/\*+$/', "") - ), - 'callnumber_fuzzy' => array( - array('uppercase'), - array('preg_replace', '/[ "]/', ""), - array('preg_replace', '/\*+$/', ""), - array('append', '*') - ) - ), - 'QueryFields' => array( - 'callnumber' => array( - array('callnumber_exact', 1000), - array('callnumber_fuzzy', '~'), - ), - 'dewey-full' => array( - array('callnumber_exact', 1000), - array('callnumber_fuzzy', '~'), - ) - ) - ); + $spec = [ + 'CustomMunge' => [ + 'callnumber_exact' => [ + ['uppercase'], + ['preg_replace', '/[ "]/', ""], + ['preg_replace', '/\*+$/', ""] + ], + 'callnumber_fuzzy' => [ + ['uppercase'], + ['preg_replace', '/[ "]/', ""], + ['preg_replace', '/\*+$/', ""], + ['append', '*'] + ] + ], + 'QueryFields' => [ + 'callnumber' => [ + ['callnumber_exact', 1000], + ['callnumber_fuzzy', '~'], + ], + 'dewey-full' => [ + ['callnumber_exact', 1000], + ['callnumber_fuzzy', '~'], + ] + ] + ]; $hndl = new SearchHandler($spec); $this->assertEquals( diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php index d833cbcdcc6..bac4d299d2a 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/BackendTest.php @@ -68,7 +68,7 @@ class BackendTest extends TestCase */ public function testRetrieve() { - $conn = $this->getConnectorMock(array('getRecord')); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') ->will($this->returnValue($this->loadResponse('single-record'))); @@ -90,13 +90,13 @@ class BackendTest extends TestCase */ public function testRetrieveBatch() { - $conn = $this->getConnectorMock(array('query')); - $expected1 = new SummonQuery(null, array('idsToFetch' => range(1, 50), 'pageNumber' => 1, 'pageSize' => 50)); + $conn = $this->getConnectorMock(['query']); + $expected1 = new SummonQuery(null, ['idsToFetch' => range(1, 50), 'pageNumber' => 1, 'pageSize' => 50]); $conn->expects($this->at(0)) ->method('query') ->with($this->equalTo($expected1)) ->will($this->returnValue($this->loadResponse('retrieve1'))); - $expected2 = new SummonQuery(null, array('idsToFetch' => range(51, 60), 'pageNumber' => 1, 'pageSize' => 50)); + $expected2 = new SummonQuery(null, ['idsToFetch' => range(51, 60), 'pageNumber' => 1, 'pageSize' => 50]); $conn->expects($this->at(1)) ->method('query') ->with($this->equalTo($expected2)) @@ -125,7 +125,7 @@ class BackendTest extends TestCase public function testRetrieveWrapsSummonException() { $fact = $this->getMock('VuFindSearch\Response\RecordCollectionFactoryInterface'); - $conn = $this->getConnectorMock(array('getRecord')); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') ->will($this->throwException(new SummonException())); @@ -140,7 +140,7 @@ class BackendTest extends TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->returnValue($this->loadResponse('search'))); @@ -162,7 +162,7 @@ class BackendTest extends TestCase $facets = $coll->getFacets(); $this->assertEquals('Language', $facets[0]['displayName']); $this->assertEquals(0, $coll->getOffset()); - $this->assertEquals(array(), $coll->getSpellcheck()); + $this->assertEquals([], $coll->getSpellcheck()); $this->assertEquals(false, $coll->getBestBets()); $this->assertEquals(false, $coll->getDatabaseRecommendations()); } @@ -176,7 +176,7 @@ class BackendTest extends TestCase public function testSearchWrapsSummonException() { $fact = $this->getMock('VuFindSearch\Response\RecordCollectionFactoryInterface'); - $conn = $this->getConnectorMock(array('query')); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->will($this->throwException(new SummonException())); @@ -191,13 +191,13 @@ class BackendTest extends TestCase */ public function testMergedParamBag() { - $myParams = new ParamBag(array('maxTopics' => 32)); - $expectedParams = new SummonQuery('boo:(baz)', array('pageSize' => 10, 'pageNumber' => 1.0, 'maxTopics' => 32)); - $conn = $this->getConnectorMock(array('query')); + $myParams = new ParamBag(['maxTopics' => 32]); + $expectedParams = new SummonQuery('boo:(baz)', ['pageSize' => 10, 'pageNumber' => 1.0, 'maxTopics' => 32]); + $conn = $this->getConnectorMock(['query']); $conn->expects($this->once()) ->method('query') ->with($this->equalTo($expectedParams)) - ->will($this->returnValue(array('recordCount' => 0, 'documents' => array()))); + ->will($this->returnValue(['recordCount' => 0, 'documents' => []])); $back = new Backend($conn); $back->search(new Query('baz', 'boo'), 0, 10, $myParams); } @@ -256,10 +256,10 @@ class BackendTest extends TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { return $this->getMock( - 'SerialsSolutions\Summon\Zend2', $mock, array('id', 'key') + 'SerialsSolutions\Summon\Zend2', $mock, ['id', 'key'] ); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/QueryBuilderTest.php index 46d1ce2ec48..4ade8283061 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/QueryBuilderTest.php @@ -52,10 +52,10 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase // Set up an array of expected inputs (serialized objects) and outputs // (queries): // @codingStandardsIgnoreStart - $tests = array( - array('basic', 'Author:(john smith)'), - array('advanced', '(Title:(bananas)) AND (SubjectTerms:(oranges) OR apples) NOT ((PublicationSeriesTitle:(pears)))') - ); + $tests = [ + ['basic', 'Author:(john smith)'], + ['advanced', '(Title:(bananas)) AND (SubjectTerms:(oranges) OR apples) NOT ((PublicationSeriesTitle:(pears)))'] + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder(); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionTest.php index 84da675c0ef..059d23c553a 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Summon/Response/RecordCollectionTest.php @@ -49,11 +49,11 @@ class RecordCollectionTest extends PHPUnit_Framework_TestCase */ public function testDefaults() { - $rc = new RecordCollection(array()); + $rc = new RecordCollection([]); $this->assertEquals(0, $rc->getTotal()); $this->assertEquals(0, $rc->getOffset()); - $this->assertEquals(array(), $rc->getFacets()); - $this->assertEquals(array(), $rc->getSpellcheck()); + $this->assertEquals([], $rc->getFacets()); + $this->assertEquals([], $rc->getSpellcheck()); $this->assertEquals(false, $rc->getBestBets()); $this->assertEquals(false, $rc->getDatabaseRecommendations()); $this->assertEquals(false, $rc->getTopicRecommendations()); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/BackendTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/BackendTest.php index 13d4aac92a0..dc66b82dc49 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/BackendTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/BackendTest.php @@ -51,7 +51,7 @@ class BackendTest extends PHPUnit_Framework_TestCase */ public function testRetrieve() { - $conn = $this->getConnectorMock(array('getRecord')); + $conn = $this->getConnectorMock(['getRecord']); $conn->expects($this->once()) ->method('getRecord') ->will($this->returnValue($this->loadResponse('single-record'))); @@ -73,7 +73,7 @@ class BackendTest extends PHPUnit_Framework_TestCase */ public function testSearch() { - $conn = $this->getConnectorMock(array('search')); + $conn = $this->getConnectorMock(['search']); $conn->expects($this->once()) ->method('search') ->will($this->returnValue($this->loadResponse('search'))); @@ -147,12 +147,12 @@ class BackendTest extends PHPUnit_Framework_TestCase * * @return array */ - protected function getConnectorMock(array $mock = array()) + protected function getConnectorMock(array $mock = []) { $client = $this->getMock('Zend\Http\Client'); return $this->getMock( 'VuFindSearch\Backend\WorldCat\Connector', - $mock, array('fake', $client) + $mock, ['fake', $client] ); } } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php index 11ae3cc9e06..205f6e762b6 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/ConnectorTest.php @@ -138,7 +138,7 @@ class ConnectorTest extends \PHPUnit_Framework_TestCase $client->expects($this->once())->method('send') ->will($this->returnValue($response)); $final = $connector->getRecord('baz'); - $this->assertEquals(array(), $final['docs']); + $this->assertEquals([], $final['docs']); } /** @@ -163,7 +163,7 @@ class ConnectorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $client->expects($this->once())->method('send') ->will($this->returnValue($response)); - $final = $connector->search(new ParamBag(array('x' => 'y')), 0, 20); + $final = $connector->search(new ParamBag(['x' => 'y']), 0, 20); $this->assertEquals('<recordData>bar</recordData>', $final['docs'][0]); $this->assertEquals(1, $final['total']); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/QueryBuilderTest.php index 8d660dda15f..74bbb293607 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/WorldCat/QueryBuilderTest.php @@ -52,10 +52,10 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase // Set up an array of expected inputs (serialized objects) and outputs // (queries): // @codingStandardsIgnoreStart - $tests = array( - array('basic', '(srw.au all "john smith" OR srw.pn all "john smith" OR srw.cn all "john smith")'), - array('advanced', '((srw.ti all "bananas" OR srw.se all "bananas")) AND ((srw.su all "oranges") OR (srw.su all "apples")) NOT (((srw.se all "pears")))') - ); + $tests = [ + ['basic', '(srw.au all "john smith" OR srw.pn all "john smith" OR srw.cn all "john smith")'], + ['advanced', '((srw.ti all "bananas" OR srw.se all "bananas")) AND ((srw.su all "oranges") OR (srw.su all "apples")) NOT (((srw.se all "pears")))'] + ]; // @codingStandardsIgnoreEnd $qb = new QueryBuilder(); diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/ParamBagTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/ParamBagTest.php index 02b63722053..73f0899a959 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/ParamBagTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/ParamBagTest.php @@ -54,7 +54,7 @@ class ParamBagTest extends TestCase $bag->set('foo', 'bar'); $bag->set('bar', 'baz'); $bag->remove('foo'); - $this->assertEquals(array('bar' => array('baz')), $bag->getArrayCopy()); + $this->assertEquals(['bar' => ['baz']], $bag->getArrayCopy()); } /** @@ -64,10 +64,10 @@ class ParamBagTest extends TestCase */ public function testMergeWithAll() { - $bag1 = new ParamBag(array('a' => 1)); - $bag2 = new ParamBag(array('b' => 2)); - $bag3 = new ParamBag(array('c' => 3)); - $bag3->mergeWithAll(array($bag1, $bag2)); - $this->assertEquals(array('a' => array(1), 'b' => array(2), 'c' => array(3)), $bag3->getArrayCopy()); + $bag1 = new ParamBag(['a' => 1]); + $bag2 = new ParamBag(['b' => 2]); + $bag3 = new ParamBag(['c' => 3]); + $bag3->mergeWithAll([$bag1, $bag2]); + $this->assertEquals(['a' => [1], 'b' => [2], 'c' => [3]], $bag3->getArrayCopy()); } } \ No newline at end of file diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php index 38d0a95d1fd..87ccae852b1 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Query/QueryGroupTest.php @@ -141,6 +141,6 @@ class QueryGroupTest extends PHPUnit_Framework_TestCase $q1 = new Query('test'); $q2 = new Query('query'); $q3 = new Query('multi word query'); - return new QueryGroup('OR', array($q1, $q2, $q3)); + return new QueryGroup('OR', [$q1, $q2, $q3]); } } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php index 8134b464574..678eaf76a90 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/SearchServiceTest.php @@ -68,7 +68,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); $response = 'fake'; - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $backend->expects($this->once())->method('retrieve') ->with($this->equalTo('bar'), $this->equalTo($params)) ->will($this->returnValue($response)); @@ -91,7 +91,7 @@ class SearchServiceTest extends TestCase { $service = $this->getService(); $backend = $this->getBackend(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $exception = new BackendException('test'); $backend->expects($this->once())->method('retrieve') ->with($this->equalTo('bar'), $this->equalTo($params)) @@ -138,8 +138,8 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); - $params = new ParamBag(array('x' => 'y')); - $ids = array('bar', 'baz'); + $params = new ParamBag(['x' => 'y']); + $ids = ['bar', 'baz']; $backend->expects($this->once(0))->method('retrieveBatch') ->with($this->equalTo($ids), $this->equalTo($params)) ->will($this->returnValue('response')); @@ -170,7 +170,7 @@ class SearchServiceTest extends TestCase $response2 = $this->getRecordCollection(); $response2->expects($this->once())->method('first') ->will($this->returnValue($mockRecord)); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $backend->expects($this->at(0))->method('retrieve') ->with($this->equalTo('bar'), $this->equalTo($params)) ->will($this->returnValue($response1)); @@ -182,7 +182,7 @@ class SearchServiceTest extends TestCase ->with($this->equalTo('pre'), $this->equalTo($backend)); $em->expects($this->at(1))->method('trigger') ->with($this->equalTo('post'), $this->equalTo($response1)); - $service->retrieveBatch('foo', array('bar', 'baz'), $params); + $service->retrieveBatch('foo', ['bar', 'baz'], $params); } /** @@ -199,9 +199,9 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $exception = new BackendException('test'); - $ids = array('bar', 'baz'); + $ids = ['bar', 'baz']; $backend->expects($this->once(0))->method('retrieveBatch') ->with($this->equalTo($ids), $this->equalTo($params)) ->will($this->throwException($exception)); @@ -228,7 +228,7 @@ class SearchServiceTest extends TestCase { $service = $this->getService(); $backend = $this->getBackend(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $exception = new BackendException('test'); $backend->expects($this->once())->method('retrieve') ->with($this->equalTo('bar'), $this->equalTo($params)) @@ -238,7 +238,7 @@ class SearchServiceTest extends TestCase ->with($this->equalTo('pre'), $this->equalTo($backend)); $em->expects($this->at(1))->method('trigger') ->with($this->equalTo('error'), $this->equalTo($exception)); - $service->retrieveBatch('foo', array('bar'), $params); + $service->retrieveBatch('foo', ['bar'], $params); } /** @@ -254,7 +254,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); $response = $this->getRecordCollection(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); $backend->expects($this->once())->method('random') @@ -290,7 +290,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); $exception = new BackendException('test'); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); $backend->expects($this->once())->method('random') @@ -324,7 +324,7 @@ class SearchServiceTest extends TestCase $backend = $this->getBackend(); $responseForZero = $this->getRecordCollection(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // First Search Grabs 0 records but uses get total method @@ -374,7 +374,7 @@ class SearchServiceTest extends TestCase $backend = $this->getBackend(); $responseForZero = $this->getRecordCollection(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // First Search Grabs 0 records but uses get total method @@ -412,7 +412,7 @@ class SearchServiceTest extends TestCase $responseForZero = $this->getRecordCollection(); $response = $this->getRecordCollection(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // First Search Grabs 0 records but uses get total method @@ -457,7 +457,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); $exception = new BackendException('test'); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // Exception at first search @@ -487,7 +487,7 @@ class SearchServiceTest extends TestCase $responseForZero = $this->getRecordCollection(); $exception = new BackendException('test'); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // First Search Grabs 0 records but uses get total method @@ -530,7 +530,7 @@ class SearchServiceTest extends TestCase $response = $this->getRecordCollection(); $exception = new BackendException('test'); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $query = new Query('test'); // First Search Grabs 0 records but uses get total method @@ -570,7 +570,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); $response = 'fake'; - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $backend->expects($this->once())->method('similar') ->with($this->equalTo('bar'), $this->equalTo($params)) ->will($this->returnValue($response)); @@ -595,7 +595,7 @@ class SearchServiceTest extends TestCase public function testSimilarOnNonSupportingBackend() { $service = $this->getService(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $service->similar('foo', 'bar', $params); } @@ -613,7 +613,7 @@ class SearchServiceTest extends TestCase $service = $this->getService(); $backend = $this->getBackend(); - $params = new ParamBag(array('x' => 'y')); + $params = new ParamBag(['x' => 'y']); $exception = new BackendException('test'); $backend->expects($this->once())->method('similar') ->with($this->equalTo('bar'), $this->equalTo($params)) @@ -672,7 +672,7 @@ class SearchServiceTest extends TestCase protected function getService() { $em = $this->getMock('Zend\EventManager\EventManagerInterface'); - $service = $this->getMock('VuFindSearch\Service', array('resolve')); + $service = $this->getMock('VuFindSearch\Service', ['resolve']); $service->expects($this->any())->method('resolve') ->will($this->returnValue($this->getBackend())); $service->setEventManager($em); diff --git a/module/VuFindTheme/Module.php b/module/VuFindTheme/Module.php index 733322f7d2a..7de985e38ac 100644 --- a/module/VuFindTheme/Module.php +++ b/module/VuFindTheme/Module.php @@ -45,13 +45,13 @@ class Module */ public function getAutoloaderConfig() { - return array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + return [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); + ], + ], + ]; } /** @@ -61,15 +61,15 @@ class Module */ public function getServiceConfig() { - return array( - 'factories' => array( + return [ + 'factories' => [ 'VuFindTheme\ThemeInfo' => 'VuFindTheme\Module::getThemeInfo', - ), - 'invokables' => array( + ], + 'invokables' => [ 'VuFindTheme\Mobile' => 'VuFindTheme\Mobile', 'VuFindTheme\ResourceContainer' => 'VuFindTheme\ResourceContainer', - ), - ); + ], + ]; } /** @@ -79,8 +79,8 @@ class Module */ public function getViewHelperConfig() { - return array( - 'factories' => array( + return [ + 'factories' => [ 'headlink' => 'VuFindTheme\View\Helper\Factory::getHeadLink', 'headscript' => 'VuFindTheme\View\Helper\Factory::getHeadScript', 'headthemeresources' => @@ -89,8 +89,8 @@ class Module 'inlinescript' => 'VuFindTheme\View\Helper\Factory::getInlineScript', 'mobileurl' => 'VuFindTheme\View\Helper\Factory::getMobileUrl', - ), - ); + ], + ]; } /** diff --git a/module/VuFindTheme/src/VuFindTheme/Initializer.php b/module/VuFindTheme/src/VuFindTheme/Initializer.php index 53440dd3c7e..4ddb7985c09 100644 --- a/module/VuFindTheme/src/VuFindTheme/Initializer.php +++ b/module/VuFindTheme/src/VuFindTheme/Initializer.php @@ -154,7 +154,7 @@ class Initializer $injectTemplateListener = new InjectTemplateListener(); $sharedEvents->attach( 'Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, - array($injectTemplateListener, 'injectTemplate'), $priority + [$injectTemplateListener, 'injectTemplate'], $priority ); } @@ -272,7 +272,7 @@ class Initializer */ protected function getThemeOptions() { - $options = array(); + $options = []; if (isset($this->config->selectable_themes)) { $parts = explode(',', $this->config->selectable_themes); foreach ($parts as $part) { @@ -281,10 +281,10 @@ class Initializer $desc = isset($subparts[1]) ? trim($subparts[1]) : ''; $desc = empty($desc) ? $name : $desc; if (!empty($name)) { - $options[] = array( + $options[] = [ 'name' => $name, 'desc' => $desc, 'selected' => ($_COOKIE['ui'] == $name) - ); + ]; } } } @@ -317,7 +317,7 @@ class Initializer */ protected function setUpThemes($themes) { - $templatePathStack = array(); + $templatePathStack = []; // Grab the resource manager for tracking CSS, JS, etc.: $resources = $this->serviceManager->get('VuFindTheme\ResourceContainer'); diff --git a/module/VuFindTheme/src/VuFindTheme/LessCompiler.php b/module/VuFindTheme/src/VuFindTheme/LessCompiler.php index 9697eec78ad..a128979ac8a 100644 --- a/module/VuFindTheme/src/VuFindTheme/LessCompiler.php +++ b/module/VuFindTheme/src/VuFindTheme/LessCompiler.php @@ -159,13 +159,13 @@ class LessCompiler { $config = $this->basePath . '/themes/' . $theme . '/theme.config.php'; if (!file_exists($config)) { - return array(); + return []; } $configArr = include $config; $base = (isset($configArr['extends'])) ? $this->getAllLessFiles($configArr['extends']) - : array(); - $current = isset($configArr['less']) ? $configArr['less'] : array(); + : []; + $current = isset($configArr['less']) ? $configArr['less'] : []; return array_merge($base, $current); } @@ -189,7 +189,7 @@ class LessCompiler $this->logMessage("\tcompiling '" . $less . "' into '" . $finalFile . "'"); $start = microtime(true); - $directories = array(); + $directories = []; $info = new ThemeInfo($this->basePath . '/themes', $theme); foreach (array_keys($info->getThemeInfo()) as $curTheme) { $directories["{$this->basePath}/themes/$curTheme/less/"] @@ -203,13 +203,13 @@ class LessCompiler return; } $outFile = \Less_Cache::Regen( - array($lessDir . $less => $this->fakePath . "themes/$theme/css/less"), - array( + [$lessDir . $less => $this->fakePath . "themes/$theme/css/less"], + [ 'cache_dir' => $this->tempPath, 'cache_method' => false, 'compress' => true, 'import_dirs' => $directories - ) + ] ); $css = file_get_contents($this->tempPath . '/' . $outFile); if (!is_dir(dirname($finalFile))) { @@ -253,7 +253,7 @@ class LessCompiler { $baseDir = $this->basePath . '/themes/'; $dir = opendir($baseDir); - $list = array(); + $list = []; while ($line = readdir($dir)) { if (is_dir($baseDir . $line) && file_exists($baseDir . $line . '/theme.config.php') diff --git a/module/VuFindTheme/src/VuFindTheme/ResourceContainer.php b/module/VuFindTheme/src/VuFindTheme/ResourceContainer.php index 309fd4ecbb6..27cf61cbe27 100644 --- a/module/VuFindTheme/src/VuFindTheme/ResourceContainer.php +++ b/module/VuFindTheme/src/VuFindTheme/ResourceContainer.php @@ -43,21 +43,21 @@ class ResourceContainer * * @var array */ - protected $less = array(); + protected $less = []; /** * CSS files * * @var array */ - protected $css = array(); + protected $css = []; /** * Javascript files * * @var array */ - protected $js = array(); + protected $js = []; /** * Favicon @@ -90,7 +90,7 @@ class ResourceContainer public function addLessCss($less) { if (!is_array($less) && !is_a($less, 'Traversable')) { - $less = array($less); + $less = [$less]; } unset($less['active']); foreach ($less as $current) { @@ -110,7 +110,7 @@ class ResourceContainer public function addCss($css) { if (!is_array($css) && !is_a($css, 'Traversable')) { - $css = array($css); + $css = [$css]; } foreach ($css as $current) { if (!$this->dynamicallyParsed($current)) { @@ -130,7 +130,7 @@ class ResourceContainer public function addJs($js) { if (!is_array($js) && !is_a($js, 'Traversable')) { - $js = array($js); + $js = [$js]; } foreach ($js as $current) { $this->js[] = $current; diff --git a/module/VuFindTheme/src/VuFindTheme/ThemeInfo.php b/module/VuFindTheme/src/VuFindTheme/ThemeInfo.php index fd385ce2b8a..98aaf955abe 100644 --- a/module/VuFindTheme/src/VuFindTheme/ThemeInfo.php +++ b/module/VuFindTheme/src/VuFindTheme/ThemeInfo.php @@ -146,7 +146,7 @@ class ThemeInfo // Fill in the theme info cache if it is not already populated: if (null === $this->allThemeInfo) { // Build an array of theme information by inheriting up the theme tree: - $this->allThemeInfo = array(); + $this->allThemeInfo = []; $currentTheme = $this->getTheme(); do { $this->allThemeInfo[$currentTheme] @@ -174,7 +174,7 @@ class ThemeInfo { $basePath = $this->getBaseDir(); $allPaths = is_array($relativePath) - ? $relativePath : array($relativePath); + ? $relativePath : [$relativePath]; $currentTheme = $this->getTheme(); $allThemeInfo = $this->getThemeInfo(); @@ -186,7 +186,7 @@ class ThemeInfo if (true === $returnType) { return $file; } else if (self::RETURN_ALL_DETAILS === $returnType) { - return array('path' => $file, 'theme' => $currentTheme); + return ['path' => $file, 'theme' => $currentTheme]; } // Default return type: return $currentTheme; diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadLink.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadLink.php index 14d3dd5c718..4df32618025 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadLink.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadLink.php @@ -102,25 +102,25 @@ class HeadLink extends \Zend\View\Helper\HeadLink $cssDirectory = $helperHome . 'themes/' . $currentTheme . '/css/less/'; try { - $less_files = array( + $less_files = [ APPLICATION_PATH . '/themes/' . $currentTheme . '/' . $relPath => $cssDirectory - ); + ]; $themeParents = array_keys($this->themeInfo->getThemeInfo()); - $directories = array(); + $directories = []; foreach ($themeParents as $theme) { $directories[APPLICATION_PATH . '/themes/' . $theme . '/less/'] = $helperHome . 'themes/' . $theme . '/css/less/'; } $css_file_name = \Less_Cache::Get( $less_files, - array( + [ 'cache_dir' => $home . 'css/less/', 'cache_method' => false, 'compress' => true, 'import_dirs' => $directories, 'output' => str_replace('.less', '.css', $file) - ) + ] ); $this->prependStylesheet( $cssDirectory . $css_file_name, $media, $conditionalStylesheet diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php index 602a042d25c..4b279a3f216 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php @@ -124,10 +124,10 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper $favicon = $this->container->getFavicon(); if (!empty($favicon)) { $imageLink = $this->getView()->plugin('imagelink'); - $headLink(array( + $headLink([ 'href' => $imageLink($favicon), 'type' => 'image/x-icon', 'rel' => 'shortcut icon' - )); + ]); } } @@ -146,7 +146,7 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper trim($parts[0]), 'text/javascript', isset($parts[1]) - ? array('conditional' => trim($parts[1])) : array() + ? ['conditional' => trim($parts[1])] : [] ); } } diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/InlineScript.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/InlineScript.php index 33def484022..644d275e832 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/InlineScript.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/InlineScript.php @@ -59,7 +59,7 @@ class InlineScript extends HeadScript * @return InlineScript */ public function __invoke($mode = HeadScript::FILE, $spec = null, - $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript' + $placement = 'APPEND', array $attrs = [], $type = 'text/javascript' ) { return parent::__invoke($mode, $spec, $placement, $attrs, $type); } diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/MobileUrl.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/MobileUrl.php index b89c8775c49..778ac0bdfea 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/MobileUrl.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/MobileUrl.php @@ -72,7 +72,7 @@ class MobileUrl extends \Zend\View\Helper\AbstractHelper $urlHelper = $this->getView()->plugin('serverurl'); $currentUrl = $urlHelper(true); $currentUrl = preg_replace( - array('/\&ui=[^&]*/', '/\?ui=[^&]*\&?/'), array('', '?'), $currentUrl + ['/\&ui=[^&]*/', '/\?ui=[^&]*\&?/'], ['', '?'], $currentUrl ); $currentUrl = rtrim($currentUrl, '?'); $currentUrl .= strstr($currentUrl, '?') ? '&' : '?'; diff --git a/module/VuFindTheme/tests/unit-tests/bootstrap.php b/module/VuFindTheme/tests/unit-tests/bootstrap.php index e8a15882941..1a7694d7214 100644 --- a/module/VuFindTheme/tests/unit-tests/bootstrap.php +++ b/module/VuFindTheme/tests/unit-tests/bootstrap.php @@ -9,13 +9,13 @@ */ require_once('Zend/Loader/AutoloaderFactory.php'); \Zend\Loader\AutoloaderFactory::factory( - array( - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( + [ + 'Zend\Loader\StandardAutoloader' => [ + 'namespaces' => [ 'VuFindTheme' => realpath(__DIR__ . '/../../src/VuFindTheme'), 'VuFindTest' => realpath(__DIR__ . '/src/VuFindTest'), - ), + ], 'autoregister_zf' => true - ) - ) + ] + ] ); diff --git a/module/VuFindTheme/tests/unit-tests/fixtures/themes/child/theme.config.php b/module/VuFindTheme/tests/unit-tests/fixtures/themes/child/theme.config.php index 5feedae8f9b..64db8df45e8 100644 --- a/module/VuFindTheme/tests/unit-tests/fixtures/themes/child/theme.config.php +++ b/module/VuFindTheme/tests/unit-tests/fixtures/themes/child/theme.config.php @@ -1,4 +1,4 @@ <?php -return array( +return [ 'extends' => 'parent', -); +]; diff --git a/module/VuFindTheme/tests/unit-tests/fixtures/themes/parent/theme.config.php b/module/VuFindTheme/tests/unit-tests/fixtures/themes/parent/theme.config.php index e67baba26d1..94c5760c4c7 100644 --- a/module/VuFindTheme/tests/unit-tests/fixtures/themes/parent/theme.config.php +++ b/module/VuFindTheme/tests/unit-tests/fixtures/themes/parent/theme.config.php @@ -1,4 +1,4 @@ <?php -return array( +return [ 'extends' => false, -); +]; diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php index 9f667ec6620..1a02b96aa51 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/LessCompilerTest.php @@ -116,7 +116,7 @@ class LessCompilerTest extends Unit\TestCase // adapted from http://php.net/manual/en/function.rmdir.php protected static function delTree($dir) { - $files = array_diff(scandir($dir), array('.', '..')); + $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { is_dir("$dir/$file") ? self::delTree("$dir/$file") : unlink("$dir/$file"); @@ -126,7 +126,7 @@ class LessCompilerTest extends Unit\TestCase public function testThemeCompile() { - $this->compiler->compile(array('child')); + $this->compiler->compile(['child']); $this->assertTrue(file_exists($this->testDest . 'themes/child/css/compiled.css')); $this->assertFalse(file_exists($this->testDest . 'themes/parent/css/compiled.css')); unlink($this->testDest . 'themes/child/css/compiled.css'); @@ -134,7 +134,7 @@ class LessCompilerTest extends Unit\TestCase public function testAllCompile() { - $this->compiler->compile(array()); + $this->compiler->compile([]); $this->assertTrue(file_exists($this->testDest . 'themes/child/css/compiled.css')); $this->assertTrue(file_exists($this->testDest . 'themes/parent/css/compiled.css')); $this->assertTrue(file_exists($this->testDest . 'themes/parent/css/relative/relative.css')); diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php index a446dd1884d..b5780ae9c76 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInfoTest.php @@ -98,7 +98,7 @@ class ThemeInfoTest extends Unit\TestCase { $ti = $this->getThemeInfo(); $ti->setTheme('child'); - $this->assertEquals(array('child' => array('extends' => 'parent'), 'parent' => array('extends' => false)), $ti->getThemeInfo()); + $this->assertEquals(['child' => ['extends' => 'parent'], 'parent' => ['extends' => false]], $ti->getThemeInfo()); } /** @@ -123,7 +123,7 @@ class ThemeInfoTest extends Unit\TestCase $this->assertEquals('child', $ti->findContainingTheme('child.txt')); $this->assertEquals('parent', $ti->findContainingTheme('parent.txt')); $this->assertEquals($this->fixturePath . '/parent/parent.txt', $ti->findContainingTheme('parent.txt', true)); - $expected = array('theme' => 'parent', 'path' => $this->fixturePath . '/parent/parent.txt'); + $expected = ['theme' => 'parent', 'path' => $this->fixturePath . '/parent/parent.txt']; $this->assertEquals($expected, $ti->findContainingTheme('parent.txt', ThemeInfo::RETURN_ALL_DETAILS)); } diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php index 80fede64290..b07de0ba226 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php @@ -48,7 +48,7 @@ class ThemeInjectTemplateListenerTest extends Unit\TestCase { $l = new InjectTemplateListener(); $this->assertEquals( - '', $this->callMethod($l, 'deriveModuleNamespace', array('dummy')) + '', $this->callMethod($l, 'deriveModuleNamespace', ['dummy']) ); } @@ -61,7 +61,7 @@ class ThemeInjectTemplateListenerTest extends Unit\TestCase { $l = new InjectTemplateListener(); $this->assertEquals( - 'testcase', $this->callMethod($l, 'inflectName', array('testCase')) + 'testcase', $this->callMethod($l, 'inflectName', ['testCase']) ); } } \ No newline at end of file diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeMobileTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeMobileTest.php index eec25bcc7ce..8173c3dae18 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeMobileTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeMobileTest.php @@ -64,7 +64,7 @@ class ThemeMobileTest extends Unit\TestCase */ public function testDetection() { - $detector = $this->getMock('uagent_info', array('DetectMobileLong')); + $detector = $this->getMock('uagent_info', ['DetectMobileLong']); $detector->expects($this->once()) ->method('DetectMobileLong')->will($this->returnValue(true)); $mobile = new Mobile($detector); diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeResourceContainerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeResourceContainerTest.php index e2b6373393d..b4c59413fdf 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeResourceContainerTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeResourceContainerTest.php @@ -47,12 +47,12 @@ class ThemeResourceContainerTest extends Unit\TestCase public function testCss() { $container = new ResourceContainer(); - $container->addCss(array('a', 'b', 'c')); + $container->addCss(['a', 'b', 'c']); $container->addCss('c'); $container->addCss('d'); $container->addLessCss('e.less'); $container->addCss('e'); - $this->assertEquals(array(), array_diff(array('a', 'b', 'c', 'd'), $container->getCss())); + $this->assertEquals([], array_diff(['a', 'b', 'c', 'd'], $container->getCss())); } /** @@ -63,12 +63,12 @@ class ThemeResourceContainerTest extends Unit\TestCase public function testLess() { $container = new ResourceContainer(); - $container->addCss(array('c', 'd.css')); - $container->addLessCss(array('active' => true, 'a', 'b', 'c')); + $container->addCss(['c', 'd.css']); + $container->addLessCss(['active' => true, 'a', 'b', 'c']); $container->addLessCss('c'); $container->addLessCss('d'); - $this->assertEquals(array(), array_diff(array('a', 'b', 'c', 'd'), $container->getLessCss())); - $this->assertEquals(array('c'), $container->getCss()); + $this->assertEquals([], array_diff(['a', 'b', 'c', 'd'], $container->getLessCss())); + $this->assertEquals(['c'], $container->getCss()); } /** @@ -79,10 +79,10 @@ class ThemeResourceContainerTest extends Unit\TestCase public function testJs() { $container = new ResourceContainer(); - $container->addJs(array('a', 'b', 'c')); + $container->addJs(['a', 'b', 'c']); $container->addJs('c'); $container->addJs('d'); - $this->assertEquals(array(), array_diff(array('a', 'b', 'c', 'd'), $container->getJs())); + $this->assertEquals([], array_diff(['a', 'b', 'c', 'd'], $container->getJs())); } /** diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/View/Helper/HeadThemeResourcesTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/View/Helper/HeadThemeResourcesTest.php index 71999d88804..cabd3ae89a3 100644 --- a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/View/Helper/HeadThemeResourcesTest.php +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/View/Helper/HeadThemeResourcesTest.php @@ -93,7 +93,7 @@ class HeadThemeResourcesTest extends \VuFindTest\Unit\TestCase { $mock = $this->getMockBuilder('VuFindTheme\View\Helper\HeadMeta') ->disableOriginalConstructor() - ->setMethods(array('__invoke', 'prependHttpEquiv', 'appendName')) + ->setMethods(['__invoke', 'prependHttpEquiv', 'appendName']) ->getMock(); $mock->expects($this->any())->method('__invoke')->will($this->returnValue($mock)); $mock->expects($this->once())->method('prependHttpEquiv') -- GitLab